@contentauth/c2pa-node 0.1.3 → 0.2.1
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/README.md +212 -46
- package/dist/Builder.js +10 -66
- package/dist/Builder.spec.js +159 -69
- package/dist/IdentityAssertion.js +27 -42
- package/dist/IdentityAssertion.spec.js +54 -82
- package/dist/Reader.js +2 -39
- package/dist/Reader.spec.js +13 -50
- package/dist/Settings.js +203 -0
- package/dist/Settings.spec.js +314 -0
- package/dist/Signer.js +3 -41
- package/dist/Signer.spec.js +12 -45
- package/dist/Trustmark.js +2 -40
- package/dist/Trustmark.spec.js +10 -48
- package/dist/assertions.js +23 -0
- package/dist/index.js +7 -15
- package/dist/index.node +0 -0
- package/dist/types/Builder.d.ts +6 -7
- package/dist/types/IdentityAssertion.d.ts +16 -7
- package/dist/types/Reader.d.ts +3 -2
- package/dist/types/Settings.d.ts +63 -0
- package/dist/types/Settings.spec.d.ts +1 -0
- package/dist/types/Signer.d.ts +5 -5
- package/dist/types/Trustmark.d.ts +2 -2
- package/dist/types/assertions.d.ts +8 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/types.d.ts +92 -450
- package/package.json +14 -8
package/dist/types/types.d.ts
CHANGED
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
// specific language governing permissions and limitations under
|
|
12
12
|
// each license.
|
|
13
13
|
|
|
14
|
+
// This file contains types not included in @contentauth/c2pa-types and not directly applicable to the neon generated code (index.node.d.ts)
|
|
14
15
|
import { Buffer } from "buffer";
|
|
15
|
-
|
|
16
|
-
* Assertions in C2PA can be stored in several formats
|
|
17
|
-
*/
|
|
18
|
-
export type ManifestAssertionKind = "Cbor" | "Json";
|
|
19
|
-
export type UriOrResource = ResourceRef | HashedUri;
|
|
20
|
-
export type DateT = string;
|
|
21
|
-
export type Relationship = "parentOf" | "componentOf" | "inputTo";
|
|
16
|
+
import type { Manifest, ManifestStore } from "@contentauth/c2pa-types";
|
|
22
17
|
/**
|
|
23
18
|
* Describes the digital signature algorithms allowed by the C2PA spec
|
|
24
19
|
*
|
|
@@ -35,19 +30,18 @@ export type SigningAlg =
|
|
|
35
30
|
| "ps512"
|
|
36
31
|
| "ed25519";
|
|
37
32
|
|
|
38
|
-
// A claim_version field is now allowed in a manifest definition for Builder and, if set to 2 will generate v2 claims
|
|
39
33
|
export type ClaimVersion = 1 | 2;
|
|
40
34
|
|
|
41
35
|
// Trustmark Versions
|
|
42
36
|
export type TrustmarkVersion =
|
|
43
37
|
// Tolerates 8 bit flips
|
|
44
|
-
| "
|
|
38
|
+
| "BCH_SUPER"
|
|
45
39
|
// Tolerates 5 bit flips
|
|
46
|
-
| "
|
|
40
|
+
| "BCH_5"
|
|
47
41
|
// Tolerates 4 bit flips
|
|
48
|
-
| "
|
|
42
|
+
| "BCH_4"
|
|
49
43
|
// Tolerates 3 bit flips
|
|
50
|
-
| "
|
|
44
|
+
| "BCH_3";
|
|
51
45
|
|
|
52
46
|
// Trustmark Variants. See https://github.com/adobe/trustmark/blob/main/FAQ.md for more
|
|
53
47
|
export type TrustmarkVariant =
|
|
@@ -60,422 +54,7 @@ export type TrustmarkVariant =
|
|
|
60
54
|
// Quality Trustmark model
|
|
61
55
|
| "Q";
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
* A Container for a set of Manifests and a ValidationStatus list
|
|
65
|
-
*/
|
|
66
|
-
export interface ManifestStore {
|
|
67
|
-
/**
|
|
68
|
-
* A label for the active (most recent) manifest in the store
|
|
69
|
-
*/
|
|
70
|
-
active_manifest?: string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* A HashMap of Manifests
|
|
73
|
-
*/
|
|
74
|
-
manifests: {
|
|
75
|
-
[k: string]: Manifest;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* ValidationStatus generated when loading the ManifestStore from an asset
|
|
79
|
-
*/
|
|
80
|
-
validation_status?: ValidationStatus[] | undefined;
|
|
81
|
-
[k: string]: unknown;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* A Manifest represents all the information in a c2pa manifest
|
|
86
|
-
*/
|
|
87
|
-
export interface Manifest {
|
|
88
|
-
/**
|
|
89
|
-
* A list of assertions
|
|
90
|
-
*/
|
|
91
|
-
assertions?: ManifestAssertion[];
|
|
92
|
-
/**
|
|
93
|
-
* A User Agent formatted string identifying the software/hardware/system produced this claim Spaces are not allowed in names, versions can be specified with product/1.0 syntax
|
|
94
|
-
*/
|
|
95
|
-
claim_generator?: string;
|
|
96
|
-
claim_generator_hints?:
|
|
97
|
-
| {
|
|
98
|
-
[k: string]: unknown;
|
|
99
|
-
}
|
|
100
|
-
| undefined;
|
|
101
|
-
/**
|
|
102
|
-
* A list of claim generator info data identifying the software/hardware/system produced this claim
|
|
103
|
-
*/
|
|
104
|
-
claim_generator_info?: ClaimGeneratorInfo[] | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* A List of verified credentials
|
|
107
|
-
*/
|
|
108
|
-
credentials?: unknown[] | undefined;
|
|
109
|
-
/**
|
|
110
|
-
* The format of the source file as a MIME type
|
|
111
|
-
*/
|
|
112
|
-
format?: string;
|
|
113
|
-
/**
|
|
114
|
-
* A List of ingredients
|
|
115
|
-
*/
|
|
116
|
-
ingredients?: Ingredient[];
|
|
117
|
-
/**
|
|
118
|
-
* Instance ID from `xmpMM:InstanceID` in XMP metadata
|
|
119
|
-
*/
|
|
120
|
-
instance_id?: string;
|
|
121
|
-
label?: string | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* A list of redactions - URIs to a redacted assertions
|
|
124
|
-
*/
|
|
125
|
-
redactions?: string[] | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* container for binary assets (like thumbnails)
|
|
128
|
-
*/
|
|
129
|
-
resources?: ResourceStore;
|
|
130
|
-
/**
|
|
131
|
-
* Signature data (only used for reporting)
|
|
132
|
-
*/
|
|
133
|
-
signature_info?: SignatureInfo | undefined;
|
|
134
|
-
thumbnail?: ResourceRef | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* A human-readable title, generally source filename
|
|
137
|
-
*/
|
|
138
|
-
title?: string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Optional prefix added to the generated Manifest Label This is typically Internet domain name for the vendor (i.e. `adobe`)
|
|
141
|
-
*/
|
|
142
|
-
vendor?: string | undefined;
|
|
143
|
-
[k: string]: unknown;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* A labeled container for an Assertion value in a Manifest
|
|
148
|
-
*/
|
|
149
|
-
export interface ManifestAssertion {
|
|
150
|
-
data: unknown;
|
|
151
|
-
/**
|
|
152
|
-
* There can be more than one assertion for any label
|
|
153
|
-
*/
|
|
154
|
-
instance?: number | undefined;
|
|
155
|
-
/**
|
|
156
|
-
* The [ManifestAssertionKind] for this assertion (as stored in c2pa content)
|
|
157
|
-
*/
|
|
158
|
-
kind?: ManifestAssertionKind | undefined;
|
|
159
|
-
/**
|
|
160
|
-
* An assertion label in reverse domain format
|
|
161
|
-
*/
|
|
162
|
-
label: string;
|
|
163
|
-
[k: string]: unknown;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Description of the claim generator, or the software used in generating the claim
|
|
168
|
-
*
|
|
169
|
-
* This structure is also used for actions softwareAgent
|
|
170
|
-
*/
|
|
171
|
-
export interface ClaimGeneratorInfo {
|
|
172
|
-
/**
|
|
173
|
-
* hashed URI to the icon (either embedded or remote)
|
|
174
|
-
*/
|
|
175
|
-
icon?: UriOrResource | undefined;
|
|
176
|
-
/**
|
|
177
|
-
* A human readable string naming the claim_generator
|
|
178
|
-
*/
|
|
179
|
-
name: string;
|
|
180
|
-
/**
|
|
181
|
-
* A human readable string of the product's version
|
|
182
|
-
*/
|
|
183
|
-
version?: string | undefined;
|
|
184
|
-
[k: string]: unknown;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* A reference to a resource to be used in JSON serialization
|
|
189
|
-
*/
|
|
190
|
-
export interface ResourceRef {
|
|
191
|
-
/**
|
|
192
|
-
* The algorithm used to hash the resource (if applicable)
|
|
193
|
-
*/
|
|
194
|
-
alg?: string | undefined;
|
|
195
|
-
/**
|
|
196
|
-
* More detailed data types as defined in the C2PA spec
|
|
197
|
-
*/
|
|
198
|
-
data_types?: AssetType[] | undefined;
|
|
199
|
-
/**
|
|
200
|
-
* The mime type of the referenced resource
|
|
201
|
-
*/
|
|
202
|
-
format: string;
|
|
203
|
-
/**
|
|
204
|
-
* The hash of the resource (if applicable)
|
|
205
|
-
*/
|
|
206
|
-
hash?: string | undefined;
|
|
207
|
-
/**
|
|
208
|
-
* A URI that identifies the resource as referenced from the manifest
|
|
209
|
-
*
|
|
210
|
-
* This may be a JUMBF URI, a file path, a URL or any other string. Relative JUMBF URIs will be resolved with the manifest label. Relative file paths will be resolved with the base path if provided
|
|
211
|
-
*/
|
|
212
|
-
identifier: string;
|
|
213
|
-
[k: string]: unknown;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export interface AssetType {
|
|
217
|
-
type: string;
|
|
218
|
-
version?: string | undefined;
|
|
219
|
-
[k: string]: unknown;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Hashed Uri structure as defined by C2PA spec It is annotated to produce the correctly tagged cbor serialization
|
|
224
|
-
*/
|
|
225
|
-
export interface HashedUri {
|
|
226
|
-
alg?: string | undefined;
|
|
227
|
-
hash: number[];
|
|
228
|
-
url: string;
|
|
229
|
-
[k: string]: unknown;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* An `Ingredient` is any external asset that has been used in the creation of an image
|
|
234
|
-
*/
|
|
235
|
-
export interface Ingredient {
|
|
236
|
-
/**
|
|
237
|
-
* The active manifest label (if one exists)
|
|
238
|
-
*
|
|
239
|
-
* If this ingredient has a [`ManifestStore`], this will hold the label of the active [`Manifest`]
|
|
240
|
-
*
|
|
241
|
-
* [`Manifest`]: crate::Manifest [`ManifestStore`]: crate::ManifestStore
|
|
242
|
-
*/
|
|
243
|
-
active_manifest?: string | undefined;
|
|
244
|
-
/**
|
|
245
|
-
* A reference to the actual data of the ingredient
|
|
246
|
-
*/
|
|
247
|
-
data?: ResourceRef | undefined;
|
|
248
|
-
/**
|
|
249
|
-
* Additional description of the ingredient
|
|
250
|
-
*/
|
|
251
|
-
description?: string | undefined;
|
|
252
|
-
/**
|
|
253
|
-
* Document ID from `xmpMM:DocumentID` in XMP metadata
|
|
254
|
-
*/
|
|
255
|
-
document_id?: string | undefined;
|
|
256
|
-
/**
|
|
257
|
-
* The format of the source file as a MIME type
|
|
258
|
-
*/
|
|
259
|
-
format?: string;
|
|
260
|
-
/**
|
|
261
|
-
* An optional hash of the asset to prevent duplicates
|
|
262
|
-
*/
|
|
263
|
-
hash?: string | undefined;
|
|
264
|
-
/**
|
|
265
|
-
* URI to an informational page about the ingredient or its data
|
|
266
|
-
*/
|
|
267
|
-
informational_URI?: string | undefined;
|
|
268
|
-
/**
|
|
269
|
-
* Instance ID from `xmpMM:InstanceID` in XMP metadata
|
|
270
|
-
*/
|
|
271
|
-
instance_id?: string | undefined;
|
|
272
|
-
/**
|
|
273
|
-
* A [`ManifestStore`] from the source asset extracted as a binary C2PA blob
|
|
274
|
-
*
|
|
275
|
-
* [`ManifestStore`]: crate::ManifestStore
|
|
276
|
-
*/
|
|
277
|
-
manifest_data?: ResourceRef | undefined;
|
|
278
|
-
/**
|
|
279
|
-
* Any additional [`Metadata`] as defined in the C2PA spec
|
|
280
|
-
*
|
|
281
|
-
* [`Manifest`]: crate::Manifest
|
|
282
|
-
*/
|
|
283
|
-
metadata?: Metadata | undefined;
|
|
284
|
-
/**
|
|
285
|
-
* URI from `dcterms:provenance` in XMP metadata
|
|
286
|
-
*/
|
|
287
|
-
provenance?: string | undefined;
|
|
288
|
-
/**
|
|
289
|
-
* Set to `ParentOf` if this is the parent ingredient
|
|
290
|
-
*
|
|
291
|
-
* There can only be one parent ingredient in the ingredients
|
|
292
|
-
*/
|
|
293
|
-
relationship?: Relationship & string;
|
|
294
|
-
resources?: ResourceStore;
|
|
295
|
-
/**
|
|
296
|
-
* A thumbnail image capturing the visual state at the time of import
|
|
297
|
-
*
|
|
298
|
-
* A tuple of thumbnail MIME format (i.e. `image/jpeg`) and binary bits of the image
|
|
299
|
-
*/
|
|
300
|
-
thumbnail?: ResourceRef | undefined;
|
|
301
|
-
/**
|
|
302
|
-
* A human-readable title, generally source filename
|
|
303
|
-
*/
|
|
304
|
-
title: string;
|
|
305
|
-
/**
|
|
306
|
-
* Validation results
|
|
307
|
-
*/
|
|
308
|
-
validation_status?: ValidationStatus[] | undefined;
|
|
309
|
-
[k: string]: unknown;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* The Metadata structure can be used as part of other assertions or on its own to reference others
|
|
314
|
-
*/
|
|
315
|
-
export interface Metadata {
|
|
316
|
-
data_source?: DataSource | undefined;
|
|
317
|
-
dateTime?: DateT | undefined;
|
|
318
|
-
reference?: HashedUri | undefined;
|
|
319
|
-
reviewRatings?: ReviewRating[] | undefined;
|
|
320
|
-
[k: string]: unknown;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* A description of the source for assertion data
|
|
325
|
-
*/
|
|
326
|
-
export interface DataSource {
|
|
327
|
-
/**
|
|
328
|
-
* A list of [`Actor`]s associated with this source
|
|
329
|
-
*/
|
|
330
|
-
actors?: Actor[] | undefined;
|
|
331
|
-
/**
|
|
332
|
-
* A human-readable string giving details about the source of the assertion data
|
|
333
|
-
*/
|
|
334
|
-
details?: string | undefined;
|
|
335
|
-
/**
|
|
336
|
-
* A value from among the enumerated list indicating the source of the assertion
|
|
337
|
-
*/
|
|
338
|
-
type: string;
|
|
339
|
-
[k: string]: unknown;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Identifies a person responsible for an action
|
|
344
|
-
*/
|
|
345
|
-
export interface Actor {
|
|
346
|
-
/**
|
|
347
|
-
* List of references to W3C Verifiable Credentials
|
|
348
|
-
*/
|
|
349
|
-
credentials?: HashedUri[] | undefined;
|
|
350
|
-
/**
|
|
351
|
-
* An identifier for a human actor, used when the "type" is `humanEntry.identified`
|
|
352
|
-
*/
|
|
353
|
-
identifier?: string | undefined;
|
|
354
|
-
[k: string]: unknown;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* A rating on an Assertion
|
|
359
|
-
*
|
|
360
|
-
* See <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_claim_review>
|
|
361
|
-
*/
|
|
362
|
-
export interface ReviewRating {
|
|
363
|
-
code?: string | undefined;
|
|
364
|
-
explanation: string;
|
|
365
|
-
value: number;
|
|
366
|
-
[k: string]: unknown;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Resource store to contain binary objects referenced from JSON serializable structures
|
|
371
|
-
*/
|
|
372
|
-
export interface ResourceStore {
|
|
373
|
-
label?: string | undefined;
|
|
374
|
-
resources: {
|
|
375
|
-
[k: string]: number[];
|
|
376
|
-
};
|
|
377
|
-
[k: string]: unknown;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* A `ValidationStatus` struct describes the validation status of a specific part of a manifest
|
|
382
|
-
*
|
|
383
|
-
* See <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_existing_manifests>
|
|
384
|
-
*/
|
|
385
|
-
export interface ValidationStatus {
|
|
386
|
-
code: string;
|
|
387
|
-
explanation?: string | undefined;
|
|
388
|
-
url?: string | undefined;
|
|
389
|
-
[k: string]: unknown;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Holds information about a signature
|
|
394
|
-
*/
|
|
395
|
-
export interface SignatureInfo {
|
|
396
|
-
/**
|
|
397
|
-
* human readable issuing authority for this signature
|
|
398
|
-
*/
|
|
399
|
-
alg?: SigningAlg | undefined;
|
|
400
|
-
/**
|
|
401
|
-
* The serial number of the certificate
|
|
402
|
-
*/
|
|
403
|
-
cert_serial_number?: string | undefined;
|
|
404
|
-
/**
|
|
405
|
-
* human readable issuing authority for this signature
|
|
406
|
-
*/
|
|
407
|
-
issuer?: string | undefined;
|
|
408
|
-
/**
|
|
409
|
-
* revocation status of the certificate
|
|
410
|
-
*/
|
|
411
|
-
revocation_status?: boolean | undefined;
|
|
412
|
-
/**
|
|
413
|
-
* the time the signature was created
|
|
414
|
-
*/
|
|
415
|
-
time?: string | undefined;
|
|
416
|
-
[k: string]: unknown;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* From ManifestDefinition.d.ts
|
|
421
|
-
* A Manifest Definition This is used to define a manifest and is used to build a ManifestStore A Manifest is a collection of ingredients and assertions It is used to define a claim that can be signed and embedded into a file
|
|
422
|
-
*/
|
|
423
|
-
export interface ManifestDefinition {
|
|
424
|
-
/**
|
|
425
|
-
* A list of assertions
|
|
426
|
-
*/
|
|
427
|
-
assertions?: AssertionDefinition[];
|
|
428
|
-
/**
|
|
429
|
-
* Clam Generator Info is always required with at least one entry
|
|
430
|
-
*/
|
|
431
|
-
claim_generator_info?: ClaimGeneratorInfo[];
|
|
432
|
-
/**
|
|
433
|
-
* The format of the source file as a MIME type
|
|
434
|
-
*/
|
|
435
|
-
format?: string;
|
|
436
|
-
/**
|
|
437
|
-
* A List of ingredients
|
|
438
|
-
*/
|
|
439
|
-
ingredients?: Ingredient[];
|
|
440
|
-
/**
|
|
441
|
-
* Instance ID from `xmpMM:InstanceID` in XMP metadata
|
|
442
|
-
*/
|
|
443
|
-
instance_id?: string;
|
|
444
|
-
label?: string | undefined;
|
|
445
|
-
/**
|
|
446
|
-
* A list of redactions - URIs to a redacted assertions
|
|
447
|
-
*/
|
|
448
|
-
redactions?: string[] | undefined;
|
|
449
|
-
thumbnail?: ResourceRef | undefined;
|
|
450
|
-
/**
|
|
451
|
-
* A human-readable title, generally source filename
|
|
452
|
-
*/
|
|
453
|
-
title?: string | undefined;
|
|
454
|
-
/**
|
|
455
|
-
* Optional prefix added to the generated Manifest Label This is typically Internet domain name for the vendor (i.e. `adobe`)
|
|
456
|
-
*/
|
|
457
|
-
vendor?: string | undefined;
|
|
458
|
-
[k: string]: unknown;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
export interface AssertionDefinition {
|
|
462
|
-
data: unknown;
|
|
463
|
-
label: string;
|
|
464
|
-
[k: string]: unknown;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Types unique to index.node
|
|
469
|
-
*/
|
|
470
|
-
export interface IngredientThumbnail {
|
|
471
|
-
format: string;
|
|
472
|
-
data: Uint8Array;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
export interface IngredientOptions {
|
|
476
|
-
isParent: boolean;
|
|
477
|
-
thumbnail?: IngredientThumbnail;
|
|
478
|
-
}
|
|
57
|
+
type ManifestAssertionKind = "Cbor" | "Json" | "Binary" | "Uri";
|
|
479
58
|
|
|
480
59
|
/**
|
|
481
60
|
* A buffer for the source asset
|
|
@@ -527,7 +106,7 @@ export interface LocalSignerInterface {
|
|
|
527
106
|
certs(): Array<Buffer>;
|
|
528
107
|
reserveSize(): number;
|
|
529
108
|
timeAuthorityUrl(): string | undefined;
|
|
530
|
-
signer():
|
|
109
|
+
signer(): NeonLocalSignerHandle;
|
|
531
110
|
}
|
|
532
111
|
|
|
533
112
|
/**
|
|
@@ -539,7 +118,14 @@ export interface CallbackSignerInterface {
|
|
|
539
118
|
certs(): Array<Buffer>;
|
|
540
119
|
reserveSize(): number;
|
|
541
120
|
timeAuthorityUrl(): string | undefined;
|
|
542
|
-
signer():
|
|
121
|
+
signer(): NeonCallbackSignerHandle;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface CallbackCredentialHolderInterface {
|
|
125
|
+
sigType(): string;
|
|
126
|
+
reserveSize(): number;
|
|
127
|
+
sign(payload: SignerPayload): Promise<Buffer>;
|
|
128
|
+
signer(): NeonCallbackCredentialHolderHandle;
|
|
543
129
|
}
|
|
544
130
|
|
|
545
131
|
/**
|
|
@@ -547,6 +133,14 @@ export interface CallbackSignerInterface {
|
|
|
547
133
|
* Internal type used for Rust/Node.js interop
|
|
548
134
|
*/
|
|
549
135
|
export type CallbackSignerConfig = unknown;
|
|
136
|
+
export type NeonCallbackSignerHandle = unknown;
|
|
137
|
+
export type NeonCallbackCredentialHolderHandle = unknown;
|
|
138
|
+
export type NeonLocalSignerHandle = unknown;
|
|
139
|
+
export type NeonBuilderHandle = unknown;
|
|
140
|
+
export type NeonReaderHandle = unknown;
|
|
141
|
+
export type NeonIdentityAssertionSignerHandle = unknown;
|
|
142
|
+
export type NeonIdentityAssertionBuilderHandle = unknown;
|
|
143
|
+
export type NeonTrustmarkHandle = unknown;
|
|
550
144
|
|
|
551
145
|
/*
|
|
552
146
|
* Configuration for an asynchronous signer.
|
|
@@ -554,11 +148,28 @@ export type CallbackSignerConfig = unknown;
|
|
|
554
148
|
*/
|
|
555
149
|
export interface JsCallbackSignerConfig {
|
|
556
150
|
alg: SigningAlg;
|
|
557
|
-
certs
|
|
151
|
+
certs?: Buffer[];
|
|
558
152
|
reserveSize: number;
|
|
559
153
|
tsaUrl?: string;
|
|
560
154
|
tsaHeaders?: Array<[string, string]>;
|
|
561
155
|
tsaBody?: Buffer;
|
|
156
|
+
// TODO: directCoseHandling is currently not implemented in the signing logic.
|
|
157
|
+
// The field is read from config but the actual signing implementation does not
|
|
158
|
+
// differentiate between directCoseHandling: true/false - both cases pass the
|
|
159
|
+
// same data to the JavaScript callback regardless of this setting.
|
|
160
|
+
directCoseHandling: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface SignerPayload {
|
|
164
|
+
referencedAssertions: HashedUri[];
|
|
165
|
+
sigType: string;
|
|
166
|
+
roles: string[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface HashedUri {
|
|
170
|
+
url: string;
|
|
171
|
+
hash: Uint8Array;
|
|
172
|
+
alg?: string;
|
|
562
173
|
}
|
|
563
174
|
|
|
564
175
|
export interface BuilderInterface {
|
|
@@ -575,11 +186,12 @@ export interface BuilderInterface {
|
|
|
575
186
|
/**
|
|
576
187
|
* Add CBOR assertion to the builder
|
|
577
188
|
* @param label The label of the assertion
|
|
578
|
-
* @param assertion The
|
|
189
|
+
* @param assertion The assertion, should be a string if the type is JSON, otherwise a JS Object
|
|
190
|
+
* @param assertionKind The type of assertion
|
|
579
191
|
*/
|
|
580
192
|
addAssertion(
|
|
581
193
|
label: string,
|
|
582
|
-
assertion:
|
|
194
|
+
assertion: unknown,
|
|
583
195
|
assertionKind?: ManifestAssertionKind,
|
|
584
196
|
): void;
|
|
585
197
|
/**
|
|
@@ -640,7 +252,7 @@ export interface BuilderInterface {
|
|
|
640
252
|
* @returns the bytes of the c2pa_manifest that was embedded
|
|
641
253
|
*/
|
|
642
254
|
signAsync(
|
|
643
|
-
callbackSigner: CallbackSignerInterface,
|
|
255
|
+
callbackSigner: CallbackSignerInterface | IdentityAssertionSignerInterface,
|
|
644
256
|
input: SourceAsset,
|
|
645
257
|
output: DestinationAsset,
|
|
646
258
|
): Promise<Buffer>;
|
|
@@ -658,25 +270,11 @@ export interface BuilderInterface {
|
|
|
658
270
|
output: DestinationAsset,
|
|
659
271
|
): Buffer;
|
|
660
272
|
|
|
661
|
-
/**
|
|
662
|
-
* Sign an asset from a buffer or file asynchronously, using an
|
|
663
|
-
* IdentityAssertionSigner
|
|
664
|
-
* @param signer The IdentityAssertionSigner
|
|
665
|
-
* @param source The file or buffer containing the asset
|
|
666
|
-
* @param dest The file or buffer to write the asset to
|
|
667
|
-
* @returns the bytes of the c2pa_manifest that was embedded
|
|
668
|
-
*/
|
|
669
|
-
identitySignAsync(
|
|
670
|
-
callbackSigner: IdentityAssertionSignerInterface,
|
|
671
|
-
input: SourceAsset,
|
|
672
|
-
output: DestinationAsset,
|
|
673
|
-
): Promise<Buffer>;
|
|
674
|
-
|
|
675
273
|
/**
|
|
676
274
|
* Getter for the builder's manifest definition
|
|
677
275
|
* @returns The manifest definition
|
|
678
276
|
*/
|
|
679
|
-
getManifestDefinition():
|
|
277
|
+
getManifestDefinition(): Manifest;
|
|
680
278
|
|
|
681
279
|
/**
|
|
682
280
|
* Update a string property of the manifest
|
|
@@ -724,6 +322,8 @@ export interface IdentityAssertionSignerInterface {
|
|
|
724
322
|
addIdentityAssertion(
|
|
725
323
|
identityAssertionBuilder: IdentityAssertionBuilderInterface,
|
|
726
324
|
): void;
|
|
325
|
+
|
|
326
|
+
signer(): NeonIdentityAssertionSignerHandle;
|
|
727
327
|
}
|
|
728
328
|
|
|
729
329
|
export interface IdentityAssertionBuilderInterface {
|
|
@@ -744,7 +344,7 @@ export interface IdentityAssertionBuilderInterface {
|
|
|
744
344
|
/**
|
|
745
345
|
* Get the underlying IdentityAssertionBuilder
|
|
746
346
|
*/
|
|
747
|
-
builder():
|
|
347
|
+
builder(): NeonIdentityAssertionBuilderHandle;
|
|
748
348
|
}
|
|
749
349
|
|
|
750
350
|
export interface TrustmarkInterface {
|
|
@@ -769,3 +369,45 @@ export interface TrustmarkConfig {
|
|
|
769
369
|
version: TrustmarkVersion;
|
|
770
370
|
modelPath?: string;
|
|
771
371
|
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Configuration for trust settings in C2PA.
|
|
375
|
+
* Controls certificate trust validation and trust anchor management.
|
|
376
|
+
*/
|
|
377
|
+
export interface TrustConfig {
|
|
378
|
+
/** Whether to verify against the trust list */
|
|
379
|
+
verifyTrustList: boolean;
|
|
380
|
+
/** User-provided trust anchors (PEM format or base64-encoded certificate hashes) */
|
|
381
|
+
userAnchors?: string;
|
|
382
|
+
/** Trust anchors for validation (PEM format or base64-encoded certificate hashes) */
|
|
383
|
+
trustAnchors?: string;
|
|
384
|
+
/** Trust configuration file path */
|
|
385
|
+
trustConfig?: string;
|
|
386
|
+
/** Allowed list of certificates (PEM format or base64-encoded certificate hashes) */
|
|
387
|
+
allowedList?: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Configuration for verification settings in C2PA.
|
|
392
|
+
* Controls various verification behaviors and options.
|
|
393
|
+
*/
|
|
394
|
+
export interface VerifyConfig {
|
|
395
|
+
/** Whether to verify after reading a manifest */
|
|
396
|
+
verifyAfterReading: boolean;
|
|
397
|
+
/** Whether to verify after signing a manifest */
|
|
398
|
+
verifyAfterSign: boolean;
|
|
399
|
+
/** Whether to verify trust during validation */
|
|
400
|
+
verifyTrust: boolean;
|
|
401
|
+
/** Whether to verify timestamp trust */
|
|
402
|
+
verifyTimestampTrust: boolean;
|
|
403
|
+
/** Whether to fetch OCSP responses */
|
|
404
|
+
ocspFetch: boolean;
|
|
405
|
+
/** Whether to fetch remote manifests */
|
|
406
|
+
remoteManifestFetch: boolean;
|
|
407
|
+
/** Whether to check ingredient trust */
|
|
408
|
+
checkIngredientTrust: boolean;
|
|
409
|
+
/** Whether to skip ingredient conflict resolution */
|
|
410
|
+
skipIngredientConflictResolution: boolean;
|
|
411
|
+
/** Whether to use strict v1 validation */
|
|
412
|
+
strictV1Validation: boolean;
|
|
413
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "git+https://github.com/contentauth/c2pa-node-v2.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1
|
|
7
|
+
"version": "0.2.1",
|
|
8
8
|
"description": "Node.js bindings for C2PA",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"types": "dist/types/index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"author": "Colin Murphy <colmurph@adobe.com>",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@changesets/cli": "^2.29.
|
|
20
|
+
"@changesets/cli": "^2.29.6",
|
|
21
|
+
"@contentauth/c2pa-types": "^0.2.1",
|
|
21
22
|
"@eslint/js": "^9.33.0",
|
|
22
23
|
"@neon-rs/cli": "0.1.82",
|
|
23
24
|
"@types/debug": "^4.1.12",
|
|
@@ -26,17 +27,19 @@
|
|
|
26
27
|
"@types/node": "^22.17.1",
|
|
27
28
|
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
28
29
|
"@typescript-eslint/parser": "^8.39.1",
|
|
30
|
+
"@vitest/ui": "^3.2.4",
|
|
31
|
+
"cbor2": "^2.0.1",
|
|
29
32
|
"cpy-cli": "^5.0.0",
|
|
30
33
|
"eslint": "^9.33.0",
|
|
31
34
|
"fs-extra": "^11.3.1",
|
|
32
|
-
"jest": "^29.7.0",
|
|
33
35
|
"npm-run-all": "^4.1.5",
|
|
34
36
|
"rimraf": "^6.0.1",
|
|
35
37
|
"sharp": "^0.34.3",
|
|
36
38
|
"ts-jest": "^29.4.1",
|
|
37
39
|
"typedoc": "^0.28.10",
|
|
38
40
|
"typedoc-plugin-markdown": "^4.8.1",
|
|
39
|
-
"typescript": "^5.9.2"
|
|
41
|
+
"typescript": "^5.9.2",
|
|
42
|
+
"vitest": "^3.2.4"
|
|
40
43
|
},
|
|
41
44
|
"keywords": [
|
|
42
45
|
"c2pa"
|
|
@@ -46,7 +49,8 @@
|
|
|
46
49
|
},
|
|
47
50
|
"homepage": "https://github.com/contentauth/c2pa-node-v2#readme",
|
|
48
51
|
"dependencies": {
|
|
49
|
-
"debug": "^4.4.1"
|
|
52
|
+
"debug": "^4.4.1",
|
|
53
|
+
"node-fetch": "^3.3.2"
|
|
50
54
|
},
|
|
51
55
|
"scripts": {
|
|
52
56
|
"build": "run-s build:rust build:ts",
|
|
@@ -54,9 +58,10 @@
|
|
|
54
58
|
"build:docs": "rimraf docs && typedoc --plugin typedoc-plugin-markdown --readme none --out docs js-src/index.ts",
|
|
55
59
|
"build:rust": "pnpm run build:rust-debug --release",
|
|
56
60
|
"build:rust-debug": "cargo build --message-format=json-render-diagnostics > cargo.log",
|
|
57
|
-
"build:ts": "tsc -b && cpy index.node dist && cpy --flat js-src/types.d.ts dist/types",
|
|
61
|
+
"build:ts": "tsc -b && cpy index.node dist && cpy index.node js-src && cpy --flat js-src/types.d.ts dist/types",
|
|
58
62
|
"changeset:publish": "changeset publish",
|
|
59
63
|
"ci": "run-s build:rust-debug build:ts test",
|
|
64
|
+
"ci:release": "pnpm run build && changeset tag && pnpm publish --access=public --no-git-checks",
|
|
60
65
|
"clean": "rimraf dist generated target",
|
|
61
66
|
"cross": "pnpm run cross-build --release",
|
|
62
67
|
"cross-build": "cross build --message-format=json-render-diagnostics > cross.log",
|
|
@@ -65,7 +70,8 @@
|
|
|
65
70
|
"postbuild:rust-debug": "neon dist < cargo.log",
|
|
66
71
|
"postcross-build": "neon dist -m /target < cross.log",
|
|
67
72
|
"release": "run-s build changeset:publish",
|
|
68
|
-
"test": "
|
|
69
|
-
"test:watch": "
|
|
73
|
+
"test": "pnpm build:debug && vitest run",
|
|
74
|
+
"test:watch": "pnpm build:debug && vitest",
|
|
75
|
+
"test:ui": "pnpm build:debug && vitest --ui"
|
|
70
76
|
}
|
|
71
77
|
}
|