@fedify/vocab 2.4.0-dev.1599 → 2.4.0-dev.1634

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 (41) hide show
  1. package/deno.json +1 -1
  2. package/dist/mod.cjs +472 -16
  3. package/dist/mod.d.cts +119 -1
  4. package/dist/mod.d.ts +119 -1
  5. package/dist/mod.js +473 -17
  6. package/dist-tests/{actor-NhcklZK0.mjs → actor-BQd8S953.mjs} +2 -2
  7. package/dist-tests/actor.test.mjs +2 -2
  8. package/dist-tests/application.yaml +15 -0
  9. package/dist-tests/audio.yaml +2 -1
  10. package/dist-tests/document.yaml +14 -1
  11. package/dist-tests/endpoints.yaml +14 -0
  12. package/dist-tests/group.yaml +15 -0
  13. package/dist-tests/image.yaml +2 -1
  14. package/dist-tests/link.yaml +14 -1
  15. package/dist-tests/lookup.test.mjs +71 -4
  16. package/dist-tests/organization.yaml +15 -0
  17. package/dist-tests/page.yaml +2 -1
  18. package/dist-tests/person.yaml +15 -0
  19. package/dist-tests/service.yaml +15 -0
  20. package/dist-tests/type.test.mjs +1 -1
  21. package/dist-tests/video.yaml +2 -1
  22. package/dist-tests/{vocab-BQ8y6QS7.mjs → vocab-Bjwctrxn.mjs} +472 -16
  23. package/dist-tests/vocab.test.mjs +232 -2
  24. package/package.json +4 -4
  25. package/src/__snapshots__/vocab.test.ts.snap +60 -18
  26. package/src/application.yaml +15 -0
  27. package/src/audio.yaml +2 -1
  28. package/src/document.yaml +14 -1
  29. package/src/endpoints.yaml +14 -0
  30. package/src/group.yaml +15 -0
  31. package/src/image.yaml +2 -1
  32. package/src/link.yaml +14 -1
  33. package/src/lookup.test.ts +121 -0
  34. package/src/lookup.ts +3 -1
  35. package/src/organization.yaml +15 -0
  36. package/src/page.yaml +2 -1
  37. package/src/person.yaml +15 -0
  38. package/src/preprocessors.ts +3 -1
  39. package/src/service.yaml +15 -0
  40. package/src/video.yaml +2 -1
  41. package/src/vocab.test.ts +372 -0
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Describes a software application.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/fep/ef61"
10
11
  - "https://w3id.org/security/v1"
11
12
  - "https://w3id.org/security/data-integrity/v1"
12
13
  - "https://www.w3.org/ns/did/v1"
@@ -78,6 +79,20 @@ properties:
78
79
  range:
79
80
  - "https://w3id.org/security#Multikey"
80
81
 
82
+ - pluralName: gateways
83
+ singularName: gateway
84
+ singularAccessor: true
85
+ compactName: gateways
86
+ uri: "https://w3id.org/fep/ef61/gateways"
87
+ container: list
88
+ description: |
89
+ Gateways where the latest version of this portable actor object can be
90
+ retrieved.
91
+
92
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
93
+ range:
94
+ - "fedify:gatewayUrl"
95
+
81
96
  - singularName: manuallyApprovesFollowers
82
97
  functional: true
83
98
  compactName: manuallyApprovesFollowers
package/src/audio.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents an audio document of any kind.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
- - "https://w3id.org/security/data-integrity/v1"
10
+ - "https://w3id.org/security/data-integrity/v2"
11
+ - digestMultibase: "https://www.w3.org/ns/credentials/v2#digestMultibase"
11
12
  - "https://gotosocial.org/ns"
12
13
  properties: []
package/src/document.yaml CHANGED
@@ -7,7 +7,8 @@ entity: true
7
7
  description: Represents a document of any kind.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
- - "https://w3id.org/security/data-integrity/v1"
10
+ - "https://w3id.org/security/data-integrity/v2"
11
+ - digestMultibase: "https://www.w3.org/ns/credentials/v2#digestMultibase"
11
12
  - "https://gotosocial.org/ns"
12
13
 
13
14
  properties:
@@ -30,3 +31,15 @@ properties:
30
31
  device-independent pixels of the linked resource.
31
32
  range:
32
33
  - "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
