@trylimbo/sdk-verifier-wasm 0.1.0-canary.100
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/gen/wasm/comlink.js +270 -0
- package/gen/wasm/trylimbo_sdk_verifier.d.ts +704 -0
- package/gen/wasm/trylimbo_sdk_verifier.js +1683 -0
- package/gen/wasm/trylimbo_sdk_verifier_bg.wasm +0 -0
- package/gen/wasm/trylimbo_sdk_verifier_bg.wasm.d.ts +62 -0
- package/gen/wasm/worker-thread.js +1604 -0
- package/gen/wasm/worker.d.ts +624 -0
- package/gen/wasm/worker.js +21 -0
- package/package.json +45 -0
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* The `ReadableStreamType` enum.
|
|
5
|
+
*
|
|
6
|
+
* *This API requires the following crate features to be activated: `ReadableStreamType`*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ReadableStreamType = "bytes";
|
|
10
|
+
|
|
11
|
+
/** Sync ranged reader for Node.js (backed by `fs.readSync`). */
|
|
12
|
+
export interface RangeSource {
|
|
13
|
+
length: number;
|
|
14
|
+
readAt: (offset: number, length: number) => Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A C2PA soft binding: an algorithm id (from the C2PA soft-binding algorithm
|
|
20
|
+
* list, e.g. `io.iscc.v0`) plus its algorithm-specific value (the `ISCC:…` code,
|
|
21
|
+
* a watermark token, …). The signer embeds it as a `c2pa.soft-binding` assertion
|
|
22
|
+
* and indexes it, so a transcoded copy whose exact content hash no longer
|
|
23
|
+
* matches still recovers the manifest from the registry.
|
|
24
|
+
*/
|
|
25
|
+
export interface SoftBinding {
|
|
26
|
+
/**
|
|
27
|
+
* C2PA soft-binding algorithm id, e.g. `io.iscc.v0`.
|
|
28
|
+
*/
|
|
29
|
+
alg: string;
|
|
30
|
+
/**
|
|
31
|
+
* Algorithm-specific binding value: the canonical string the algorithm
|
|
32
|
+
* produces (an `ISCC:…` code, a watermark token). Its UTF-8 bytes are what
|
|
33
|
+
* the registry lookup base64-encodes.
|
|
34
|
+
*/
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A canonical gRPC/Connect status code: the coarse, closed failure class.
|
|
40
|
+
*
|
|
41
|
+
* The wasm lane projects this as the Connect `snake_case` string, so a consumer
|
|
42
|
+
* narrows on `err.code === \"resource_exhausted\"`; the native lane projects an enum.
|
|
43
|
+
*/
|
|
44
|
+
export type Code = "canceled" | "unknown" | "invalid_argument" | "deadline_exceeded" | "not_found" | "already_exists" | "permission_denied" | "resource_exhausted" | "failed_precondition" | "aborted" | "out_of_range" | "unimplemented" | "internal" | "unavailable" | "data_loss" | "unauthenticated";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A request-validation fault, `google.rpc.BadRequest` (`kind: \"invalid\"`).
|
|
48
|
+
*/
|
|
49
|
+
export interface InvalidError {
|
|
50
|
+
code: Code;
|
|
51
|
+
message: string;
|
|
52
|
+
fieldViolations: FieldViolation[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A semantic fault carrying a `google.rpc.ErrorInfo` reason (`kind: \"reason\"`).
|
|
57
|
+
*
|
|
58
|
+
* `hashmap_as_object` restates what [`SdkError`] already sets: a container\'s `.d.ts` is
|
|
59
|
+
* generated from its own config, so without it `metadata` is declared `Map<string, string>`
|
|
60
|
+
* for a value the ABI never emits as a `Map`.
|
|
61
|
+
*/
|
|
62
|
+
export interface ReasonError {
|
|
63
|
+
code: Code;
|
|
64
|
+
message: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
domain: string;
|
|
67
|
+
metadata: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A session signing key from the init manifest\'s roster (spec §19.4.4).
|
|
72
|
+
*/
|
|
73
|
+
export interface SessionKeySummary {
|
|
74
|
+
/**
|
|
75
|
+
* Identifier of the session signing key.
|
|
76
|
+
*/
|
|
77
|
+
keyId: Uint8Array;
|
|
78
|
+
/**
|
|
79
|
+
* The session key\'s public half (SEC1-encoded bytes).
|
|
80
|
+
*/
|
|
81
|
+
publicKey: Uint8Array;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A status with no structured detail (`kind: \"status\"`).
|
|
86
|
+
*/
|
|
87
|
+
export interface StatusError {
|
|
88
|
+
code: Code;
|
|
89
|
+
message: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* C2PA validation state of a manifest (spec §14.3).
|
|
94
|
+
*/
|
|
95
|
+
export type ValidationState = "Invalid" | "Valid" | "Trusted";
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Construction options for [`AssetVerifier::new`] (and the `AssetVerifier.create` JS
|
|
99
|
+
* binding). `trust_c2pa_anchors` defaults to `true` when omitted.
|
|
100
|
+
*
|
|
101
|
+
* One definition, all lanes: `#[binding]` derives the shapes directly here:
|
|
102
|
+
* tsify (camelCase, optional fields) on wasm, a `uniffi::Record` on the native
|
|
103
|
+
* `ffi` build, so there is no per-lane DTO copy. Off both lanes it is a plain struct.
|
|
104
|
+
*/
|
|
105
|
+
export interface AssetVerifierOptions {
|
|
106
|
+
/**
|
|
107
|
+
* The registry to recover from. Omit for a verifier that only checks embedded manifests.
|
|
108
|
+
*/
|
|
109
|
+
registry?: RegistryOptions;
|
|
110
|
+
/**
|
|
111
|
+
* PEM trust anchors for the caller\'s own issuers.
|
|
112
|
+
*/
|
|
113
|
+
trustAnchors: string[];
|
|
114
|
+
/**
|
|
115
|
+
* Also trust the bundled official C2PA anchors on top of `trust_anchors`.
|
|
116
|
+
* Defaults to `true`; set `false` to trust only `trust_anchors`.
|
|
117
|
+
*/
|
|
118
|
+
trustC2paAnchors?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Issuer DIDs whose CAWG identity (ICA) credentials count as validated, matched
|
|
121
|
+
* exactly against the credential issuer. Omitted or empty trusts no issuer: every
|
|
122
|
+
* identity assertion then reports `cawg.ica.untrusted_issuer` and withholds
|
|
123
|
+
* `cawg.ica.credential_valid`, which leaves the manifest\'s own validity untouched.
|
|
124
|
+
*/
|
|
125
|
+
trustedIcaIssuers?: string[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Construction options for [`StreamVerifier::new`] (and the `StreamVerifier.create`
|
|
130
|
+
* JS binding). `trust_c2pa_anchors` defaults to `true` when omitted.
|
|
131
|
+
*
|
|
132
|
+
* `#[binding]` derives the wasm shape (`trustC2paAnchors` camelCase, optional) and,
|
|
133
|
+
* with `ffi`, a `uniffi::Record` for the native `StreamVerifier.create` binding, so there
|
|
134
|
+
* is no per-lane DTO copy. Off both lanes it is a plain struct.
|
|
135
|
+
*/
|
|
136
|
+
export interface StreamVerifierOptions {
|
|
137
|
+
/**
|
|
138
|
+
* PEM trust anchors for the caller\'s own issuers.
|
|
139
|
+
*/
|
|
140
|
+
trustAnchors: string[];
|
|
141
|
+
/**
|
|
142
|
+
* Also trust the bundled official C2PA anchors on top of `trust_anchors`.
|
|
143
|
+
* Defaults to `true`; set `false` to trust only `trust_anchors`.
|
|
144
|
+
*/
|
|
145
|
+
trustC2paAnchors?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Issuer DIDs whose CAWG identity (ICA) credentials count as validated, matched
|
|
148
|
+
* exactly against the credential issuer. Omitted or empty trusts no issuer: an
|
|
149
|
+
* identity assertion on the init segment\'s manifest then reports
|
|
150
|
+
* `cawg.ica.untrusted_issuer` and withholds `cawg.ica.credential_valid`.
|
|
151
|
+
*/
|
|
152
|
+
trustedIcaIssuers?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* How far a segment\'s timestamp may sit from wall-clock before it is rejected as
|
|
155
|
+
* skewed. Defaults to [`DEFAULT_SEGMENT_SKEW_TOLERANCE_SECS`]. A deployment whose
|
|
156
|
+
* encoder clock drifts further than that needs this rather than a fork.
|
|
157
|
+
*/
|
|
158
|
+
segmentSkewToleranceSecs?: number;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* How far a recovery may go, which decides what leaves the caller.
|
|
163
|
+
*
|
|
164
|
+
* Separate from [`RecoveryPolicy`], which decides *when* a recovery runs: one names the trigger
|
|
165
|
+
* and the other the reach, and crossing them is what the two enums exist to keep legible.
|
|
166
|
+
*/
|
|
167
|
+
export type RegistryQueries = "derived" | "derivedThenContent";
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* One C2PA validation status entry (spec §15.3).
|
|
171
|
+
*/
|
|
172
|
+
export interface ValidationCode {
|
|
173
|
+
/**
|
|
174
|
+
* C2PA validation status string (e.g. `signingCredential.trusted`).
|
|
175
|
+
*/
|
|
176
|
+
code: string;
|
|
177
|
+
kind: ValidationCodeKind;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* One `google.rpc.BadRequest.FieldViolation`.
|
|
182
|
+
*/
|
|
183
|
+
export interface FieldViolation {
|
|
184
|
+
field: string;
|
|
185
|
+
description: string;
|
|
186
|
+
reason: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* One `verify` credential: the c2pa `ManifestStore`, where it came from, and whether the
|
|
191
|
+
* asset\'s own fingerprint backs it up.
|
|
192
|
+
*/
|
|
193
|
+
export interface FoundCredential {
|
|
194
|
+
/**
|
|
195
|
+
* The bytes behind every thumbnail the manifests reference, by that reference\'s
|
|
196
|
+
* `identifier`: each manifest\'s claim thumbnail and each ingredient\'s. The manifests state
|
|
197
|
+
* identifiers and no images, so this is what a chain draws from.
|
|
198
|
+
*/
|
|
199
|
+
thumbnails: Record<string, Uint8Array>;
|
|
200
|
+
/**
|
|
201
|
+
* Where this credential came from. See [`CredentialOrigin`].
|
|
202
|
+
*/
|
|
203
|
+
origin: CredentialOrigin;
|
|
204
|
+
manifest: import('@contentauth/c2pa-types').ManifestStore;
|
|
205
|
+
/**
|
|
206
|
+
* Whether the asset\'s own fingerprint backs up a mark that led here (C2PA 2.4 1.2.2.3).
|
|
207
|
+
*/
|
|
208
|
+
fingerprintCheck: FingerprintCheck;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Outcome of validating a media segment against its stream\'s init.
|
|
213
|
+
*/
|
|
214
|
+
export interface MediaValidation {
|
|
215
|
+
valid: boolean;
|
|
216
|
+
codes: ValidationCode[];
|
|
217
|
+
keyId: Uint8Array;
|
|
218
|
+
timing: SegmentTiming;
|
|
219
|
+
manifestId: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Outcome of validating a stream\'s init segment.
|
|
224
|
+
*/
|
|
225
|
+
export interface InitValidation {
|
|
226
|
+
state: ValidationState;
|
|
227
|
+
codes: ValidationCode[];
|
|
228
|
+
manifest: import('@contentauth/c2pa-types').ManifestStore;
|
|
229
|
+
sessionKeys: SessionKeySummary[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Result of `StreamValidation.validate`, discriminated by `kind`.
|
|
234
|
+
*/
|
|
235
|
+
export type SegmentValidation = ({ kind: "init" } & InitValidation) | ({ kind: "media" } & MediaValidation) | { kind: "unknown" };
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The error every SDK call throws: a decoded `google.rpc.Status`, discriminated
|
|
239
|
+
* by `kind`. A consumer switches on `err.kind` (`\"reason\" | \"invalid\" | \"status\"`)
|
|
240
|
+
* and reads the shape-specific fields; `code` and `message` are common to every
|
|
241
|
+
* shape. Thrown as a plain object across the wasm boundary (tsify).
|
|
242
|
+
*/
|
|
243
|
+
export type SdkError = ({ kind: "status" } & StatusError) | ({ kind: "reason" } & ReasonError) | ({ kind: "invalid" } & InvalidError);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Timing facts carried by a media segment\'s container.
|
|
247
|
+
*/
|
|
248
|
+
export interface SegmentTiming {
|
|
249
|
+
/**
|
|
250
|
+
* Media segment sequence number (exact below 2^53).
|
|
251
|
+
*/
|
|
252
|
+
sequenceNumber: number;
|
|
253
|
+
/**
|
|
254
|
+
* MP4 timescale (ticks per second) for this segment\'s timing, if present.
|
|
255
|
+
*/
|
|
256
|
+
timescale?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Segment duration in seconds, if the container reports it.
|
|
259
|
+
*/
|
|
260
|
+
eventDurationSecs?: number;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* When [`AssetVerifier::verify_asset`] queries the registry.
|
|
265
|
+
*/
|
|
266
|
+
export type RecoveryPolicy = "whenMissing" | "always";
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Where the registry is, when to query it, and how far. One value rather than an endpoint beside
|
|
270
|
+
* loose flags, so a policy cannot be configured on a verifier that has nowhere to apply it.
|
|
271
|
+
*/
|
|
272
|
+
export interface RegistryOptions {
|
|
273
|
+
/**
|
|
274
|
+
* Soft Binding Resolution API base URL (`https://registry.trylimbo.com`).
|
|
275
|
+
*/
|
|
276
|
+
url: string;
|
|
277
|
+
/**
|
|
278
|
+
* Defaults to [`RecoveryPolicy::WhenMissing`].
|
|
279
|
+
*/
|
|
280
|
+
recovery?: RecoveryPolicy;
|
|
281
|
+
/**
|
|
282
|
+
* Defaults to [`RegistryQueries::DerivedThenContent`].
|
|
283
|
+
*/
|
|
284
|
+
queries?: RegistryQueries;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Whether a code is a success, an informational note, or a failure.
|
|
289
|
+
*/
|
|
290
|
+
export type ValidationCodeKind = "success" | "informational" | "failure";
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* [`crate::asset::CredentialOrigin`] as JS sees it: a tagged union, since each way of finding a
|
|
294
|
+
* credential carries different evidence. Lane-local for the same reason [`FingerprintCheck`] is: a
|
|
295
|
+
* tag layout is what `#[binding(wasm)]` declines to express.
|
|
296
|
+
*/
|
|
297
|
+
export type CredentialOrigin = { kind: "embedded" } | { kind: "recoveredByFingerprint"; binding: SoftBinding; registryScore: number | undefined } | { kind: "recoveredByWatermark"; binding: SoftBinding; registryScore: number | undefined } | { kind: "recoveredByContent"; discoveries: ContentBindingEvidence[] };
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* [`crate::asset::FingerprintCheck`] as JS sees it: a tagged union, since `compared` carries a
|
|
301
|
+
* measurement the other two do not. Lane-local rather than `#[binding(wasm)]` on the core,
|
|
302
|
+
* because a tag layout is exactly what that macro declines to express.
|
|
303
|
+
*/
|
|
304
|
+
export type FingerprintCheck = { kind: "notNeeded" } | { kind: "nothingToCompare" } | { kind: "unsupported"; algorithm: string } | { kind: "indeterminate" } | { kind: "compared"; score: number };
|
|
305
|
+
|
|
306
|
+
export interface AssetVerification {
|
|
307
|
+
credentials: FoundCredential[];
|
|
308
|
+
recovery: RecoverySummary;
|
|
309
|
+
goldenComparison: GoldenComparison;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface ContentBindingEvidence {
|
|
313
|
+
algorithm: string;
|
|
314
|
+
class: ContentBindingClass;
|
|
315
|
+
hint: SoftBinding | undefined;
|
|
316
|
+
registryScore: number | undefined;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface RecoveryIssue {
|
|
320
|
+
kind: RecoveryIssueKind;
|
|
321
|
+
manifestId: string | undefined;
|
|
322
|
+
message: string;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface RecoverySummary {
|
|
326
|
+
status: RecoveryStatus;
|
|
327
|
+
bestCredentialIndex: number | undefined;
|
|
328
|
+
issues: RecoveryIssue[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export type ContentBindingClass = "fingerprint" | "watermark";
|
|
332
|
+
|
|
333
|
+
export type GoldenComparison = { kind: "notRequested" } | { kind: "noEmbeddedManifest" } | { kind: "noRecoveredManifest" } | { kind: "matches"; recoveredIndex: number } | { kind: "differs"; recoveredIndex: number } | { kind: "indeterminate"; recoveredIndex: number | undefined };
|
|
334
|
+
|
|
335
|
+
export type RecoveryIssueKind = "binder" | "bindingQuery" | "queryRefused" | "contentQuery" | "capabilities" | "contentTooLarge" | "candidateFetch" | "candidateValidation" | "resourceLimit";
|
|
336
|
+
|
|
337
|
+
export type RecoveryStatus = "notRequested" | "notFound" | "recovered" | "incomplete";
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
export class AssetVerifier {
|
|
341
|
+
private constructor();
|
|
342
|
+
free(): void;
|
|
343
|
+
[Symbol.dispose](): void;
|
|
344
|
+
/**
|
|
345
|
+
* # Errors
|
|
346
|
+
*
|
|
347
|
+
* Throws `TRUST_CONFIG_INVALID` when the trust anchors are invalid.
|
|
348
|
+
*/
|
|
349
|
+
static create(options: AssetVerifierOptions): AssetVerifier;
|
|
350
|
+
/**
|
|
351
|
+
* Verify an asset against the configured trust anchors. `binders` compose
|
|
352
|
+
* soft-binding recovery after the embedded pass, tried in order,
|
|
353
|
+
* first hit wins; pass `[]` to proceed directly to registry `byContent` recovery.
|
|
354
|
+
*
|
|
355
|
+
* Reads the C2PA-native formats. A container format (MXF) is plugin-backed, and plugins
|
|
356
|
+
* are native, so a master is verified through the native SDK.
|
|
357
|
+
*
|
|
358
|
+
* # Errors
|
|
359
|
+
*
|
|
360
|
+
* Throws on a malformed `input`, a registry (or binder) failure, or a validation
|
|
361
|
+
* failure.
|
|
362
|
+
*/
|
|
363
|
+
verify(input: RangeSource, binders: Binder[]): Promise<AssetVerification>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* A soft-binding binder a client runs itself. Build with `Binder.iscc()` or
|
|
368
|
+
* `Binder.held(binding)`, and pass a list to `verify`.
|
|
369
|
+
*
|
|
370
|
+
* Vendor watermark detection is registry-side in this SDK: configured detectors participate in
|
|
371
|
+
* `verify` through `byContent`, while `Binder.held` covers values already available to the caller.
|
|
372
|
+
*/
|
|
373
|
+
export class Binder {
|
|
374
|
+
private constructor();
|
|
375
|
+
free(): void;
|
|
376
|
+
[Symbol.dispose](): void;
|
|
377
|
+
/**
|
|
378
|
+
* Derive this binder's binding standalone; `undefined` when it finds none.
|
|
379
|
+
* Input is a `RangeSource` (format inferred from content when omitted).
|
|
380
|
+
*
|
|
381
|
+
* # Errors
|
|
382
|
+
*
|
|
383
|
+
* Throws on malformed or unreadable input.
|
|
384
|
+
*/
|
|
385
|
+
derive(content: RangeSource, format?: string | null): Promise<SoftBinding | undefined>;
|
|
386
|
+
/**
|
|
387
|
+
* A binder contributing a binding you already hold (e.g. an out-of-band video ISCC).
|
|
388
|
+
*/
|
|
389
|
+
static held(binding: SoftBinding): Binder;
|
|
390
|
+
/**
|
|
391
|
+
* Local ISCC Image-Code for supported image formats.
|
|
392
|
+
*/
|
|
393
|
+
static iscc(): Binder;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* A [`RangeSource`](crate::wasm::RangeInput) over a `Blob`: a `File` off an `<input>`, a
|
|
398
|
+
* `Response.blob()`, a handle from the file system access API.
|
|
399
|
+
*
|
|
400
|
+
* The only source here that holds nothing. The SDK reads one slice at a time, so an asset larger
|
|
401
|
+
* than the tab's memory verifies at the disk's speed rather than the heap's, and neither ceiling
|
|
402
|
+
* the other two carry applies.
|
|
403
|
+
*
|
|
404
|
+
* # Worker only
|
|
405
|
+
*
|
|
406
|
+
* A `Blob` has exactly one synchronous read, `FileReaderSync`, and it is defined on workers alone.
|
|
407
|
+
* Constructing this on a document's own thread throws. That is the platform's constraint rather
|
|
408
|
+
* than the SDK's, and it is reported at construction rather than at the first read.
|
|
409
|
+
*/
|
|
410
|
+
export class BlobSource {
|
|
411
|
+
free(): void;
|
|
412
|
+
[Symbol.dispose](): void;
|
|
413
|
+
/**
|
|
414
|
+
* # Errors
|
|
415
|
+
*
|
|
416
|
+
* Throws when this is not a worker thread, where a `Blob` cannot be read synchronously.
|
|
417
|
+
*/
|
|
418
|
+
constructor(blob: Blob);
|
|
419
|
+
/**
|
|
420
|
+
* Answers the platform's own array, never routed through linear memory: the port's JS-facing
|
|
421
|
+
* half exists so this hop costs one copy rather than three.
|
|
422
|
+
*
|
|
423
|
+
* # Errors
|
|
424
|
+
*
|
|
425
|
+
* Throws when the platform refuses the slice or the read. Reading at or past the end is not a
|
|
426
|
+
* failure: it answers empty, which every caller already reads as an end of file.
|
|
427
|
+
*/
|
|
428
|
+
readAt(offset: number, length: number): Uint8Array;
|
|
429
|
+
/**
|
|
430
|
+
* The offset is a JS number rather than a `u32` because a `Blob` is the one store here that
|
|
431
|
+
* can outrun what a `u32` names, and it is the width the platform's own slice takes.
|
|
432
|
+
*/
|
|
433
|
+
readonly length: number;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* A [`RangeSource`](crate::wasm::RangeInput) over bytes the caller already holds, read in place.
|
|
438
|
+
*
|
|
439
|
+
* [`MemorySource`] without the copy: the array stays on the JS side and only the window the SDK
|
|
440
|
+
* asks for crosses, so nothing is resident here and linear memory's 4 GiB ceiling never applies to
|
|
441
|
+
* the asset.
|
|
442
|
+
*/
|
|
443
|
+
export class BytesSource {
|
|
444
|
+
free(): void;
|
|
445
|
+
[Symbol.dispose](): void;
|
|
446
|
+
constructor(data: Uint8Array);
|
|
447
|
+
readAt(offset: number, length: number): Uint8Array;
|
|
448
|
+
readonly length: number;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function C2PA_TRUST_LIST(): string;
|
|
452
|
+
|
|
453
|
+
export function C2PA_TSA_TRUST_LIST(): string;
|
|
454
|
+
|
|
455
|
+
export function DEV_CA(): string;
|
|
456
|
+
|
|
457
|
+
export class IntoUnderlyingByteSource {
|
|
458
|
+
private constructor();
|
|
459
|
+
free(): void;
|
|
460
|
+
[Symbol.dispose](): void;
|
|
461
|
+
cancel(): void;
|
|
462
|
+
pull(controller: ReadableByteStreamController): Promise<any>;
|
|
463
|
+
start(controller: ReadableByteStreamController): void;
|
|
464
|
+
readonly autoAllocateChunkSize: number;
|
|
465
|
+
readonly type: ReadableStreamType;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export class IntoUnderlyingSink {
|
|
469
|
+
private constructor();
|
|
470
|
+
free(): void;
|
|
471
|
+
[Symbol.dispose](): void;
|
|
472
|
+
abort(reason: any): Promise<any>;
|
|
473
|
+
close(): Promise<any>;
|
|
474
|
+
write(chunk: any): Promise<any>;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export class IntoUnderlyingSource {
|
|
478
|
+
private constructor();
|
|
479
|
+
free(): void;
|
|
480
|
+
[Symbol.dispose](): void;
|
|
481
|
+
cancel(): void;
|
|
482
|
+
pull(controller: ReadableStreamDefaultController): Promise<any>;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* An in-memory [`RangeSource`](crate::wasm::RangeInput), for a caller that already holds the whole
|
|
487
|
+
* asset as bytes.
|
|
488
|
+
*
|
|
489
|
+
* # Size ceiling
|
|
490
|
+
*
|
|
491
|
+
* The constructor copies the bytes into wasm linear memory, which is 32-bit addressed, so the
|
|
492
|
+
* asset and everything else the module allocates share a 4 GiB ceiling (a browser tab reaches its
|
|
493
|
+
* own memory limit well before that). [`BytesSource`] takes the same bytes without the copy, and
|
|
494
|
+
* [`BlobSource`] holds nothing at all.
|
|
495
|
+
*/
|
|
496
|
+
export class MemorySource {
|
|
497
|
+
free(): void;
|
|
498
|
+
[Symbol.dispose](): void;
|
|
499
|
+
constructor(data: Uint8Array);
|
|
500
|
+
readAt(offset: number, length: number): Uint8Array;
|
|
501
|
+
readonly length: number;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* One stream being validated. It owns the session keys and manifest ids its init segments
|
|
506
|
+
* advertised, so releasing the stream is dropping this object.
|
|
507
|
+
*/
|
|
508
|
+
export class StreamValidation {
|
|
509
|
+
private constructor();
|
|
510
|
+
free(): void;
|
|
511
|
+
[Symbol.dispose](): void;
|
|
512
|
+
/**
|
|
513
|
+
* Everything this stream's init segments have registered, as CBOR for another node to
|
|
514
|
+
* `StreamVerifier.resume` from.
|
|
515
|
+
*
|
|
516
|
+
* The one piece of stream state that leaves the SDK, and only because a clustered
|
|
517
|
+
* verifier needs it: the init URL is overwritten on rotation, so a node joining during
|
|
518
|
+
* the overlap cannot rebuild the previous key by refetching. One value, produced once
|
|
519
|
+
* and consumed once. Not a store.
|
|
520
|
+
*
|
|
521
|
+
* # Errors
|
|
522
|
+
*
|
|
523
|
+
* Throws an `SdkError` (`STREAM_INVALID`) when a registered session key cannot be
|
|
524
|
+
* re-encoded.
|
|
525
|
+
*/
|
|
526
|
+
export(): Uint8Array;
|
|
527
|
+
/**
|
|
528
|
+
* Validate a stream segment.
|
|
529
|
+
*
|
|
530
|
+
* # Errors
|
|
531
|
+
*
|
|
532
|
+
* Throws an `SdkError` on parse or signature failure, or when a media segment arrives
|
|
533
|
+
* before any init was processed for the stream.
|
|
534
|
+
*/
|
|
535
|
+
validate(data: RangeSource): Promise<SegmentValidation>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export class StreamVerifier {
|
|
539
|
+
private constructor();
|
|
540
|
+
free(): void;
|
|
541
|
+
[Symbol.dispose](): void;
|
|
542
|
+
/**
|
|
543
|
+
* Create a `StreamVerifier`.
|
|
544
|
+
*
|
|
545
|
+
* # Errors
|
|
546
|
+
*
|
|
547
|
+
* Throws an `SdkError` (`TRUST_CONFIG_INVALID`) when the trust anchors are invalid.
|
|
548
|
+
*/
|
|
549
|
+
static create(options: StreamVerifierOptions): StreamVerifier;
|
|
550
|
+
/**
|
|
551
|
+
* Open `stream_id` for validation, handing back a `StreamValidation` to feed segments to.
|
|
552
|
+
*
|
|
553
|
+
* No I/O: the handle carries the id so it cannot be mistyped or confused with another
|
|
554
|
+
* stream's, and classification still happens per segment. Opening one id twice hands
|
|
555
|
+
* back the same live session, so a component that remounts keeps the state its earlier
|
|
556
|
+
* handle accumulated.
|
|
557
|
+
*/
|
|
558
|
+
open(stream_id: string): StreamValidation;
|
|
559
|
+
/**
|
|
560
|
+
* Open `stream_id` on the state another node exported, merged into whatever this one
|
|
561
|
+
* holds for that id already.
|
|
562
|
+
*
|
|
563
|
+
* # Errors
|
|
564
|
+
*
|
|
565
|
+
* Throws an `SdkError` (`STREAM_INVALID`) when `state` is not a value
|
|
566
|
+
* `StreamValidation.export` produced, or carries a version this SDK no longer reads.
|
|
567
|
+
*/
|
|
568
|
+
resume(stream_id: string, state: Uint8Array): StreamValidation;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export function init_panic_hook(): void;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Parse a detached C2PA manifest store: a `.c2pa` sidecar, or the bytes a registry serves for a
|
|
575
|
+
* manifest id.
|
|
576
|
+
*
|
|
577
|
+
* Contents, not a verdict. A hard binding is a hash of the asset, so a store read without one
|
|
578
|
+
* says nothing about whether the credential is authentic or which file it belongs to, and the
|
|
579
|
+
* validation fields it carries are not a state anything established here; verifying is
|
|
580
|
+
* `AssetVerifier.verify`, which takes the asset.
|
|
581
|
+
*
|
|
582
|
+
* # Errors
|
|
583
|
+
*
|
|
584
|
+
* Throws `READER_INVALID` when the bytes are not a manifest store c2pa can parse.
|
|
585
|
+
*/
|
|
586
|
+
export function parse(manifest: Uint8Array): import('@contentauth/c2pa-types').ManifestStore;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* The bytes of one resource in a detached manifest store, or `undefined` when it holds none
|
|
590
|
+
* under `uri`.
|
|
591
|
+
*
|
|
592
|
+
* `uri` is the `identifier` on a resource reference the store carries, so walking the chain in
|
|
593
|
+
* the parsed store is what produces it: any manifest's claim thumbnail, including a non-active
|
|
594
|
+
* one, and any ingredient's. Render it with the `format` beside that identifier. A `uri` naming a
|
|
595
|
+
* manifest rather than a resource answers that manifest's own JUMBF, so pass what a reference
|
|
596
|
+
* states, never a bare label.
|
|
597
|
+
*
|
|
598
|
+
* # Errors
|
|
599
|
+
*
|
|
600
|
+
* Throws `READER_INVALID` when the bytes are not a manifest store c2pa can parse, or the store
|
|
601
|
+
* holds the resource but cannot produce it.
|
|
602
|
+
*/
|
|
603
|
+
export function resource(manifest: Uint8Array, uri: string): Uint8Array | undefined;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Every thumbnail the store references, by the `identifier` it references them under: each
|
|
607
|
+
* manifest's claim thumbnail and each ingredient's, whichever manifest carries them.
|
|
608
|
+
*
|
|
609
|
+
* One parse for the whole set, where `resource` pays one per call, so a chain view asks once
|
|
610
|
+
* instead of once per tile. Render each one as the `format` beside its identifier. A reference
|
|
611
|
+
* the store cannot produce is left out rather than failing the set.
|
|
612
|
+
*
|
|
613
|
+
* # Errors
|
|
614
|
+
*
|
|
615
|
+
* Throws `READER_INVALID` when the bytes are not a manifest store c2pa can parse.
|
|
616
|
+
*/
|
|
617
|
+
export function thumbnails(manifest: Uint8Array): Record<string, Uint8Array>;
|
|
618
|
+
|
|
619
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
620
|
+
|
|
621
|
+
export interface InitOutput {
|
|
622
|
+
readonly memory: WebAssembly.Memory;
|
|
623
|
+
readonly __wbg_binder_free: (a: number, b: number) => void;
|
|
624
|
+
readonly __wbg_blobsource_free: (a: number, b: number) => void;
|
|
625
|
+
readonly __wbg_bytessource_free: (a: number, b: number) => void;
|
|
626
|
+
readonly __wbg_memorysource_free: (a: number, b: number) => void;
|
|
627
|
+
readonly binder_derive: (a: number, b: any, c: number, d: number) => any;
|
|
628
|
+
readonly binder_held: (a: any) => [number, number, number];
|
|
629
|
+
readonly binder_iscc: () => number;
|
|
630
|
+
readonly blobsource_length: (a: number) => number;
|
|
631
|
+
readonly blobsource_new: (a: any) => [number, number, number];
|
|
632
|
+
readonly blobsource_readAt: (a: number, b: number, c: number) => [number, number, number];
|
|
633
|
+
readonly bytessource_length: (a: number) => number;
|
|
634
|
+
readonly bytessource_new: (a: any) => number;
|
|
635
|
+
readonly bytessource_readAt: (a: number, b: number, c: number) => any;
|
|
636
|
+
readonly memorysource_length: (a: number) => number;
|
|
637
|
+
readonly memorysource_new: (a: number, b: number) => number;
|
|
638
|
+
readonly memorysource_readAt: (a: number, b: number, c: number) => any;
|
|
639
|
+
readonly __wbg_assetverifier_free: (a: number, b: number) => void;
|
|
640
|
+
readonly assetverifier_create: (a: any) => [number, number, number];
|
|
641
|
+
readonly assetverifier_verify: (a: number, b: any, c: number, d: number) => any;
|
|
642
|
+
readonly parse: (a: number, b: number) => [number, number, number];
|
|
643
|
+
readonly resource: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
644
|
+
readonly thumbnails: (a: number, b: number) => [number, number, number];
|
|
645
|
+
readonly C2PA_TRUST_LIST: () => [number, number];
|
|
646
|
+
readonly C2PA_TSA_TRUST_LIST: () => [number, number];
|
|
647
|
+
readonly DEV_CA: () => [number, number];
|
|
648
|
+
readonly __wbg_streamvalidation_free: (a: number, b: number) => void;
|
|
649
|
+
readonly __wbg_streamverifier_free: (a: number, b: number) => void;
|
|
650
|
+
readonly init_panic_hook: () => void;
|
|
651
|
+
readonly streamvalidation_export: (a: number) => [number, number, number, number];
|
|
652
|
+
readonly streamvalidation_validate: (a: number, b: any) => any;
|
|
653
|
+
readonly streamverifier_create: (a: any) => [number, number, number];
|
|
654
|
+
readonly streamverifier_open: (a: number, b: number, c: number) => number;
|
|
655
|
+
readonly streamverifier_resume: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
656
|
+
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
657
|
+
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
658
|
+
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
659
|
+
readonly intounderlyingbytesource_pull: (a: number, b: any) => any;
|
|
660
|
+
readonly intounderlyingbytesource_start: (a: number, b: any) => void;
|
|
661
|
+
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
662
|
+
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
663
|
+
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
664
|
+
readonly intounderlyingsource_pull: (a: number, b: any) => any;
|
|
665
|
+
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
666
|
+
readonly intounderlyingsink_abort: (a: number, b: any) => any;
|
|
667
|
+
readonly intounderlyingsink_close: (a: number) => any;
|
|
668
|
+
readonly intounderlyingsink_write: (a: number, b: any) => any;
|
|
669
|
+
readonly wasm_bindgen__convert__closures_____invoke__h87666057de2caf05: (a: number, b: number, c: any) => [number, number];
|
|
670
|
+
readonly wasm_bindgen__convert__closures_____invoke__h427ac36a6c93c398: (a: number, b: number, c: any, d: any) => void;
|
|
671
|
+
readonly wasm_bindgen__convert__closures_____invoke__h57ac022b707ce0a7: (a: number, b: number, c: any) => void;
|
|
672
|
+
readonly wasm_bindgen__convert__closures_____invoke__hfcd26b19c01d430a: (a: number, b: number) => void;
|
|
673
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
674
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
675
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
676
|
+
readonly __externref_table_alloc: () => number;
|
|
677
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
678
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
679
|
+
readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
680
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
681
|
+
readonly __wbindgen_start: () => void;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
688
|
+
* a precompiled `WebAssembly.Module`.
|
|
689
|
+
*
|
|
690
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
691
|
+
*
|
|
692
|
+
* @returns {InitOutput}
|
|
693
|
+
*/
|
|
694
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
698
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
699
|
+
*
|
|
700
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
701
|
+
*
|
|
702
|
+
* @returns {Promise<InitOutput>}
|
|
703
|
+
*/
|
|
704
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|