@sockethub/schemas 3.0.0-alpha.10 → 3.0.0-alpha.12

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.
Files changed (46) hide show
  1. package/dist/context.js +101 -0
  2. package/dist/context.js.map +10 -0
  3. package/dist/contexts/platform/dummy/v1.jsonld +8 -0
  4. package/dist/contexts/platform/error/v1.jsonld +8 -0
  5. package/dist/contexts/platform/feeds/v1.jsonld +8 -0
  6. package/dist/contexts/platform/irc/v1.jsonld +8 -0
  7. package/dist/contexts/platform/metadata/v1.jsonld +8 -0
  8. package/dist/contexts/platform/sockethub%3Ainternal/v1.jsonld +8 -0
  9. package/dist/contexts/platform/xmpp/v1.jsonld +8 -0
  10. package/dist/contexts/v1.jsonld +7 -0
  11. package/dist/index.js +533 -796
  12. package/dist/index.js.map +10 -15
  13. package/dist/maps/context-map.json +35 -0
  14. package/dist/schemas/platform/dummy/v1/credentials.schema.json +1 -0
  15. package/dist/schemas/platform/dummy/v1/messages.schema.json +22 -0
  16. package/dist/schemas/platform/error/v1/credentials.schema.json +1 -0
  17. package/dist/schemas/platform/error/v1/messages.schema.json +1 -0
  18. package/dist/schemas/platform/feeds/v1/credentials.schema.json +1 -0
  19. package/dist/schemas/platform/feeds/v1/messages.schema.json +36 -0
  20. package/dist/schemas/platform/irc/v1/credentials.schema.json +48 -0
  21. package/dist/schemas/platform/irc/v1/messages.schema.json +19 -0
  22. package/dist/schemas/platform/metadata/v1/credentials.schema.json +1 -0
  23. package/dist/schemas/platform/metadata/v1/messages.schema.json +29 -0
  24. package/dist/schemas/platform/sockethub%3Ainternal/v1/credentials.schema.json +1 -0
  25. package/dist/schemas/platform/sockethub%3Ainternal/v1/messages.schema.json +1 -0
  26. package/dist/schemas/platform/xmpp/v1/credentials.schema.json +43 -0
  27. package/dist/schemas/platform/xmpp/v1/messages.schema.json +21 -0
  28. package/package.json +15 -8
  29. package/src/context.ts +125 -0
  30. package/src/helpers/error-parser.ts +65 -18
  31. package/src/helpers/objects.ts +59 -3
  32. package/src/index.test.data.credentials.ts +37 -5
  33. package/src/index.test.data.platform.ts +3 -0
  34. package/src/index.test.data.streams.ts +117 -25
  35. package/src/index.test.ts +31 -3
  36. package/src/index.ts +30 -1
  37. package/src/schemas/activity-stream.ts +30 -9
  38. package/src/schemas/json/activity-object.json +50 -1
  39. package/src/schemas/json/activity-stream.json +77 -44
  40. package/src/schemas/json/platform.json +22 -2
  41. package/src/schemas/json/sockethub-config.json +120 -28
  42. package/src/schemas/platform.ts +25 -1
  43. package/src/schemas/sockethub-config.ts +94 -14
  44. package/src/types/ajv-formats-draft2019.d.ts +5 -0
  45. package/src/types.ts +29 -12
  46. package/src/validator.ts +138 -25
@@ -1,5 +1,5 @@
1
- export const validObjectRefs = [];
2
- export const validObjectDefs = {};
1
+ export const validObjectRefs: Array<{ $ref: string }> = [];
2
+ export const validObjectDefs: Record<string, unknown> = {};
3
3
 
