@fedify/fedify 0.10.0-dev.212 → 0.10.0-dev.218
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.
- package/CHANGES.md +11 -0
- package/FEDERATION.md +1 -0
- package/README.md +2 -0
- package/esm/federation/handler.js +3 -0
- package/esm/federation/middleware.js +5 -19
- package/esm/mod.js +2 -0
- package/esm/vocab/arrive.yaml +13 -0
- package/esm/vocab/vocab.js +251 -118
- package/package.json +1 -1
- package/types/federation/handler.d.ts.map +1 -1
- package/types/federation/middleware.d.ts +0 -13
- package/types/federation/middleware.d.ts.map +1 -1
- package/types/mod.d.ts +2 -0
- package/types/mod.d.ts.map +1 -1
- package/types/vocab/vocab.d.ts +298 -149
- package/types/vocab/vocab.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -106,6 +106,9 @@ To be released.
|
|
106
106
|
- The `Context.sendActivity()` method's first parameter now accepts
|
107
107
|
`SenderKeyPair[]` as well.
|
108
108
|
|
109
|
+
- Added `Arrive` class to Activity Vocabulary API.
|
110
|
+
[[#65], [#68] by Randy Wressell]
|
111
|
+
|
109
112
|
- Added `Question` class to Activity Vocabulary API.
|
110
113
|
|
111
114
|
- Added `context` option to `Object.toJsonLd()` method. This applies to
|
@@ -115,6 +118,12 @@ To be released.
|
|
115
118
|
Instead, use the [x-forwarded-fetch] library to recognize the
|
116
119
|
`X-Forwarded-Host` and `X-Forwarded-Proto` headers.
|
117
120
|
|
121
|
+
- Removed the `Federation.handle()` method which was deprecated in version
|
122
|
+
0.6.0.
|
123
|
+
|
124
|
+
- Removed the `integrateHandlerOptions()` function from
|
125
|
+
`@fedify/fedify/x/fresh` which was deprecated in version 0.6.0.
|
126
|
+
|
118
127
|
- Ephemeral actors and inboxes that the `fedify inbox` command spawns are
|
119
128
|
now more interoperable with other ActivityPub implementations.
|
120
129
|
|
@@ -134,6 +143,8 @@ To be released.
|
|
134
143
|
|
135
144
|
[#54]: https://github.com/dahlia/fedify/issues/54
|
136
145
|
[#55]: https://github.com/dahlia/fedify/issues/55
|
146
|
+
[#65]: https://github.com/dahlia/fedify/issues/65
|
147
|
+
[#68]: https://github.com/dahlia/fedify/pull/68
|
137
148
|
[FEP-521a]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
|
138
149
|
[FEP-8b32]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8b32/fep-8b32.md
|
139
150
|
[x-forwarded-fetch]: https://github.com/dahlia/x-forwarded-fetch
|
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
|
@@ -19,6 +19,9 @@ export function acceptsJsonLd(request) {
|
|
19
19
|
export async function handleActor(request, { handle, context, actorDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized, }) {
|
20
20
|
if (actorDispatcher == null)
|
21
21
|
return await onNotFound(request);
|
22
|
+
// FIXME: When the deprecated last parameter (key) of ActorDispatcher
|
23
|
+
// is removed, replace the below line with a direct all to
|
24
|
+
// actorDispatcher:
|
22
25
|
const actor = await context.getActor(handle);
|
23
26
|
if (actor == null)
|
24
27
|
return await onNotFound(request);
|
@@ -670,22 +670,6 @@ export class Federation {
|
|
670
670
|
this.#queue.enqueue(message);
|
671
671
|
}
|
672
672
|
}
|
673
|
-
/**
|
674
|
-
* Handles a request related to federation. If a request is not related to
|
675
|
-
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|
676
|
-
*
|
677
|
-
* Usually, this method is called from a server's request handler or
|
678
|
-
* a web framework's middleware.
|
679
|
-
*
|
680
|
-
* @param request The request object.
|
681
|
-
* @param parameters The parameters for handling the request.
|
682
|
-
* @returns The response to the request.
|
683
|
-
* @deprecated Use {@link Federation.fetch} instead.
|
684
|
-
*/
|
685
|
-
handle(request, options) {
|
686
|
-
getLogger(["fedify", "federation"]).warn("Federation.handle() is deprecated. Use Federation.fetch() instead.");
|
687
|
-
return this.fetch(request, options);
|
688
|
-
}
|
689
673
|
/**
|
690
674
|
* Handles a request related to federation. If a request is not related to
|
691
675
|
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|
@@ -743,9 +727,11 @@ export class Federation {
|
|
743
727
|
nodeInfoDispatcher: this.#nodeInfoDispatcher,
|
744
728
|
});
|
745
729
|
case "actor":
|
746
|
-
|
747
|
-
|
748
|
-
|
730
|
+
// FIXME: When the deprecated last parameter (key) of ActorDispatcher
|
731
|
+
// is removed, uncomment the following line.
|
732
|
+
// context = this.#createContext(request, contextData, {
|
733
|
+
// invokedFromActorDispatcher: { handle: route.values.handle },
|
734
|
+
// });
|
749
735
|
return await handleActor(request, {
|
750
736
|
handle: route.values.handle,
|
751
737
|
context,
|
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: []
|
package/esm/vocab/vocab.js
CHANGED
@@ -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 +1 @@
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.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E,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAChD,cAAc,EAAE,GAAG,CACjB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,EACpC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CACtC,CAAC;IACF,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;CACpD;AAED,wBAAsB,WAAW,CAAC,YAAY,EAC5C,OAAO,EAAE,OAAO,EAChB,EACE,MAAM,EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CA0InB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,aAAa,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
|
@@ -355,19 +355,6 @@ export declare class Federation<TContextData> {
|
|
355
355
|
* @throws {TypeError} If the activity to send does not have an actor.
|
356
356
|
*/
|
357
357
|
sendActivity(keys: SenderKeyPair[], recipients: Recipient | Recipient[], activity: Activity, { preferSharedInbox, immediate, excludeBaseUris, collectionSync }?: SendActivityInternalOptions): Promise<void>;
|
358
|
-
/**
|
359
|
-
* Handles a request related to federation. If a request is not related to
|
360
|
-
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|
361
|
-
*
|
362
|
-
* Usually, this method is called from a server's request handler or
|
363
|
-
* a web framework's middleware.
|
364
|
-
*
|
365
|
-
* @param request The request object.
|
366
|
-
* @param parameters The parameters for handling the request.
|
367
|
-
* @returns The response to the request.
|
368
|
-
* @deprecated Use {@link Federation.fetch} instead.
|
369
|
-
*/
|
370
|
-
handle(request: Request, options: FederationFetchOptions<TContextData>): Promise<Response>;
|
371
358
|
/**
|
372
359
|
* Handles a request related to federation. If a request is not related to
|
373
360
|
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|