@fedify/fedify 0.10.0-dev.213 → 0.10.0-dev.219

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md CHANGED
@@ -106,6 +106,18 @@ To be released.
106
106
  - The `Context.sendActivity()` method's first parameter now accepts
107
107
  `SenderKeyPair[]` as well.
108
108
 
109
+ - In the future, `Federation` class will become an interface.
110
+ For the forward compatibility, the following changes are made:
111
+
112
+ - Added `createFederation()` function.
113
+ - Added `CreateFederationOptions` interface.
114
+ - Deprecated `new Federation()` constructor. Use `createFederation()`
115
+ function instead.
116
+ - Deprecated `FederationParameters` interface.
117
+
118
+ - Added `Arrive` class to Activity Vocabulary API.
119
+ [[#65], [#68] by Randy Wressell]
120
+
109
121
  - Added `Question` class to Activity Vocabulary API.
110
122
 
111
123
  - Added `context` option to `Object.toJsonLd()` method. This applies to
@@ -140,6 +152,8 @@ To be released.
140
152
 
141
153
  [#54]: https://github.com/dahlia/fedify/issues/54
142
154
  [#55]: https://github.com/dahlia/fedify/issues/55
155
+ [#65]: https://github.com/dahlia/fedify/issues/65
156
+ [#68]: https://github.com/dahlia/fedify/pull/68
143
157
  [FEP-521a]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
144
158
  [FEP-8b32]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md
145
159
  [x-forwarded-fetch]: https://github.com/dahlia/x-forwarded-fetch
@@ -713,3 +727,5 @@ Version 0.1.0
713
727
  -------------
714
728
 
715
729
  Initial release. Released on March 8, 2024.
730
+
731
+ <!-- cSpell: ignore Wressell -->
package/FEDERATION.md CHANGED
@@ -48,6 +48,7 @@ lists the activity types that Fedify provides:
48
48
  - [`Accept`](https://jsr.io/@fedify/fedify/doc/vocab/~/Accept)
49
49
  - [`Add`](https://jsr.io/@fedify/fedify/doc/vocab/~/Add)
50
50
  - [`Announce`](https://jsr.io/@fedify/fedify/doc/vocab/~/Announce)
51
+ - [`Arrive`](https://jsr.io/@fedify/fedify/doc/vocab/~/Arrive)
51
52
  - [`Block`](https://jsr.io/@fedify/fedify/doc/vocab/~/Block)
52
53
  - [`Create`](https://jsr.io/@fedify/fedify/doc/vocab/~/Create)
53
54
  - [`Delete`](https://jsr.io/@fedify/fedify/doc/vocab/~/Delete)
package/README.md CHANGED
@@ -25,6 +25,7 @@ Currently, Fedify provides the following features out of the box:
25
25
  extensions)
26
26
  - [WebFinger] client and server
27
27
  - [HTTP Signatures]
28
+ - [Object Integrity Proofs][FEP-8b32]
28
29
  - Middlewares for handling webhooks
29
30
  - [NodeInfo] protocol
30
31
  - Special touch for interoperability with Mastodon and few other popular
@@ -61,6 +62,7 @@ join our [Matrix chat space][Matrix] or [GitHub Discussions]. Or tag
61
62
  [Activity Vocabulary]: https://www.w3.org/TR/activitystreams-vocabulary/
62
63
  [WebFinger]: https://datatracker.ietf.org/doc/html/rfc7033
63
64
  [HTTP Signatures]: https://tools.ietf.org/html/draft-cavage-http-signatures-12
65
+ [FEP-8b32]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md
64
66
  [NodeInfo]: https://nodeinfo.diaspora.software/
65
67
  [GitHub Discussions]: https://github.com/dahlia/fedify/discussions
66
68
  [#Fedify]: https://elk.zone/mastodon.social/tags/fedify
@@ -11,6 +11,20 @@ import { buildCollectionSynchronizationHeader } from "./collection.js";
11
11
  import { handleActor, handleCollection, handleInbox, handleObject, } from "./handler.js";
12
12
  import { Router, RouterError } from "./router.js";
13
13
  import { extractInboxes, sendActivity } from "./send.js";
14
+ const invokedByCreateFederation = Symbol("invokedByCreateFederation");
15
+ /**
16
+ * Create a new {@link Federation} instance.
17
+ * @param parameters Parameters for initializing the instance.
18
+ * @returns A new {@link Federation} instance.
19
+ * @since 0.10.0
20
+ */
21
+ export function createFederation(options) {
22
+ return new Federation({
23
+ ...options,
24
+ // @ts-ignore: This is a private symbol.
25
+ [invokedByCreateFederation]: true,
26
+ });
27
+ }
14
28
  /**
15
29
  * An object that registers federation-related business logic and dispatches
16
30
  * requests to the appropriate handlers.
@@ -43,17 +57,24 @@ export class Federation {
43
57
  /**
44
58
  * Create a new {@link Federation} instance.
45
59
  * @param parameters Parameters for initializing the instance.
60
+ * @deprecated Use {@link createFederation} method instead.
46
61
  */
47
- constructor({ kv, kvPrefixes, queue, documentLoader, contextLoader, authenticatedDocumentLoaderFactory, treatHttps, onOutboxError, signatureTimeWindow, backoffSchedule, }) {
48
- this.#kv = kv;
62
+ constructor(options) {
63
+ const logger = getLogger(["fedify", "federation"]);
64
+ // @ts-ignore: This is a private symbol.
65
+ if (!options[invokedByCreateFederation]) {
66
+ logger.warn("The Federation constructor is deprecated. Use the createFederation()" +
67
+ "function instead.");
68
+ }
69
+ this.#kv = options.kv;
49
70
  this.#kvPrefixes = {
50
71
  ...({
51
72
  activityIdempotence: ["_fedify", "activityIdempotence"],
52
73
  remoteDocument: ["_fedify", "remoteDocument"],
53
74
  }),
54
- ...(kvPrefixes ?? {}),
75
+ ...(options.kvPrefixes ?? {}),
55
76
  };
56
- this.#queue = queue;
77
+ this.#queue = options.queue;
57
78
  this.#queueStarted = false;
58
79
  this.#router = new Router();
59
80
  this.#router.add("/.well-known/webfinger", "webfinger");
@@ -61,25 +82,25 @@ export class Federation {
61
82
  this.#inboxListeners = new Map();
62
83
  this.#objectCallbacks = {};
63
84
  this.#objectTypeIds = {};
64
- this.#documentLoader = documentLoader ?? kvCache({
85
+ this.#documentLoader = options.documentLoader ?? kvCache({
65
86
  loader: fetchDocumentLoader,
66
- kv: kv,
87
+ kv: options.kv,
67
88
  prefix: this.#kvPrefixes.remoteDocument,
68
89
  });
69
- this.#contextLoader = contextLoader ?? this.#documentLoader;
90
+ this.#contextLoader = options.contextLoader ?? this.#documentLoader;
70
91
  this.#authenticatedDocumentLoaderFactory =
71
- authenticatedDocumentLoaderFactory ??
92
+ options.authenticatedDocumentLoaderFactory ??
72
93
  getAuthenticatedDocumentLoader;
73
- this.#onOutboxError = onOutboxError;
74
- this.#treatHttps = treatHttps ?? false;
75
- if (treatHttps) {
76
- getLogger(["fedify", "federation"]).warn("The treatHttps option is deprecated and will be removed in " +
94
+ this.#onOutboxError = options.onOutboxError;
95
+ this.#treatHttps = options.treatHttps ?? false;
96
+ if (options.treatHttps) {
97
+ logger.warn("The treatHttps option is deprecated and will be removed in " +
77
98
  "a future release. Instead, use the x-forwarded-fetch library" +
78
99
  " to recognize the X-Forwarded-Host and X-Forwarded-Proto " +
79
100
  "headers. See also: <https://github.com/dahlia/x-forwarded-fetch>.");
80
101
  }
81
- this.#signatureTimeWindow = signatureTimeWindow ?? { minutes: 1 };
82
- this.#backoffSchedule = backoffSchedule ?? [
102
+ this.#signatureTimeWindow = options.signatureTimeWindow ?? { minutes: 1 };
103
+ this.#backoffSchedule = options.backoffSchedule ?? [
83
104
  3000,
84
105
  15000,
85
106
  60000,
package/esm/mod.js CHANGED
@@ -14,6 +14,7 @@
14
14
  * extensions)
15
15
  * - [WebFinger] client and server
16
16
  * - [HTTP Signatures]
17
+ * - [Object Integrity Proofs][FEP-8b32]
17
18
  * - Middlewares for handling webhooks
18
19
  * - [NodeInfo] protocol
19
20
  * - Special touch for interoperability with Mastodon and few other popular
@@ -32,6 +33,7 @@
32
33
  * [Activity Vocabulary]: https://www.w3.org/TR/activitystreams-vocabulary/
33
34
  * [WebFinger]: https://datatracker.ietf.org/doc/html/rfc7033
34
35
  * [HTTP Signatures]: https://tools.ietf.org/html/draft-cavage-http-signatures-12
36
+ * [FEP-8b32]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md
35
37
  * [NodeInfo]: https://nodeinfo.diaspora.software/
36
38
  *
37
39
  * @module
@@ -0,0 +1,13 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: Arrive
3
+ uri: "https://www.w3.org/ns/activitystreams#Arrive"
4
+ extends: "https://www.w3.org/ns/activitystreams#IntransitiveActivity"
5
+ entity: true
6
+ description: |
7
+ An `IntransitiveActivity` that indicates that the `actor` has arrived at the `location`.
8
+ The `origin` can be used to identify the context from which the `actor` originated.
9
+ The `target` typically has no defined meaning.
10
+ defaultContext:
11
+ - "https://www.w3.org/ns/activitystreams"
12
+ - "https://w3id.org/security/data-integrity/v1"
13
+ properties: []
@@ -2198,6 +2198,10 @@ export class Object {
2198
2198
  delete values["@type"];
2199
2199
  return await IntransitiveActivity.fromJsonLd(values, options);
2200
2200
  }
2201
+ if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
2202
+ delete values["@type"];
2203
+ return await Arrive.fromJsonLd(values, options);
2204
+ }
2201
2205
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
2202
2206
  delete values["@type"];
2203
2207
  return await Question.fromJsonLd(values, options);
@@ -2338,6 +2342,7 @@ export class Object {
2338
2342
  "https://www.w3.org/ns/activitystreams#Ignore",
2339
2343
  "https://www.w3.org/ns/activitystreams#Block",
2340
2344
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2345
+ "https://www.w3.org/ns/activitystreams#Arrive",
2341
2346
  "https://www.w3.org/ns/activitystreams#Question",
2342
2347
  "https://www.w3.org/ns/activitystreams#Like",
2343
2348
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2476,6 +2481,7 @@ export class Object {
2476
2481
  "https://www.w3.org/ns/activitystreams#Ignore",
2477
2482
  "https://www.w3.org/ns/activitystreams#Block",
2478
2483
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2484
+ "https://www.w3.org/ns/activitystreams#Arrive",
2479
2485
  "https://www.w3.org/ns/activitystreams#Question",
2480
2486
  "https://www.w3.org/ns/activitystreams#Like",
2481
2487
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2569,6 +2575,7 @@ export class Object {
2569
2575
  "https://www.w3.org/ns/activitystreams#Ignore",
2570
2576
  "https://www.w3.org/ns/activitystreams#Block",
2571
2577
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2578
+ "https://www.w3.org/ns/activitystreams#Arrive",
2572
2579
  "https://www.w3.org/ns/activitystreams#Question",
2573
2580
  "https://www.w3.org/ns/activitystreams#Like",
2574
2581
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2662,6 +2669,7 @@ export class Object {
2662
2669
  "https://www.w3.org/ns/activitystreams#Ignore",
2663
2670
  "https://www.w3.org/ns/activitystreams#Block",
2664
2671
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2672
+ "https://www.w3.org/ns/activitystreams#Arrive",
2665
2673
  "https://www.w3.org/ns/activitystreams#Question",
2666
2674
  "https://www.w3.org/ns/activitystreams#Like",
2667
2675
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2731,6 +2739,7 @@ export class Object {
2731
2739
  "https://www.w3.org/ns/activitystreams#Ignore",
2732
2740
  "https://www.w3.org/ns/activitystreams#Block",
2733
2741
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2742
+ "https://www.w3.org/ns/activitystreams#Arrive",
2734
2743
  "https://www.w3.org/ns/activitystreams#Question",
2735
2744
  "https://www.w3.org/ns/activitystreams#Like",
2736
2745
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2808,6 +2817,7 @@ export class Object {
2808
2817
  "https://www.w3.org/ns/activitystreams#Ignore",
2809
2818
  "https://www.w3.org/ns/activitystreams#Block",
2810
2819
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2820
+ "https://www.w3.org/ns/activitystreams#Arrive",
2811
2821
  "https://www.w3.org/ns/activitystreams#Question",
2812
2822
  "https://www.w3.org/ns/activitystreams#Like",
2813
2823
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -2912,6 +2922,7 @@ export class Object {
2912
2922
  "https://www.w3.org/ns/activitystreams#Ignore",
2913
2923
  "https://www.w3.org/ns/activitystreams#Block",
2914
2924
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
2925
+ "https://www.w3.org/ns/activitystreams#Arrive",
2915
2926
  "https://www.w3.org/ns/activitystreams#Question",
2916
2927
  "https://www.w3.org/ns/activitystreams#Like",
2917
2928
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -5206,6 +5217,10 @@ export class Activity extends Object {
5206
5217
  delete values["@type"];
5207
5218
  return await IntransitiveActivity.fromJsonLd(values, options);
5208
5219
  }
5220
+ if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
5221
+ delete values["@type"];
5222
+ return await Arrive.fromJsonLd(values, options);
5223
+ }
5209
5224
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
5210
5225
  delete values["@type"];
5211
5226
  return await Question.fromJsonLd(values, options);
@@ -6933,6 +6948,240 @@ export class Application extends Object {
6933
6948
  return "Application " + inspect(proxy, options);
6934
6949
  }
6935
6950
  }
6951
+ /** Instances of `IntransitiveActivity` are a subtype of {@link Activity}
6952
+ * representing intransitive actions. The `object` property is therefore
6953
+ * inappropriate for these activities.
6954
+ */
6955
+ export class IntransitiveActivity extends Activity {
6956
+ /**
6957
+ * The type URI of {@link IntransitiveActivity}: `https://www.w3.org/ns/activitystreams#IntransitiveActivity`.
6958
+ */
6959
+ static get typeId() {
6960
+ return new URL("https://www.w3.org/ns/activitystreams#IntransitiveActivity");
6961
+ }
6962
+ /**
6963
+ * Constructs a new instance of IntransitiveActivity with the given values.
6964
+ * @param values The values to initialize the instance with.
6965
+ * @param options The options to use for initialization.
6966
+ */
6967
+ constructor(values, { documentLoader, contextLoader, } = {}) {
6968
+ super(values, { documentLoader, contextLoader });
6969
+ }
6970
+ /**
6971
+ * Clones this instance, optionally updating it with the given values.
6972
+ * @param values The values to update the clone with.
6973
+ * @options The options to use for cloning.
6974
+ * @returns The cloned instance.
6975
+ */
6976
+ clone(values = {}, options = {}) {
6977
+ const clone = super.clone(values, options);
6978
+ return clone;
6979
+ }
6980
+ /**
6981
+ * Converts this object to a JSON-LD structure.
6982
+ * @returns The JSON-LD representation of this object.
6983
+ */
6984
+ async toJsonLd(options = {}) {
6985
+ options = {
6986
+ ...options,
6987
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
6988
+ };
6989
+ // deno-lint-ignore no-unused-vars prefer-const
6990
+ let array;
6991
+ const baseValues = await super.toJsonLd({
6992
+ ...options,
6993
+ expand: true,
6994
+ });
6995
+ const values = baseValues[0];
6996
+ values["@type"] = [
6997
+ "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
6998
+ ];
6999
+ if (this.id)
7000
+ values["@id"] = this.id.href;
7001
+ if (options.expand) {
7002
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
7003
+ }
7004
+ return await jsonld.compact(values, options.context ??
7005
+ [
7006
+ "https://www.w3.org/ns/activitystreams",
7007
+ "https://w3id.org/security/data-integrity/v1",
7008
+ ], { documentLoader: options.contextLoader });
7009
+ }
7010
+ /**
7011
+ * Converts a JSON-LD structure to an object of this type.
7012
+ * @param json The JSON-LD structure to convert.
7013
+ * @returns The object of this type.
7014
+ * @throws {TypeError} If the given `json` is invalid.
7015
+ */
7016
+ static async fromJsonLd(json, options = {}) {
7017
+ if (typeof json === "undefined") {
7018
+ throw new TypeError("Invalid JSON-LD: undefined.");
7019
+ }
7020
+ else if (json === null)
7021
+ throw new TypeError("Invalid JSON-LD: null.");
7022
+ options = {
7023
+ ...options,
7024
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
7025
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
7026
+ };
7027
+ // deno-lint-ignore no-explicit-any
7028
+ let values;
7029
+ if (globalThis.Object.keys(json).length == 0) {
7030
+ values = {};
7031
+ }
7032
+ else {
7033
+ const expanded = await jsonld.expand(json, {
7034
+ documentLoader: options.contextLoader,
7035
+ keepFreeFloatingNodes: true,
7036
+ });
7037
+ values =
7038
+ // deno-lint-ignore no-explicit-any
7039
+ (expanded[0] ?? {});
7040
+ }
7041
+ if ("@type" in values) {
7042
+ if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
7043
+ delete values["@type"];
7044
+ return await Arrive.fromJsonLd(values, options);
7045
+ }
7046
+ if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
7047
+ delete values["@type"];
7048
+ return await Question.fromJsonLd(values, options);
7049
+ }
7050
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#IntransitiveActivity")) {
7051
+ throw new TypeError("Invalid type: " + values["@type"]);
7052
+ }
7053
+ }
7054
+ const instance = await super.fromJsonLd(values, options);
7055
+ if (!(instance instanceof IntransitiveActivity)) {
7056
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
7057
+ }
7058
+ return instance;
7059
+ }
7060
+ _getCustomInspectProxy() {
7061
+ const proxy = super._getCustomInspectProxy();
7062
+ return proxy;
7063
+ }
7064
+ [Symbol.for("Deno.customInspect")](inspect, options) {
7065
+ const proxy = this._getCustomInspectProxy();
7066
+ return "IntransitiveActivity " + inspect(proxy, options);
7067
+ }
7068
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
7069
+ const proxy = this._getCustomInspectProxy();
7070
+ return "IntransitiveActivity " + inspect(proxy, options);
7071
+ }
7072
+ }
7073
+ /** An `IntransitiveActivity` that indicates that the `actor` has arrived at the `location`.
7074
+ * The `origin` can be used to identify the context from which the `actor` originated.
7075
+ * The `target` typically has no defined meaning.
7076
+ */
7077
+ export class Arrive extends IntransitiveActivity {
7078
+ /**
7079
+ * The type URI of {@link Arrive}: `https://www.w3.org/ns/activitystreams#Arrive`.
7080
+ */
7081
+ static get typeId() {
7082
+ return new URL("https://www.w3.org/ns/activitystreams#Arrive");
7083
+ }
7084
+ /**
7085
+ * Constructs a new instance of Arrive with the given values.
7086
+ * @param values The values to initialize the instance with.
7087
+ * @param options The options to use for initialization.
7088
+ */
7089
+ constructor(values, { documentLoader, contextLoader, } = {}) {
7090
+ super(values, { documentLoader, contextLoader });
7091
+ }
7092
+ /**
7093
+ * Clones this instance, optionally updating it with the given values.
7094
+ * @param values The values to update the clone with.
7095
+ * @options The options to use for cloning.
7096
+ * @returns The cloned instance.
7097
+ */
7098
+ clone(values = {}, options = {}) {
7099
+ const clone = super.clone(values, options);
7100
+ return clone;
7101
+ }
7102
+ /**
7103
+ * Converts this object to a JSON-LD structure.
7104
+ * @returns The JSON-LD representation of this object.
7105
+ */
7106
+ async toJsonLd(options = {}) {
7107
+ options = {
7108
+ ...options,
7109
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
7110
+ };
7111
+ // deno-lint-ignore no-unused-vars prefer-const
7112
+ let array;
7113
+ const baseValues = await super.toJsonLd({
7114
+ ...options,
7115
+ expand: true,
7116
+ });
7117
+ const values = baseValues[0];
7118
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Arrive"];
7119
+ if (this.id)
7120
+ values["@id"] = this.id.href;
7121
+ if (options.expand) {
7122
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
7123
+ }
7124
+ return await jsonld.compact(values, options.context ??
7125
+ [
7126
+ "https://www.w3.org/ns/activitystreams",
7127
+ "https://w3id.org/security/data-integrity/v1",
7128
+ ], { documentLoader: options.contextLoader });
7129
+ }
7130
+ /**
7131
+ * Converts a JSON-LD structure to an object of this type.
7132
+ * @param json The JSON-LD structure to convert.
7133
+ * @returns The object of this type.
7134
+ * @throws {TypeError} If the given `json` is invalid.
7135
+ */
7136
+ static async fromJsonLd(json, options = {}) {
7137
+ if (typeof json === "undefined") {
7138
+ throw new TypeError("Invalid JSON-LD: undefined.");
7139
+ }
7140
+ else if (json === null)
7141
+ throw new TypeError("Invalid JSON-LD: null.");
7142
+ options = {
7143
+ ...options,
7144
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
7145
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
7146
+ };
7147
+ // deno-lint-ignore no-explicit-any
7148
+ let values;
7149
+ if (globalThis.Object.keys(json).length == 0) {
7150
+ values = {};
7151
+ }
7152
+ else {
7153
+ const expanded = await jsonld.expand(json, {
7154
+ documentLoader: options.contextLoader,
7155
+ keepFreeFloatingNodes: true,
7156
+ });
7157
+ values =
7158
+ // deno-lint-ignore no-explicit-any
7159
+ (expanded[0] ?? {});
7160
+ }
7161
+ if ("@type" in values) {
7162
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
7163
+ throw new TypeError("Invalid type: " + values["@type"]);
7164
+ }
7165
+ }
7166
+ const instance = await super.fromJsonLd(values, options);
7167
+ if (!(instance instanceof Arrive)) {
7168
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
7169
+ }
7170
+ return instance;
7171
+ }
7172
+ _getCustomInspectProxy() {
7173
+ const proxy = super._getCustomInspectProxy();
7174
+ return proxy;
7175
+ }
7176
+ [Symbol.for("Deno.customInspect")](inspect, options) {
7177
+ const proxy = this._getCustomInspectProxy();
7178
+ return "Arrive " + inspect(proxy, options);
7179
+ }
7180
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
7181
+ const proxy = this._getCustomInspectProxy();
7182
+ return "Arrive " + inspect(proxy, options);
7183
+ }
7184
+ }
6936
7185
  /** Represents any kind of multi-paragraph written work.
6937
7186
  */
6938
7187
  export class Article extends Object {
@@ -8151,6 +8400,7 @@ export class Collection extends Object {
8151
8400
  "https://www.w3.org/ns/activitystreams#Ignore",
8152
8401
  "https://www.w3.org/ns/activitystreams#Block",
8153
8402
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
8403
+ "https://www.w3.org/ns/activitystreams#Arrive",
8154
8404
  "https://www.w3.org/ns/activitystreams#Question",
8155
8405
  "https://www.w3.org/ns/activitystreams#Like",
8156
8406
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -11548,6 +11798,7 @@ export class Link {
11548
11798
  "https://www.w3.org/ns/activitystreams#Ignore",
11549
11799
  "https://www.w3.org/ns/activitystreams#Block",
11550
11800
  "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
11801
+ "https://www.w3.org/ns/activitystreams#Arrive",
11551
11802
  "https://www.w3.org/ns/activitystreams#Question",
11552
11803
  "https://www.w3.org/ns/activitystreams#Like",
11553
11804
  "https://www.w3.org/ns/activitystreams#Reject",
@@ -11920,124 +12171,6 @@ export class Image extends Document {
11920
12171
  return "Image " + inspect(proxy, options);
11921
12172
  }
11922
12173
  }
11923
- /** Instances of `IntransitiveActivity` are a subtype of {@link Activity}
11924
- * representing intransitive actions. The `object` property is therefore
11925
- * inappropriate for these activities.
11926
- */
11927
- export class IntransitiveActivity extends Activity {
11928
- /**
11929
- * The type URI of {@link IntransitiveActivity}: `https://www.w3.org/ns/activitystreams#IntransitiveActivity`.
11930
- */
11931
- static get typeId() {
11932
- return new URL("https://www.w3.org/ns/activitystreams#IntransitiveActivity");
11933
- }
11934
- /**
11935
- * Constructs a new instance of IntransitiveActivity with the given values.
11936
- * @param values The values to initialize the instance with.
11937
- * @param options The options to use for initialization.
11938
- */
11939
- constructor(values, { documentLoader, contextLoader, } = {}) {
11940
- super(values, { documentLoader, contextLoader });
11941
- }
11942
- /**
11943
- * Clones this instance, optionally updating it with the given values.
11944
- * @param values The values to update the clone with.
11945
- * @options The options to use for cloning.
11946
- * @returns The cloned instance.
11947
- */
11948
- clone(values = {}, options = {}) {
11949
- const clone = super.clone(values, options);
11950
- return clone;
11951
- }
11952
- /**
11953
- * Converts this object to a JSON-LD structure.
11954
- * @returns The JSON-LD representation of this object.
11955
- */
11956
- async toJsonLd(options = {}) {
11957
- options = {
11958
- ...options,
11959
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
11960
- };
11961
- // deno-lint-ignore no-unused-vars prefer-const
11962
- let array;
11963
- const baseValues = await super.toJsonLd({
11964
- ...options,
11965
- expand: true,
11966
- });
11967
- const values = baseValues[0];
11968
- values["@type"] = [
11969
- "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
11970
- ];
11971
- if (this.id)
11972
- values["@id"] = this.id.href;
11973
- if (options.expand) {
11974
- return await jsonld.expand(values, { documentLoader: options.contextLoader });
11975
- }
11976
- return await jsonld.compact(values, options.context ??
11977
- [
11978
- "https://www.w3.org/ns/activitystreams",
11979
- "https://w3id.org/security/data-integrity/v1",
11980
- ], { documentLoader: options.contextLoader });
11981
- }
11982
- /**
11983
- * Converts a JSON-LD structure to an object of this type.
11984
- * @param json The JSON-LD structure to convert.
11985
- * @returns The object of this type.
11986
- * @throws {TypeError} If the given `json` is invalid.
11987
- */
11988
- static async fromJsonLd(json, options = {}) {
11989
- if (typeof json === "undefined") {
11990
- throw new TypeError("Invalid JSON-LD: undefined.");
11991
- }
11992
- else if (json === null)
11993
- throw new TypeError("Invalid JSON-LD: null.");
11994
- options = {
11995
- ...options,
11996
- documentLoader: options.documentLoader ?? fetchDocumentLoader,
11997
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
11998
- };
11999
- // deno-lint-ignore no-explicit-any
12000
- let values;
12001
- if (globalThis.Object.keys(json).length == 0) {
12002
- values = {};
12003
- }
12004
- else {
12005
- const expanded = await jsonld.expand(json, {
12006
- documentLoader: options.contextLoader,
12007
- keepFreeFloatingNodes: true,
12008
- });
12009
- values =
12010
- // deno-lint-ignore no-explicit-any
12011
- (expanded[0] ?? {});
12012
- }
12013
- if ("@type" in values) {
12014
- if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
12015
- delete values["@type"];
12016
- return await Question.fromJsonLd(values, options);
12017
- }
12018
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#IntransitiveActivity")) {
12019
- throw new TypeError("Invalid type: " + values["@type"]);
12020
- }
12021
- }
12022
- const instance = await super.fromJsonLd(values, options);
12023
- if (!(instance instanceof IntransitiveActivity)) {
12024
- throw new TypeError("Unexpected type: " + instance.constructor.name);
12025
- }
12026
- return instance;
12027
- }
12028
- _getCustomInspectProxy() {
12029
- const proxy = super._getCustomInspectProxy();
12030
- return proxy;
12031
- }
12032
- [Symbol.for("Deno.customInspect")](inspect, options) {
12033
- const proxy = this._getCustomInspectProxy();
12034
- return "IntransitiveActivity " + inspect(proxy, options);
12035
- }
12036
- [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
12037
- const proxy = this._getCustomInspectProxy();
12038
- return "IntransitiveActivity " + inspect(proxy, options);
12039
- }
12040
- }
12041
12174
  /** Indicates that the `actor` likes, recommends or endorses the `object`.
12042
12175
  * The `target` and `origin` typically have no defined meaning.
12043
12176
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.10.0-dev.213+d066facc",
3
+ "version": "0.10.0-dev.219+22cef13a",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",