4
4
  export const ObjectTypesSchema = {
5
5
  credentials: {
@@ -118,6 +118,22 @@ export const ObjectTypesSchema = {
118
118
  },
119
119
  },
120
120
 
121
+ platform: {
122
+ required: ["id", "type"],
123
+ additionalProperties: true,
124
+ properties: {
125
+ id: {
126
+ type: "string",
127
+ },
128
+ type: {
129
+ enum: ["platform"],
130
+ },
131
+ name: {
132
+ type: "string",
133
+ },
134
+ },
135
+ },
136
+
121
137
  website: {
122
138
  required: ["id", "type"],
123
139
  additionalProperties: true,
@@ -214,14 +230,54 @@ export const ObjectTypesSchema = {
214
230
  },
215
231
  },
216
232
  },
233
+
234
+ heartbeat: {
235
+ required: ["type", "timestamp"],
236
+ additionalProperties: false,
237
+ properties: {
238
+ type: {
239
+ enum: ["heartbeat"],
240
+ },
241
+ timestamp: {
242
+ type: "number",
243
+ },
244
+ },
245
+ },
217
246
  };
218
247
 
248
+ // Internal AS object types reserved for Sockethub IPC/housekeeping.
249
+ export const InternalObjectTypesList = ["platform", "heartbeat"];
219
250
  export const ObjectTypesList = Object.keys(ObjectTypesSchema);
251
+ export const ActorTypesList = [
252
+ "person",
253
+ "room",
254
+ "service",
255
+ "feed",
256
+ "website",
257
+ "platform",
258
+ ];
259
+ export const TargetTypesList = [
260
+ "person",
261
+ "room",
262
+ "service",
263
+ "feed",
264
+ "website",
265
+ "platform",
266
+ "address",
267
+ ];
268
+ export const validActorRefs = ActorTypesList.map((type) => ({
269
+ $ref: `#/definitions/type/${type}`,
270
+ }));
271
+ export const validTargetRefs = TargetTypesList.map((type) => ({
272
+ $ref: `#/definitions/type/${type}`,
273
+ }));
220
274
 
221
275
  for (const type of ObjectTypesList) {
222
276
  if (type === "credentials") {
223
277
  continue;
224
278
  }
225
279
  validObjectRefs.push({ $ref: `#/definitions/type/${type}` });
226
- validObjectDefs[type] = ObjectTypesSchema[type];
280
+ validObjectDefs[type] = (ObjectTypesSchema as Record<string, unknown>)[
281
+ type
282
+ ];
227
283
  }
@@ -8,13 +8,21 @@ export default [
8
8
  },
9
9
  },
10
10
  false,
11
- "credential activity streams must have a context set",
11
+ "credential activity streams must have an @context set",
12
12
  ],
13
13
 
