@sockethub/schemas 3.0.0-beta.0 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ {
2
+ "required": [
3
+ "type",
4
+ "actor",
5
+ "target",
6
+ "object"
7
+ ],
8
+ "properties": {
9
+ "type": {
10
+ "enum": [
11
+ "send"
12
+ ]
13
+ },
14
+ "actor": {
15
+ "type": "object",
16
+ "required": [
17
+ "id",
18
+ "type"
19
+ ],
20
+ "additionalProperties": false,
21
+ "properties": {
22
+ "id": {
23
+ "type": "string",
24
+ "pattern": "^[0-9]+$",
25
+ "maxLength": 128
26
+ },
27
+ "type": {
28
+ "const": "person"
29
+ }
30
+ }
31
+ },
32
+ "target": {
33
+ "type": "object",
34
+ "required": [
35
+ "id",
36
+ "type"
37
+ ],
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "id": {
41
+ "type": "string",
42
+ "pattern": "^[0-9]+$",
43
+ "maxLength": 128
44
+ },
45
+ "type": {
46
+ "const": "person"
47
+ }
48
+ }
49
+ },
50
+ "object": {
51
+ "type": "object",
52
+ "required": [
53
+ "type",
54
+ "content"
55
+ ],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "type": {
59
+ "const": "message"
60
+ },
61
+ "content": {
62
+ "type": "string",
63
+ "minLength": 1,
64
+ "maxLength": 1000
65
+ },
66
+ "humanAgent": {
67
+ "type": "boolean"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "required": [
3
+ "object"
4
+ ],
5
+ "properties": {
6
+ "object": {
7
+ "type": "object",
8
+ "required": [
9
+ "type",
10
+ "token",
11
+ "apiVersion"
12
+ ],
13
+ "additionalProperties": false,
14
+ "properties": {
15
+ "type": {
16
+ "const": "credentials"
17
+ },
18
+ "token": {
19
+ "type": "string",
20
+ "minLength": 1,
21
+ "maxLength": 8192,
22
+ "pattern": "^[^\\r\\n]+$"
23
+ },
24
+ "apiVersion": {
25
+ "type": "string",
26
+ "pattern": "^v[0-9]{1,3}\\.[0-9]{1,2}$"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "required": [
3
+ "type",
4
+ "actor",
5
+ "target",
6
+ "object"
7
+ ],
8
+ "properties": {
9
+ "type": {
10
+ "enum": [
11
+ "send"
12
+ ]
13
+ },
14
+ "actor": {
15
+ "type": "object",
16
+ "required": [
17
+ "id",
18
+ "type"
19
+ ],
20
+ "additionalProperties": false,
21
+ "properties": {
22
+ "id": {
23
+ "type": "string",
24
+ "pattern": "^[0-9]+$",
25
+ "maxLength": 128
26
+ },
27
+ "type": {
28
+ "const": "person"
29
+ }
30
+ }
31
+ },
32
+ "target": {
33
+ "type": "object",
34
+ "required": [
35
+ "id",
36
+ "type"
37
+ ],
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "id": {
41
+ "type": "string",
42
+ "pattern": "^[0-9]+$",
43
+ "maxLength": 128
44
+ },
45
+ "type": {
46
+ "const": "person"
47
+ }
48
+ }
49
+ },
50
+ "object": {
51
+ "type": "object",
52
+ "required": [
53
+ "type",
54
+ "content"
55
+ ],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "type": {
59
+ "const": "message"
60
+ },
61
+ "content": {
62
+ "type": "string",
63
+ "minLength": 1,
64
+ "maxLength": 2000
65
+ },
66
+ "humanAgent": {
67
+ "type": "boolean"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
@@ -32,7 +32,9 @@
32
32
  "type": "string"
33
33
  },
34
34
  "port": {
35
- "type": "number"
35
+ "type": "integer",
36
+ "minimum": 1,
37
+ "maximum": 65535
36
38
  },
37
39
  "resource": {
38
40
  "type": "string"
@@ -116,6 +116,10 @@ export declare const SockethubConfigSchema: {
116
116
  type: string;
117
117
  minimum: number;
118
118
  };
119
+ discoveryCacheTtlMs: {
120
+ type: string;
121
+ minimum: number;
122
+ };
119
123
  };
120
124
  };
121
125
  "@sockethub/platform-caldav": {
@@ -136,6 +140,24 @@ export declare const SockethubConfigSchema: {
136
140
  type: string;
137
141
  minimum: number;
138
142
  };
143
+ discoveryCacheTtlMs: {
144
+ type: string;
145
+ minimum: number;
146
+ };
147
+ };
148
+ };
149
+ "@sockethub/platform-email": {
150
+ type: string;
151
+ additionalProperties: boolean;
152
+ properties: {
153
+ connectTimeoutMs: {
154
+ type: string;
155
+ minimum: number;
156
+ maximum: number;
157
+ };
158
+ allowPrivateAddresses: {
159
+ type: string;
160
+ };
139
161
  };
140
162
  };
141
163
  "@sockethub/platform-dummy": {
@@ -171,6 +193,9 @@ export declare const SockethubConfigSchema: {
171
193
  connectTimeoutMs: {
172
194
  type: string;
173
195
  };
196
+ allowPrivateAddresses: {
197
+ type: string;
198
+ };
174
199
  };
175
200
  };
176
201
  "@sockethub/platform-xmpp": {
@@ -180,6 +205,9 @@ export declare const SockethubConfigSchema: {
180
205
  connectTimeoutMs: {
181
206
  type: string;
182
207
  };
208
+ allowPrivateAddresses: {
209
+ type: string;
210
+ };
183
211
  };
184
212
  };
185
213
  "@sockethub/platform-metadata": {
@@ -274,6 +302,24 @@ export declare const SockethubConfigSchema: {
274
302
  type: string;
275
303
  additionalProperties: boolean;
276
304
  properties: {
305
+ maxInstancesPerSession: {
306
+ type: string;
307
+ minimum: number;
308
+ default: number;
309
+ description: string;
310
+ };
311
+ maxInstancesPerIp: {
312
+ type: string;
313
+ minimum: number;
314
+ default: number;
315
+ description: string;
316
+ };
317
+ maxStartsPerIpPerMinute: {
318
+ type: string;
319
+ minimum: number;
320
+ default: number;
321
+ description: string;
322
+ };
277
323
  maxPlatformInstances: {
278
324
  type: string;
279
325
  minimum: number;
@@ -1,4 +1,9 @@
1
1
  import { type ServiceDescriptor, ServiceDescriptorSchema, type ServiceEndpoints } from "./schemas/service-descriptor.js";
2
+ /**
3
+ * Type guard for a server's service descriptor. Validates with Ajv when code
4
+ * generation is available and falls back to a structural check when a Content
5
+ * Security Policy blocks it.
6
+ */
2
7
  export declare function validateServiceDescriptor(descriptor: unknown): descriptor is ServiceDescriptor;
3
8
  export { ServiceDescriptorSchema };
4
9
  export type { ServiceDescriptor, ServiceEndpoints };
@@ -6222,6 +6222,28 @@ var require_ajv = __commonJS(function(exports, module) {
6222
6222
  // src/service-descriptor.ts
6223
6223
  var import_ajv = __toESM(require_ajv(), 1);
6224
6224
 
6225
+ // src/helpers/codegen.ts
6226
+ var available;
6227
+ var warned = false;
6228
+ function isCodegenAvailable() {
6229
+ if (available === undefined) {
6230
+ try {
6231
+ new Function("return true");
6232
+ available = true;
6233
+ } catch {
6234
+ available = false;
6235
+ }
6236
+ }
6237
+ return available;
6238
+ }
6239
+ function warnCodegenUnavailable() {
6240
+ if (warned) {
6241
+ return;
6242
+ }
6243
+ warned = true;
6244
+ console.warn("[@sockethub/schemas] Schema validation is disabled: this environment's Content Security Policy blocks `new Function`, which Ajv needs to compile schemas. The Sockethub server still validates every message.");
6245
+ }
6246
+
6225
6247
  // src/schemas/service-descriptor.ts
6226
6248
  var apiVersion = {
6227
6249
  type: "integer",
@@ -6266,15 +6288,68 @@ var ServiceDescriptorSchema = {
6266
6288
  };
6267
6289
 
6268
6290
  // src/service-descriptor.ts
6269
- var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
6291
+ var ajv;
6270
6292
  var validator;
6271
6293
  function validateServiceDescriptor(descriptor) {
6294
+ if (!isCodegenAvailable()) {
6295
+ warnCodegenUnavailable();
6296
+ return isServiceDescriptorShape(descriptor);
6297
+ }
6298
+ if (!ajv) {
6299
+ ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
6300
+ }
6272
6301
  validator ??= ajv.compile(ServiceDescriptorSchema);
6273
6302
  return validator(descriptor);
6274
6303
  }
6304
+ function isServiceDescriptorShape(descriptor) {
6305
+ if (!descriptor || typeof descriptor !== "object") {
6306
+ return false;
6307
+ }
6308
+ const value = descriptor;
6309
+ if (value.name !== "sockethub") {
6310
+ return false;
6311
+ }
6312
+ if (!isApiVersion(value.apiVersion)) {
6313
+ return false;
6314
+ }
6315
+ if (!Array.isArray(value.platforms)) {
6316
+ return false;
6317
+ }
6318
+ for (const platform of value.platforms) {
6319
+ if (!platform || typeof platform !== "object") {
6320
+ return false;
6321
+ }
6322
+ const entry = platform;
6323
+ if (typeof entry.id !== "string" || entry.id.length === 0) {
6324
+ return false;
6325
+ }
6326
+ if (!isApiVersion(entry.apiVersion)) {
6327
+ return false;
6328
+ }
6329
+ }
6330
+ if (value.endpoints !== undefined) {
6331
+ if (!value.endpoints || typeof value.endpoints !== "object") {
6332
+ return false;
6333
+ }
6334
+ const endpoints = value.endpoints;
6335
+ if (!isAbsolutePath(endpoints.socketIO)) {
6336
+ return false;
6337
+ }
6338
+ if (endpoints.httpActions !== undefined && !isAbsolutePath(endpoints.httpActions)) {
6339
+ return false;
6340
+ }
6341
+ }
6342
+ return true;
6343
+ }
6344
+ function isApiVersion(value) {
6345
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
6346
+ }
6347
+ function isAbsolutePath(value) {
6348
+ return typeof value === "string" && /^\/(?![/\\])[^\s\\]*$/.test(value);
6349
+ }
6275
6350
  export {
6276
6351
  ServiceDescriptorSchema,
6277
6352
  validateServiceDescriptor
6278
6353
  };
6279
6354
 
6280
- //# debugId=80A2C8695850A8EE64756E2164756E21
6355
+ //# debugId=D62B42AEB54699FA64756E2164756E21