@contentauth/c2pa-node 0.1.3 → 0.2.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.
@@ -0,0 +1,314 @@
1
+ // Copyright 2025 Adobe. All rights reserved.
2
+ // This file is licensed to you under the Apache License,
3
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
+ // or the MIT license (http://opensource.org/licenses/MIT),
5
+ // at your option.
6
+ import { loadC2paSettings, loadTrustConfig, loadCawgTrustConfig, getSettingsJson, getTrustConfig, getCawgTrustConfig, loadVerifyConfig, getVerifyConfig, patchVerifyConfig, } from "./Settings";
7
+ describe("Settings", () => {
8
+ it("loads a trustlist-shaped JSON and returns JSON via getSettingsJson", () => {
9
+ var _a, _b;
10
+ // Matches c2pa-rs settings structure: trust + verify
11
+ // trust.allowed_list accepts base64 lines or PEMs; provide a simple base64 line
12
+ const settings = {
13
+ trust: {
14
+ allowed_list: "Zm9v\n", // base64("foo") with newline
15
+ },
16
+ verify: {
17
+ verify_trust: true,
18
+ },
19
+ };
20
+ loadC2paSettings(JSON.stringify(settings));
21
+ const obj = JSON.parse(getSettingsJson());
22
+ expect(obj).toBeTruthy();
23
+ expect((_a = obj.trust) === null || _a === void 0 ? void 0 : _a.allowed_list).toBe("Zm9v\n");
24
+ expect((_b = obj.verify) === null || _b === void 0 ? void 0 : _b.verify_trust).toBe(true);
25
+ });
26
+ describe("loadTrustConfig", () => {
27
+ it("preserves other settings when loading trust config", () => {
28
+ // First, load basic settings that work with c2pa-rs
29
+ const initialSettings = {
30
+ trust: {
31
+ allowed_list: "Zm9v\n", // base64("foo") with newline - valid base64
32
+ },
33
+ verify: {
34
+ verify_trust: true,
35
+ },
36
+ };
37
+ loadC2paSettings(JSON.stringify(initialSettings));
38
+ // Verify initial settings are loaded
39
+ const currentSettings = JSON.parse(getSettingsJson());
40
+ expect(currentSettings.verify.verify_trust).toBe(true);
41
+ expect(currentSettings.trust.allowed_list).toBe("Zm9v\n");
42
+ // Now load only trust config
43
+ const trustConfig = {
44
+ verifyTrustList: true,
45
+ userAnchors: "dGVzdA==\n", // base64("test") with newline - valid base64
46
+ trustAnchors: "YW5jaG9y\n", // base64("anchor") with newline - valid base64
47
+ allowedList: "Zm9v\n", // base64("foo") with newline
48
+ };
49
+ loadTrustConfig(trustConfig);
50
+ // Verify trust config was updated
51
+ const updatedSettings = JSON.parse(getSettingsJson());
52
+ expect(updatedSettings.trust.allowed_list).toBe("Zm9v\n");
53
+ expect(updatedSettings.trust.user_anchors).toBe("dGVzdA==\n");
54
+ expect(updatedSettings.trust.trust_anchors).toBe("YW5jaG9y\n");
55
+ // Verify other settings are preserved
56
+ expect(updatedSettings.verify.verify_trust).toBe(true);
57
+ });
58
+ it("works with getTrustConfig to retrieve current trust settings", () => {
59
+ // Load initial trust config
60
+ const initialTrustConfig = {
61
+ verifyTrustList: false,
62
+ userAnchors: "dGVzdA==\n", // base64("test") with newline - valid base64
63
+ trustAnchors: "YW5jaG9y\n", // base64("anchor") with newline - valid base64
64
+ };
65
+ loadTrustConfig(initialTrustConfig);
66
+ // Verify we can retrieve it
67
+ const retrievedConfig = getTrustConfig();
68
+ expect(retrievedConfig.verifyTrustList).toBe(false);
69
+ expect(retrievedConfig.userAnchors).toBe("dGVzdA==\n");
70
+ expect(retrievedConfig.trustAnchors).toBe("YW5jaG9y\n");
71
+ // Update trust config
72
+ const updatedTrustConfig = {
73
+ verifyTrustList: true,
74
+ allowedList: "YmFy\n", // base64("bar") with newline
75
+ trustConfig: "dHJ1c3Q=\n", // base64("trust") with newline - valid base64
76
+ };
77
+ loadTrustConfig(updatedTrustConfig);
78
+ // Verify updated config
79
+ const updatedRetrievedConfig = getTrustConfig();
80
+ expect(updatedRetrievedConfig.verifyTrustList).toBe(true);
81
+ expect(updatedRetrievedConfig.allowedList).toBe("YmFy\n");
82
+ expect(updatedRetrievedConfig.trustConfig).toBe("dHJ1c3Q=\n");
83
+ // Previous values should be cleared when not specified
84
+ expect(updatedRetrievedConfig.userAnchors).toBeNull();
85
+ expect(updatedRetrievedConfig.trustAnchors).toBeNull();
86
+ });
87
+ it("handles empty trust config without errors", () => {
88
+ // Load some initial settings
89
+ const initialSettings = {
90
+ core: { hash_alg: "sha256" },
91
+ verify: { verify_trust: true },
92
+ };
93
+ loadC2paSettings(JSON.stringify(initialSettings));
94
+ // Load empty trust config
95
+ const emptyTrustConfig = {
96
+ verifyTrustList: true,
97
+ };
98
+ expect(() => loadTrustConfig(emptyTrustConfig)).not.toThrow();
99
+ // Verify settings are still intact
100
+ const currentSettings = JSON.parse(getSettingsJson());
101
+ expect(currentSettings.core.hash_alg).toBe("sha256");
102
+ expect(currentSettings.verify.verify_trust).toBe(true);
103
+ expect(currentSettings.trust.verify_trust_list).toBe(true);
104
+ });
105
+ });
106
+ describe("loadCawgTrustConfig", () => {
107
+ it("preserves other settings when loading CAWG trust config", () => {
108
+ // First, load basic settings that work with c2pa-rs
109
+ const initialSettings = {
110
+ verify: {
111
+ verify_trust: false,
112
+ },
113
+ trust: {
114
+ allowed_list: "YmFy\n", // base64("bar") with newline - valid base64
115
+ },
116
+ };
117
+ loadC2paSettings(JSON.stringify(initialSettings));
118
+ // Load CAWG trust config
119
+ const cawgTrustConfig = {
120
+ verifyTrustList: true,
121
+ userAnchors: "Y2F3Zw==\n", // base64("cawg") with newline - valid base64
122
+ allowedList: "Y2F3Zw==\n", // base64("cawg") with newline
123
+ };
124
+ loadCawgTrustConfig(cawgTrustConfig);
125
+ // Verify CAWG trust config was updated
126
+ const updatedSettings = JSON.parse(getSettingsJson());
127
+ expect(updatedSettings.cawg_trust.allowed_list).toBe("Y2F3Zw==\n");
128
+ expect(updatedSettings.cawg_trust.user_anchors).toBe("Y2F3Zw==\n");
129
+ // Verify other settings are preserved
130
+ expect(updatedSettings.verify.verify_trust).toBe(false);
131
+ expect(updatedSettings.trust.allowed_list).toBe("YmFy\n");
132
+ });
133
+ it("works with getCawgTrustConfig to retrieve current CAWG trust settings", () => {
134
+ // Load CAWG trust config
135
+ const cawgTrustConfig = {
136
+ verifyTrustList: true,
137
+ userAnchors: "Y2F3Zw==\n", // base64("cawg") with newline - valid base64
138
+ trustConfig: "c3RvcmU=\n", // base64("store") with newline - valid base64
139
+ };
140
+ loadCawgTrustConfig(cawgTrustConfig);
141
+ // Verify we can retrieve it
142
+ const retrievedConfig = getCawgTrustConfig();
143
+ expect(retrievedConfig.verifyTrustList).toBe(true);
144
+ expect(retrievedConfig.userAnchors).toBe("Y2F3Zw==\n");
145
+ expect(retrievedConfig.trustConfig).toBe("c3RvcmU=\n");
146
+ });
147
+ });
148
+ describe("settings merge behavior", () => {
149
+ it("maintains separate trust and CAWG trust configurations", () => {
150
+ // Load initial settings with basic trust config and verify settings
151
+ const initialSettings = {
152
+ trust: {
153
+ allowed_list: "bWFpbg==\n", // base64("main") with newline - valid base64
154
+ },
155
+ verify: {
156
+ verify_trust: true,
157
+ remote_manifest_fetch: false,
158
+ },
159
+ };
160
+ loadC2paSettings(JSON.stringify(initialSettings));
161
+ // Update main trust config
162
+ const mainTrustConfig = {
163
+ verifyTrustList: true,
164
+ allowedList: "bWFpbg==\n", // base64("main") with newline
165
+ };
166
+ loadTrustConfig(mainTrustConfig);
167
+ // Update CAWG trust config
168
+ const cawgTrustConfig = {
169
+ verifyTrustList: false,
170
+ allowedList: "Y2F3Zw==\n", // base64("cawg") with newline
171
+ };
172
+ loadCawgTrustConfig(cawgTrustConfig);
173
+ // Update verify config to ensure it doesn't conflict with trust settings
174
+ const verifyConfig = {
175
+ verifyAfterReading: false,
176
+ verifyAfterSign: true,
177
+ verifyTrust: false, // This should not affect trust.allowed_list
178
+ verifyTimestampTrust: true,
179
+ ocspFetch: false,
180
+ remoteManifestFetch: true, // This should not affect trust settings
181
+ checkIngredientTrust: false,
182
+ skipIngredientConflictResolution: true,
183
+ strictV1Validation: false,
184
+ };
185
+ loadVerifyConfig(verifyConfig);
186
+ // Verify all configs are maintained separately
187
+ const finalSettings = JSON.parse(getSettingsJson());
188
+ // Main trust config should be preserved
189
+ expect(finalSettings.trust.allowed_list).toBe("bWFpbg==\n");
190
+ expect(finalSettings.trust.verify_trust_list).toBe(true);
191
+ // CAWG trust config should be preserved
192
+ expect(finalSettings.cawg_trust.allowed_list).toBe("Y2F3Zw==\n");
193
+ expect(finalSettings.cawg_trust.verify_trust_list).toBe(false);
194
+ // Verify config should be updated independently
195
+ expect(finalSettings.verify.verify_after_reading).toBe(false);
196
+ expect(finalSettings.verify.verify_after_sign).toBe(true);
197
+ expect(finalSettings.verify.verify_trust).toBe(false);
198
+ expect(finalSettings.verify.verify_timestamp_trust).toBe(true);
199
+ expect(finalSettings.verify.ocsp_fetch).toBe(false);
200
+ expect(finalSettings.verify.remote_manifest_fetch).toBe(true);
201
+ expect(finalSettings.verify.check_ingredient_trust).toBe(false);
202
+ expect(finalSettings.verify.skip_ingredient_conflict_resolution).toBe(true);
203
+ expect(finalSettings.verify.strict_v1_validation).toBe(false);
204
+ // Verify that trust settings are not affected by verify settings
205
+ expect(finalSettings.trust.allowed_list).toBe("bWFpbg==\n");
206
+ expect(finalSettings.cawg_trust.allowed_list).toBe("Y2F3Zw==\n");
207
+ // Settings structure is maintained
208
+ expect(finalSettings).toBeTruthy();
209
+ });
210
+ });
211
+ describe("Verify Settings", () => {
212
+ it("loads and retrieves verify configuration", () => {
213
+ const verifyConfig = {
214
+ verifyAfterReading: true,
215
+ verifyAfterSign: false,
216
+ verifyTrust: true,
217
+ verifyTimestampTrust: false,
218
+ ocspFetch: true,
219
+ remoteManifestFetch: false,
220
+ checkIngredientTrust: true,
221
+ skipIngredientConflictResolution: false,
222
+ strictV1Validation: true,
223
+ };
224
+ loadVerifyConfig(verifyConfig);
225
+ const retrievedConfig = getVerifyConfig();
226
+ expect(retrievedConfig).toEqual(verifyConfig);
227
+ });
228
+ it("preserves other settings when loading verify config", () => {
229
+ // First, load basic settings
230
+ const initialSettings = {
231
+ trust: {
232
+ allowed_list: "Zm9v\n", // base64("foo") with newline - valid base64
233
+ },
234
+ verify: {
235
+ verify_trust: true,
236
+ },
237
+ };
238
+ loadC2paSettings(JSON.stringify(initialSettings));
239
+ // Load verify config
240
+ const verifyConfig = {
241
+ verifyAfterReading: false,
242
+ verifyAfterSign: true,
243
+ verifyTrust: false,
244
+ verifyTimestampTrust: true,
245
+ ocspFetch: false,
246
+ remoteManifestFetch: true,
247
+ checkIngredientTrust: false,
248
+ skipIngredientConflictResolution: true,
249
+ strictV1Validation: false,
250
+ };
251
+ loadVerifyConfig(verifyConfig);
252
+ // Verify the settings are maintained
253
+ const finalSettings = JSON.parse(getSettingsJson());
254
+ expect(finalSettings.trust.allowed_list).toBe("Zm9v\n");
255
+ expect(finalSettings.verify.verify_after_reading).toBe(false);
256
+ expect(finalSettings.verify.verify_after_sign).toBe(true);
257
+ expect(finalSettings.verify.verify_trust).toBe(false);
258
+ expect(finalSettings.verify.verify_timestamp_trust).toBe(true);
259
+ expect(finalSettings.verify.ocsp_fetch).toBe(false);
260
+ expect(finalSettings.verify.remote_manifest_fetch).toBe(true);
261
+ expect(finalSettings.verify.check_ingredient_trust).toBe(false);
262
+ expect(finalSettings.verify.skip_ingredient_conflict_resolution).toBe(true);
263
+ expect(finalSettings.verify.strict_v1_validation).toBe(false);
264
+ });
265
+ it("patches verify configuration with partial updates", () => {
266
+ // First, load initial verify configuration
267
+ const initialVerifyConfig = {
268
+ verifyAfterReading: true,
269
+ verifyAfterSign: true,
270
+ verifyTrust: false,
271
+ verifyTimestampTrust: true,
272
+ ocspFetch: false,
273
+ remoteManifestFetch: true,
274
+ checkIngredientTrust: true,
275
+ skipIngredientConflictResolution: false,
276
+ strictV1Validation: false,
277
+ };
278
+ loadVerifyConfig(initialVerifyConfig);
279
+ // Verify initial configuration is loaded
280
+ const initialRetrievedConfig = getVerifyConfig();
281
+ expect(initialRetrievedConfig).toEqual(initialVerifyConfig);
282
+ // Patch only specific fields
283
+ const patch = {
284
+ verifyTrust: true,
285
+ ocspFetch: true,
286
+ strictV1Validation: true,
287
+ };
288
+ patchVerifyConfig(patch);
289
+ // Verify the patched configuration
290
+ const patchedRetrievedConfig = getVerifyConfig();
291
+ expect(patchedRetrievedConfig.verifyAfterReading).toBe(true); // unchanged
292
+ expect(patchedRetrievedConfig.verifyAfterSign).toBe(true); // unchanged
293
+ expect(patchedRetrievedConfig.verifyTrust).toBe(true); // patched
294
+ expect(patchedRetrievedConfig.verifyTimestampTrust).toBe(true); // unchanged
295
+ expect(patchedRetrievedConfig.ocspFetch).toBe(true); // patched
296
+ expect(patchedRetrievedConfig.remoteManifestFetch).toBe(true); // unchanged
297
+ expect(patchedRetrievedConfig.checkIngredientTrust).toBe(true); // unchanged
298
+ expect(patchedRetrievedConfig.skipIngredientConflictResolution).toBe(false); // unchanged
299
+ expect(patchedRetrievedConfig.strictV1Validation).toBe(true); // patched
300
+ // Verify the changes are reflected in getSettingsJson()
301
+ const settingsJson = getSettingsJson();
302
+ const settings = JSON.parse(settingsJson);
303
+ expect(settings.verify.verify_trust).toBe(true);
304
+ expect(settings.verify.ocsp_fetch).toBe(true);
305
+ expect(settings.verify.strict_v1_validation).toBe(true);
306
+ expect(settings.verify.verify_after_reading).toBe(true);
307
+ expect(settings.verify.verify_after_sign).toBe(true);
308
+ expect(settings.verify.verify_timestamp_trust).toBe(true);
309
+ expect(settings.verify.remote_manifest_fetch).toBe(true);
310
+ expect(settings.verify.check_ingredient_trust).toBe(true);
311
+ expect(settings.verify.skip_ingredient_conflict_resolution).toBe(false);
312
+ });
313
+ });
314
+ });
package/dist/Signer.js CHANGED
@@ -1,42 +1,8 @@
1
- "use strict";
2
1
  // Copyright 2024 Adobe. All rights reserved.
