@fedify/vocab-runtime 2.0.0-pr.451.1730
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/LICENSE +20 -0
- package/README.md +26 -0
- package/deno.json +29 -0
- package/dist/mod.cjs +5183 -0
- package/dist/mod.d.cts +274 -0
- package/dist/mod.d.ts +276 -0
- package/dist/mod.js +5149 -0
- package/package.json +52 -0
- package/src/contexts.ts +4237 -0
- package/src/docloader.test.ts +365 -0
- package/src/docloader.ts +311 -0
- package/src/jwk.ts +70 -0
- package/src/key.test.ts +179 -0
- package/src/key.ts +187 -0
- package/src/langstr.test.ts +28 -0
- package/src/langstr.ts +38 -0
- package/src/link.test.ts +82 -0
- package/src/link.ts +345 -0
- package/src/mod.ts +31 -0
- package/src/multibase/base.ts +34 -0
- package/src/multibase/constants.ts +89 -0
- package/src/multibase/mod.ts +82 -0
- package/src/multibase/multibase.test.ts +117 -0
- package/src/multibase/rfc4648.ts +103 -0
- package/src/multibase/types.d.ts +61 -0
- package/src/multibase/util.ts +22 -0
- package/src/request.ts +115 -0
- package/src/url.test.ts +59 -0
- package/src/url.ts +96 -0
- package/tsdown.config.ts +9 -0
package/dist/mod.d.cts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
//#region src/request.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for making `User-Agent` string.
|
|
5
|
+
* @see {@link getUserAgent}
|
|
6
|
+
* @since 1.3.0
|
|
7
|
+
*/
|
|
8
|
+
interface GetUserAgentOptions {
|
|
9
|
+
/**
|
|
10
|
+
* An optional software name and version, e.g., `"Hollo/1.0.0"`.
|
|
11
|
+
*/
|
|
12
|
+
software?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* An optional URL to append to the user agent string.
|
|
15
|
+
* Usually the URL of the ActivityPub instance.
|
|
16
|
+
*/
|
|
17
|
+
url?: string | URL | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the user agent string for the given application and URL.
|
|
21
|
+
* @param options The options for making the user agent string.
|
|
22
|
+
* @returns The user agent string.
|
|
23
|
+
* @since 1.3.0
|
|
24
|
+
*/
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/docloader.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* A remote JSON-LD document and its context fetched by
|
|
29
|
+
* a {@link DocumentLoader}.
|
|
30
|
+
*/
|
|
31
|
+
interface RemoteDocument {
|
|
32
|
+
/**
|
|
33
|
+
* The URL of the context document.
|
|
34
|
+
*/
|
|
35
|
+
contextUrl: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The fetched JSON-LD document.
|
|
38
|
+
*/
|
|
39
|
+
document: unknown;
|
|
40
|
+
/**
|
|
41
|
+
* The URL of the fetched document.
|
|
42
|
+
*/
|
|
43
|
+
documentUrl: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link DocumentLoader}.
|
|
47
|
+
* @since 1.8.0
|
|
48
|
+
*/
|
|
49
|
+
interface DocumentLoaderOptions {
|
|
50
|
+
/**
|
|
51
|
+
* An `AbortSignal` for cancellation.
|
|
52
|
+
* @since 1.8.0
|
|
53
|
+
*/
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A JSON-LD document loader that fetches documents from the Web.
|
|
58
|
+
* @param url The URL of the document to load.
|
|
59
|
+
* @param options The options for the document loader.
|
|
60
|
+
* @returns The loaded remote document.
|
|
61
|
+
*/
|
|
62
|
+
type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
|
|
63
|
+
/**
|
|
64
|
+
* A factory function that creates a {@link DocumentLoader} with options.
|
|
65
|
+
* @param options The options for the document loader.
|
|
66
|
+
* @returns The document loader.
|
|
67
|
+
* @since 1.4.0
|
|
68
|
+
*/
|
|
69
|
+
type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
70
|
+
/**
|
|
71
|
+
* Options for {@link DocumentLoaderFactory}.
|
|
72
|
+
* @see {@link DocumentLoaderFactory}
|
|
73
|
+
* @see {@link AuthenticatedDocumentLoaderFactory}
|
|
74
|
+
* @since 1.4.0
|
|
75
|
+
*/
|
|
76
|
+
interface DocumentLoaderFactoryOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Whether to allow fetching private network addresses.
|
|
79
|
+
* Turned off by default.
|
|
80
|
+
* @default `false``
|
|
81
|
+
*/
|
|
82
|
+
allowPrivateAddress?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Options for making `User-Agent` string.
|
|
85
|
+
* If a string is given, it is used as the `User-Agent` header value.
|
|
86
|
+
* If an object is given, it is passed to {@link getUserAgent} function.
|
|
87
|
+
*/
|
|
88
|
+
userAgent?: GetUserAgentOptions | string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A factory function that creates an authenticated {@link DocumentLoader} for
|
|
92
|
+
* a given identity. This is used for fetching documents that require
|
|
93
|
+
* authentication.
|
|
94
|
+
* @param identity The identity to create the document loader for.
|
|
95
|
+
* The actor's key pair.
|
|
96
|
+
* @param options The options for the document loader.
|
|
97
|
+
* @returns The authenticated document loader.
|
|
98
|
+
* @since 0.4.0
|
|
99
|
+
*/
|
|
100
|
+
type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
101
|
+
keyId: URL;
|
|
102
|
+
privateKey: CryptoKey;
|
|
103
|
+
}, options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
104
|
+
/**
|
|
105
|
+
* Gets a {@link RemoteDocument} from the given response.
|
|
106
|
+
* @param url The URL of the document to load.
|
|
107
|
+
* @param response The response to get the document from.
|
|
108
|
+
* @param fetch The function to fetch the document.
|
|
109
|
+
* @returns The loaded remote document.
|
|
110
|
+
* @throws {FetchError} If the response is not OK.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>;
|
|
114
|
+
/**
|
|
115
|
+
* Options for {@link getDocumentLoader}.
|
|
116
|
+
* @since 1.3.0
|
|
117
|
+
*/
|
|
118
|
+
interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
119
|
+
/**
|
|
120
|
+
* Whether to preload the frequently used contexts.
|
|
121
|
+
*/
|
|
122
|
+
skipPreloadedContexts?: boolean;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
126
|
+
*
|
|
127
|
+
* The created loader preloads the below frequently used contexts by default
|
|
128
|
+
* (unless `options.ignorePreloadedContexts` is set to `true`):
|
|
129
|
+
*
|
|
130
|
+
* - <https://www.w3.org/ns/activitystreams>
|
|
131
|
+
* - <https://w3id.org/security/v1>
|
|
132
|
+
* - <https://w3id.org/security/data-integrity/v1>
|
|
133
|
+
* - <https://www.w3.org/ns/did/v1>
|
|
134
|
+
* - <https://w3id.org/security/multikey/v1>
|
|
135
|
+
* - <https://purl.archive.org/socialweb/webfinger>
|
|
136
|
+
* - <http://schema.org/>
|
|
137
|
+
* @param options Options for the document loader.
|
|
138
|
+
* @returns The document loader.
|
|
139
|
+
* @since 1.3.0
|
|
140
|
+
*/
|
|
141
|
+
declare function getDocumentLoader({
|
|
142
|
+
allowPrivateAddress,
|
|
143
|
+
skipPreloadedContexts,
|
|
144
|
+
userAgent
|
|
145
|
+
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/key.d.ts
|
|
148
|
+
/**
|
|
149
|
+
* Imports a PEM-SPKI formatted public key.
|
|
150
|
+
* @param pem The PEM-SPKI formatted public key.
|
|
151
|
+
* @returns The imported public key.
|
|
152
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
153
|
+
* @since 0.5.0
|
|
154
|
+
*/
|
|
155
|
+
declare function importSpki(pem: string): Promise<CryptoKey>;
|
|
156
|
+
/**
|
|
157
|
+
* Exports a public key in PEM-SPKI format.
|
|
158
|
+
* @param key The public key to export.
|
|
159
|
+
* @returns The exported public key in PEM-SPKI format.
|
|
160
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
161
|
+
* @since 0.5.0
|
|
162
|
+
*/
|
|
163
|
+
declare function exportSpki(key: CryptoKey): Promise<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Imports a PEM-PKCS#1 formatted public key.
|
|
166
|
+
* @param pem The PEM-PKCS#1 formatted public key.
|
|
167
|
+
* @returns The imported public key.
|
|
168
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
169
|
+
* @since 1.5.0
|
|
170
|
+
*/
|
|
171
|
+
declare function importPkcs1(pem: string): Promise<CryptoKey>;
|
|
172
|
+
/**
|
|
173
|
+
* Imports a PEM formatted public key (SPKI or PKCS#1).
|
|
174
|
+
* @param pem The PEM formatted public key to import (SPKI or PKCS#1).
|
|
175
|
+
* @returns The imported public key.
|
|
176
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
177
|
+
* @since 1.5.0
|
|
178
|
+
*/
|
|
179
|
+
declare function importPem(pem: string): Promise<CryptoKey>;
|
|
180
|
+
/**
|
|
181
|
+
* Imports a [Multibase]-encoded public key.
|
|
182
|
+
*
|
|
183
|
+
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
184
|
+
* @param key The Multibase-encoded public key.
|
|
185
|
+
* @returns The imported public key.
|
|
186
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
187
|
+
* @since 0.10.0
|
|
188
|
+
*/
|
|
189
|
+
declare function importMultibaseKey(key: string): Promise<CryptoKey>;
|
|
190
|
+
/**
|
|
191
|
+
* Exports a public key in [Multibase] format.
|
|
192
|
+
*
|
|
193
|
+
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
194
|
+
* @param key The public key to export.
|
|
195
|
+
* @returns The exported public key in Multibase format.
|
|
196
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
197
|
+
* @since 0.10.0
|
|
198
|
+
*/
|
|
199
|
+
declare function exportMultibaseKey(key: CryptoKey): Promise<string>;
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/langstr.d.ts
|
|
202
|
+
/**
|
|
203
|
+
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
204
|
+
*/
|
|
205
|
+
declare class LanguageString extends String {
|
|
206
|
+
/**
|
|
207
|
+
* The locale of the string.
|
|
208
|
+
* @since 2.0.0
|
|
209
|
+
*/
|
|
210
|
+
readonly locale: Intl.Locale;
|
|
211
|
+
/**
|
|
212
|
+
* Constructs a new `LanguageString`.
|
|
213
|
+
* @param value A string value written in the given language.
|
|
214
|
+
* @param locale The language of the string. If a string is given, it will
|
|
215
|
+
* be parsed as a `Intl.Locale` object.
|
|
216
|
+
*/
|
|
217
|
+
constructor(value: string, language: Intl.Locale | string);
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/multibase/types.d.ts
|
|
221
|
+
type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* - Names of the supported encodings
|
|
225
|
+
*/
|
|
226
|
+
type BaseName = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad";
|
|
227
|
+
type BaseNameOrCode = BaseCode | BaseName;
|
|
228
|
+
interface Codec {
|
|
229
|
+
encode: (buffer: Uint8Array) => string;
|
|
230
|
+
decode: (hash: string) => Uint8Array;
|
|
231
|
+
}
|
|
232
|
+
interface CodecFactory {
|
|
233
|
+
(input: string): Codec;
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/multibase/base.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* Class to encode/decode in the supported Bases
|
|
239
|
+
*/
|
|
240
|
+
declare class Base {
|
|
241
|
+
name: BaseName;
|
|
242
|
+
private code;
|
|
243
|
+
private alphabet;
|
|
244
|
+
codeBuf: Uint8Array;
|
|
245
|
+
codec: Codec;
|
|
246
|
+
constructor(name: BaseName, code: BaseCode, factory: CodecFactory, alphabet: string);
|
|
247
|
+
encode(buf: Uint8Array): string;
|
|
248
|
+
decode(string: string): Uint8Array;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/multibase/mod.d.ts
|
|
252
|
+
/**
|
|
253
|
+
* Encode data with the specified base and add the multibase prefix.
|
|
254
|
+
*
|
|
255
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
256
|
+
*/
|
|
257
|
+
declare function encodeMultibase(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array;
|
|
258
|
+
/**
|
|
259
|
+
* Takes a Uint8Array or string encoded with multibase header, decodes it and
|
|
260
|
+
* returns the decoded buffer
|
|
261
|
+
*
|
|
262
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
263
|
+
*/
|
|
264
|
+
declare function decodeMultibase(data: Uint8Array | string): Uint8Array;
|
|
265
|
+
/**
|
|
266
|
+
* Get encoding multibase from data
|
|
267
|
+
*
|
|
268
|
+
* @param {string|Uint8Array} data
|
|
269
|
+
* @returns {Base}
|
|
270
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
271
|
+
*/
|
|
272
|
+
declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
273
|
+
//#endregion
|
|
274
|
+
export { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, GetDocumentLoaderOptions, LanguageString, RemoteDocument, decodeMultibase, encodeMultibase, encodingFromBaseData, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, importMultibaseKey, importPem, importPkcs1, importSpki };
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import "@logtape/logtape";
|
|
2
|
+
|
|
3
|
+
//#region src/request.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for making `User-Agent` string.
|
|
7
|
+
* @see {@link getUserAgent}
|
|
8
|
+
* @since 1.3.0
|
|
9
|
+
*/
|
|
10
|
+
interface GetUserAgentOptions {
|
|
11
|
+
/**
|
|
12
|
+
* An optional software name and version, e.g., `"Hollo/1.0.0"`.
|
|
13
|
+
*/
|
|
14
|
+
software?: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* An optional URL to append to the user agent string.
|
|
17
|
+
* Usually the URL of the ActivityPub instance.
|
|
18
|
+
*/
|
|
19
|
+
url?: string | URL | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets the user agent string for the given application and URL.
|
|
23
|
+
* @param options The options for making the user agent string.
|
|
24
|
+
* @returns The user agent string.
|
|
25
|
+
* @since 1.3.0
|
|
26
|
+
*/
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/docloader.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* A remote JSON-LD document and its context fetched by
|
|
31
|
+
* a {@link DocumentLoader}.
|
|
32
|
+
*/
|
|
33
|
+
interface RemoteDocument {
|
|
34
|
+
/**
|
|
35
|
+
* The URL of the context document.
|
|
36
|
+
*/
|
|
37
|
+
contextUrl: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* The fetched JSON-LD document.
|
|
40
|
+
*/
|
|
41
|
+
document: unknown;
|
|
42
|
+
/**
|
|
43
|
+
* The URL of the fetched document.
|
|
44
|
+
*/
|
|
45
|
+
documentUrl: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for {@link DocumentLoader}.
|
|
49
|
+
* @since 1.8.0
|
|
50
|
+
*/
|
|
51
|
+
interface DocumentLoaderOptions {
|
|
52
|
+
/**
|
|
53
|
+
* An `AbortSignal` for cancellation.
|
|
54
|
+
* @since 1.8.0
|
|
55
|
+
*/
|
|
56
|
+
signal?: AbortSignal;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A JSON-LD document loader that fetches documents from the Web.
|
|
60
|
+
* @param url The URL of the document to load.
|
|
61
|
+
* @param options The options for the document loader.
|
|
62
|
+
* @returns The loaded remote document.
|
|
63
|
+
*/
|
|
64
|
+
type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
|
|
65
|
+
/**
|
|
66
|
+
* A factory function that creates a {@link DocumentLoader} with options.
|
|
67
|
+
* @param options The options for the document loader.
|
|
68
|
+
* @returns The document loader.
|
|
69
|
+
* @since 1.4.0
|
|
70
|
+
*/
|
|
71
|
+
type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
72
|
+
/**
|
|
73
|
+
* Options for {@link DocumentLoaderFactory}.
|
|
74
|
+
* @see {@link DocumentLoaderFactory}
|
|
75
|
+
* @see {@link AuthenticatedDocumentLoaderFactory}
|
|
76
|
+
* @since 1.4.0
|
|
77
|
+
*/
|
|
78
|
+
interface DocumentLoaderFactoryOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Whether to allow fetching private network addresses.
|
|
81
|
+
* Turned off by default.
|
|
82
|
+
* @default `false``
|
|
83
|
+
*/
|
|
84
|
+
allowPrivateAddress?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Options for making `User-Agent` string.
|
|
87
|
+
* If a string is given, it is used as the `User-Agent` header value.
|
|
88
|
+
* If an object is given, it is passed to {@link getUserAgent} function.
|
|
89
|
+
*/
|
|
90
|
+
userAgent?: GetUserAgentOptions | string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A factory function that creates an authenticated {@link DocumentLoader} for
|
|
94
|
+
* a given identity. This is used for fetching documents that require
|
|
95
|
+
* authentication.
|
|
96
|
+
* @param identity The identity to create the document loader for.
|
|
97
|
+
* The actor's key pair.
|
|
98
|
+
* @param options The options for the document loader.
|
|
99
|
+
* @returns The authenticated document loader.
|
|
100
|
+
* @since 0.4.0
|
|
101
|
+
*/
|
|
102
|
+
type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
103
|
+
keyId: URL;
|
|
104
|
+
privateKey: CryptoKey;
|
|
105
|
+
}, options?: DocumentLoaderFactoryOptions) => DocumentLoader;
|
|
106
|
+
/**
|
|
107
|
+
* Gets a {@link RemoteDocument} from the given response.
|
|
108
|
+
* @param url The URL of the document to load.
|
|
109
|
+
* @param response The response to get the document from.
|
|
110
|
+
* @param fetch The function to fetch the document.
|
|
111
|
+
* @returns The loaded remote document.
|
|
112
|
+
* @throws {FetchError} If the response is not OK.
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>;
|
|
116
|
+
/**
|
|
117
|
+
* Options for {@link getDocumentLoader}.
|
|
118
|
+
* @since 1.3.0
|
|
119
|
+
*/
|
|
120
|
+
interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Whether to preload the frequently used contexts.
|
|
123
|
+
*/
|
|
124
|
+
skipPreloadedContexts?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
128
|
+
*
|
|
129
|
+
* The created loader preloads the below frequently used contexts by default
|
|
130
|
+
* (unless `options.ignorePreloadedContexts` is set to `true`):
|
|
131
|
+
*
|
|
132
|
+
* - <https://www.w3.org/ns/activitystreams>
|
|
133
|
+
* - <https://w3id.org/security/v1>
|
|
134
|
+
* - <https://w3id.org/security/data-integrity/v1>
|
|
135
|
+
* - <https://www.w3.org/ns/did/v1>
|
|
136
|
+
* - <https://w3id.org/security/multikey/v1>
|
|
137
|
+
* - <https://purl.archive.org/socialweb/webfinger>
|
|
138
|
+
* - <http://schema.org/>
|
|
139
|
+
* @param options Options for the document loader.
|
|
140
|
+
* @returns The document loader.
|
|
141
|
+
* @since 1.3.0
|
|
142
|
+
*/
|
|
143
|
+
declare function getDocumentLoader({
|
|
144
|
+
allowPrivateAddress,
|
|
145
|
+
skipPreloadedContexts,
|
|
146
|
+
userAgent
|
|
147
|
+
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/key.d.ts
|
|
150
|
+
/**
|
|
151
|
+
* Imports a PEM-SPKI formatted public key.
|
|
152
|
+
* @param pem The PEM-SPKI formatted public key.
|
|
153
|
+
* @returns The imported public key.
|
|
154
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
155
|
+
* @since 0.5.0
|
|
156
|
+
*/
|
|
157
|
+
declare function importSpki(pem: string): Promise<CryptoKey>;
|
|
158
|
+
/**
|
|
159
|
+
* Exports a public key in PEM-SPKI format.
|
|
160
|
+
* @param key The public key to export.
|
|
161
|
+
* @returns The exported public key in PEM-SPKI format.
|
|
162
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
163
|
+
* @since 0.5.0
|
|
164
|
+
*/
|
|
165
|
+
declare function exportSpki(key: CryptoKey): Promise<string>;
|
|
166
|
+
/**
|
|
167
|
+
* Imports a PEM-PKCS#1 formatted public key.
|
|
168
|
+
* @param pem The PEM-PKCS#1 formatted public key.
|
|
169
|
+
* @returns The imported public key.
|
|
170
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
171
|
+
* @since 1.5.0
|
|
172
|
+
*/
|
|
173
|
+
declare function importPkcs1(pem: string): Promise<CryptoKey>;
|
|
174
|
+
/**
|
|
175
|
+
* Imports a PEM formatted public key (SPKI or PKCS#1).
|
|
176
|
+
* @param pem The PEM formatted public key to import (SPKI or PKCS#1).
|
|
177
|
+
* @returns The imported public key.
|
|
178
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
179
|
+
* @since 1.5.0
|
|
180
|
+
*/
|
|
181
|
+
declare function importPem(pem: string): Promise<CryptoKey>;
|
|
182
|
+
/**
|
|
183
|
+
* Imports a [Multibase]-encoded public key.
|
|
184
|
+
*
|
|
185
|
+
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
186
|
+
* @param key The Multibase-encoded public key.
|
|
187
|
+
* @returns The imported public key.
|
|
188
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
189
|
+
* @since 0.10.0
|
|
190
|
+
*/
|
|
191
|
+
declare function importMultibaseKey(key: string): Promise<CryptoKey>;
|
|
192
|
+
/**
|
|
193
|
+
* Exports a public key in [Multibase] format.
|
|
194
|
+
*
|
|
195
|
+
* [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0
|
|
196
|
+
* @param key The public key to export.
|
|
197
|
+
* @returns The exported public key in Multibase format.
|
|
198
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
199
|
+
* @since 0.10.0
|
|
200
|
+
*/
|
|
201
|
+
declare function exportMultibaseKey(key: CryptoKey): Promise<string>;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/langstr.d.ts
|
|
204
|
+
/**
|
|
205
|
+
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
206
|
+
*/
|
|
207
|
+
declare class LanguageString extends String {
|
|
208
|
+
/**
|
|
209
|
+
* The locale of the string.
|
|
210
|
+
* @since 2.0.0
|
|
211
|
+
*/
|
|
212
|
+
readonly locale: Intl.Locale;
|
|
213
|
+
/**
|
|
214
|
+
* Constructs a new `LanguageString`.
|
|
215
|
+
* @param value A string value written in the given language.
|
|
216
|
+
* @param locale The language of the string. If a string is given, it will
|
|
217
|
+
* be parsed as a `Intl.Locale` object.
|
|
218
|
+
*/
|
|
219
|
+
constructor(value: string, language: Intl.Locale | string);
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/multibase/types.d.ts
|
|
223
|
+
type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* - Names of the supported encodings
|
|
227
|
+
*/
|
|
228
|
+
type BaseName = "identity" | "base2" | "base8" | "base10" | "base16" | "base16upper" | "base32hex" | "base32hexupper" | "base32hexpad" | "base32hexpadupper" | "base32" | "base32upper" | "base32pad" | "base32padupper" | "base32z" | "base36" | "base36upper" | "base58btc" | "base58flickr" | "base64" | "base64pad" | "base64url" | "base64urlpad";
|
|
229
|
+
type BaseNameOrCode = BaseCode | BaseName;
|
|
230
|
+
interface Codec {
|
|
231
|
+
encode: (buffer: Uint8Array) => string;
|
|
232
|
+
decode: (hash: string) => Uint8Array;
|
|
233
|
+
}
|
|
234
|
+
interface CodecFactory {
|
|
235
|
+
(input: string): Codec;
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/multibase/base.d.ts
|
|
239
|
+
/**
|
|
240
|
+
* Class to encode/decode in the supported Bases
|
|
241
|
+
*/
|
|
242
|
+
declare class Base {
|
|
243
|
+
name: BaseName;
|
|
244
|
+
private code;
|
|
245
|
+
private alphabet;
|
|
246
|
+
codeBuf: Uint8Array;
|
|
247
|
+
codec: Codec;
|
|
248
|
+
constructor(name: BaseName, code: BaseCode, factory: CodecFactory, alphabet: string);
|
|
249
|
+
encode(buf: Uint8Array): string;
|
|
250
|
+
decode(string: string): Uint8Array;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/multibase/mod.d.ts
|
|
254
|
+
/**
|
|
255
|
+
* Encode data with the specified base and add the multibase prefix.
|
|
256
|
+
*
|
|
257
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
258
|
+
*/
|
|
259
|
+
declare function encodeMultibase(nameOrCode: BaseNameOrCode, buf: Uint8Array): Uint8Array;
|
|
260
|
+
/**
|
|
261
|
+
* Takes a Uint8Array or string encoded with multibase header, decodes it and
|
|
262
|
+
* returns the decoded buffer
|
|
263
|
+
*
|
|
264
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
265
|
+
*/
|
|
266
|
+
declare function decodeMultibase(data: Uint8Array | string): Uint8Array;
|
|
267
|
+
/**
|
|
268
|
+
* Get encoding multibase from data
|
|
269
|
+
*
|
|
270
|
+
* @param {string|Uint8Array} data
|
|
271
|
+
* @returns {Base}
|
|
272
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
273
|
+
*/
|
|
274
|
+
declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
275
|
+
//#endregion
|
|
276
|
+
export { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, GetDocumentLoaderOptions, LanguageString, RemoteDocument, decodeMultibase, encodeMultibase, encodingFromBaseData, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, importMultibaseKey, importPem, importPkcs1, importSpki };
|