signalk-server
Version:
An implementation of a [Signal K](http://signalk.org) server for boats.
49 lines • 2.35 kB
JavaScript
;
/*
* Copyright 2026 Signal K project contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkAccessRequestSchema = exports.requestAccessSchema = exports.testConnectionSchema = void 0;
const typebox_1 = require("@sinclair/typebox");
// requestId is a server-generated UUID. Enforcing that shape stops a crafted id
// from being interpolated into the remote request path as a traversal sequence.
const UUID_PATTERN = '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$';
// 1-65535 expressed as a string, since the admin UI sends port as a string.
const PORT_STRING_PATTERN = '^([1-9]\\d{0,3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$';
// The admin UI sends port as a string, so accept a number or a numeric string,
// range-checked either way.
const remoteServerProps = {
host: typebox_1.Type.String({ minLength: 1 }),
port: typebox_1.Type.Union([
typebox_1.Type.Integer({ minimum: 1, maximum: 65535 }),
typebox_1.Type.String({ pattern: PORT_STRING_PATTERN })
]),
useTLS: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
selfsignedcert: typebox_1.Type.Optional(typebox_1.Type.Boolean())
};
exports.testConnectionSchema = typebox_1.Type.Object({
...remoteServerProps,
token: typebox_1.Type.Optional(typebox_1.Type.String())
});
exports.requestAccessSchema = typebox_1.Type.Object({
...remoteServerProps,
clientId: typebox_1.Type.Optional(typebox_1.Type.String()),
description: typebox_1.Type.Optional(typebox_1.Type.String())
});
exports.checkAccessRequestSchema = typebox_1.Type.Object({
...remoteServerProps,
requestId: typebox_1.Type.String({ pattern: UUID_PATTERN })
});
//# sourceMappingURL=remoteConnectionSchemas.js.map