3
2
  // This file is licensed to you under the Apache License,
4
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
4
  // or the MIT license (http://opensource.org/licenses/MIT),
6
5
  // at your option.
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
6
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
7
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
8
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -46,16 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46
12
  step((generator = generator.apply(thisArg, _arguments || [])).next());
47
13
  });
48
14
  };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.CallbackSigner = exports.LocalSigner = void 0;
51
15
  // Unless required by applicable law or agreed to in writing,
52
16
  // this software is distributed on an "AS IS" BASIS, WITHOUT
53
17
  // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
54
18
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
19
  // specific language governing permissions and limitations under
56
20
  // each license.
57
- const neon = __importStar(require("./index.node"));
58
- class LocalSigner {
21
+ const neon = require("./index.node");
22
+ export class LocalSigner {
59
23
  constructor(localSigner) {
60
24
  this.localSigner = localSigner;
61
25
  }
@@ -82,8 +46,7 @@ class LocalSigner {
82
46
  return this.localSigner;
83
47
  }
84
48
  }
85
- exports.LocalSigner = LocalSigner;
86
- class CallbackSigner {
49
+ export class CallbackSigner {
87
50
  constructor(callbackSigner) {
88
51
  this.callbackSigner = callbackSigner;
89
52
  }
@@ -114,4 +77,3 @@ class CallbackSigner {
114
77
  return neon.callbackSignerTimeAuthorityUrl.call(this.callbackSigner);
115
78
  }
116
79
  }
117
- exports.CallbackSigner = CallbackSigner;
@@ -1,42 +1,8 @@
1
- "use strict";
2
1
  // Copyright 2024 Adobe. All rights reserved.
3
2
  // This file is licensed to you under the Apache License,
4
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
4
  // or the MIT license (http://opensource.org/licenses/MIT),
6
5
  // at your option.
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
6
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
7
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
8
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -46,16 +12,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46
12
  step((generator = generator.apply(thisArg, _arguments || [])).next());
47
13
  });