14
14
  [
15
15
  "credentials with no type",
16
16
  {
17
- context: "test-platform",
17
+ "@context": [
18
+ "https://www.w3.org/ns/activitystreams",
19
+ "https://sockethub.org/ns/context/v1.jsonld",
20
+ "https://sockethub.org/ns/context/platform/test-platform/v1.jsonld",
21
+ ],
22
+ actor: {
23
+ id: "test-platform-user",
24
+ type: "person",
25
+ },
18
26
  object: {
19
27
  type: "credentials",
20
28
  },
@@ -26,8 +34,16 @@ export default [
26
34
  [
27
35
  "credentials with props",
28
36
  {
29
- context: "test-platform",
37
+ "@context": [
38
+ "https://www.w3.org/ns/activitystreams",
39
+ "https://sockethub.org/ns/context/v1.jsonld",
40
+ "https://sockethub.org/ns/context/platform/test-platform/v1.jsonld",
41
+ ],
30
42
  type: "credentials",
43
+ actor: {
44
+ id: "test-platform-user",
45
+ type: "person",
46
+ },
31
47
  object: {
32
48
  type: "credentials",
33
49
  user: "foo",
@@ -41,8 +57,16 @@ export default [
41
57
  [
42
58
  "credentials with props",
43
59
  {
44
- context: "test-platform",
60
+ "@context": [
61
+ "https://www.w3.org/ns/activitystreams",
62
+ "https://sockethub.org/ns/context/v1.jsonld",
63
+ "https://sockethub.org/ns/context/platform/test-platform/v1.jsonld",
64
+ ],
45
65
  type: "credentials",
66
+ actor: {
67
+ id: "test-platform-user",
68
+ type: "person",
69
+ },
46
70
  object: {
47
71
  type: "credentials",
48
72
  username: "foo",
@@ -56,8 +80,16 @@ export default [
56
80
  [
57
81
  "credentials with props",
58
82
  {
59
- context: "test-platform",
83
+ "@context": [
84
+ "https://www.w3.org/ns/activitystreams",
85
+ "https://sockethub.org/ns/context/v1.jsonld",
86
+ "https://sockethub.org/ns/context/platform/test-platform/v1.jsonld",
87
+ ],
60
88
  type: "credentials",
89
+ actor: {
90
+ id: "test-platform-user",
91
+ type: "person",
92
+ },
61
93
  object: {
62
94
  type: "credentials",
63
95
  username: "foo",
@@ -1,6 +1,9 @@
1
1
  export default {
2
2
  name: "fake",
3
3
  version: "1.0",
4
+ contextUrl: "https://sockethub.org/ns/context/platform/fake/v1.jsonld",
5
+ contextVersion: "1",
6
+ schemaVersion: "1",
4
7
  messages: {
5
8
  required: ["type"],
6
9
  properties: {
@@ -1,11 +1,15 @@
1
- import { ObjectTypesList } from "./helpers/objects";
1
+ import { ActorTypesList } from "./helpers/objects";
2
2
 
3
3
  export default [
4
4
  [
5
5
  "type:send, object:message",
6
6
  {
7
7
  type: "send",
8
- context: "irc",
8
+ "@context": [
9
+ "https://www.w3.org/ns/activitystreams",
10
+ "https://sockethub.org/ns/context/v1.jsonld",
11
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
12
+ ],
9
13
  actor: {
10
14
  id: "dood@irc.freenode.net",
11
15
  type: "person",
@@ -29,7 +33,11 @@ export default [
29
33
  "type:send, object:message bad published value",
30
34
  {
31
35
  type: "send",
32
- context: "irc",
36
+ "@context": [
37
+ "https://www.w3.org/ns/activitystreams",
38
+ "https://sockethub.org/ns/context/v1.jsonld",
39
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
40
+ ],
33
41
  published: "foo",
34
42
  actor: {
35
43
  id: "dood@irc.freenode.net",
@@ -54,7 +62,11 @@ export default [
54
62
  "type:credentials, object:credentials",
55
63
  {
56
64
  type: "credentials",
57
- context: "irc",
65
+ "@context": [
66
+ "https://www.w3.org/ns/activitystreams",
67
+ "https://sockethub.org/ns/context/v1.jsonld",
68
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
69
+ ],
58
70
  actor: {
59
71
  id: "dood@irc.freenode.net",
60
72
  type: "person",
@@ -76,7 +88,11 @@ export default [
76
88
  [
77
89
  "type:credentials",
78
90
  {
79
- context: "irc",
91
+ "@context": [
92
+ "https://www.w3.org/ns/activitystreams",
93
+ "https://sockethub.org/ns/context/v1.jsonld",
94
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
95
+ ],
80
96
  type: "credentials",
81
97
  actor: {
82
98
  id: "dood@irc.freenode.net",
@@ -98,7 +114,11 @@ export default [
98
114
  {
99
115
  id: "blah",
100
116
  type: "send",
101
- context: "dood",
117
+ "@context": [
118
+ "https://www.w3.org/ns/activitystreams",
119
+ "https://sockethub.org/ns/context/v1.jsonld",
120
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
121
+ ],
102
122
  actor: {
103
123
  id: "dood@irc.freenode.net",
104
124
  type: "person",
@@ -120,7 +140,11 @@ export default [
120
140
  "bad iri in object id",
121
141
  {
122
142
  type: "feed",
123
- context: "dood",
143
+ "@context": [
144
+ "https://www.w3.org/ns/activitystreams",
145
+ "https://sockethub.org/ns/context/v1.jsonld",
146
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
147
+ ],
124
148
  actor: {
125
149
  id: "dood@irc.freenode.net",
126
150
  type: "person",
@@ -138,7 +162,11 @@ export default [
138
162
  "valid iri in object id",
139
163
  {
140
164
  type: "feed",
141
- context: "dood",
165
+ "@context": [
166
+ "https://www.w3.org/ns/activitystreams",
167
+ "https://sockethub.org/ns/context/v1.jsonld",
168
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
169
+ ],
142
170
  actor: {
143
171
  id: "dood@irc.freenode.net",
144
172
  type: "person",
@@ -156,7 +184,11 @@ export default [
156
184
  "wrong actor type",
157
185
  {
158
186
  type: "send",
159
- context: "dood",
187
+ "@context": [
188
+ "https://www.w3.org/ns/activitystreams",
189
+ "https://sockethub.org/ns/context/v1.jsonld",
190
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
191
+ ],
160
192
  actor: {
161
193
  id: "doobar@freenode.net/channel",
162
194
  type: "foo",
@@ -168,7 +200,7 @@ export default [
168
200
  },
169
201
  },
170
202
  false,
171
- `[dood] /actor: must match exactly one schema in oneOf: ${ObjectTypesList.join(
203
+ `[dood] /actor: must match exactly one schema in oneOf: ${ActorTypesList.join(
172
204
  ", ",
173
205
  )}`,
174
206
  ],
@@ -178,7 +210,11 @@ export default [
178
210
  {
179
211
  id: "blah",
180
212
  type: "send",
181
- context: "dood",
213
+ "@context": [
214
+ "https://www.w3.org/ns/activitystreams",
215
+ "https://sockethub.org/ns/context/v1.jsonld",
216
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
217
+ ],
182
218
  actor: {
183
219
  type: "person",
184
220
  name: "dood",
@@ -202,7 +238,11 @@ export default [
202
238
  {
203
239
  id: "blah",
204
240
  type: "observe",
205
- context: "dood",
241
+ "@context": [
242
+ "https://www.w3.org/ns/activitystreams",
243
+ "https://sockethub.org/ns/context/v1.jsonld",
244
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
245
+ ],
206
246
  actor: {
207
247
  id: "dood",
208
248
  type: "person",
@@ -224,7 +264,11 @@ export default [
224
264
  {
225
265
  id: "blah",
226
266
  type: "observe",
227
- context: "dood",
267
+ "@context": [
268
+ "https://www.w3.org/ns/activitystreams",
269
+ "https://sockethub.org/ns/context/v1.jsonld",
270
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
271
+ ],
228
272
  actor: {
229
273
  id: "chatroom@crusty.net",
230
274
  type: "room",
@@ -244,7 +288,11 @@ export default [
244
288
  {
245
289
  id: "blah",
246
290
  type: "observe",
247
- context: "dood",
291
+ "@context": [
292
+ "https://www.w3.org/ns/activitystreams",
293
+ "https://sockethub.org/ns/context/v1.jsonld",
294
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
295
+ ],
248
296
  actor: {
249
297
  id: "dood",
250
298
  type: "person",
@@ -267,7 +315,11 @@ export default [
267
315
  {
268
316
  id: "blah",
269
317
  type: "observe",
270
- context: "dood",
318
+ "@context": [
319
+ "https://www.w3.org/ns/activitystreams",
320
+ "https://sockethub.org/ns/context/v1.jsonld",
321
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
322
+ ],
271
323
  actor: {
272
324
  id: "dood",
273
325
  type: "person",
@@ -291,7 +343,11 @@ export default [
291
343
  {
292
344
  id: "blah",
293
345
  type: "observe",
294
- context: "dood",
346
+ "@context": [
347
+ "https://www.w3.org/ns/activitystreams",
348
+ "https://sockethub.org/ns/context/v1.jsonld",
349
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
350
+ ],
295
351
  actor: {
296
352
  id: "dood",
297
353
  type: "person",
@@ -316,7 +372,11 @@ export default [
316
372
  {
317
373
  id: "blah",
318
374
  type: "observe",
319
- context: "dood",
375
+ "@context": [
376
+ "https://www.w3.org/ns/activitystreams",
377
+ "https://sockethub.org/ns/context/v1.jsonld",
378
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
379
+ ],
320
380
  actor: {
321
381
  id: "dood",
322
382
  type: "person",
@@ -339,7 +399,11 @@ export default [
339
399
  {
340
400
  id: "blah",
341
401
  type: "observe",
342
- context: "dood",
402
+ "@context": [
403
+ "https://www.w3.org/ns/activitystreams",
404
+ "https://sockethub.org/ns/context/v1.jsonld",
405
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
406
+ ],
343
407
  actor: {
344
408
  id: "dood",
345
409
  type: "person",
@@ -362,7 +426,11 @@ export default [
362
426
  {
363
427
  id: "blah",
364
428
  type: "observe",
365
- context: "dood",
429
+ "@context": [
430
+ "https://www.w3.org/ns/activitystreams",
431
+ "https://sockethub.org/ns/context/v1.jsonld",
432
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
433
+ ],
366
434
  actor: {
367
435
  id: "chatroom@crusty.net",
368
436
  type: "room",
@@ -381,7 +449,11 @@ export default [
381
449
  {
382
450
  id: "blah",
383
451
  type: "update",
384
- context: "dood",
452
+ "@context": [
453
+ "https://www.w3.org/ns/activitystreams",
454
+ "https://sockethub.org/ns/context/v1.jsonld",
455
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
456
+ ],
385
457
  actor: {
386
458
  id: "foobar@example.com",
387
459
  type: "person",
@@ -402,7 +474,11 @@ export default [
402
474
  "change user address incorrectly",
403
475
  {
404
476
  type: "update",
405
- context: "dood",
477
+ "@context": [
478
+ "https://www.w3.org/ns/activitystreams",
479
+ "https://sockethub.org/ns/context/v1.jsonld",
480
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
481
+ ],
406
482
  actor: {
407
483
  id: "foobar@example.com",
408
484
  type: "person",
@@ -420,7 +496,11 @@ export default [
420
496
  "invalid activity stream",
421
497
  {
422
498
  actor: { id: "irc://uuu@localhost", type: "person" },
423
- context: "irc",
499
+ "@context": [
500
+ "https://www.w3.org/ns/activitystreams",
501
+ "https://sockethub.org/ns/context/v1.jsonld",
502
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
503
+ ],
424
504
  target: { id: "irc://irc.dooder.net/a-room", type: "room" },
425
505
  },
426
506
  false,
@@ -430,7 +510,11 @@ export default [
430
510
  [
431
511
  "invalid room",
432
512
  {
433
- context: "irc",
513
+ "@context": [
514
+ "https://www.w3.org/ns/activitystreams",
515
+ "https://sockethub.org/ns/context/v1.jsonld",
516
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
517
+ ],
434
518
  type: "credentials",
435
519
  actor: {
436
520
  id: "sh-9K3Vk@irc.freenode.net",
@@ -448,7 +532,11 @@ export default [
448
532
  [
449
533
  "relationship",
450
534
  {
451
- context: "irc",
535
+ "@context": [
536
+ "https://www.w3.org/ns/activitystreams",
537
+ "https://sockethub.org/ns/context/v1.jsonld",
538
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
539
+ ],
452
540
  type: "add",
453
541
  actor: { type: "person", id: "alice@localhost", name: "alice" },
454
542
  target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
@@ -473,7 +561,11 @@ export default [
473
561
  [
474
562
  "invalid role in relationship",
475
563
  {
476
- context: "irc",
564
+ "@context": [
565
+ "https://www.w3.org/ns/activitystreams",
566
+ "https://sockethub.org/ns/context/v1.jsonld",
567
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
568
+ ],
477
569
  type: "add",
478
570
  actor: { type: "person", id: "alice@localhost", name: "alice" },
479
571
  target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
package/src/index.test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import type { ActivityStream } from "./types";
2
+ import type { ActivityObject, ActivityStream } from "./types";
3
3
 
4
4
  import testCredentialsData from "./index.test.data.credentials";
5
5
  import testActivityObjectsData from "./index.test.data.objects";
@@ -8,6 +8,7 @@ import testActivityStreamsData from "./index.test.data.streams";
8
8
  import { ActivityObjectSchema } from "./schemas/activity-object";
9
9
  import { ActivityStreamSchema } from "./schemas/activity-stream";
10
10
  import {
11
+ addPlatformContext,
11
12
  addPlatformSchema,
12
13
  getPlatformSchema,
13
14
  validateActivityObject,
@@ -16,6 +17,34 @@ import {
16
17
  validatePlatformSchema,
17
18
  } from "./validator";
18
19
 
20
+ const permissiveMessageSchema = {
21
+ required: ["type"],
22
+ properties: {
23
+ type: {
24
+ type: "string",
25
+ },
26
+ },
27
+ };
28
+
29
+ addPlatformSchema(permissiveMessageSchema, "irc/messages");
30
+ addPlatformSchema(permissiveMessageSchema, "dood/messages");
31
+ addPlatformSchema(
32
+ testPlatformSchemaData.credentials,
33
+ "test-platform/credentials",
34
+ );
35
+ addPlatformContext(
36
+ "irc",
37
+ "https://sockethub.org/ns/context/platform/irc/v1.jsonld",
38
+ );
39
+ addPlatformContext(
40
+ "dood",
41
+ "https://sockethub.org/ns/context/platform/dood/v1.jsonld",
42
+ );
43
+ addPlatformContext(
44
+ "test-platform",
45
+ "https://sockethub.org/ns/context/platform/test-platform/v1.jsonld",
46
+ );
47
+
19
48
  describe("schemas/src/index.ts", () => {
20
49
  describe("Platform schema validation", () => {
21
50
  it("returns an empty error for a valid schema", () => {
@@ -33,7 +62,6 @@ describe("schemas/src/index.ts", () => {
33
62
  describe("Adding a PlatformSchema", () => {
34
63
  it("returns the same schema when fetched", () => {
35
64
  const platform_type = "test-platform/credentials";
36
- addPlatformSchema(testPlatformSchemaData.credentials, platform_type);
37
65
  const compiledSchema = getPlatformSchema(platform_type);
38
66
  expect(compiledSchema.schema).toEqual(
39
67
  testPlatformSchemaData.credentials,
@@ -67,7 +95,7 @@ describe("schemas/src/index.ts", () => {
67
95
  ([name, ao, expectedResult, expectedFailureMessage]) => {
68
96
  describe("validateActivityObject " + name, () => {
69
97
  it(`returns expected result`, () => {
70
- const err = validateActivityObject(ao as ActivityStream);
98
+ const err = validateActivityObject(ao as ActivityObject);
71
99
  expect(err).toEqual(expectedFailureMessage);
72
100
  expect(!err).toEqual(expectedResult);
73
101
  });
package/src/index.ts CHANGED
@@ -1,10 +1,25 @@
1
- import { ObjectTypesList } from "./helpers/objects.js";
1
+ import {
2
+ AS2_BASE_CONTEXT_URL,
3
+ buildCanonicalContext,
4
+ ERROR_PLATFORM_CONTEXT_URL,
5
+ ERROR_PLATFORM_ID,
6
+ INTERNAL_PLATFORM_CONTEXT_URL,
7
+ INTERNAL_PLATFORM_ID,
8
+ PLATFORM_CONTEXT_PREFIX,
9
+ SOCKETHUB_BASE_CONTEXT_URL,
10
+ } from "./context.js";
11
+ import { InternalObjectTypesList, ObjectTypesList } from "./helpers/objects.js";
2
12
  import { ActivityObjectSchema } from "./schemas/activity-object.js";
3
13
  import { ActivityStreamSchema } from "./schemas/activity-stream.js";
4
14
  import { PlatformSchema } from "./schemas/platform.js";
15
+ import { SockethubConfigSchema } from "./schemas/sockethub-config.js";
5
16
  import {
17
+ addPlatformContext,
6
18
  addPlatformSchema,
7
19
  getPlatformSchema,
20
+ registerSystemPlatformContexts,
21
+ resolvePlatformId,
22
+ setValidationErrorOptions,
8
23
  validateActivityObject,
9
24
  validateActivityStream,
10
25
  validateCredentials,
@@ -12,16 +27,30 @@ import {
12
27
  } from "./validator.js";
13
28
 
14
29
  export {
30
+ AS2_BASE_CONTEXT_URL,
31
+ SOCKETHUB_BASE_CONTEXT_URL,
32
+ PLATFORM_CONTEXT_PREFIX,
33
+ ERROR_PLATFORM_ID,
34
+ ERROR_PLATFORM_CONTEXT_URL,
35
+ INTERNAL_PLATFORM_ID,
36
+ INTERNAL_PLATFORM_CONTEXT_URL,
37
+ buildCanonicalContext,
38
+ addPlatformContext,
15
39
  addPlatformSchema,
16
40
  getPlatformSchema,
41
+ resolvePlatformId,
42
+ registerSystemPlatformContexts,
17
43
  validatePlatformSchema,
18
44
  validateCredentials,
19
45
  validateActivityStream,
20
46
  validateActivityObject,
47
+ setValidationErrorOptions,
21
48
  PlatformSchema,
22
49
  ActivityObjectSchema,
23
50
  ActivityStreamSchema,
51
+ SockethubConfigSchema,
24
52
  ObjectTypesList,
53
+ InternalObjectTypesList,
25
54
  };
26
55
 
27
56
  export * from "./types.js";
@@ -1,9 +1,13 @@
1
- import { ObjectTypesList, ObjectTypesSchema } from "../helpers/objects.js";
2
- import { ActivityObjectSchema } from "./activity-object.js";
3
-
4
- const validActorRefs = ActivityObjectSchema.properties.object.oneOf;
5
- const validTargetRefs = ActivityObjectSchema.properties.object.oneOf;
6
- // console.log(validActorRefs);
1
+ import {
2
+ AS2_BASE_CONTEXT_URL,
3
+ SOCKETHUB_BASE_CONTEXT_URL,
4
+ } from "../context.js";
5
+ import {
6
+ ObjectTypesList,
7
+ ObjectTypesSchema,
8
+ validActorRefs,
9
+ validTargetRefs,
10
+ } from "../helpers/objects.js";
7
11
 
8
12
  const validObjectRefs = [];
9
13
 
@@ -12,7 +16,24 @@ for (const type of ObjectTypesList) {
12
16
  }
13
17
 
14
18
  const contextSchema = {
15
- type: "string",
19
+ type: "array",
20
+ minItems: 3,
21
+ maxItems: 3,
22
+ items: {
23
+ type: "string",
24
+ },
25
+ allOf: [
26
+ {
27
+ contains: {
28
+ const: AS2_BASE_CONTEXT_URL,
29
+ },
30
+ },
31
+ {
32
+ contains: {
33
+ const: SOCKETHUB_BASE_CONTEXT_URL,
34
+ },
35
+ },
36
+ ],
16
37
  };
17
38
  const typeSchema = {
18
39
  type: "string",
@@ -23,13 +44,13 @@ export const ActivityStreamSchema = {
23
44
  description: "Schema for Sockethub Activity Streams",
24
45
 
25
46
  type: "object",
26
- required: ["context", "type", "actor"],
47
+ required: ["@context", "type", "actor"],
27
48
  properties: {
49
+ "@context": contextSchema,
28
50
  id: {
29
51
  type: "string",
30
52
  },
31
53
  type: typeSchema,
32
- context: contextSchema,
33
54
  actor: {
34
55
  type: "object",
35
56
  oneOf: validActorRefs,