@fedify/vocab-runtime 2.4.0-dev.1570 → 2.4.0-dev.1571
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/deno.json +2 -1
- package/dist/docloader-DnUMWHaJ.d.cts +202 -0
- package/dist/docloader-xRGn1azD.d.ts +202 -0
- package/dist/internal/jsonld-cache.cjs +279 -0
- package/dist/internal/jsonld-cache.d.cts +48 -0
- package/dist/internal/jsonld-cache.d.ts +48 -0
- package/dist/internal/jsonld-cache.js +275 -0
- package/dist/mod.cjs +178 -190
- package/dist/mod.d.cts +59 -190
- package/dist/mod.d.ts +59 -190
- package/dist/mod.js +165 -184
- package/dist/tests/decimal.test.cjs +3 -3
- package/dist/tests/decimal.test.mjs +3 -3
- package/dist/tests/{docloader-C76ldE5C.mjs → docloader-DHSAmRW2.mjs} +97 -10
- package/dist/tests/{docloader-mvgIWKI7.cjs → docloader-DkiPIIAk.cjs} +102 -9
- package/dist/tests/docloader.test.cjs +58 -6
- package/dist/tests/docloader.test.mjs +58 -6
- package/dist/tests/jsonld-cache.test.cjs +652 -0
- package/dist/tests/jsonld-cache.test.d.cts +1 -0
- package/dist/tests/jsonld-cache.test.d.mts +1 -0
- package/dist/tests/jsonld-cache.test.mjs +651 -0
- package/dist/tests/{key-CrrK9mYh.mjs → key-CDGDH_vC.mjs} +69 -1
- package/dist/tests/{key-pMmqUKuo.cjs → key-_wXwomh_.cjs} +86 -0
- package/dist/tests/key.test.cjs +48 -1
- package/dist/tests/key.test.mjs +48 -1
- package/dist/tests/{request-BEXkv1ul.mjs → request-CYFeP37O.mjs} +1 -1
- package/dist/tests/{request-SworbvLc.cjs → request-D3H8nWtX.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/{url-C20FhC7p.cjs → url-2XwVbUS_.cjs} +108 -0
- package/dist/tests/{url-m9Qzxy-Y.mjs → url-YWJbnRlf.mjs} +85 -1
- package/dist/tests/url.test.cjs +104 -1
- package/dist/tests/url.test.mjs +105 -2
- package/dist/url-BAdyyqAa.cjs +315 -0
- package/dist/url-BuxPHxK2.js +261 -0
- package/package.json +11 -1
- package/src/contexts/fep-7aa9.json +24 -0
- package/src/contexts.ts +2 -0
- package/src/docloader.test.ts +102 -6
- package/src/docloader.ts +76 -8
- package/src/internal/jsonld-cache.ts +538 -0
- package/src/jsonld-cache.test.ts +554 -0
- package/src/key.test.ts +86 -0
- package/src/key.ts +125 -0
- package/src/mod.ts +8 -0
- package/src/url.test.ts +252 -1
- package/src/url.ts +141 -0
- package/tsdown.config.ts +6 -1
package/dist/mod.d.cts
CHANGED
|
@@ -1,210 +1,35 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-DnUMWHaJ.cjs";
|
|
3
3
|
import { TracerProvider } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
5
|
//#region src/contexts.d.ts
|
|
6
6
|
declare const preloadedContexts: Record<string, unknown>;
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region src/
|
|
9
|
-
/**
|
|
10
|
-
* Error thrown when fetching a JSON-LD document failed.
|
|
11
|
-
*/
|
|
12
|
-
declare class FetchError extends Error {
|
|
13
|
-
/**
|
|
14
|
-
* The URL that failed to fetch.
|
|
15
|
-
*/
|
|
16
|
-
url: URL;
|
|
17
|
-
/**
|
|
18
|
-
* The HTTP response that failed, if available.
|
|
19
|
-
*/
|
|
20
|
-
response?: Response;
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new `FetchError`.
|
|
23
|
-
*
|
|
24
|
-
* @param url The URL that failed to fetch.
|
|
25
|
-
* @param message Error message.
|
|
26
|
-
* @param response The failed HTTP response, if available.
|
|
27
|
-
*/
|
|
28
|
-
constructor(url: URL | string, message?: string, response?: Response);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Options for creating a request.
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
interface CreateRequestOptions {
|
|
35
|
-
userAgent?: GetUserAgentOptions | string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates a request for the given URL.
|
|
39
|
-
* @param url The URL to create the request for.
|
|
40
|
-
* @param options The options for the request.
|
|
41
|
-
* @returns The created request.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request;
|
|
45
|
-
/**
|
|
46
|
-
* Options for making `User-Agent` string.
|
|
47
|
-
* @see {@link getUserAgent}
|
|
48
|
-
* @since 1.3.0
|
|
49
|
-
*/
|
|
50
|
-
interface GetUserAgentOptions {
|
|
51
|
-
/**
|
|
52
|
-
* An optional software name and version, e.g., `"Hollo/1.0.0"`.
|
|
53
|
-
*/
|
|
54
|
-
software?: string | null;
|
|
55
|
-
/**
|
|
56
|
-
* An optional URL to append to the user agent string.
|
|
57
|
-
* Usually the URL of the ActivityPub instance.
|
|
58
|
-
*/
|
|
59
|
-
url?: string | URL | null;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Gets the user agent string for the given application and URL.
|
|
63
|
-
* @param options The options for making the user agent string.
|
|
64
|
-
* @returns The user agent string.
|
|
65
|
-
* @since 1.3.0
|
|
66
|
-
*/
|
|
67
|
-
declare function getUserAgent({
|
|
68
|
-
software,
|
|
69
|
-
url
|
|
70
|
-
}?: GetUserAgentOptions): string;
|
|
71
|
-
/**
|
|
72
|
-
* Logs the request.
|
|
73
|
-
* @param request The request to log.
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
declare function logRequest(logger: Logger, request: Request): void;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/docloader.d.ts
|
|
79
|
-
/**
|
|
80
|
-
* A remote JSON-LD document and its context fetched by
|
|
81
|
-
* a {@link DocumentLoader}.
|
|
82
|
-
*/
|
|
83
|
-
interface RemoteDocument {
|
|
84
|
-
/**
|
|
85
|
-
* The URL of the context document.
|
|
86
|
-
*/
|
|
87
|
-
contextUrl: string | null;
|
|
88
|
-
/**
|
|
89
|
-
* The fetched JSON-LD document.
|
|
90
|
-
*/
|
|
91
|
-
document: unknown;
|
|
92
|
-
/**
|
|
93
|
-
* The URL of the fetched document.
|
|
94
|
-
*/
|
|
95
|
-
documentUrl: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Options for {@link DocumentLoader}.
|
|
99
|
-
* @since 1.8.0
|
|
100
|
-
*/
|
|
101
|
-
interface DocumentLoaderOptions {
|
|
102
|
-
/**
|
|
103
|
-
* An `AbortSignal` for cancellation.
|
|
104
|
-
* @since 1.8.0
|
|
105
|
-
*/
|
|
106
|
-
signal?: AbortSignal;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* A JSON-LD document loader that fetches documents from the Web.
|
|
110
|
-
* @param url The URL of the document to load.
|
|
111
|
-
* @param options The options for the document loader.
|
|
112
|
-
* @returns The loaded remote document.
|
|
113
|
-
*/
|
|
114
|
-
type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
|
|
115
|
-
/**
|
|
116
|
-
* A factory function that creates a {@link DocumentLoader} with options.
|
|
117
|
-
* @param options The options for the document loader.
|
|
118
|
-
* @returns The document loader.
|
|
119
|
-
* @since 1.4.0
|
|
120
|
-
*/
|
|
121
|
-
type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
8
|
+
//#region src/key.d.ts
|
|
122
9
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @
|
|
126
|
-
* @since 1.4.0
|
|
10
|
+
* Parsed `did:key` verification method.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.4.0
|
|
127
13
|
*/
|
|
128
|
-
interface
|
|
14
|
+
interface DidKeyVerificationMethod {
|
|
129
15
|
/**
|
|
130
|
-
*
|
|
131
|
-
* Turned off by default.
|
|
132
|
-
* @default `false``
|
|
16
|
+
* The DID URL identifying the verification method.
|
|
133
17
|
*/
|
|
134
|
-
|
|
18
|
+
readonly id: URL;
|
|
135
19
|
/**
|
|
136
|
-
*
|
|
137
|
-
* If a string is given, it is used as the `User-Agent` header value.
|
|
138
|
-
* If an object is given, it is passed to {@link getUserAgent} function.
|
|
20
|
+
* The controller DID.
|
|
139
21
|
*/
|
|
140
|
-
|
|
22
|
+
readonly controller: URL;
|
|
141
23
|
/**
|
|
142
|
-
* The
|
|
143
|
-
* @default `20`
|
|
144
|
-
* @since 2.2.0
|
|
24
|
+
* The Ed25519 public key encoded as a Multibase Multikey value.
|
|
145
25
|
*/
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* A factory function that creates an authenticated {@link DocumentLoader} for
|
|
150
|
-
* a given identity. This is used for fetching documents that require
|
|
151
|
-
* authentication.
|
|
152
|
-
* @param identity The identity to create the document loader for.
|
|
153
|
-
* The actor's key pair.
|
|
154
|
-
* @param options The options for the document loader.
|
|
155
|
-
* @returns The authenticated document loader.
|
|
156
|
-
* @since 0.4.0
|
|
157
|
-
*/
|
|
158
|
-
type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
159
|
-
keyId: URL;
|
|
160
|
-
privateKey: CryptoKey;
|
|
161
|
-
}, options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
162
|
-
/**
|
|
163
|
-
* Gets a {@link RemoteDocument} from the given response.
|
|
164
|
-
* @param url The URL of the document to load.
|
|
165
|
-
* @param response The response to get the document from.
|
|
166
|
-
* @param fetch The function to fetch the document.
|
|
167
|
-
* @returns The loaded remote document.
|
|
168
|
-
* @throws {FetchError} If the response is not OK.
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>;
|
|
172
|
-
/**
|
|
173
|
-
* Options for {@link getDocumentLoader}.
|
|
174
|
-
* @since 1.3.0
|
|
175
|
-
*/
|
|
176
|
-
interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
26
|
+
readonly publicKeyMultibase: string;
|
|
177
27
|
/**
|
|
178
|
-
*
|
|
28
|
+
* The Ed25519 public key.
|
|
179
29
|
*/
|
|
180
|
-
|
|
30
|
+
readonly publicKey: CryptoKey;
|
|
181
31
|
}
|
|
182
32
|
/**
|
|
183
|
-
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
184
|
-
*
|
|
185
|
-
* The created loader preloads the below frequently used contexts by default
|
|
186
|
-
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
187
|
-
*
|
|
188
|
-
* - <https://www.w3.org/ns/activitystreams>
|
|
189
|
-
* - <https://w3id.org/security/v1>
|
|
190
|
-
* - <https://w3id.org/security/data-integrity/v1>
|
|
191
|
-
* - <https://www.w3.org/ns/did/v1>
|
|
192
|
-
* - <https://w3id.org/security/multikey/v1>
|
|
193
|
-
* - <https://purl.archive.org/socialweb/webfinger>
|
|
194
|
-
* - <http://schema.org/>
|
|
195
|
-
* @param options Options for the document loader.
|
|
196
|
-
* @returns The document loader.
|
|
197
|
-
* @since 1.3.0
|
|
198
|
-
*/
|
|
199
|
-
declare function getDocumentLoader({
|
|
200
|
-
allowPrivateAddress,
|
|
201
|
-
maxRedirection,
|
|
202
|
-
skipPreloadedContexts,
|
|
203
|
-
userAgent
|
|
204
|
-
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/key.d.ts
|
|
207
|
-
/**
|
|
208
33
|
* Imports a PEM-SPKI formatted public key.
|
|
209
34
|
* @param pem The PEM-SPKI formatted public key.
|
|
210
35
|
* @returns The imported public key.
|
|
@@ -237,6 +62,34 @@ declare function importPkcs1(pem: string): Promise<CryptoKey>;
|
|
|
237
62
|
*/
|
|
238
63
|
declare function importPem(pem: string): Promise<CryptoKey>;
|
|
239
64
|
/**
|
|
65
|
+
* Imports an Ed25519 `did:key` DID.
|
|
66
|
+
*
|
|
67
|
+
* @param did The `did:key` DID.
|
|
68
|
+
* @returns The imported Ed25519 public key.
|
|
69
|
+
* @throws {TypeError} If the DID is malformed or uses an unsupported key type.
|
|
70
|
+
* @since 2.4.0
|
|
71
|
+
*/
|
|
72
|
+
declare function importDidKey(did: string | URL): Promise<CryptoKey>;
|
|
73
|
+
/**
|
|
74
|
+
* Exports an Ed25519 public key as a `did:key` DID.
|
|
75
|
+
*
|
|
76
|
+
* @param key The Ed25519 public key.
|
|
77
|
+
* @returns The `did:key` DID.
|
|
78
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
79
|
+
* @since 2.4.0
|
|
80
|
+
*/
|
|
81
|
+
declare function exportDidKey(key: CryptoKey): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Parses an Ed25519 `did:key` verification method DID URL.
|
|
84
|
+
*
|
|
85
|
+
* @param didUrl The `did:key` DID URL.
|
|
86
|
+
* @returns The parsed verification method.
|
|
87
|
+
* @throws {TypeError} If the DID URL is malformed, unsupported, or its
|
|
88
|
+
* fragment does not identify the same key as the DID.
|
|
89
|
+
* @since 2.4.0
|
|
90
|
+
*/
|
|
91
|
+
declare function parseDidKeyVerificationMethod(didUrl: string | URL): Promise<DidKeyVerificationMethod>;
|
|
92
|
+
/**
|
|
240
93
|
* Imports a [Multibase]-encoded public key.
|
|
241
94
|
*
|
|
242
95
|
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
@@ -461,6 +314,22 @@ declare class UrlError extends Error {
|
|
|
461
314
|
constructor(message: string);
|
|
462
315
|
}
|
|
463
316
|
/**
|
|
317
|
+
* Parses a JSON-LD `@id` value as an IRI.
|
|
318
|
+
*/
|
|
319
|
+
declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL | undefined;
|
|
320
|
+
/**
|
|
321
|
+
* Parses an IRI as a URL, including FEP-ef61 portable ActivityPub IRIs.
|
|
322
|
+
*/
|
|
323
|
+
declare function parseIri(iri: string | URL, base?: string | URL): URL;
|
|
324
|
+
/**
|
|
325
|
+
* Formats a URL as an IRI, including FEP-ef61 portable ActivityPub IRIs.
|
|
326
|
+
*/
|
|
327
|
+
declare function formatIri(iri: string | URL): string;
|
|
328
|
+
/**
|
|
329
|
+
* Checks whether two IRIs have the same origin.
|
|
330
|
+
*/
|
|
331
|
+
declare function haveSameIriOrigin(left: URL, right: URL): boolean;
|
|
332
|
+
/**
|
|
464
333
|
* Validates a URL to prevent SSRF attacks.
|
|
465
334
|
*/
|
|
466
335
|
declare function validatePublicUrl(url: string): Promise<void>;
|
|
@@ -468,4 +337,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
468
337
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
469
338
|
declare function expandIPv6Address(address: string): string;
|
|
470
339
|
//#endregion
|
|
471
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, preloadedContexts, validatePublicUrl };
|
|
340
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,210 +1,35 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-xRGn1azD.js";
|
|
3
3
|
import { TracerProvider } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
5
|
//#region src/contexts.d.ts
|
|
6
6
|
declare const preloadedContexts: Record<string, unknown>;
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region src/
|
|
9
|
-
/**
|
|
10
|
-
* Error thrown when fetching a JSON-LD document failed.
|
|
11
|
-
*/
|
|
12
|
-
declare class FetchError extends Error {
|
|
13
|
-
/**
|
|
14
|
-
* The URL that failed to fetch.
|
|
15
|
-
*/
|
|
16
|
-
url: URL;
|
|
17
|
-
/**
|
|
18
|
-
* The HTTP response that failed, if available.
|
|
19
|
-
*/
|
|
20
|
-
response?: Response;
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new `FetchError`.
|
|
23
|
-
*
|
|
24
|
-
* @param url The URL that failed to fetch.
|
|
25
|
-
* @param message Error message.
|
|
26
|
-
* @param response The failed HTTP response, if available.
|
|
27
|
-
*/
|
|
28
|
-
constructor(url: URL | string, message?: string, response?: Response);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Options for creating a request.
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
interface CreateRequestOptions {
|
|
35
|
-
userAgent?: GetUserAgentOptions | string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates a request for the given URL.
|
|
39
|
-
* @param url The URL to create the request for.
|
|
40
|
-
* @param options The options for the request.
|
|
41
|
-
* @returns The created request.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request;
|
|
45
|
-
/**
|
|
46
|
-
* Options for making `User-Agent` string.
|
|
47
|
-
* @see {@link getUserAgent}
|
|
48
|
-
* @since 1.3.0
|
|
49
|
-
*/
|
|
50
|
-
interface GetUserAgentOptions {
|
|
51
|
-
/**
|
|
52
|
-
* An optional software name and version, e.g., `"Hollo/1.0.0"`.
|
|
53
|
-
*/
|
|
54
|
-
software?: string | null;
|
|
55
|
-
/**
|
|
56
|
-
* An optional URL to append to the user agent string.
|
|
57
|
-
* Usually the URL of the ActivityPub instance.
|
|
58
|
-
*/
|
|
59
|
-
url?: string | URL | null;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Gets the user agent string for the given application and URL.
|
|
63
|
-
* @param options The options for making the user agent string.
|
|
64
|
-
* @returns The user agent string.
|
|
65
|
-
* @since 1.3.0
|
|
66
|
-
*/
|
|
67
|
-
declare function getUserAgent({
|
|
68
|
-
software,
|
|
69
|
-
url
|
|
70
|
-
}?: GetUserAgentOptions): string;
|
|
71
|
-
/**
|
|
72
|
-
* Logs the request.
|
|
73
|
-
* @param request The request to log.
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
declare function logRequest(logger: Logger, request: Request): void;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/docloader.d.ts
|
|
79
|
-
/**
|
|
80
|
-
* A remote JSON-LD document and its context fetched by
|
|
81
|
-
* a {@link DocumentLoader}.
|
|
82
|
-
*/
|
|
83
|
-
interface RemoteDocument {
|
|
84
|
-
/**
|
|
85
|
-
* The URL of the context document.
|
|
86
|
-
*/
|
|
87
|
-
contextUrl: string | null;
|
|
88
|
-
/**
|
|
89
|
-
* The fetched JSON-LD document.
|
|
90
|
-
*/
|
|
91
|
-
document: unknown;
|
|
92
|
-
/**
|
|
93
|
-
* The URL of the fetched document.
|
|
94
|
-
*/
|
|
95
|
-
documentUrl: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Options for {@link DocumentLoader}.
|
|
99
|
-
* @since 1.8.0
|
|
100
|
-
*/
|
|
101
|
-
interface DocumentLoaderOptions {
|
|
102
|
-
/**
|
|
103
|
-
* An `AbortSignal` for cancellation.
|
|
104
|
-
* @since 1.8.0
|
|
105
|
-
*/
|
|
106
|
-
signal?: AbortSignal;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* A JSON-LD document loader that fetches documents from the Web.
|
|
110
|
-
* @param url The URL of the document to load.
|
|
111
|
-
* @param options The options for the document loader.
|
|
112
|
-
* @returns The loaded remote document.
|
|
113
|
-
*/
|
|
114
|
-
type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
|
|
115
|
-
/**
|
|
116
|
-
* A factory function that creates a {@link DocumentLoader} with options.
|
|
117
|
-
* @param options The options for the document loader.
|
|
118
|
-
* @returns The document loader.
|
|
119
|
-
* @since 1.4.0
|
|
120
|
-
*/
|
|
121
|
-
type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
8
|
+
//#region src/key.d.ts
|
|
122
9
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @
|
|
126
|
-
* @since 1.4.0
|
|
10
|
+
* Parsed `did:key` verification method.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.4.0
|
|
127
13
|
*/
|
|
128
|
-
interface
|
|
14
|
+
interface DidKeyVerificationMethod {
|
|
129
15
|
/**
|
|
130
|
-
*
|
|
131
|
-
* Turned off by default.
|
|
132
|
-
* @default `false``
|
|
16
|
+
* The DID URL identifying the verification method.
|
|
133
17
|
*/
|
|
134
|
-
|
|
18
|
+
readonly id: URL;
|
|
135
19
|
/**
|
|
136
|
-
*
|
|
137
|
-
* If a string is given, it is used as the `User-Agent` header value.
|
|
138
|
-
* If an object is given, it is passed to {@link getUserAgent} function.
|
|
20
|
+
* The controller DID.
|
|
139
21
|
*/
|
|
140
|
-
|
|
22
|
+
readonly controller: URL;
|
|
141
23
|
/**
|
|
142
|
-
* The
|
|
143
|
-
* @default `20`
|
|
144
|
-
* @since 2.2.0
|
|
24
|
+
* The Ed25519 public key encoded as a Multibase Multikey value.
|
|
145
25
|
*/
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* A factory function that creates an authenticated {@link DocumentLoader} for
|
|
150
|
-
* a given identity. This is used for fetching documents that require
|
|
151
|
-
* authentication.
|
|
152
|
-
* @param identity The identity to create the document loader for.
|
|
153
|
-
* The actor's key pair.
|
|
154
|
-
* @param options The options for the document loader.
|
|
155
|
-
* @returns The authenticated document loader.
|
|
156
|
-
* @since 0.4.0
|
|
157
|
-
*/
|
|
158
|
-
type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
159
|
-
keyId: URL;
|
|
160
|
-
privateKey: CryptoKey;
|
|
161
|
-
}, options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
162
|
-
/**
|
|
163
|
-
* Gets a {@link RemoteDocument} from the given response.
|
|
164
|
-
* @param url The URL of the document to load.
|
|
165
|
-
* @param response The response to get the document from.
|
|
166
|
-
* @param fetch The function to fetch the document.
|
|
167
|
-
* @returns The loaded remote document.
|
|
168
|
-
* @throws {FetchError} If the response is not OK.
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>;
|
|
172
|
-
/**
|
|
173
|
-
* Options for {@link getDocumentLoader}.
|
|
174
|
-
* @since 1.3.0
|
|
175
|
-
*/
|
|
176
|
-
interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
26
|
+
readonly publicKeyMultibase: string;
|
|
177
27
|
/**
|
|
178
|
-
*
|
|
28
|
+
* The Ed25519 public key.
|
|
179
29
|
*/
|
|
180
|
-
|
|
30
|
+
readonly publicKey: CryptoKey;
|
|
181
31
|
}
|
|
182
32
|
/**
|
|
183
|
-
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
184
|
-
*
|
|
185
|
-
* The created loader preloads the below frequently used contexts by default
|
|
186
|
-
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
187
|
-
*
|
|
188
|
-
* - <https://www.w3.org/ns/activitystreams>
|
|
189
|
-
* - <https://w3id.org/security/v1>
|
|
190
|
-
* - <https://w3id.org/security/data-integrity/v1>
|
|
191
|
-
* - <https://www.w3.org/ns/did/v1>
|
|
192
|
-
* - <https://w3id.org/security/multikey/v1>
|
|
193
|
-
* - <https://purl.archive.org/socialweb/webfinger>
|
|
194
|
-
* - <http://schema.org/>
|
|
195
|
-
* @param options Options for the document loader.
|
|
196
|
-
* @returns The document loader.
|
|
197
|
-
* @since 1.3.0
|
|
198
|
-
*/
|
|
199
|
-
declare function getDocumentLoader({
|
|
200
|
-
allowPrivateAddress,
|
|
201
|
-
maxRedirection,
|
|
202
|
-
skipPreloadedContexts,
|
|
203
|
-
userAgent
|
|
204
|
-
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/key.d.ts
|
|
207
|
-
/**
|
|
208
33
|
* Imports a PEM-SPKI formatted public key.
|
|
209
34
|
* @param pem The PEM-SPKI formatted public key.
|
|
210
35
|
* @returns The imported public key.
|
|
@@ -237,6 +62,34 @@ declare function importPkcs1(pem: string): Promise<CryptoKey>;
|
|
|
237
62
|
*/
|
|
238
63
|
declare function importPem(pem: string): Promise<CryptoKey>;
|
|
239
64
|
/**
|
|
65
|
+
* Imports an Ed25519 `did:key` DID.
|
|
66
|
+
*
|
|
67
|
+
* @param did The `did:key` DID.
|
|
68
|
+
* @returns The imported Ed25519 public key.
|
|
69
|
+
* @throws {TypeError} If the DID is malformed or uses an unsupported key type.
|
|
70
|
+
* @since 2.4.0
|
|
71
|
+
*/
|
|
72
|
+
declare function importDidKey(did: string | URL): Promise<CryptoKey>;
|
|
73
|
+
/**
|
|
74
|
+
* Exports an Ed25519 public key as a `did:key` DID.
|
|
75
|
+
*
|
|
76
|
+
* @param key The Ed25519 public key.
|
|
77
|
+
* @returns The `did:key` DID.
|
|
78
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
79
|
+
* @since 2.4.0
|
|
80
|
+
*/
|
|
81
|
+
declare function exportDidKey(key: CryptoKey): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Parses an Ed25519 `did:key` verification method DID URL.
|
|
84
|
+
*
|
|
85
|
+
* @param didUrl The `did:key` DID URL.
|
|
86
|
+
* @returns The parsed verification method.
|
|
87
|
+
* @throws {TypeError} If the DID URL is malformed, unsupported, or its
|
|
88
|
+
* fragment does not identify the same key as the DID.
|
|
89
|
+
* @since 2.4.0
|
|
90
|
+
*/
|
|
91
|
+
declare function parseDidKeyVerificationMethod(didUrl: string | URL): Promise<DidKeyVerificationMethod>;
|
|
92
|
+
/**
|
|
240
93
|
* Imports a [Multibase]-encoded public key.
|
|
241
94
|
*
|
|
242
95
|
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
@@ -461,6 +314,22 @@ declare class UrlError extends Error {
|
|
|
461
314
|
constructor(message: string);
|
|
462
315
|
}
|
|
463
316
|
/**
|
|
317
|
+
* Parses a JSON-LD `@id` value as an IRI.
|
|
318
|
+
*/
|
|
319
|
+
declare function parseJsonLdId(id: string | undefined, base?: string | URL): URL | undefined;
|
|
320
|
+
/**
|
|
321
|
+
* Parses an IRI as a URL, including FEP-ef61 portable ActivityPub IRIs.
|
|
322
|
+
*/
|
|
323
|
+
declare function parseIri(iri: string | URL, base?: string | URL): URL;
|
|
324
|
+
/**
|
|
325
|
+
* Formats a URL as an IRI, including FEP-ef61 portable ActivityPub IRIs.
|
|
326
|
+
*/
|
|
327
|
+
declare function formatIri(iri: string | URL): string;
|
|
328
|
+
/**
|
|
329
|
+
* Checks whether two IRIs have the same origin.
|
|
330
|
+
*/
|
|
331
|
+
declare function haveSameIriOrigin(left: URL, right: URL): boolean;
|
|
332
|
+
/**
|
|
464
333
|
* Validates a URL to prevent SSRF attacks.
|
|
465
334
|
*/
|
|
466
335
|
declare function validatePublicUrl(url: string): Promise<void>;
|
|
@@ -468,4 +337,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
468
337
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
469
338
|
declare function expandIPv6Address(address: string): string;
|
|
470
339
|
//#endregion
|
|
471
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, preloadedContexts, validatePublicUrl };
|
|
340
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getRemoteDocument, getUserAgent, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
|