@contentauth/c2pa-node 0.5.5 → 0.6.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.
@@ -3,15 +3,6 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  // Unless required by applicable law or agreed to in writing,
16
7
  // this software is distributed on an "AS IS" BASIS, WITHOUT
17
8
  // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
@@ -20,14 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
11
  // each license.
21
12
  import { getNeonBinary } from "./binary.js";
22
13
  export class IdentityAssertionBuilder {
14
+ _builder;
23
15
  constructor(_builder) {
24
16
  this._builder = _builder;
25
17
  }
26
- static identityBuilderForCredentialHolder(credentialHolder) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const builder = getNeonBinary().identityBuilderForCredentialHolder(credentialHolder.getHandle());
29
- return new IdentityAssertionBuilder(builder);
30
- });
18
+ static async identityBuilderForCredentialHolder(credentialHolder) {
19
+ const builder = getNeonBinary().identityBuilderForCredentialHolder(credentialHolder.getHandle());
20
+ return new IdentityAssertionBuilder(builder);
31
21
  }
32
22
  addReferencedAssertions(referencedAssertions) {
33
23
  getNeonBinary().identityBuilderAddReferencedAssertions.call(this._builder, referencedAssertions);
@@ -40,6 +30,7 @@ export class IdentityAssertionBuilder {
40
30
  }
41
31
  }
42
32
  export class IdentityAssertionSigner {
33
+ _signer;
43
34
  constructor(_signer) {
44
35
  this._signer = _signer;
45
36
  }
@@ -55,6 +46,7 @@ export class IdentityAssertionSigner {
55
46
  }
56
47
  }
57
48
  export class CallbackCredentialHolder {
49
+ callbackCredentialHolder;
58
50
  constructor(callbackCredentialHolder) {
59
51
  this.callbackCredentialHolder = callbackCredentialHolder;
60
52
  }
@@ -65,10 +57,8 @@ export class CallbackCredentialHolder {
65
57
  const credentialHolder = getNeonBinary().newCallbackCredentialHolder(reserveSize, sigType, callback);
66
58
  return new CallbackCredentialHolder(credentialHolder);
67
59
  }
68
- sign(payload) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- return getNeonBinary().callbackSignerSignPayload.call(this.callbackCredentialHolder, payload);
71
- });
60
+ async sign(payload) {
61
+ return getNeonBinary().callbackSignerSignPayload.call(this.callbackCredentialHolder, payload);
72
62
  }
