@fedify/fedify 2.0.0-dev.1604 → 2.0.0-dev.1690
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/dist/actor-Be0ThtXy.cjs +42609 -0
- package/dist/{actor-BC3XtGTj.js → actor-ChbPLm6n.js} +7266 -2443
- package/dist/actor-D6K058Tb.d.cts +128 -0
- package/dist/{actor-CmRlosMl.js → actor-DuCeRiNh.js} +1 -1
- package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
- package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
- package/dist/{authdocloader-CzpPQC01.js → authdocloader-Brax1A32.js} +3 -3
- package/dist/{authdocloader-D-DICGXT.js → authdocloader-CrxhFL8e.js} +6 -6
- package/dist/authdocloader-OSn_teLV.cjs +58 -0
- package/dist/{builder-D9zidAqR.js → builder-CYOcDUkj.js} +10 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-CegPX0Rn.d.cts +222 -0
- package/dist/{client-Bsj0vQPr.js → client-CnOdwLLN.js} +1 -1
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +18 -17
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-CDSZdQHD.d.ts → context-ByZprN0S.d.ts} +66 -6
- package/dist/context-C5BsZkDr.d.cts +2315 -0
- package/dist/docloader-CCqXeagZ.cjs +4861 -0
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{docloader-CkASOfZ5.js → docloader-XK3y2jn5.js} +189 -9
- package/dist/{esm-CXF1VoeR.js → esm-DnIzfEj0.js} +1 -1
- package/dist/federation/builder.test.js +10 -10
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +26 -145
- package/dist/federation/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +9 -8
- package/dist/federation/middleware.test.js +232 -38
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.d.ts +3 -0
- package/dist/federation/negotiation.test.js +28 -0
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +8 -8
- package/dist/federation/send.test.js +15 -15
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-CSYNybkH.js → http-BNOYnVsU.js} +2 -2
- package/dist/{http-B_pxY5of.js → http-BxbM8sEy.js} +6 -6
- package/dist/http-C7vbQwbz.cjs +826 -0
- package/dist/http-D-e6AFwR.d.cts +253 -0
- package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
- package/dist/{inbox-DoJlwIE4.js → inbox-BRru9pX3.js} +24 -7
- package/dist/{key-BOzqiGbl.js → key-1KXru8Ug.js} +2 -2
- package/dist/key-B3uag-rz.js +10 -0
- package/dist/key-BiBmb1Yy.cjs +10 -0
- package/dist/{key-DWWqeyaq.js → key-DK_nfU4I.js} +3 -3
- package/dist/key-Z6ceKnZC.cjs +290 -0
- package/dist/{key-Bif4eMj7.js → key-jyNTxCvK.js} +5 -5
- package/dist/{keycache--NYDYifd.js → keycache-CN61iGVj.js} +1 -1
- package/dist/{keys-MacD9GP6.js → keys-BPdFKgiy.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-D9oTBLrs.js → ld-Dv8DNNAT.js} +2 -2
- package/dist/{lookup-Cz9VSYxw.js → lookup-BPviO8ij.js} +4 -4
- package/dist/lookup-hnMAAU5r.cjs +137 -0
- package/dist/{lookup-DuzrBbTj.js → lookup-pV0JOsuV.js} +21 -12
- package/dist/middleware-BmoOlgc1.cjs +4231 -0
- package/dist/{middleware-C0w2M0tb.js → middleware-Bz_A2jeJ.js} +87 -91
- package/dist/middleware-CI0-zw4U.js +26 -0
- package/dist/{middleware-CgNm3XOJ.js → middleware-DY9B2lL8.js} +57 -148
- package/dist/middleware-QNK-W-jE.cjs +17 -0
- package/dist/middleware-_vjt6FWU.js +17 -0
- package/dist/mod-8DMWKtQE.d.cts +80 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
- package/dist/mod-Cj1tHXBR.d.cts +102 -0
- package/dist/mod-CxkWO3Mg.d.cts +307 -0
- package/dist/{mod-RI3-KvUI.d.ts → mod-D6hQoxC5.d.ts} +2 -2
- package/dist/mod-Djzcw2ry.d.cts +266 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +150 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +10 -10
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +11 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-BN_tO3cY.d.cts +67 -0
- package/dist/{owner-gB-pDKA-.js → owner-e3FYDhsk.js} +2 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
- package/dist/{proof-CScVkkIT.js → proof-6gFMwMNJ.js} +2 -2
- package/dist/proof-B-eqv0Ug.cjs +673 -0
- package/dist/{proof-VPikK_0V.js → proof-DfgvA3al.js} +6 -6
- package/dist/runtime/authdocloader.test.js +14 -14
- package/dist/runtime/docloader.test.js +9 -9
- package/dist/runtime/key.test.js +10 -10
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-flZ7H10-.js → send-Tl9NOnmO.js} +2 -2
- package/dist/sig/http.test.js +13 -13
- package/dist/sig/key.test.js +11 -11
- package/dist/sig/ld.test.js +10 -10
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.d.ts +272 -0
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CdBSI4xF.js → testing-BWNCAbL-.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-CAteiET0.js → type-C69ZBu7f.js} +7258 -2255
- package/dist/{types-Vo0qKhN7.js → types-DqxyTxOf.js} +4 -4
- package/dist/types-zqdWZh4O.cjs +315 -0
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +259 -9
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +438 -14
- package/dist/vocab-B39-pFl9.cjs +291 -0
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
- package/dist/{vocab-89qErSc9.js → vocab-BWoeZsME.js} +26 -17
- package/dist/vocab-Dw1-yVGg.d.cts +14922 -0
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +6 -6
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-BteSu1lX.js +0 -10
- package/dist/middleware-CNfiKLIZ.js +0 -25
- package/dist/middleware-CnvU63kV.js +0 -17
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
- /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
- /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -0,0 +1,307 @@
|
|
1
|
+
import { DocumentLoader, GetUserAgentOptions } from "./docloader-D-MrRyHl.cjs";
|
2
|
+
import { Collection, Link, Object as Object$1 } from "./vocab-Dw1-yVGg.cjs";
|
3
|
+
import { TracerProvider } from "@opentelemetry/api";
|
4
|
+
|
5
|
+
//#region src/vocab/lookup.d.ts
|
6
|
+
/**
|
7
|
+
* Options for the {@link lookupObject} function.
|
8
|
+
*
|
9
|
+
* @since 0.2.0
|
10
|
+
*/
|
11
|
+
interface LookupObjectOptions {
|
12
|
+
/**
|
13
|
+
* The document loader for loading remote JSON-LD documents.
|
14
|
+
*/
|
15
|
+
documentLoader?: DocumentLoader;
|
16
|
+
/**
|
17
|
+
* The context loader for loading remote JSON-LD contexts.
|
18
|
+
* @since 0.8.0
|
19
|
+
*/
|
20
|
+
contextLoader?: DocumentLoader;
|
21
|
+
/**
|
22
|
+
* Whether to allow fetching an object with an `@id` having a different
|
23
|
+
* origin than the object's URL. This is not recommended, as it may
|
24
|
+
* lead to security issues. Only use this option if you know what you
|
25
|
+
* are doing.
|
26
|
+
*
|
27
|
+
* How to handle the case when an object's `@id` has a different origin
|
28
|
+
* than the object's URL:
|
29
|
+
*
|
30
|
+
* - `"ignore"` (default): Do not return the object, and log a warning.
|
31
|
+
* - `"throw"`: Throw an error.
|
32
|
+
* - `"trust"`: Bypass the check and return the object anyway. This
|
33
|
+
* is not recommended, as it may lead to security issues. Only use
|
34
|
+
* this option if you know what you are doing.
|
35
|
+
*
|
36
|
+
* @since 1.9.0
|
37
|
+
*/
|
38
|
+
crossOrigin?: "ignore" | "throw" | "trust";
|
39
|
+
/**
|
40
|
+
* The options for making `User-Agent` header.
|
41
|
+
* If a string is given, it is used as the `User-Agent` header value.
|
42
|
+
* If an object is given, it is passed to {@link getUserAgent} to generate
|
43
|
+
* the `User-Agent` header value.
|
44
|
+
* @since 1.3.0
|
45
|
+
*/
|
46
|
+
userAgent?: GetUserAgentOptions | string;
|
47
|
+
/**
|
48
|
+
* The OpenTelemetry tracer provider. If omitted, the global tracer provider
|
49
|
+
* is used.
|
50
|
+
* @since 1.3.0
|
51
|
+
*/
|
52
|
+
tracerProvider?: TracerProvider;
|
53
|
+
/**
|
54
|
+
* AbortSignal for cancelling the request.
|
55
|
+
* @since 1.8.0
|
56
|
+
*/
|
57
|
+
signal?: AbortSignal;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
61
|
+
* or a fediverse handle (e.g., `@user@server` or `user@server`).
|
62
|
+
*
|
63
|
+
* @example
|
64
|
+
* ``` typescript
|
65
|
+
* // Look up an actor by its fediverse handle:
|
66
|
+
* await lookupObject("@hongminhee@fosstodon.org");
|
67
|
+
* // returning a `Person` object.
|
68
|
+
*
|
69
|
+
* // A fediverse handle can omit the leading '@':
|
70
|
+
* await lookupObject("hongminhee@fosstodon.org");
|
71
|
+
* // returning a `Person` object.
|
72
|
+
*
|
73
|
+
* // A `acct:` URI can be used as well:
|
74
|
+
* await lookupObject("acct:hongminhee@fosstodon.org");
|
75
|
+
* // returning a `Person` object.
|
76
|
+
*
|
77
|
+
* // Look up an object by its URI:
|
78
|
+
* await lookupObject("https://todon.eu/@hongminhee/112060633798771581");
|
79
|
+
* // returning a `Note` object.
|
80
|
+
*
|
81
|
+
* // It can be a `URL` object as well:
|
82
|
+
* await lookupObject(new URL("https://todon.eu/@hongminhee/112060633798771581"));
|
83
|
+
* // returning a `Note` object.
|
84
|
+
* ```
|
85
|
+
*
|
86
|
+
* @param identifier The URI or fediverse handle to look up.
|
87
|
+
* @param options Lookup options.
|
88
|
+
* @returns The object, or `null` if not found.
|
89
|
+
* @since 0.2.0
|
90
|
+
*/
|
91
|
+
declare function lookupObject(identifier: string | URL, options?: LookupObjectOptions): Promise<Object$1 | null>;
|
92
|
+
/**
|
93
|
+
* Options for the {@link traverseCollection} function.
|
94
|
+
* @since 1.1.0
|
95
|
+
*/
|
96
|
+
interface TraverseCollectionOptions {
|
97
|
+
/**
|
98
|
+
* The document loader for loading remote JSON-LD documents.
|
99
|
+
*/
|
100
|
+
documentLoader?: DocumentLoader;
|
101
|
+
/**
|
102
|
+
* The context loader for loading remote JSON-LD contexts.
|
103
|
+
*/
|
104
|
+
contextLoader?: DocumentLoader;
|
105
|
+
/**
|
106
|
+
* Whether to suppress errors when fetching pages. If `true`,
|
107
|
+
* errors will be logged but not thrown. Defaults to `false`.
|
108
|
+
*/
|
109
|
+
suppressError?: boolean;
|
110
|
+
/**
|
111
|
+
* The interval to wait between fetching pages. Zero or negative
|
112
|
+
* values will disable the interval. Disabled by default.
|
113
|
+
*
|
114
|
+
* @default `{ seconds: 0 }`
|
115
|
+
*/
|
116
|
+
interval?: Temporal.Duration | Temporal.DurationLike;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* Traverses a collection, yielding each item in the collection.
|
120
|
+
* If the collection is paginated, it will fetch the next page
|
121
|
+
* automatically.
|
122
|
+
*
|
123
|
+
* @example
|
124
|
+
* ``` typescript
|
125
|
+
* const collection = await lookupObject(collectionUrl);
|
126
|
+
* if (collection instanceof Collection) {
|
127
|
+
* for await (const item of traverseCollection(collection)) {
|
128
|
+
* console.log(item.id?.href);
|
129
|
+
* }
|
130
|
+
* }
|
131
|
+
* ```
|
132
|
+
*
|
133
|
+
* @param collection The collection to traverse.
|
134
|
+
* @param options Options for traversing the collection.
|
135
|
+
* @returns An async iterable of each item in the collection.
|
136
|
+
* @since 1.1.0
|
137
|
+
*/
|
138
|
+
declare function traverseCollection(collection: Collection, options?: TraverseCollectionOptions): AsyncIterable<Object$1 | Link>;
|
139
|
+
//#endregion
|
140
|
+
//#region src/vocab/constants.d.ts
|
141
|
+
/**
|
142
|
+
* The special public collection for [public addressing]. *Do not mutate this
|
143
|
+
* object.*
|
144
|
+
*
|
145
|
+
* [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
|
146
|
+
*
|
147
|
+
* @since 0.7.0
|
148
|
+
*/
|
149
|
+
declare const PUBLIC_COLLECTION: URL;
|
150
|
+
//#endregion
|
151
|
+
//#region src/vocab/handle.d.ts
|
152
|
+
/**
|
153
|
+
* Represents a fediverse handle, which consists of a username and a host.
|
154
|
+
* The username can be alphanumeric and may include special characters,
|
155
|
+
* while the host is typically a domain name.
|
156
|
+
* @since 1.8.0
|
157
|
+
*/
|
158
|
+
interface FediverseHandle {
|
159
|
+
/**
|
160
|
+
* The username part of the fediverse handle.
|
161
|
+
* It can include alphanumeric characters and some special characters.
|
162
|
+
*/
|
163
|
+
readonly username: string;
|
164
|
+
/**
|
165
|
+
* The host part of the fediverse handle, typically a domain name.
|
166
|
+
* It is the part after the `@` symbol in the handle.
|
167
|
+
*/
|
168
|
+
readonly host: string;
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Parses a fediverse handle in the format `@user@server` or `user@server`.
|
172
|
+
* The `user` part can contain alphanumeric characters and some special
|
173
|
+
* characters except `@`. The `server` part is all characters after the `@`
|
174
|
+
* symbol in the middle.
|
175
|
+
*
|
176
|
+
* @example
|
177
|
+
* ```typescript
|
178
|
+
* const handle = parseFediverseHandle("@username@example.com");
|
179
|
+
* console.log(handle?.username); // "username"
|
180
|
+
* console.log(handle?.host); // "example.com"
|
181
|
+
* ```
|
182
|
+
*
|
183
|
+
* @param handle - The fediverse handle string to parse.
|
184
|
+
* @returns A {@link FediverseHandle} object with `username` and `host`
|
185
|
+
* if the input is valid; otherwise `null`.
|
186
|
+
* @since 1.8.0
|
187
|
+
*/
|
188
|
+
declare function parseFediverseHandle(handle: string): FediverseHandle | null;
|
189
|
+
/**
|
190
|
+
* Checks if a string is a valid fediverse handle in the format `@user@server`
|
191
|
+
* or `user@server`. The `user` part can contain alphanumeric characters and
|
192
|
+
* some special characters except `@`. The `server` part is all characters
|
193
|
+
* after the `@` symbol in the middle.
|
194
|
+
*
|
195
|
+
* @example
|
196
|
+
* ```typescript
|
197
|
+
* console.log(isFediverseHandle("@username@example.com")); // true
|
198
|
+
* console.log(isFediverseHandle("username@example.com")); // true
|
199
|
+
* console.log(isFediverseHandle("@username@")); // false
|
200
|
+
* ```
|
201
|
+
*
|
202
|
+
* @param handle - The string to test as a fediverse handle.
|
203
|
+
* @returns `true` if the string matches the fediverse handle pattern;
|
204
|
+
* otherwise `false`.
|
205
|
+
* @since 1.8.0
|
206
|
+
*/
|
207
|
+
declare function isFediverseHandle(handle: string): handle is `${string}@${string}`;
|
208
|
+
/**
|
209
|
+
* Converts a fediverse handle in the format `@user@server` or `user@server`
|
210
|
+
* to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
|
211
|
+
*
|
212
|
+
* @example
|
213
|
+
* ```typescript
|
214
|
+
* const identifier = toAcctUrl("@username@example.com");
|
215
|
+
* console.log(identifier?.href); // "acct:username@example.com"
|
216
|
+
* ```
|
217
|
+
*
|
218
|
+
* @param handle - The fediverse handle string to convert.
|
219
|
+
* @returns A `URL` object representing the `acct:` URI if conversion succeeds;
|
220
|
+
* otherwise `null`.
|
221
|
+
* @since 1.8.0
|
222
|
+
*/
|
223
|
+
declare function toAcctUrl(handle: string): URL | null;
|
224
|
+
//#endregion
|
225
|
+
//#region src/vocab/type.d.ts
|
226
|
+
/**
|
227
|
+
* Returns the type URI of the given object.
|
228
|
+
*
|
229
|
+
* @example
|
230
|
+
* ``` typescript
|
231
|
+
* import { getTypeId, Person } from "@fedify/fedify";
|
232
|
+
*
|
233
|
+
* const obj = new Person({});
|
234
|
+
* console.log(getTypeId(obj));
|
235
|
+
* // => new URL("https://www.w3.org/ns/activitystreams#Person")
|
236
|
+
* ```
|
237
|
+
*
|
238
|
+
* @param object The Activity Vocabulary object.
|
239
|
+
* @returns The type URI of the object, e.g.,
|
240
|
+
* `new URL("https://www.w3.org/ns/activitystreams#Person")`.
|
241
|
+
* If the given `object` is `null` or `undefined`, returns `null` or
|
242
|
+
* `undefined`, respectively.
|
243
|
+
* @since 1.3.0
|
244
|
+
*/
|
245
|
+
declare function getTypeId(object: Object$1 | Link): URL;
|
246
|
+
/**
|
247
|
+
* Returns the type URI of the given object.
|
248
|
+
*
|
249
|
+
* @example
|
250
|
+
* ``` typescript
|
251
|
+
* import { getTypeId, Person } from "@fedify/fedify";
|
252
|
+
*
|
253
|
+
* const obj = new Person({});
|
254
|
+
* console.log(getTypeId(obj));
|
255
|
+
* // => new URL("https://www.w3.org/ns/activitystreams#Person")
|
256
|
+
* ```
|
257
|
+
*
|
258
|
+
* @param object The Activity Vocabulary object.
|
259
|
+
* @returns The type URI of the object, e.g.,
|
260
|
+
* `new URL("https://www.w3.org/ns/activitystreams#Person")`.
|
261
|
+
* If the given `object` is `null` or `undefined`, returns `null` or
|
262
|
+
* `undefined`, respectively.
|
263
|
+
* @since 1.3.0
|
264
|
+
*/
|
265
|
+
declare function getTypeId(object: Object$1 | Link | undefined): URL | undefined;
|
266
|
+
/**
|
267
|
+
* Returns the type URI of the given object.
|
268
|
+
*
|
269
|
+
* @example
|
270
|
+
* ``` typescript
|
271
|
+
* import { getTypeId, Person } from "@fedify/fedify";
|
272
|
+
*
|
273
|
+
* const obj = new Person({});
|
274
|
+
* console.log(getTypeId(obj));
|
275
|
+
* // => new URL("https://www.w3.org/ns/activitystreams#Person")
|
276
|
+
* ```
|
277
|
+
*
|
278
|
+
* @param object The Activity Vocabulary object.
|
279
|
+
* @returns The type URI of the object, e.g.,
|
280
|
+
* `new URL("https://www.w3.org/ns/activitystreams#Person")`.
|
281
|
+
* If the given `object` is `null` or `undefined`, returns `null` or
|
282
|
+
* `undefined`, respectively.
|
283
|
+
* @since 1.3.0
|
284
|
+
*/
|
285
|
+
declare function getTypeId(object: Object$1 | Link | null): URL | null;
|
286
|
+
/**
|
287
|
+
* Returns the type URI of the given object.
|
288
|
+
*
|
289
|
+
* @example
|
290
|
+
* ``` typescript
|
291
|
+
* import { getTypeId, Person } from "@fedify/fedify";
|
292
|
+
*
|
293
|
+
* const obj = new Person({});
|
294
|
+
* console.log(getTypeId(obj));
|
295
|
+
* // => new URL("https://www.w3.org/ns/activitystreams#Person")
|
296
|
+
* ```
|
297
|
+
*
|
298
|
+
* @param object The Activity Vocabulary object.
|
299
|
+
* @returns The type URI of the object, e.g.,
|
300
|
+
* `new URL("https://www.w3.org/ns/activitystreams#Person")`.
|
301
|
+
* If the given `object` is `null` or `undefined`, returns `null` or
|
302
|
+
* `undefined`, respectively.
|
303
|
+
* @since 1.3.0
|
304
|
+
*/
|
305
|
+
declare function getTypeId(object: Object$1 | Link | null | undefined): URL | null | undefined;
|
306
|
+
//#endregion
|
307
|
+
export { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
|
-
import { Activity } from "./vocab-
|
4
|
-
import { ActivityTransformer, Context } from "./context-
|
3
|
+
import { Activity } from "./vocab-BI0Ak5lL.js";
|
4
|
+
import { ActivityTransformer, Context } from "./context-ByZprN0S.js";
|
5
5
|
|
6
6
|
//#region src/compat/transformers.d.ts
|
7
7
|
|
@@ -0,0 +1,266 @@
|
|
1
|
+
import { DocumentLoader } from "./docloader-D-MrRyHl.cjs";
|
2
|
+
import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "./vocab-Dw1-yVGg.cjs";
|
3
|
+
import { KeyCache } from "./http-D-e6AFwR.cjs";
|
4
|
+
import { TracerProvider } from "@opentelemetry/api";
|
5
|
+
|
6
|
+
//#region src/sig/ld.d.ts
|
7
|
+
/**
|
8
|
+
* A signature of a JSON-LD document.
|
9
|
+
* @since 1.0.0
|
10
|
+
*/
|
11
|
+
interface Signature {
|
12
|
+
"@context"?: "https://w3id.org/identity/v1";
|
13
|
+
type: "RsaSignature2017";
|
14
|
+
id?: string;
|
15
|
+
creator: string;
|
16
|
+
created: string;
|
17
|
+
signatureValue: string;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Attaches a LD signature to the given JSON-LD document.
|
21
|
+
* @param jsonLd The JSON-LD document to attach the signature to. It is not
|
22
|
+
* modified.
|
23
|
+
* @param signature The signature to attach.
|
24
|
+
* @returns The JSON-LD document with the attached signature.
|
25
|
+
* @throws {TypeError} If the input document is not a valid JSON-LD document.
|
26
|
+
* @since 1.0.0
|
27
|
+
*/
|
28
|
+
declare function attachSignature(jsonLd: unknown, signature: Signature): {
|
29
|
+
signature: Signature;
|
30
|
+
};
|
31
|
+
/**
|
32
|
+
* Options for creating Linked Data Signatures.
|
33
|
+
* @since 1.0.0
|
34
|
+
*/
|
35
|
+
interface CreateSignatureOptions {
|
36
|
+
/**
|
37
|
+
* The context loader for loading remote JSON-LD contexts.
|
38
|
+
*/
|
39
|
+
contextLoader?: DocumentLoader;
|
40
|
+
/**
|
41
|
+
* The time when the signature was created. If not specified, the current
|
42
|
+
* time will be used.
|
43
|
+
*/
|
44
|
+
created?: Temporal.Instant;
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Creates a LD signature for the given JSON-LD document.
|
48
|
+
* @param jsonLd The JSON-LD document to sign.
|
49
|
+
* @param privateKey The private key to sign the document.
|
50
|
+
* @param keyId The ID of the public key that corresponds to the private key.
|
51
|
+
* @param options Additional options for creating the signature.
|
52
|
+
* See also {@link CreateSignatureOptions}.
|
53
|
+
* @return The created signature.
|
54
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
55
|
+
* @since 1.0.0
|
56
|
+
*/
|
57
|
+
declare function createSignature(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, {
|
58
|
+
contextLoader,
|
59
|
+
created
|
60
|
+
}?: CreateSignatureOptions): Promise<Signature>;
|
61
|
+
/**
|
62
|
+
* Options for signing JSON-LD documents.
|
63
|
+
* @since 1.0.0
|
64
|
+
*/
|
65
|
+
interface SignJsonLdOptions extends CreateSignatureOptions {
|
66
|
+
/**
|
67
|
+
* The OpenTelemetry tracer provider for tracing the signing process.
|
68
|
+
* If omitted, the global tracer provider is used.
|
69
|
+
* @since 1.3.0
|
70
|
+
*/
|
71
|
+
tracerProvider?: TracerProvider;
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Signs the given JSON-LD document with the private key and returns the signed
|
75
|
+
* JSON-LD document.
|
76
|
+
* @param jsonLd The JSON-LD document to sign.
|
77
|
+
* @param privateKey The private key to sign the document.
|
78
|
+
* @param keyId The key ID to use in the signature. It will be used by the
|
79
|
+
* verifier to fetch the corresponding public key.
|
80
|
+
* @param options Additional options for signing the document.
|
81
|
+
* See also {@link SignJsonLdOptions}.
|
82
|
+
* @returns The signed JSON-LD document.
|
83
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
84
|
+
* @since 1.0.0
|
85
|
+
*/
|
86
|
+
declare function signJsonLd(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, options: SignJsonLdOptions): Promise<{
|
87
|
+
signature: Signature;
|
88
|
+
}>;
|
89
|
+
/**
|
90
|
+
* Detaches Linked Data Signatures from the given JSON-LD document.
|
91
|
+
* @param jsonLd The JSON-LD document to modify.
|
92
|
+
* @returns The modified JSON-LD document. If the input document does not
|
93
|
+
* contain a signature, the original document is returned.
|
94
|
+
* @since 1.0.0
|
95
|
+
*/
|
96
|
+
declare function detachSignature(jsonLd: unknown): unknown;
|
97
|
+
/**
|
98
|
+
* Options for verifying Linked Data Signatures.
|
99
|
+
* @since 1.0.0
|
100
|
+
*/
|
101
|
+
interface VerifySignatureOptions {
|
102
|
+
/**
|
103
|
+
* The document loader to use for fetching the public key.
|
104
|
+
*/
|
105
|
+
documentLoader?: DocumentLoader;
|
106
|
+
/**
|
107
|
+
* The context loader to use for JSON-LD context retrieval.
|
108
|
+
*/
|
109
|
+
contextLoader?: DocumentLoader;
|
110
|
+
/**
|
111
|
+
* The key cache to use for caching public keys.
|
112
|
+
*/
|
113
|
+
keyCache?: KeyCache;
|
114
|
+
/**
|
115
|
+
* The OpenTelemetry tracer provider for tracing the verification process.
|
116
|
+
* If omitted, the global tracer provider is used.
|
117
|
+
* @since 1.3.0
|
118
|
+
*/
|
119
|
+
tracerProvider?: TracerProvider;
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Verifies Linked Data Signatures of the given JSON-LD document.
|
123
|
+
* @param jsonLd The JSON-LD document to verify.
|
124
|
+
* @param options Options for verifying the signature.
|
125
|
+
* @returns The public key that signed the document or `null` if the signature
|
126
|
+
* is invalid or the key is not found.
|
127
|
+
* @since 1.0.0
|
128
|
+
*/
|
129
|
+
declare function verifySignature(jsonLd: unknown, options?: VerifySignatureOptions): Promise<CryptographicKey | null>;
|
130
|
+
/**
|
131
|
+
* Options for verifying JSON-LD documents.
|
132
|
+
*/
|
133
|
+
interface VerifyJsonLdOptions extends VerifySignatureOptions {}
|
134
|
+
/**
|
135
|
+
* Verify the authenticity of the given JSON-LD document using Linked Data
|
136
|
+
* Signatures. If the document is signed, this function verifies the signature
|
137
|
+
* and checks if the document is attributed to the owner of the public key.
|
138
|
+
* If the document is not signed, this function returns `false`.
|
139
|
+
* @param jsonLd The JSON-LD document to verify.
|
140
|
+
* @param options Options for verifying the document.
|
141
|
+
* @returns `true` if the document is authentic; `false` otherwise.
|
142
|
+
*/
|
143
|
+
declare function verifyJsonLd(jsonLd: unknown, options?: VerifyJsonLdOptions): Promise<boolean>;
|
144
|
+
//#endregion
|
145
|
+
//#region src/sig/proof.d.ts
|
146
|
+
/**
|
147
|
+
* Options for {@link createProof}.
|
148
|
+
* @since 0.10.0
|
149
|
+
*/
|
150
|
+
interface CreateProofOptions {
|
151
|
+
/**
|
152
|
+
* The context loader for loading remote JSON-LD contexts.
|
153
|
+
*/
|
154
|
+
contextLoader?: DocumentLoader;
|
155
|
+
/**
|
156
|
+
* The JSON-LD context to use for serializing the object to sign.
|
157
|
+
*/
|
158
|
+
context?: string | Record<string, string> | (string | Record<string, string>)[];
|
159
|
+
/**
|
160
|
+
* The time when the proof was created. If not specified, the current time
|
161
|
+
* will be used.
|
162
|
+
*/
|
163
|
+
created?: Temporal.Instant;
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* Creates a proof for the given object.
|
167
|
+
* @param object The object to create a proof for.
|
168
|
+
* @param privateKey The private key to sign the proof with.
|
169
|
+
* @param keyId The key ID to use in the proof. It will be used by the verifier.
|
170
|
+
* @param options Additional options. See also {@link CreateProofOptions}.
|
171
|
+
* @returns The created proof.
|
172
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
173
|
+
* @since 0.10.0
|
174
|
+
*/
|
175
|
+
declare function createProof(object: Object$1, privateKey: CryptoKey, keyId: URL, {
|
176
|
+
contextLoader,
|
177
|
+
context,
|
178
|
+
created
|
179
|
+
}?: CreateProofOptions): Promise<DataIntegrityProof>;
|
180
|
+
/**
|
181
|
+
* Options for {@link signObject}.
|
182
|
+
* @since 0.10.0
|
183
|
+
*/
|
184
|
+
interface SignObjectOptions extends CreateProofOptions {
|
185
|
+
/**
|
186
|
+
* The document loader for loading remote JSON-LD documents.
|
187
|
+
*/
|
188
|
+
documentLoader?: DocumentLoader;
|
189
|
+
/**
|
190
|
+
* The OpenTelemetry tracer provider. If omitted, the global tracer provider
|
191
|
+
* is used.
|
192
|
+
* @since 1.3.0
|
193
|
+
*/
|
194
|
+
tracerProvider?: TracerProvider;
|
195
|
+
}
|
196
|
+
/**
|
197
|
+
* Signs the given object with the private key and returns the signed object.
|
198
|
+
* @param object The object to create a proof for.
|
199
|
+
* @param privateKey The private key to sign the proof with.
|
200
|
+
* @param keyId The key ID to use in the proof. It will be used by the verifier.
|
201
|
+
* @param options Additional options. See also {@link SignObjectOptions}.
|
202
|
+
* @returns The signed object.
|
203
|
+
* @throws {TypeError} If the private key is invalid or unsupported.
|
204
|
+
* @since 0.10.0
|
205
|
+
*/
|
206
|
+
declare function signObject<T extends Object$1>(object: T, privateKey: CryptoKey, keyId: URL, options?: SignObjectOptions): Promise<T>;
|
207
|
+
/**
|
208
|
+
* Options for {@link verifyProof}.
|
209
|
+
* @since 0.10.0
|
210
|
+
*/
|
211
|
+
interface VerifyProofOptions {
|
212
|
+
/**
|
213
|
+
* The context loader for loading remote JSON-LD contexts.
|
214
|
+
*/
|
215
|
+
contextLoader?: DocumentLoader;
|
216
|
+
/**
|
217
|
+
* The document loader for loading remote JSON-LD documents.
|
218
|
+
*/
|
219
|
+
documentLoader?: DocumentLoader;
|
220
|
+
/**
|
221
|
+
* The key cache to use for caching public keys.
|
222
|
+
* @since 0.12.0
|
223
|
+
*/
|
224
|
+
keyCache?: KeyCache;
|
225
|
+
/**
|
226
|
+
* The OpenTelemetry tracer provider. If omitted, the global tracer provider
|
227
|
+
* is used.
|
228
|
+
* @since 1.3.0
|
229
|
+
*/
|
230
|
+
tracerProvider?: TracerProvider;
|
231
|
+
}
|
232
|
+
/**
|
233
|
+
* Verifies the given proof for the object.
|
234
|
+
* @param jsonLd The JSON-LD object to verify the proof for. If it contains
|
235
|
+
* any proofs, they will be ignored.
|
236
|
+
* @param proof The proof to verify.
|
237
|
+
* @param options Additional options. See also {@link VerifyProofOptions}.
|
238
|
+
* @returns The public key that was used to sign the proof, or `null` if the
|
239
|
+
* proof is invalid.
|
240
|
+
* @since 0.10.0
|
241
|
+
*/
|
242
|
+
declare function verifyProof(jsonLd: unknown, proof: DataIntegrityProof, options?: VerifyProofOptions): Promise<Multikey | null>;
|
243
|
+
/**
|
244
|
+
* Options for {@link verifyObject}.
|
245
|
+
* @since 0.10.0
|
246
|
+
*/
|
247
|
+
interface VerifyObjectOptions extends VerifyProofOptions {}
|
248
|
+
/**
|
249
|
+
* Verifies the given object. It will verify all the proofs in the object,
|
250
|
+
* and succeed only if all the proofs are valid and all attributions and
|
251
|
+
* actors are authenticated by the proofs.
|
252
|
+
* @template T The type of the object to verify.
|
253
|
+
* @param cls The class of the object to verify. It must be a subclass of
|
254
|
+
* the {@link Object}.
|
255
|
+
* @param jsonLd The JSON-LD object to verify. It's assumed that the object
|
256
|
+
* is a compacted JSON-LD representation of a `T` with `@context`.
|
257
|
+
* @param options Additional options. See also {@link VerifyObjectOptions}.
|
258
|
+
* @returns The object if it's verified, or `null` if it's not.
|
259
|
+
* @throws {TypeError} If the object is invalid or unsupported.
|
260
|
+
* @since 0.10.0
|
261
|
+
*/
|
262
|
+
declare function verifyObject<T extends Object$1>(cls: (new (...args: any[]) => T) & {
|
263
|
+
fromJsonLd(jsonLd: unknown, options: VerifyObjectOptions): Promise<T>;
|
264
|
+
}, jsonLd: unknown, options?: VerifyObjectOptions): Promise<T | null>;
|
265
|
+
//#endregion
|
266
|
+
export { CreateProofOptions, CreateSignatureOptions, SignJsonLdOptions, SignObjectOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyProofOptions, VerifySignatureOptions, attachSignature, createProof, createSignature, detachSignature, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
3
|
import { DocumentLoader, GetUserAgentOptions } from "./docloader-CxWcuWqQ.js";
|
4
|
-
import { Collection, Link, Object as Object$1 } from "./vocab-
|
4
|
+
import { Collection, Link, Object as Object$1 } from "./vocab-BI0Ak5lL.js";
|
5
5
|
import { TracerProvider } from "@opentelemetry/api";
|
6
6
|
|
7
7
|
//#region src/vocab/lookup.d.ts
|
@@ -20,6 +20,24 @@ interface LookupObjectOptions {
|
|
20
20
|
* @since 0.8.0
|
21
21
|
*/
|
22
22
|
contextLoader?: DocumentLoader;
|
23
|
+
/**
|
24
|
+
* Whether to allow fetching an object with an `@id` having a different
|
25
|
+
* origin than the object's URL. This is not recommended, as it may
|
26
|
+
* lead to security issues. Only use this option if you know what you
|
27
|
+
* are doing.
|
28
|
+
*
|
29
|
+
* How to handle the case when an object's `@id` has a different origin
|
30
|
+
* than the object's URL:
|
31
|
+
*
|
32
|
+
* - `"ignore"` (default): Do not return the object, and log a warning.
|
33
|
+
* - `"throw"`: Throw an error.
|
34
|
+
* - `"trust"`: Bypass the check and return the object anyway. This
|
35
|
+
* is not recommended, as it may lead to security issues. Only use
|
36
|
+
* this option if you know what you are doing.
|
37
|
+
*
|
38
|
+
* @since 1.9.0
|
39
|
+
*/
|
40
|
+
crossOrigin?: "ignore" | "throw" | "trust";
|
23
41
|
/**
|
24
42
|
* The options for making `User-Agent` header.
|
25
43
|
* If a string is given, it is used as the `User-Agent` header value.
|
@@ -0,0 +1 @@
|
|
1
|
+
export { };
|