48
14
  };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
15
  // Unless required by applicable law or agreed to in writing,
51
16
  // this software is distributed on an "AS IS" BASIS, WITHOUT
52
17
  // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
53
18
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
54
19
  // specific language governing permissions and limitations under
55
20
  // each license.
56
- const Signer_1 = require("./Signer");
57
- const fs = __importStar(require("fs-extra"));
58
- const crypto = __importStar(require("crypto"));
21
+ import { CallbackSigner } from "./Signer";
22
+ import * as fs from "fs-extra";
23
+ import * as crypto from "crypto";
59
24
  class TestSigner {
60
25
  constructor(privateKey) {
61
26
  this.sign = (bytes) => __awaiter(this, void 0, void 0, function* () {
@@ -87,34 +52,35 @@ describe("CallbackSigner", () => {
87
52
  tsaUrl: "https://timestamp.digicert.com",
88
53
  tsaHeaders: [["Content-Type", "application/json"]],
89
54
  tsaBody: Buffer.from('{"test": "body"}'),
55
+ directCoseHandling: false,
90
56
  };
91
57
  it("should create a new instance", () => {
92
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
58
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
93
59
  expect(signer).toBeDefined();
94
60
  });
95
61
  it("should sign data", () => __awaiter(void 0, void 0, void 0, function* () {
96
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
62
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
97
63
  const data = Buffer.from("test data");
98
64
  const signature = yield signer.sign(data);
99
65
  expect(signature).toBeDefined();
100
66
  }));
101
67
  it("should get algorithm", () => {
102
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
68
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
103
69
  const alg = signer.alg();
104
70
  expect(alg).toBe("es256");
105
71
  });
106
72
  it("should return certificates", () => {
107
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
73
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
108
74
  const certs = signer.certs();
109
75
  expect(Array.isArray(certs)).toBe(true);
110
76
  expect(certs.length).toBeGreaterThan(0);
111
77
  });
112
78
  it("should return reserve size", () => {
113
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
79
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
114
80
  expect(signer.reserveSize()).toBe(10000);
115
81
  });
116
82
  it("should return time authority URL when provided", () => {
117
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
83
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
118
84
  expect(signer.timeAuthorityUrl()).toBe("https://timestamp.digicert.com");
119
85
  });
120
86
  it("should return undefined for time authority URL when not provided", () => __awaiter(void 0, void 0, void 0, function* () {
@@ -125,8 +91,9 @@ describe("CallbackSigner", () => {
125
91
  tsaUrl: undefined,
126
92
  tsaHeaders: undefined,
127
93
  tsaBody: undefined,
94
+ directCoseHandling: false,
128
95
  };
129
- const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
96
+ const signer = CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
130
97
  expect(signer.timeAuthorityUrl()).toBeUndefined();
131
98
  }));
132
99
  });
package/dist/Trustmark.js CHANGED
@@ -1,42 +1,8 @@
1
- "use strict";
2
1
  // Copyright 2025 Adobe. All rights reserved.
3
2
  // This file is licensed to you under the Apache License,
4
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
4
  // or the MIT license (http://opensource.org/licenses/MIT),
6
5
  // at your option.
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
6
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
7
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
8
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -46,17 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46
12
  step((generator = generator.apply(thisArg, _arguments || [])).next());
47
13
  });
48
14
  };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.Trustmark = void 0;
51
15
  // Unless required by applicable law or agreed to in writing,
52
16
  // this software is distributed on an "AS IS" BASIS, WITHOUT
53
17
  // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
54
18
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
19
  // specific language governing permissions and limitations under
56
20
  // each license.
57
- //const neon = require("../index.node");
58
- const neon = __importStar(require("./index.node"));
59
- class Trustmark {
21
+ const neon = require("./index.node");
22
+ export class Trustmark {
60
23
  constructor(trustmark) {
61
24
  this.trustmark = trustmark;
62
25
  }
@@ -77,4 +40,3 @@ class Trustmark {
77
40
  });
78
41
  }
79
42
  }
80
- exports.Trustmark = Trustmark;