73
63
  reserveSize() {
74
64
  return getNeonBinary().callbackCredentialHolderReserveSize.call(this.callbackCredentialHolder);
@@ -3,40 +3,33 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  import * as fs from "fs-extra";
16
7
  import * as crypto from "crypto";
17
8
  import { encode } from "cbor2";
18
9
  class TestSigner {
10
+ privateKey;
19
11
  constructor(privateKey) {
20
- this.sign = (bytes) => __awaiter(this, void 0, void 0, function* () {
21
- const sign = crypto.createSign("SHA256");
22
- sign.update(bytes);
23
- sign.end();
24
- return sign.sign(this.privateKey);
25
- });
26
12
  this.privateKey = crypto.createPrivateKey({
27
13
  key: privateKey,
28
14
  format: "pem",
29
15
  });
30
16
  }
17
+ sign = async (bytes) => {
18
+ const sign = crypto.createSign("SHA256");
19
+ sign.update(bytes);
20
+ sign.end();
21
+ return sign.sign(this.privateKey);
22
+ };
31
23
  }
32
24
  class TestCawgSigner {
25
+ manifestSigner;
33
26
  constructor(manifestSigner) {
34
27
  this.manifestSigner = manifestSigner;
35
- this.sign = (payload) => __awaiter(this, void 0, void 0, function* () {
36
- const cborBytes = Buffer.from(encode(payload));
37
- return this.manifestSigner.sign(cborBytes);
38
- });
39
28
  }
29
+ sign = async (payload) => {
30
+ const cborBytes = Buffer.from(encode(payload));
31
+ return this.manifestSigner.sign(cborBytes);
32
+ };
40
33
  }
41
34
  describe("IdentityAssertionBuilder", () => {
42
35
  const manifestDefinition = {
@@ -93,14 +86,14 @@ describe("IdentityAssertionBuilder", () => {
93
86
  },
94
87
  ],
95
88
  };
96
- it("should build an Identity Assertion Signer", () => __awaiter(void 0, void 0, void 0, function* () {
97
- const { CallbackSigner } = yield import("./Signer");
98
- const { Reader } = yield import("./Reader");
99
- const { Builder } = yield import("./Builder");
100
- const { IdentityAssertionBuilder, IdentityAssertionSigner, CallbackCredentialHolder, } = yield import("./IdentityAssertion");
89
+ it("should build an Identity Assertion Signer", async () => {
90
+ const { CallbackSigner } = await import("./Signer");
91
+ const { Reader } = await import("./Reader");
92
+ const { Builder } = await import("./Builder");
93
+ const { IdentityAssertionBuilder, IdentityAssertionSigner, CallbackCredentialHolder, } = await import("./IdentityAssertion");
101
94
  // Read certificate files once
102
- const c2paPrivateKey = yield fs.readFile("./tests/fixtures/certs/es256.pem");
103
- const c2paPublicKey = yield fs.readFile("./tests/fixtures/certs/es256.pub");
95
+ const c2paPrivateKey = await fs.readFile("./tests/fixtures/certs/es256.pem");
96
+ const c2paPublicKey = await fs.readFile("./tests/fixtures/certs/es256.pub");
104
97
  // Use the same signer for both C2PA manifest and COSE signing
105
98
  // Create signer configurations
106
99
  const c2paConfig = {
@@ -118,7 +111,7 @@ describe("IdentityAssertionBuilder", () => {
118
111
  const cawgTestSigner = new TestCawgSigner(c2paTestSigner);
119
112
  const cawgSigner = CallbackCredentialHolder.newCallbackCredentialHolder(10000, "cawg.x509.cose", cawgTestSigner.sign);
120
113
  const source = {
121
- buffer: yield fs.readFile("./tests/fixtures/CA.jpg"),
114
+ buffer: await fs.readFile("./tests/fixtures/CA.jpg"),
122
115
  mimeType: "image/jpeg",
123
116
  };
124
117
  const dest = {
@@ -127,25 +120,25 @@ describe("IdentityAssertionBuilder", () => {
127
120
  // Create the manifest builder
128
121
  const builder = Builder.withJson(manifestDefinition);
129
122
  // Add the required resources
130
- yield builder.addResource("thumbnail.jpg", {
123
+ await builder.addResource("thumbnail.jpg", {
131
124
  mimeType: "image/jpeg",
132
- buffer: yield fs.readFile("./tests/fixtures/thumbnail.jpg"),
125
+ buffer: await fs.readFile("./tests/fixtures/thumbnail.jpg"),
133
126
  });
134
- yield builder.addResource("ingredient-thumb.jpg", {
127
+ await builder.addResource("ingredient-thumb.jpg", {
135
128
  mimeType: "image/jpeg",
136
- buffer: yield fs.readFile("./tests/fixtures/thumbnail.jpg"),
129
+ buffer: await fs.readFile("./tests/fixtures/thumbnail.jpg"),
137
130
  });
138
131
  // Create and configure the identity assertion
139
132
  const iaSigner = IdentityAssertionSigner.new(c2paSigner.getHandle());
140
- const iab = yield IdentityAssertionBuilder.identityBuilderForCredentialHolder(cawgSigner);
133
+ const iab = await IdentityAssertionBuilder.identityBuilderForCredentialHolder(cawgSigner);
141
134
  iab.addReferencedAssertions(["cawg.training-mining"]);
142
135
  iaSigner.addIdentityAssertion(iab);
143
136
  // Sign the manifest (standard async flow)
144
- yield builder.signAsync(iaSigner, source, dest);
137
+ await builder.signAsync(iaSigner, source, dest);
145
138
  // Verify the manifest
146
- yield Reader.fromAsset({
139
+ await Reader.fromAsset({
147
140
  buffer: dest.buffer,
148
141
  mimeType: "image/jpeg",
149
142
  });
150
- }));
143
+ });
151
144
  });
package/dist/Reader.js CHANGED
@@ -3,17 +3,9 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  import { getNeonBinary } from "./binary.js";
16
7
  export class Reader {
8
+ reader;
17
9
  constructor(reader) {
18
10
  this.reader = reader;
19
11
  }
@@ -26,39 +18,31 @@ export class Reader {
26
18
  isEmbedded() {
27
19
  return getNeonBinary().readerIsEmbedded.call(this.reader);
28
20
  }
29
- resourceToAsset(uri, asset) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- return getNeonBinary().readerResourceToAsset.call(this.reader, uri, asset);
32
- });
21
+ async resourceToAsset(uri, asset) {
22
+ return getNeonBinary().readerResourceToAsset.call(this.reader, uri, asset);
33
23
  }
34
- static fromAsset(asset, settings) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const settingsStr = settings ? (typeof settings === 'string' ? settings : JSON.stringify(settings)) : undefined;
37
- const reader = yield getNeonBinary().readerFromAsset(asset, settingsStr);
38
- return reader ? new Reader(reader) : null;
39
- });
24
+ static async fromAsset(asset, settings) {
25
+ const settingsStr = settings ? (typeof settings === 'string' ? settings : JSON.stringify(settings)) : undefined;
26
+ const reader = await getNeonBinary().readerFromAsset(asset, settingsStr);
27
+ return reader ? new Reader(reader) : null;
40
28
  }
41
- static fromManifestDataAndAsset(manifestData, asset, settings) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const settingsStr = settings ? (typeof settings === 'string' ? settings : JSON.stringify(settings)) : undefined;
44
- const reader = yield getNeonBinary().readerFromManifestDataAndAsset(manifestData, asset, settingsStr);
45
- return new Reader(reader);
46
- });
29
+ static async fromManifestDataAndAsset(manifestData, asset, settings) {
30
+ const settingsStr = settings ? (typeof settings === 'string' ? settings : JSON.stringify(settings)) : undefined;
31
+ const reader = await getNeonBinary().readerFromManifestDataAndAsset(manifestData, asset, settingsStr);
32
+ return new Reader(reader);
47
33
  }
48
34
  // Non-neon methods, copied from c2pa-js
49
35
  activeLabel() {
50
- var _a;
51
36
  const manifestStore = this.json();
52
- return (_a = manifestStore.active_manifest) !== null && _a !== void 0 ? _a : undefined;
37
+ return manifestStore.active_manifest ?? undefined;
53
38
  }
54
39
  getActive() {
55
- var _a;
56
40
  const manifestStore = this.json();
57
41
  const activeManifest = manifestStore.active_manifest;
58
42
  if (!activeManifest) {
59
43
  return undefined;
60
44
  }
61
- return (_a = manifestStore.manifests) === null || _a === void 0 ? void 0 : _a[activeManifest];
45
+ return manifestStore.manifests?.[activeManifest];
62
46
  }
63
47
  getHandle() {
64
48
  return this.reader;
@@ -3,15 +3,6 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  import path from "path";
16
7
  import * as fs from "fs-extra";
17
8
  import { Reader } from "./Reader.js";
@@ -103,15 +94,15 @@ describe("Reader", () => {
103
94
  }
104
95
  }
105
96
  }`);
106
- beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
107
- yield fs.ensureDir(tempDir);
108
- }));
109
- afterAll(() => __awaiter(void 0, void 0, void 0, function* () {
110
- yield fs.remove(tempDir);
111
- }));
112
- it("should read from an ArrayBuffer", () => __awaiter(void 0, void 0, void 0, function* () {
113
- const buffer = yield fs.readFile("./tests/fixtures/CA.jpg");
114
- const reader = yield Reader.fromAsset({
97
+ beforeAll(async () => {
98
+ await fs.ensureDir(tempDir);
99
+ });
100
+ afterAll(async () => {
101
+ await fs.remove(tempDir);
102
+ });
103
+ it("should read from an ArrayBuffer", async () => {
104
+ const buffer = await fs.readFile("./tests/fixtures/CA.jpg");
105
+ const reader = await Reader.fromAsset({
115
106
  buffer,
116
107
  mimeType: "jpeg",
117
108
  });
@@ -119,52 +110,52 @@ describe("Reader", () => {
119
110
  const json = reader.json();
120
111
  expect(json.manifests).toEqual(manifestStore.manifests);
121
112
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
122
- }));
123
- it("should read from a file", () => __awaiter(void 0, void 0, void 0, function* () {
124
- const reader = yield Reader.fromAsset({
113
+ });
114
+ it("should read from a file", async () => {
115
+ const reader = await Reader.fromAsset({
125
116
  path: "./tests/fixtures/CA.jpg",
126
117
  });
127
118
  expect(reader).not.toBeNull();
128
119
  const json = reader.json();
129
120
  expect(json.manifests).toEqual(manifestStore.manifests);
130
121
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
131
- }));
132
- it("should return null for a file without C2PA data", () => __awaiter(void 0, void 0, void 0, function* () {
133
- const reader = yield Reader.fromAsset({
122
+ });
123
+ it("should return null for a file without C2PA data", async () => {
124
+ const reader = await Reader.fromAsset({
134
125
  path: "./tests/fixtures/A.jpg",
135
126
  });
136
127
  expect(reader).toBeNull();
137
- }));
138
- it("should read from manifest data and buffer", () => __awaiter(void 0, void 0, void 0, function* () {
139
- const manifestData = yield fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
140
- const buffer = yield fs.readFile("./tests/fixtures/CA.jpg");
141
- const reader = yield Reader.fromManifestDataAndAsset(manifestData, {
128
+ });
129
+ it("should read from manifest data and buffer", async () => {
130
+ const manifestData = await fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
131
+ const buffer = await fs.readFile("./tests/fixtures/CA.jpg");
132
+ const reader = await Reader.fromManifestDataAndAsset(manifestData, {
142
133
  buffer,
143
134
  mimeType: "jpeg",
144
135
  });
145
136
  const json = reader.json();
146
137
  expect(json.manifests).toEqual(manifestStore.manifests);
147
138
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
148
- }));
149
- it("should read from manifest data and file", () => __awaiter(void 0, void 0, void 0, function* () {
150
- const manifestData = yield fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
151
- const reader = yield Reader.fromManifestDataAndAsset(manifestData, {
139
+ });
140
+ it("should read from manifest data and file", async () => {
141
+ const manifestData = await fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
142
+ const reader = await Reader.fromManifestDataAndAsset(manifestData, {
152
143
  path: "./tests/fixtures/CA.jpg",
153
144
  });
154
145
  const json = reader.json();
155
146
  expect(json.manifests).toEqual(manifestStore.manifests);
156
147
  expect(json.validation_status[0].code).toEqual("signingCredential.untrusted");
157
- }));
158
- it("should read from manifest data and file with settings context", () => __awaiter(void 0, void 0, void 0, function* () {
159
- const manifestData = yield fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
160
- const buffer = yield fs.readFile("./tests/fixtures/CA.jpg");
148
+ });
149
+ it("should read from manifest data and file with settings context", async () => {
150
+ const manifestData = await fs.readFile("./tests/fixtures/CA/manifest_data.c2pa");
151
+ const buffer = await fs.readFile("./tests/fixtures/CA.jpg");
161
152
  const settings = {
162
153
  verify: {
163
154
  verify_after_reading: false,
164
155
  verify_trust: false,
165
156
  },
166
157
  };
167
- const reader = yield Reader.fromManifestDataAndAsset(manifestData, {
158
+ const reader = await Reader.fromManifestDataAndAsset(manifestData, {
168
159
  buffer,
169
160
  mimeType: "jpeg",
170
161
  }, settings);
@@ -175,56 +166,54 @@ describe("Reader", () => {
175
166
  expect(json.validation_status).toBeUndefined();
176
167
  expect(json.manifests).toBeDefined();
177
168
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
178
- }));
179
- it("should write to a file", () => __awaiter(void 0, void 0, void 0, function* () {
180
- var _a;
169
+ });
170
+ it("should write to a file", async () => {
181
171
  const outputPath = path.join(tempDir, "thumbnail.jpg");
182
- const reader = yield Reader.fromAsset({
172
+ const reader = await Reader.fromAsset({
183
173
  path: "./tests/fixtures/CA.jpg",
184
174
  });
185
175
  expect(reader).not.toBeNull();
186
176
  const activeManifest = reader.getActive();
187
- const uri = (_a = activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.thumbnail) === null || _a === void 0 ? void 0 : _a.identifier;
177
+ const uri = activeManifest?.thumbnail?.identifier;
188
178
  expect(uri).toBeDefined();
189
- const bytesWritten = yield reader.resourceToAsset(uri, {
179
+ const bytesWritten = await reader.resourceToAsset(uri, {
190
180
  path: outputPath,
191
181
  });
192
182
  expect(bytesWritten.bytes_written).toBe(49690);
193
183
  expect(fs.existsSync(outputPath));
194
- }));
195
- it("should report manifest is embedded", () => __awaiter(void 0, void 0, void 0, function* () {
196
- const reader = yield Reader.fromAsset({
184
+ });
185
+ it("should report manifest is embedded", async () => {
186
+ const reader = await Reader.fromAsset({
197
187
  path: "./tests/fixtures/CA.jpg",
198
188
  });
199
189
  expect(reader).not.toBeNull();
200
190
  expect(reader.remoteUrl()).toEqual("");
201
191
  expect(reader.isEmbedded()).toBeTruthy();
202
- }));
203
- it("should report manifest is not embedded", () => __awaiter(void 0, void 0, void 0, function* () {
204
- const reader = yield Reader.fromAsset({
192
+ });
193
+ it("should report manifest is not embedded", async () => {
194
+ const reader = await Reader.fromAsset({
205
195
  path: "./tests/fixtures/cloud.jpg",
206
196
  });
207
197
  expect(reader).not.toBeNull();
208
198
  expect(reader.remoteUrl()).toEqual("https://cai-manifests.adobe.com/manifests/adobe-urn-uuid-5f37e182-3687-462e-a7fb-573462780391");
209
199
  expect(reader.isEmbedded()).toBeFalsy();
210
- }));
211
- it("should decode CAWG identity assertion with signature_info", () => __awaiter(void 0, void 0, void 0, function* () {
212
- var _a;
200
+ });
201
+ it("should decode CAWG identity assertion with signature_info", async () => {
213
202
  // This test verifies that postValidateCawg() properly decodes CAWG assertions
214
203
  // and extracts signature_info from the signature data, matching c2pa-js behavior
215
- const reader = yield Reader.fromAsset({
204
+ const reader = await Reader.fromAsset({
216
205
  path: "./tests/fixtures/C_with_CAWG_data.jpg",
217
206
  });
218
207
  expect(reader).not.toBeNull();
219
208
  const activeManifest = reader.getActive();
220
209
  // Find the cawg.identity assertion
221
- const cawgIdentityAssertion = (_a = activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.assertions) === null || _a === void 0 ? void 0 : _a.find((assertion) => assertion.label === "cawg.identity");
210
+ const cawgIdentityAssertion = activeManifest?.assertions?.find((assertion) => assertion.label === "cawg.identity");
222
211
  expect(cawgIdentityAssertion).toBeDefined();
223
- expect(cawgIdentityAssertion === null || cawgIdentityAssertion === void 0 ? void 0 : cawgIdentityAssertion.data).toBeDefined();
224
- expect(cawgIdentityAssertion === null || cawgIdentityAssertion === void 0 ? void 0 : cawgIdentityAssertion.data.signature_info).toBeDefined();
212
+ expect(cawgIdentityAssertion?.data).toBeDefined();
213
+ expect(cawgIdentityAssertion?.data.signature_info).toBeDefined();
225
214
  // Verify signature_info structure matches c2pa-js behavior
226
- const signatureInfo = cawgIdentityAssertion === null || cawgIdentityAssertion === void 0 ? void 0 : cawgIdentityAssertion.data.signature_info;
227
- const signerPayload = cawgIdentityAssertion === null || cawgIdentityAssertion === void 0 ? void 0 : cawgIdentityAssertion.data.signer_payload;
215
+ const signatureInfo = cawgIdentityAssertion?.data.signature_info;
216
+ const signerPayload = cawgIdentityAssertion?.data.signer_payload;
228
217
  // Verify signature_info values
229
218
  expect(signatureInfo.alg).toBe("Ed25519");
230
219
  expect(signatureInfo.issuer).toBe("C2PA Test Signing Cert");
@@ -241,8 +230,8 @@ describe("Reader", () => {
241
230
  url: "self#jumbf=c2pa.assertions/c2pa.hash.data",
242
231
  hash: "sASozh9KFSkW+cyMI0Pw5KYoD2qn7MkUEq9jUUhe/sM=",
243
232
  });
244
- }));
245
- it("should return null when reading an asset without C2PA metadata", () => __awaiter(void 0, void 0, void 0, function* () {
233
+ });
234
+ it("should return null when reading an asset without C2PA metadata", async () => {
246
235
  // Create a simple JPEG without C2PA data
247
236
  const simpleJpeg = Buffer.from([
248
237
  0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
@@ -252,7 +241,7 @@ describe("Reader", () => {
252
241
  buffer: simpleJpeg,
253
242
  mimeType: "image/jpeg",
254
243
  };
255
- const reader = yield Reader.fromAsset(asset);
244
+ const reader = await Reader.fromAsset(asset);
256
245
  expect(reader).toBeNull();
257
- }));
246
+ });
258
247
  });
package/dist/Settings.js CHANGED
@@ -3,15 +3,6 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  // Unless required by applicable law or agreed to in writing,
16
7
  // this software is distributed on an "AS IS" BASIS, WITHOUT
17
8
  // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
@@ -36,7 +27,7 @@ function snakeCase(str) {
36
27
  * @returns Settings object that can be passed to Reader/Builder
37
28
  */
38
29
  export function createTrustSettings(trustConfig) {
39
- return { trust: Object.assign({}, trustConfig) };
30
+ return { trust: { ...trustConfig } };
40
31
  }
41
32
  /**
42
33
  * Create a settings object with CAWG trust configuration.
@@ -44,7 +35,7 @@ export function createTrustSettings(trustConfig) {
44
35
  * @returns Settings object that can be passed to Reader/Builder
45
36
  */
46
37
  export function createCawgTrustSettings(trustConfig) {
47
- return { cawgTrust: Object.assign({}, trustConfig) };
38
+ return { cawgTrust: { ...trustConfig } };
48
39
  }
49
40
  /**
50
41
  * Create a settings object with verify configuration.
@@ -52,7 +43,7 @@ export function createCawgTrustSettings(trustConfig) {
52
43
  * @returns Settings object that can be passed to Reader/Builder
53
44
  */
54
45
  export function createVerifySettings(verifyConfig) {
55
- return { verify: Object.assign({}, verifyConfig) };
46
+ return { verify: { ...verifyConfig } };
56
47
  }
57
48
  /**
58
49
  * Merge multiple settings objects into one.
@@ -64,16 +55,16 @@ export function mergeSettings(...settings) {
64
55
  const merged = {};
65
56
  for (const setting of settings) {
66
57
  if (setting.trust) {
67
- merged.trust = Object.assign(Object.assign({}, merged.trust), setting.trust);
58
+ merged.trust = { ...merged.trust, ...setting.trust };
68
59
  }
69
60
  if (setting.cawgTrust) {
70
- merged.cawgTrust = Object.assign(Object.assign({}, merged.cawgTrust), setting.cawgTrust);
61
+ merged.cawgTrust = { ...merged.cawgTrust, ...setting.cawgTrust };
71
62
  }
72
63
  if (setting.verify) {
73
- merged.verify = Object.assign(Object.assign({}, merged.verify), setting.verify);
64
+ merged.verify = { ...merged.verify, ...setting.verify };
74
65
  }
75
66
  if (setting.builder) {
76
- merged.builder = Object.assign(Object.assign({}, merged.builder), setting.builder);
67
+ merged.builder = { ...merged.builder, ...setting.builder };
77
68
  }
78
69
  }
79
70
  return merged;
@@ -92,23 +83,19 @@ export function settingsToJson(settings) {
92
83
  * @param filePath The path to the settings file
93
84
  * @returns Settings as a string (TOML or JSON depending on file extension)
94
85
  */
95
- export function loadSettingsFromFile(filePath) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const content = yield fs.readFile(filePath, "utf8");
98
- return content;
99
- });
86
+ export async function loadSettingsFromFile(filePath) {
87
+ const content = await fs.readFile(filePath, "utf8");
88
+ return content;
100
89
  }
101
90
  /**
102
91
  * Load settings from a URL.
103
92
  * @param url The URL to fetch the settings from
104
93
  * @returns Settings as a string
105
94
  */
106
- export function loadSettingsFromUrl(url) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const res = yield fetch(url);
109
- if (!res.ok) {
110
- throw new Error(`Failed to fetch settings from URL: ${res.status} ${res.statusText}`);
111
- }
112
- return yield res.text();
113
- });
95
+ export async function loadSettingsFromUrl(url) {
96
+ const res = await fetch(url);
97
+ if (!res.ok) {
98
+ throw new Error(`Failed to fetch settings from URL: ${res.status} ${res.statusText}`);
99
+ }
100
+ return await res.text();
114
101
  }