34
+
35
+ - singularName: digestMultibase
36
+ functional: true
37
+ compactName: digestMultibase
38
+ uri: "https://www.w3.org/ns/credentials/v2#digestMultibase"
39
+ description: |
40
+ The multibase-encoded integrity digest of an external resource represented
41
+ by this document.
42
+
43
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
44
+ range:
45
+ - "http://www.w3.org/2001/XMLSchema#string"
@@ -84,3 +84,17 @@ properties:
84
84
  objects which are not addressed to the `Public`` endpoint.
85
85
  range:
86
86
  - "http://www.w3.org/2001/XMLSchema#anyURI"
87
+
88
+ - singularName: uploadMedia
89
+ functional: true
90
+ compactName: uploadMedia
91
+ uri: "https://www.w3.org/ns/activitystreams#uploadMedia"
92
+ description: |
93
+ Upload endpoint URI for this user for binary data, such as an image or
94
+ video, as described in the [ActivityPub Media
95
+ Upload](https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload) extension.
96
+ Clients `POST` a `multipart/form-data` request containing a `file` part
97
+ (the binary payload) and an `object` part (an ActivityStreams object shell)
98
+ to this endpoint.
99
+ range:
100
+ - "http://www.w3.org/2001/XMLSchema#anyURI"
package/src/group.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents a formal or informal collective of Actors.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/fep/ef61"
10
11
  - "https://w3id.org/security/v1"
11
12
  - "https://w3id.org/security/data-integrity/v1"
12
13
  - "https://www.w3.org/ns/did/v1"
@@ -78,6 +79,20 @@ properties:
78
79
  range:
79
80
  - "https://w3id.org/security#Multikey"
80
81
 
82
+ - pluralName: gateways
83
+ singularName: gateway
84
+ singularAccessor: true
85
+ compactName: gateways
86
+ uri: "https://w3id.org/fep/ef61/gateways"
87
+ container: list
88
+ description: |
89
+ Gateways where the latest version of this portable actor object can be
90
+ retrieved.
91
+
92
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
93
+ range:
94
+ - "fedify:gatewayUrl"
95
+
81
96
  - singularName: manuallyApprovesFollowers
82
97
  functional: true
83
98
  compactName: manuallyApprovesFollowers
package/src/image.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: An image document of any kind.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
- - "https://w3id.org/security/data-integrity/v1"
10
+ - "https://w3id.org/security/data-integrity/v2"
11
+ - digestMultibase: "https://www.w3.org/ns/credentials/v2#digestMultibase"
11
12
  - "https://gotosocial.org/ns"
12
13
  properties: []
package/src/link.yaml CHANGED
@@ -12,7 +12,9 @@ description: |
12
12
  object) to the resource identified by the `href`. Properties of
13
13
  the {@link Link} are properties of the reference as opposed to properties of
14
14
  the resource.
15
- defaultContext: "https://www.w3.org/ns/activitystreams"
15
+ defaultContext:
16
+ - "https://www.w3.org/ns/activitystreams"
17
+ - "https://w3id.org/fep/ef61"
16
18
 
17
19
  properties:
18
20
  - singularName: href
@@ -48,6 +50,17 @@ properties:
48
50
  range:
49
51
  - "http://www.w3.org/2001/XMLSchema#string"
50
52
 
53
+ - singularName: digestMultibase
54
+ functional: true
55
+ compactName: digestMultibase
56
+ uri: "https://www.w3.org/ns/credentials/v2#digestMultibase"
57
+ description: |
58
+ The multibase-encoded integrity digest of the linked resource.
59
+
60
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
61
+ range:
62
+ - "http://www.w3.org/2001/XMLSchema#string"
63
+
51
64
  - pluralName: names
52
65
  singularName: name
53
66
  singularAccessor: true
@@ -416,6 +416,127 @@ test("FEP-fe34: lookupObject() cross-origin security", {
416
416
  );
417
417
  });
418
418
 
419
+ await t.step(
420
+ "same-authority non-FE34 IRIs are still trusted",
421
+ async () => {
422
+ // deno-lint-ignore require-await
423
+ const atProtoDocumentLoader = async (url: string) => {
424
+ if (url === "https://gateway.example/at-item") {
425
+ return {
426
+ documentUrl: "at://did%3Aplc%3Aexample/collection/item",
427
+ contextUrl: null,
428
+ document: {
429
+ "@context": "https://www.w3.org/ns/activitystreams",
430
+ type: "Note",
431
+ id: "at://did:plc:example/collection/reply",
432
+ content: "AT Protocol note",
433
+ },
434
+ };
435
+ }
436
+ throw new Error(`Unexpected URL: ${url}`);
437
+ };
438
+
439
+ const result = await lookupObject(
440
+ "https://gateway.example/at-item",
441
+ {
442
+ documentLoader: atProtoDocumentLoader,
443
+ contextLoader: mockDocumentLoader,
444
+ },
445
+ );
446
+
447
+ assertInstanceOf(result, Note);
448
+ deepStrictEqual(
449
+ result.id,
450
+ new URL("at://did%3Aplc%3Aexample/collection/reply"),
451
+ );
452
+ deepStrictEqual(result.content, "AT Protocol note");
453
+ },
454
+ );
455
+
456
+ await t.step(
457
+ "portable object IDs are trusted by DID cryptographic origin",
458
+ async () => {
459
+ // deno-lint-ignore require-await
460
+ const portableDocumentLoader = async (url: string) => {
461
+ if (
462
+ url ===
463
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/note"
464
+ ) {
465
+ return {
466
+ documentUrl: "ap+ef61://did:key:z6Mkabc/note",
467
+ contextUrl: null,
468
+ document: {
469
+ "@context": "https://www.w3.org/ns/activitystreams",
470
+ type: "Note",
471
+ id: "ap://did:key:z6Mkabc/note",
472
+ content: "Portable note",
473
+ },
474
+ };
475
+ }
476
+ throw new Error(`Unexpected URL: ${url}`);
477
+ };
478
+
479
+ const result = await lookupObject(
480
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/note",
481
+ {
482
+ documentLoader: portableDocumentLoader,
483
+ contextLoader: mockDocumentLoader,
484
+ },
485
+ );
486
+
487
+ assertInstanceOf(result, Note);
488
+ deepStrictEqual(result.content, "Portable note");
489
+ },
490
+ );
491
+
492
+ await t.step(
493
+ "portable object IDs reject mismatched cryptographic origins",
494
+ async () => {
495
+ // deno-lint-ignore require-await
496
+ const portableDocumentLoader = async (url: string) => {
497
+ if (
498
+ url ===
499
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/note"
500
+ ) {
501
+ return {
502
+ documentUrl: "ap+ef61://did:key:z6Mkabc/note",
503
+ contextUrl: null,
504
+ document: {
505
+ "@context": "https://www.w3.org/ns/activitystreams",
506
+ type: "Note",
507
+ id: "ap://did:key:z6Mkdef/note",
508
+ content: "Spoofed portable note",
509
+ },
510
+ };
511
+ }
512
+ throw new Error(`Unexpected URL: ${url}`);
513
+ };
514
+
515
+ const result = await lookupObject(
516
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/note",
517
+ {
518
+ documentLoader: portableDocumentLoader,
519
+ contextLoader: mockDocumentLoader,
520
+ },
521
+ );
522
+
523
+ deepStrictEqual(result, null);
524
+ await rejects(
525
+ () =>
526
+ lookupObject(
527
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/note",
528
+ {
529
+ documentLoader: portableDocumentLoader,
530
+ contextLoader: mockDocumentLoader,
531
+ crossOrigin: "throw",
532
+ },
533
+ ),
534
+ Error,
535
+ "The object's @id (ap+ef61://did%3Akey%3Az6Mkdef/note) has a different origin than the document URL (ap+ef61://did:key:z6Mkabc/note)",
536
+ );
537
+ },
538
+ );
539
+
419
540
  await t.step("objects without @id are trusted", async () => {
420
541
  // deno-lint-ignore require-await
421
542
  const noIdDocumentLoader = async (url: string) => {
package/src/lookup.ts CHANGED
@@ -2,6 +2,7 @@ import type { GetUserAgentOptions } from "@fedify/vocab-runtime";
2
2
  import {
3
3
  type DocumentLoader,
4
4
  getDocumentLoader,
5
+ haveSameFe34Origin,
5
6
  haveSameIriOrigin,
6
7
  parseIri,
7
8
  type RemoteDocument,
@@ -335,7 +336,8 @@ async function lookupObjectInternal(
335
336
  }
336
337
  if (
337
338
  options.crossOrigin !== "trust" && object.id != null &&
338
- !haveSameIriOrigin(object.id, documentUrl)
339
+ !haveSameIriOrigin(object.id, documentUrl) &&
340
+ !haveSameFe34Origin(object.id, documentUrl)
339
341
  ) {
340
342
  if (options.crossOrigin === "throw") {
341
343
  throw new Error(
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents an organization.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/fep/ef61"
10
11
  - "https://w3id.org/security/v1"
11
12
  - "https://w3id.org/security/data-integrity/v1"
12
13
  - "https://www.w3.org/ns/did/v1"
@@ -78,6 +79,20 @@ properties:
78
79
  range:
79
80
  - "https://w3id.org/security#Multikey"
80
81
 
82
+ - pluralName: gateways
83
+ singularName: gateway
84
+ singularAccessor: true
85
+ compactName: gateways
86
+ uri: "https://w3id.org/fep/ef61/gateways"
87
+ container: list
88
+ description: |
89
+ Gateways where the latest version of this portable actor object can be
90
+ retrieved.
91
+
92
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
93
+ range:
94
+ - "fedify:gatewayUrl"
95
+
81
96
  - singularName: manuallyApprovesFollowers
82
97
  functional: true
83
98
  compactName: manuallyApprovesFollowers
package/src/page.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents a Web Page.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
- - "https://w3id.org/security/data-integrity/v1"
10
+ - "https://w3id.org/security/data-integrity/v2"
11
+ - digestMultibase: "https://www.w3.org/ns/credentials/v2#digestMultibase"
11
12
  - "https://gotosocial.org/ns"
12
13
  properties: []
package/src/person.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents an individual person.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/fep/ef61"
10
11
  - "https://w3id.org/security/v1"
11
12
  - "https://w3id.org/security/data-integrity/v1"
12
13
  - "https://www.w3.org/ns/did/v1"
@@ -78,6 +79,20 @@ properties:
78
79
  range:
79
80
  - "https://w3id.org/security#Multikey"
80
81
 
82
+ - pluralName: gateways
83
+ singularName: gateway
84
+ singularAccessor: true
85
+ compactName: gateways
86
+ uri: "https://w3id.org/fep/ef61/gateways"
87
+ container: list
88
+ description: |
89
+ Gateways where the latest version of this portable actor object can be
90
+ retrieved.
91
+
92
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
93
+ range:
94
+ - "fedify:gatewayUrl"
95
+
81
96
  - singularName: manuallyApprovesFollowers
82
97
  functional: true
83
98
  compactName: manuallyApprovesFollowers
@@ -7,7 +7,8 @@ import { Image, Link } from "./vocab.ts";
7
7
  * When an `icon` or `image` property on a vocabulary object contains an
8
8
  * explicit ActivityStreams `Link` rather than an `Image`, this preprocessor
9
9
  * converts it into an `Image` by mapping `href` to `url`, copying
10
- * `mediaType`, `name`, `width`, and `height`, and discarding the rest.
10
+ * `mediaType`, `name`, `width`, `height`, and `digestMultibase`, and
11
+ * discarding the rest.
11
12
  *
12
13
  * If the value is not a Link, or the Link has no `href`, it returns
13
14
  * `undefined` so the normal range decoder continues.
@@ -44,5 +45,6 @@ export const normalizeLinkToImage: PropertyPreprocessor<Image> = async (
44
45
  names: link.names != null && link.names.length > 0 ? link.names : undefined,
45
46
  width: link.width,
46
47
  height: link.height,
48
+ digestMultibase: link.digestMultibase,
47
49
  });
48
50
  };
package/src/service.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents a service of any kind.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/fep/ef61"
10
11
  - "https://w3id.org/security/v1"
11
12
  - "https://w3id.org/security/data-integrity/v1"
12
13
  - "https://www.w3.org/ns/did/v1"
@@ -78,6 +79,20 @@ properties:
78
79
  range:
79
80
  - "https://w3id.org/security#Multikey"
80
81
 
82
+ - pluralName: gateways
83
+ singularName: gateway
84
+ singularAccessor: true
85
+ compactName: gateways
86
+ uri: "https://w3id.org/fep/ef61/gateways"
87
+ container: list
88
+ description: |
89
+ Gateways where the latest version of this portable actor object can be
90
+ retrieved.
91
+
92
+ See [FEP-ef61](https://w3id.org/fep/ef61) for details.
93
+ range:
94
+ - "fedify:gatewayUrl"
95
+
81
96
  - singularName: manuallyApprovesFollowers
82
97
  functional: true
83
98
  compactName: manuallyApprovesFollowers
package/src/video.yaml CHANGED
@@ -7,6 +7,7 @@ entity: true
7
7
  description: Represents a video document of any kind.
8
8
  defaultContext:
9
9
  - "https://www.w3.org/ns/activitystreams"
10
- - "https://w3id.org/security/data-integrity/v1"
10
+ - "https://w3id.org/security/data-integrity/v2"
11
+ - digestMultibase: "https://www.w3.org/ns/credentials/v2#digestMultibase"
11
12
  - "https://gotosocial.org/ns"
12
13
  properties: []