@fedify/vocab-runtime 2.4.0-pr.934.40 → 2.4.0
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 +4 -2
- package/dist/{tests/docloader-Xi61Le8w.mjs → contexts-BK1CqBR5.cjs} +164 -269
- package/dist/{tests/docloader-BFedvemb.cjs → contexts-DPuJ4UYL.js} +160 -288
- package/dist/{docloader-DnUMWHaJ.d.cts → docloader-CYwqh5Df.d.cts} +68 -2
- package/dist/{docloader-xRGn1azD.d.ts → docloader-CYwqh5Df.d.ts} +68 -2
- package/dist/internal/jsonld-cache.cjs +70 -1
- package/dist/internal/jsonld-cache.d.cts +35 -2
- package/dist/internal/jsonld-cache.d.ts +35 -2
- package/dist/internal/jsonld-cache.js +67 -2
- package/dist/internal/portable-dereference.cjs +721 -0
- package/dist/internal/portable-dereference.d.cts +349 -0
- package/dist/internal/portable-dereference.d.ts +349 -0
- package/dist/internal/portable-dereference.js +702 -0
- package/dist/internal/signed-representation.cjs +378 -0
- package/dist/internal/signed-representation.d.cts +144 -0
- package/dist/internal/signed-representation.d.ts +144 -0
- package/dist/internal/signed-representation.js +371 -0
- package/dist/jsonld.cjs +2 -2
- package/dist/mod.cjs +715 -4523
- package/dist/mod.d.cts +406 -6
- package/dist/mod.d.ts +406 -7
- package/dist/mod.js +694 -4518
- package/dist/portable-DqtfLy_1.d.cts +160 -0
- package/dist/portable-DtWsu2yU.d.ts +160 -0
- package/dist/tests/body-CYiu9CO-.mjs +130 -0
- package/dist/tests/body-CkEwROsn.cjs +153 -0
- package/dist/tests/body.test.cjs +89 -0
- package/dist/tests/body.test.d.cts +1 -0
- package/dist/tests/body.test.d.mts +1 -0
- package/dist/tests/body.test.mjs +90 -0
- package/dist/tests/contexts-CIKsin4e.mjs +4512 -0
- package/dist/tests/contexts-DizzBjz4.cjs +4523 -0
- package/dist/tests/decimal.test.cjs +8 -7
- package/dist/tests/decimal.test.mjs +8 -6
- package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
- package/dist/tests/digest-COC7xDiQ.mjs +141 -0
- package/dist/tests/digest.test.cjs +102 -0
- package/dist/tests/digest.test.d.cts +1 -0
- package/dist/tests/digest.test.d.mts +1 -0
- package/dist/tests/digest.test.mjs +103 -0
- package/dist/tests/docloader-C3YFl6y4.cjs +396 -0
- package/dist/tests/docloader-CvmS4sVq.mjs +373 -0
- package/dist/tests/docloader.test.cjs +692 -39
- package/dist/tests/docloader.test.mjs +686 -34
- package/dist/tests/internal/multicodec.test.cjs +2 -3
- package/dist/tests/internal/multicodec.test.mjs +2 -2
- package/dist/tests/internal/portable-dereference.test.cjs +172 -0
- package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
- package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
- package/dist/tests/internal/portable-dereference.test.mjs +173 -0
- package/dist/tests/jsonld-cache-BPQmOZWD.mjs +342 -0
- package/dist/tests/jsonld-cache-C07AyNOY.cjs +397 -0
- package/dist/tests/jsonld-cache.test.cjs +101 -298
- package/dist/tests/jsonld-cache.test.mjs +94 -289
- package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
- package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
- package/dist/tests/key.test.cjs +6 -5
- package/dist/tests/key.test.mjs +6 -4
- package/dist/tests/langstr.test.cjs +4 -4
- package/dist/tests/langstr.test.mjs +2 -2
- package/dist/tests/link.test.cjs +2 -3
- package/dist/tests/link.test.mjs +2 -2
- package/dist/tests/multibase/multibase.test.cjs +8 -9
- package/dist/tests/multibase/multibase.test.mjs +6 -6
- package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
- package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
- package/dist/tests/portable-dereference-BNXtgg5U.cjs +278 -0
- package/dist/tests/portable-dereference-DRE5bz-l.mjs +249 -0
- package/dist/tests/portable-media-BLKllU56.cjs +153 -0
- package/dist/tests/portable-media-DRSGBORB.mjs +148 -0
- package/dist/tests/portable-media.test.cjs +222 -0
- package/dist/tests/portable-media.test.d.cts +1 -0
- package/dist/tests/portable-media.test.d.mts +1 -0
- package/dist/tests/portable-media.test.mjs +223 -0
- package/dist/tests/portable-workers.test.cjs +36 -0
- package/dist/tests/portable-workers.test.d.cts +2 -0
- package/dist/tests/portable-workers.test.d.mts +2 -0
- package/dist/tests/portable-workers.test.mjs +35 -0
- package/dist/tests/{request-cCPgOxYG.cjs → request-8vPWtV1-.cjs} +10 -4
- package/dist/tests/{request-BOS-hNaf.mjs → request-DRaOaTqD.mjs} +8 -2
- package/dist/tests/request.test.cjs +7 -4
- package/dist/tests/request.test.mjs +5 -2
- package/dist/tests/signed-representation.test.cjs +588 -0
- package/dist/tests/signed-representation.test.d.cts +1 -0
- package/dist/tests/signed-representation.test.d.mts +1 -0
- package/dist/tests/signed-representation.test.mjs +589 -0
- package/dist/tests/temporal.test.cjs +1 -2
- package/dist/tests/temporal.test.mjs +1 -1
- package/dist/tests/url-BNakuZ8k.cjs +998 -0
- package/dist/tests/url-DMxmp7ZG.mjs +859 -0
- package/dist/tests/url.test.cjs +503 -3
- package/dist/tests/url.test.mjs +503 -2
- package/dist/url-DrGTR8yv.cjs +993 -0
- package/dist/url-Dzyp-NsC.js +860 -0
- package/package.json +27 -4
- package/scripts/test-bun.mjs +17 -0
- package/src/body.test.ts +125 -0
- package/src/body.ts +152 -0
- package/src/contexts/cid-v1.json +114 -0
- package/src/contexts/fep-22cd.json +21 -0
- package/src/contexts/fep-ef61.json +10 -0
- package/src/contexts/miscellany.json +17 -0
- package/src/contexts/security-data-integrity-v1.json +0 -4
- package/src/contexts.ts +40 -0
- package/src/digest.test.ts +220 -0
- package/src/digest.ts +229 -0
- package/src/docloader.test.ts +918 -27
- package/src/docloader.ts +322 -105
- package/src/internal/jsonld-cache.ts +97 -1
- package/src/internal/portable-dereference.test.ts +254 -0
- package/src/internal/portable-dereference.ts +1000 -0
- package/src/internal/signed-representation.ts +565 -0
- package/src/jsonld-cache.test.ts +89 -0
- package/src/key.test.ts +9 -0
- package/src/key.ts +11 -1
- package/src/mod.ts +30 -0
- package/src/multibase/multibase.test.ts +5 -5
- package/src/portable-media.test.ts +293 -0
- package/src/portable-media.ts +264 -0
- package/src/portable-workers.test.ts +81 -0
- package/src/portable.ts +180 -0
- package/src/preprocessor.ts +7 -0
- package/src/request.test.ts +10 -1
- package/src/request.ts +9 -1
- package/src/signed-representation.test.ts +338 -0
- package/src/url.test.ts +844 -1
- package/src/url.ts +717 -17
- package/tsdown.config.ts +2 -0
- package/dist/tests/url-BvjYQdxL.cjs +0 -456
- package/dist/tests/url-a2D8NAgh.mjs +0 -378
- package/dist/url-Ck3dGEwH.cjs +0 -457
- package/dist/url-m1YxGNZ0.js +0 -379
- /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
- /package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-C4Fl80ae.cjs} +0 -0
- /package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-CQ26J_L7.mjs} +0 -0
- /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
- /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
- /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
- /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
- /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { n as DocumentLoader, s as RemoteDocument } from "../docloader-CYwqh5Df.js";
|
|
3
|
+
import { r as PortableObjectVerifier } from "../portable-DtWsu2yU.js";
|
|
4
|
+
import { Span, TracerProvider } from "@opentelemetry/api";
|
|
5
|
+
|
|
6
|
+
//#region src/internal/portable-dereference.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* A reference from a vocabulary object's property, which generated
|
|
9
|
+
* accessors pass to {@link dereferencePortableIri}.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
interface PortableReferrerLink {
|
|
14
|
+
readonly object: object;
|
|
15
|
+
readonly property: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether a vocabulary object is part of a chain of portable objects,
|
|
19
|
+
* i.e., whether it has a portable ID, has an FEP-ef61 compatible identifier
|
|
20
|
+
* as its ID (even a malformed one, so that it fails closed), or was obtained
|
|
21
|
+
* from a portable object. Accessors of such objects dereference references
|
|
22
|
+
* as portable objects.
|
|
23
|
+
*
|
|
24
|
+
* Being part of a chain does not mean that the object itself is verified:
|
|
25
|
+
* an object parsed from arbitrary JSON-LD is in a chain just because of its
|
|
26
|
+
* ID. Only {@link dereferencePortableIri} records that an object was
|
|
27
|
+
* accepted by a verifier.
|
|
28
|
+
*
|
|
29
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
30
|
+
* part of the public API contract. This is not considered public API for
|
|
31
|
+
* Semantic Versioning decisions.
|
|
32
|
+
*/
|
|
33
|
+
declare function isInPortableChain(object: object): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Checks whether a vocabulary object was accepted without an integrity
|
|
36
|
+
* proof, e.g., as an unsecured portable collection served by a trusted
|
|
37
|
+
* gateway. Objects embedded in such an object must not be trusted because
|
|
38
|
+
* of their origin.
|
|
39
|
+
*
|
|
40
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
41
|
+
* part of the public API contract. This is not considered public API for
|
|
42
|
+
* Semantic Versioning decisions.
|
|
43
|
+
*/
|
|
44
|
+
declare function isUnsecuredPortableObject(object: object): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether a URL is an FEP-ef61 compatible identifier, i.e., an HTTP(S)
|
|
47
|
+
* URL under a gateway's `/.well-known/apgateway/` path that stands for
|
|
48
|
+
* a portable object. Malformed compatible identifiers count as compatible
|
|
49
|
+
* identifiers too.
|
|
50
|
+
*
|
|
51
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
52
|
+
* part of the public API contract. This is not considered public API for
|
|
53
|
+
* Semantic Versioning decisions.
|
|
54
|
+
*/
|
|
55
|
+
declare function isCompatibleEf61Iri(url: URL | string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Records that a vocabulary object returned by a property accessor was
|
|
58
|
+
* obtained through the given property of a portable object, so that later
|
|
59
|
+
* dereferences from it can tell where it came from. Nothing is recorded if
|
|
60
|
+
* the parent is not in a portable chain, or if the child already has its
|
|
61
|
+
* provenance.
|
|
62
|
+
*
|
|
63
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
64
|
+
* part of the public API contract. This is not considered public API for
|
|
65
|
+
* Semantic Versioning decisions.
|
|
66
|
+
*/
|
|
67
|
+
declare function recordPortableReferrer(parent: object, child: unknown, property: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Copies the provenance of a vocabulary object to its clone. The clone
|
|
70
|
+
* keeps where the original came from and the restriction on unsecured
|
|
71
|
+
* objects, but not a positive verification status nor a collection context,
|
|
72
|
+
* since the clone may have different property values.
|
|
73
|
+
*
|
|
74
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
75
|
+
* part of the public API contract. This is not considered public API for
|
|
76
|
+
* Semantic Versioning decisions.
|
|
77
|
+
*/
|
|
78
|
+
declare function copyPortableProvenance(from: object, to: object): void;
|
|
79
|
+
/**
|
|
80
|
+
* Recognizes an FEP-ef61 compatible identifier to dereference as a portable
|
|
81
|
+
* object.
|
|
82
|
+
*
|
|
83
|
+
* @returns `undefined` if the URL is not a compatible identifier; `null` if
|
|
84
|
+
* it is a malformed compatible identifier; otherwise, the portable
|
|
85
|
+
* ID it stands for and the gateway it names.
|
|
86
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
87
|
+
* part of the public API contract. This is not considered public API for
|
|
88
|
+
* Semantic Versioning decisions.
|
|
89
|
+
*/
|
|
90
|
+
declare function parseCompatibleEf61Reference(url: URL | string): {
|
|
91
|
+
readonly id: URL;
|
|
92
|
+
readonly gateway: URL;
|
|
93
|
+
} | null | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Checks whether a property accessor call on a vocabulary object applies the
|
|
96
|
+
* FEP-ef61 portable object policy, i.e., whether the `verifyPortableObject`
|
|
97
|
+
* option is given or the object is part of a chain of portable objects.
|
|
98
|
+
* In this mode, compatible identifiers are dereferenced as portable objects,
|
|
99
|
+
* and fetched documents that turn out to stand for portable objects are
|
|
100
|
+
* verified as such.
|
|
101
|
+
*
|
|
102
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
103
|
+
* part of the public API contract. This is not considered public API for
|
|
104
|
+
* Semantic Versioning decisions.
|
|
105
|
+
*/
|
|
106
|
+
declare function isPortableMode(object: object, options: {
|
|
107
|
+
readonly verifyPortableObject?: PortableObjectVerifier;
|
|
108
|
+
}): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Checks whether an object embedded in a property of a vocabulary object has
|
|
111
|
+
* to be dereferenced by its `@id` and verified as a portable object rather
|
|
112
|
+
* than trusted as embedded, even with `crossOrigin: "trust"`. This is the
|
|
113
|
+
* case in {@link isPortableMode | portable mode} if its `@id` is an FEP-ef61
|
|
114
|
+
* compatible identifier, or a portable IRI whose DID differs from the
|
|
115
|
+
* owner's portable ID.
|
|
116
|
+
*
|
|
117
|
+
* @param parent The object whose property embeds the object.
|
|
118
|
+
* @param ownerId The ID of the object that vouches for embedded objects, or
|
|
119
|
+
* `null` if embedded objects are not trusted by their owner.
|
|
120
|
+
* @param id The `@id` of the embedded object.
|
|
121
|
+
* @param options The options of the accessor.
|
|
122
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
123
|
+
* part of the public API contract. This is not considered public API for
|
|
124
|
+
* Semantic Versioning decisions.
|
|
125
|
+
*/
|
|
126
|
+
declare function mustDereferencePortableObject(parent: object, ownerId: URL | null, id: URL, options: {
|
|
127
|
+
readonly verifyPortableObject?: PortableObjectVerifier;
|
|
128
|
+
}): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The portable object that a document fetched as an ordinary HTTP(S)
|
|
131
|
+
* document claims to be.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
interface PortableResponseClaim {
|
|
136
|
+
/** The portable ID that the document has to have. */
|
|
137
|
+
readonly id: URL;
|
|
138
|
+
/**
|
|
139
|
+
* The gateways inferred from the document's URL or `@id`, which are
|
|
140
|
+
* reported to the verifier as gateway hints.
|
|
141
|
+
*/
|
|
142
|
+
readonly inferredGateways: readonly URL[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Finds out whether a document fetched as an ordinary HTTP(S) document
|
|
146
|
+
* claims to be a portable object: its final URL is a portable IRI or an
|
|
147
|
+
* FEP-ef61 compatible identifier, or else its `@id` is. The final URL takes
|
|
148
|
+
* precedence, so a document whose `@id` claims another object fails the
|
|
149
|
+
* identity check against the final URL.
|
|
150
|
+
*
|
|
151
|
+
* @param documentUrl The final URL of the document.
|
|
152
|
+
* @param objectId The `@id` of the parsed document.
|
|
153
|
+
* @returns `undefined` if the document does not claim to be a portable
|
|
154
|
+
* object; `null` if the claim is malformed; otherwise, the claim.
|
|
155
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
156
|
+
* part of the public API contract. This is not considered public API for
|
|
157
|
+
* Semantic Versioning decisions.
|
|
158
|
+
*/
|
|
159
|
+
declare function getPortableResponseClaim(documentUrl: string, objectId: URL | null): PortableResponseClaim | null | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Records that an object fetched as an ordinary HTTP(S) object stands for
|
|
162
|
+
* a portable object if its reference, its final URL, or its `@id` is
|
|
163
|
+
* a portable IRI or an FEP-ef61 compatible identifier. Accessors do not
|
|
164
|
+
* cache such objects in their parents, so that a later call with the
|
|
165
|
+
* `verifyPortableObject` option dereferences and verifies them.
|
|
166
|
+
*
|
|
167
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
168
|
+
* part of the public API contract. This is not considered public API for
|
|
169
|
+
* Semantic Versioning decisions.
|
|
170
|
+
*/
|
|
171
|
+
declare function markUnverifiedPortableClaim(object: object, reference: URL, documentUrl: string): void;
|
|
172
|
+
/**
|
|
173
|
+
* Checks whether an object was fetched as an ordinary HTTP(S) object although
|
|
174
|
+
* it stands for a portable object. See {@link markUnverifiedPortableClaim}.
|
|
175
|
+
*
|
|
176
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
177
|
+
* part of the public API contract. This is not considered public API for
|
|
178
|
+
* Semantic Versioning decisions.
|
|
179
|
+
*/
|
|
180
|
+
declare function isUnverifiedPortableClaim(object: object): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Rejects a malformed FEP-ef61 compatible identifier found in a reference,
|
|
183
|
+
* the final URL of a fetched document, or its `@id`, when it would be
|
|
184
|
+
* dereferenced as a portable object. It is rejected without a request (or
|
|
185
|
+
* without returning the fetched document), since it cannot be verified as
|
|
186
|
+
* a portable object, and fetching it as an ordinary HTTP(S) object would
|
|
187
|
+
* skip the portable object policy.
|
|
188
|
+
*
|
|
189
|
+
* @param url The rejected URL, for the log message.
|
|
190
|
+
* @param options The options of the accessor.
|
|
191
|
+
* @returns Always `null`.
|
|
192
|
+
* @throws {Error} If `crossOrigin` is `"throw"` and `suppressError` is not
|
|
193
|
+
* set.
|
|
194
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
195
|
+
* part of the public API contract. This is not considered public API for
|
|
196
|
+
* Semantic Versioning decisions.
|
|
197
|
+
*/
|
|
198
|
+
declare function rejectMalformedCompatibleReference(url: string, options: {
|
|
199
|
+
readonly crossOrigin?: "ignore" | "throw" | "trust";
|
|
200
|
+
readonly suppressError?: boolean;
|
|
201
|
+
}): null;
|
|
202
|
+
/**
|
|
203
|
+
* Logs that an embedded object without `@id` in an object accepted without
|
|
204
|
+
* an integrity proof is dropped, because it cannot be dereferenced and
|
|
205
|
+
* verified on its own.
|
|
206
|
+
*
|
|
207
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
208
|
+
* part of the public API contract. This is not considered public API for
|
|
209
|
+
* Semantic Versioning decisions.
|
|
210
|
+
*/
|
|
211
|
+
declare function warnUnverifiableEmbeddedObject(parent: object, property: string): void;
|
|
212
|
+
/**
|
|
213
|
+
* Checks whether a URL is an FEP-ef61 portable ActivityPub IRI.
|
|
214
|
+
*
|
|
215
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
216
|
+
* part of the public API contract. This is not considered public API for
|
|
217
|
+
* Semantic Versioning decisions.
|
|
218
|
+
*/
|
|
219
|
+
declare function isPortableIri(url: URL): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Picks the ordered list of FEP-ef61 gateways to fetch a portable IRI from.
|
|
222
|
+
*
|
|
223
|
+
* If `gateways` is given, it is used as is (even when empty), and `@gateway`
|
|
224
|
+
* location hints in the IRI are ignored. Otherwise, up to
|
|
225
|
+
* {@link MAX_GATEWAY_HINTS} valid `@gateway` hints are used. Duplicate
|
|
226
|
+
* gateways are dropped in both cases.
|
|
227
|
+
*
|
|
228
|
+
* @throws {TypeError} If an explicit gateway is not an HTTP(S) origin.
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
declare function getPortableGatewayCandidates(url: URL, gateways?: readonly (string | URL)[]): URL[];
|
|
232
|
+
/**
|
|
233
|
+
* Gets the gateways through which a portable reference without location hints
|
|
234
|
+
* can be dereferenced, from the portable actor that the reference belongs to.
|
|
235
|
+
*
|
|
236
|
+
* The references in a portable actor's own document, such as its `outbox`,
|
|
237
|
+
* usually have no `@gateway` hints, as they are not needed there, since
|
|
238
|
+
* the actor's `gateways` already tells where to retrieve them. So this walks
|
|
239
|
+
* from the object whose property is being dereferenced up through the objects
|
|
240
|
+
* it was obtained from, e.g., from a collection page to the collection and
|
|
241
|
+
* then to the actor, and returns the `gateways` of the first object that has
|
|
242
|
+
* any, but only if that object has the same DID as the reference. The
|
|
243
|
+
* gateways only tell where to look; whatever they serve is still verified.
|
|
244
|
+
*
|
|
245
|
+
* @param object The object whose property is being dereferenced.
|
|
246
|
+
* @param url The portable IRI to dereference.
|
|
247
|
+
* @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
|
|
248
|
+
* the IRI has valid `@gateway` hints or no such object is found.
|
|
249
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
250
|
+
* part of the public API contract. This is not considered public API for
|
|
251
|
+
* Semantic Versioning decisions.
|
|
252
|
+
*/
|
|
253
|
+
declare function getReferrerGateways(object: object, url: URL): URL[] | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a context loader that returns the same context documents for the
|
|
256
|
+
* whole dereference operation, so that the identity check, the proof
|
|
257
|
+
* verifier, and the parser interpret the fetched document identically even
|
|
258
|
+
* if the underlying loader is nondeterministic. Failed loads are not
|
|
259
|
+
* remembered, so a transient failure does not affect the next gateway.
|
|
260
|
+
*
|
|
261
|
+
* The parsed object keeps the loader for its own later dereferences, so
|
|
262
|
+
* `release()` turns it into a plain pass-through to the underlying loader
|
|
263
|
+
* once the operation is over.
|
|
264
|
+
*
|
|
265
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
266
|
+
* part of the public API contract. This is not considered public API for
|
|
267
|
+
* Semantic Versioning decisions.
|
|
268
|
+
*/
|
|
269
|
+
declare function createSnapshotContextLoader(contextLoader: DocumentLoader, suppressError?: boolean): {
|
|
270
|
+
loader: DocumentLoader;
|
|
271
|
+
release: () => void;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Options for {@link dereferencePortableIri}.
|
|
275
|
+
*
|
|
276
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
277
|
+
* part of the public API contract. This is not considered public API for
|
|
278
|
+
* Semantic Versioning decisions.
|
|
279
|
+
*/
|
|
280
|
+
interface DereferencePortableIriOptions<T> {
|
|
281
|
+
documentLoader: DocumentLoader;
|
|
282
|
+
contextLoader: DocumentLoader;
|
|
283
|
+
tracerProvider: TracerProvider;
|
|
284
|
+
gateways?: readonly (string | URL)[];
|
|
285
|
+
/**
|
|
286
|
+
* The gateways inferred from where the reference came from, e.g., the
|
|
287
|
+
* gateway of a compatible identifier. When given, they replace the
|
|
288
|
+
* `@gateway` location hints of the IRI, are asked before the explicit
|
|
289
|
+
* `gateways`, and are reported to the verifier as gateway hints unless
|
|
290
|
+
* `gateways` is given.
|
|
291
|
+
*/
|
|
292
|
+
inferredGateways?: readonly URL[];
|
|
293
|
+
/**
|
|
294
|
+
* An already fetched document to validate instead of fetching the object
|
|
295
|
+
* from gateways. It is validated the same way as a gateway's response,
|
|
296
|
+
* and nothing else is tried if it is rejected.
|
|
297
|
+
*/
|
|
298
|
+
response?: RemoteDocument;
|
|
299
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
300
|
+
referrer?: PortableReferrerLink;
|
|
301
|
+
suppressError?: boolean;
|
|
302
|
+
crossOrigin?: "ignore" | "throw" | "trust";
|
|
303
|
+
/**
|
|
304
|
+
* The signal for cancelling the dereference. It is passed to the document
|
|
305
|
+
* loader for requests to gateways, and checked between attempts. Requests
|
|
306
|
+
* for JSON-LD contexts and verification methods may not be cancelled.
|
|
307
|
+
*/
|
|
308
|
+
signal?: AbortSignal;
|
|
309
|
+
parse: (document: unknown, options: {
|
|
310
|
+
contextLoader: DocumentLoader;
|
|
311
|
+
baseUrl: URL;
|
|
312
|
+
}) => Promise<T>;
|
|
313
|
+
span?: Span;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The error thrown by {@link dereferencePortableIri} under
|
|
317
|
+
* `crossOrigin: "throw"` when gateways returned objects but none of them
|
|
318
|
+
* satisfied the identity and proof checks.
|
|
319
|
+
*
|
|
320
|
+
* @internal Not part of the public API contract.
|
|
321
|
+
*/
|
|
322
|
+
declare class PortableObjectRejectedError extends Error {
|
|
323
|
+
constructor(message: string);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Dereferences an FEP-ef61 portable IRI through its gateways.
|
|
327
|
+
*
|
|
328
|
+
* Gateways are tried one by one until one of them returns a single-node
|
|
329
|
+
* document whose `@id`, if any, canonically matches the requested IRI and
|
|
330
|
+
* which passes `verifyPortableObject`. When there is no gateway to try, the
|
|
331
|
+
* document loader is asked for the portable IRI itself, and its result is
|
|
332
|
+
* validated the same way. If the `response` option is given, only that
|
|
333
|
+
* document is validated, and nothing is fetched.
|
|
334
|
+
*
|
|
335
|
+
* @returns The parsed object, or `null` if no valid object was retrieved and
|
|
336
|
+
* `suppressError` is set or the failure was a rejected object
|
|
337
|
+
* (unless `crossOrigin` is `"throw"`).
|
|
338
|
+
* @throws {TypeError} If `gateways` has an invalid entry (always), if no
|
|
339
|
+
* verifier is given, or if the IRI cannot be turned into
|
|
340
|
+
* a gateway URL (unless `suppressError` is set).
|
|
341
|
+
* @internal Technically exported for generated vocabulary classes, but not
|
|
342
|
+
* part of the public API contract. This is not considered public API for
|
|
343
|
+
* Semantic Versioning decisions.
|
|
344
|
+
*/
|
|
345
|
+
declare function dereferencePortableIri<T extends {
|
|
346
|
+
id: URL | null;
|
|
347
|
+
}>(url: URL, options: DereferencePortableIriOptions<T>): Promise<T | null>;
|
|
348
|
+
//#endregion
|
|
349
|
+
export { DereferencePortableIriOptions, PortableObjectRejectedError, PortableReferrerLink, PortableResponseClaim, copyPortableProvenance, createSnapshotContextLoader, dereferencePortableIri, getPortableGatewayCandidates, getPortableResponseClaim, getReferrerGateways, isCompatibleEf61Iri, isInPortableChain, isPortableIri, isPortableMode, isUnsecuredPortableObject, isUnverifiedPortableClaim, markUnverifiedPortableClaim, mustDereferencePortableObject, parseCompatibleEf61Reference, recordPortableReferrer, rejectMalformedCompatibleReference, warnUnverifiableEmbeddedObject };
|