@contentauth/c2pa-node 0.1.2 → 0.1.3

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/dist/Builder.js CHANGED
@@ -54,7 +54,7 @@ exports.Builder = void 0;
54
54
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
55
  // specific language governing permissions and limitations under
56
56
  // each license.
57
- const neon = __importStar(require("index.node"));
57
+ const neon = __importStar(require("./index.node"));
58
58
  class Builder {
59
59
  constructor(builder) {
60
60
  this.builder = builder;
@@ -73,7 +73,7 @@ class Builder {
73
73
  if (error instanceof Error) {
74
74
  throw new Error(`Failed to stringify JSON Manifest Definition: ${error.message}`);
75
75
  }
76
- throw new Error('Failed to stringify JSON Manifest Definition: Unknown error');
76
+ throw new Error("Failed to stringify JSON Manifest Definition: Unknown error");
77
77
  }
78
78
  const builder = neon.builderWithJson(jsonString);
79
79
  return new Builder(builder);
@@ -120,13 +120,13 @@ class Builder {
120
120
  .call(this.builder, callback, signerConfig, input, output)
121
121
  .then((result) => {
122
122
  // output is a buffer and result is the manifest and the signed asset.
123
- if ('buffer' in output) {
124
- if ('signedAsset' in result && 'manifest' in result) {
123
+ if ("buffer" in output) {
124
+ if ("signedAsset" in result && "manifest" in result) {
125
125
  output.buffer = result.signedAsset;
126
126
  return result.manifest;
127
127
  }
128
128
  else {
129
- throw new Error('Unexpected result for DestinationBuffer');
129
+ throw new Error("Unexpected result for DestinationBuffer");
130
130
  }
131
131
  }
132
132
  else {
@@ -145,13 +145,13 @@ class Builder {
145
145
  .call(this.builder, signer.signer(), input, output)
146
146
  .then((result) => {
147
147
  // output is a buffer and result is the manifest and the signed asset.
148
- if ('buffer' in output) {
149
- if ('signedAsset' in result && 'manifest' in result) {
148
+ if ("buffer" in output) {
149
+ if ("signedAsset" in result && "manifest" in result) {
150
150
  output.buffer = result.signedAsset;
151
151
  return result.manifest;
152
152
  }
153
153
  else {
154
- throw new Error('Unexpected result for DestinationBuffer');
154
+ throw new Error("Unexpected result for DestinationBuffer");
155
155
  }
156
156
  }
157
157
  else {
@@ -170,13 +170,13 @@ class Builder {
170
170
  .call(this.builder, signer.signer(), input, output)
171
171
  .then((result) => {
172
172
  // output is a buffer and result is the manifest and the signed asset.
173
- if ('buffer' in output) {
174
- if ('signedAsset' in result && 'manifest' in result) {
173
+ if ("buffer" in output) {
174
+ if ("signedAsset" in result && "manifest" in result) {
175
175
  output.buffer = result.signedAsset;
176
176
  return result.manifest;
177
177
  }
178
178
  else {
179
- throw new Error('Unexpected result for DestinationBuffer');
179
+ throw new Error("Unexpected result for DestinationBuffer");
180
180
  }
181
181
  }
182
182
  else {
@@ -50,22 +50,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- // Unless required by applicable law or agreed to in writing,
54
- // this software is distributed on an "AS IS" BASIS, WITHOUT
55
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
56
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
57
- // specific language governing permissions and limitations under
58
- // each license.
59
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
60
- const index_1 = require("./index");
53
+ const Signer_1 = require("./Signer");
54
+ const Reader_1 = require("./Reader");
55
+ const Builder_1 = require("./Builder");
61
56
  const fs = __importStar(require("fs-extra"));
62
57
  const path_1 = __importDefault(require("path"));
63
58
  const crypto = __importStar(require("crypto"));
64
- const tempDir = path_1.default.join(__dirname, 'tmp');
59
+ const tempDir = path_1.default.join(__dirname, "tmp");
65
60
  class TestSigner {
66
61
  constructor(privateKey) {
67
62
  this.sign = (bytes) => __awaiter(this, void 0, void 0, function* () {
68
- const sign = crypto.createSign('SHA256');
63
+ const sign = crypto.createSign("SHA256");
69
64
  sign.update(bytes);
70
65
  sign.end();
71
66
  const signature = sign.sign(this.privateKey);
@@ -73,19 +68,19 @@ class TestSigner {
73
68
  });
74
69
  this.privateKey = crypto.createPrivateKey({
75
70
  key: privateKey,
76
- format: 'pem',
71
+ format: "pem",
77
72
  });
78
73
  }
79
74
  }
80
- describe('TestSigner', () => {
81
- it('should sign data', () => __awaiter(void 0, void 0, void 0, function* () {
82
- const signer = new TestSigner(yield fs.readFile('./tests/fixtures/certs/es256.pem'));
83
- const bytes = Buffer.from('Hello, World!');
75
+ describe("TestSigner", () => {
76
+ it("should sign data", () => __awaiter(void 0, void 0, void 0, function* () {
77
+ const signer = new TestSigner(yield fs.readFile("./tests/fixtures/certs/es256.pem"));
78
+ const bytes = Buffer.from("Hello, World!");
84
79
  const signature = yield signer.sign(bytes);
85
80
  expect(signature.length).toBeGreaterThan(0);
86
81
  }));
87
82
  });
88
- describe('Builder', () => {
83
+ describe("Builder", () => {
89
84
  const parent_json = `{
90
85
  "title": "c2pa-bindings Test",
91
86
  "format": "image/jpeg",
@@ -93,42 +88,42 @@ describe('Builder', () => {
93
88
  "relationship": "parentOf"
94
89
  }`;
95
90
  const thumbnail_ref = {
96
- format: 'ingredient/jpeg',
97
- identifier: '5678',
91
+ format: "ingredient/jpeg",
92
+ identifier: "5678",
98
93
  };
99
94
  const manifestDefinition = {
100
- vendor: 'test',
95
+ vendor: "test",
101
96
  claim_generator_info: [
102
97
  {
103
- name: 'c2pa_test',
104
- version: '1.0.0',
98
+ name: "c2pa_test",
99
+ version: "1.0.0",
105
100
  },
106
101
  ],
107
102
  metadata: [
108
103
  {
109
- dateTime: '1985-04-12T23:20:50.52Z',
110
- my_custom_metadata: 'my custom metatdata value',
104
+ dateTime: "1985-04-12T23:20:50.52Z",
105
+ my_custom_metadata: "my custom metatdata value",
111
106
  },
112
107
  ],
113
- title: 'Test_Manifest',
114
- format: 'image/tiff',
115
- instance_id: '1234',
108
+ title: "Test_Manifest",
109
+ format: "image/tiff",
110
+ instance_id: "1234",
116
111
  thumbnail: {
117
- format: 'image/jpeg',
118
- identifier: 'thumbnail.jpg',
112
+ format: "image/jpeg",
113
+ identifier: "thumbnail.jpg",
119
114
  },
120
115
  ingredients: [
121
116
  {
122
- title: 'Test',
123
- format: 'image/jpeg',
124
- instance_id: '12345',
125
- relationship: 'componentOf',
117
+ title: "Test",
118
+ format: "image/jpeg",
119
+ instance_id: "12345",
120
+ relationship: "componentOf",
126
121
  },
127
122
  ],
128
123
  assertions: [
129
124
  {
130
- label: 'org.test.assertion',
131
- data: 'assertion',
125
+ label: "org.test.assertion",
126
+ data: "assertion",
132
127
  },
133
128
  ],
134
129
  };
@@ -141,108 +136,108 @@ describe('Builder', () => {
141
136
  yield fs.ensureDir(tempDir);
142
137
  // Read all test files once
143
138
  source = {
144
- buffer: yield fs.readFile('./tests/fixtures/CA.jpg'),
145
- mimeType: 'jpeg',
139
+ buffer: yield fs.readFile("./tests/fixtures/CA.jpg"),
140
+ mimeType: "jpeg",
146
141
  };
147
- testThumbnail = yield fs.readFile('./tests/fixtures/thumbnail.jpg');
148
- publicKey = yield fs.readFile('./tests/fixtures/certs/es256.pub');
149
- privateKey = yield fs.readFile('./tests/fixtures/certs/es256.pem');
142
+ testThumbnail = yield fs.readFile("./tests/fixtures/thumbnail.jpg");
143
+ publicKey = yield fs.readFile("./tests/fixtures/certs/es256.pub");
144
+ privateKey = yield fs.readFile("./tests/fixtures/certs/es256.pem");
150
145
  testAssertion = JSON.stringify({ answer: 42 });
151
146
  }));
152
147
  afterAll(() => __awaiter(void 0, void 0, void 0, function* () {
153
148
  yield fs.remove(tempDir);
154
149
  }));
155
- it('should build a manifest store', () => __awaiter(void 0, void 0, void 0, function* () {
150
+ it("should build a manifest store", () => __awaiter(void 0, void 0, void 0, function* () {
156
151
  const test_definition = {
157
152
  claim_generator_info: [
158
153
  {
159
- name: 'c2pa-js tests',
160
- version: '1.0.0',
154
+ name: "c2pa-js tests",
155
+ version: "1.0.0",
161
156
  },
162
157
  ],
163
- format: 'image/tiff',
164
- instance_id: '1234',
165
- title: 'builder-test-manifest',
166
- vendor: 'test',
158
+ format: "image/tiff",
159
+ instance_id: "1234",
160
+ title: "builder-test-manifest",
161
+ vendor: "test",
167
162
  thumbnail: thumbnail_ref,
168
- label: 'ABCDE',
163
+ label: "ABCDE",
169
164
  };
170
- const builder = index_1.Builder.withJson(test_definition);
165
+ const builder = Builder_1.Builder.withJson(test_definition);
171
166
  yield builder.addIngredient(parent_json, source);
172
- builder.addAssertion('org.test.assertion', 'assertion');
167
+ builder.addAssertion("org.test.assertion", "assertion");
173
168
  yield builder.addResource(thumbnail_ref.identifier, {
174
- buffer: Buffer.from('12345'),
175
- mimeType: 'jpeg',
169
+ buffer: Buffer.from("12345"),
170
+ mimeType: "jpeg",
176
171
  });
177
172
  // Wait for any pending async operations
178
173
  yield Promise.resolve();
179
174
  const definition = builder.getManifestDefinition();
180
- expect(definition.vendor).toBe('test');
181
- expect(definition.title).toBe('builder-test-manifest');
182
- expect(definition.format).toBe('image/tiff');
183
- expect(definition.instance_id).toBe('1234');
184
- expect(definition.ingredients[0].title).toStrictEqual('c2pa-bindings Test');
185
- expect(definition.assertions[0].label).toBe('org.test.assertion');
186
- expect(definition.label).toBe('ABCDE');
175
+ expect(definition.vendor).toBe("test");
176
+ expect(definition.title).toBe("builder-test-manifest");
177
+ expect(definition.format).toBe("image/tiff");
178
+ expect(definition.instance_id).toBe("1234");
179
+ expect(definition.ingredients[0].title).toStrictEqual("c2pa-bindings Test");
180
+ expect(definition.assertions[0].label).toBe("org.test.assertion");
181
+ expect(definition.label).toBe("ABCDE");
187
182
  }));
188
- describe('Sign and Archive', () => {
183
+ describe("Sign and Archive", () => {
189
184
  let builder;
190
185
  beforeEach(() => {
191
- builder = index_1.Builder.withJson(manifestDefinition);
192
- builder.updateManifestProperty('claim_version', 1);
186
+ builder = Builder_1.Builder.withJson(manifestDefinition);
187
+ builder.updateManifestProperty("claim_version", 1);
193
188
  });
194
189
  beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
195
190
  // Add ingredients and resources after builder is initialized
196
191
  yield builder.addIngredient(parent_json, source);
197
- yield builder.addResource('thumbnail.jpg', {
198
- mimeType: 'jpeg',
192
+ yield builder.addResource("thumbnail.jpg", {
193
+ mimeType: "jpeg",
199
194
  buffer: testThumbnail,
200
195
  });
201
- yield builder.addResource('prompt.txt', {
202
- buffer: Buffer.from('a random prompt'),
203
- mimeType: 'text/plain',
196
+ yield builder.addResource("prompt.txt", {
197
+ buffer: Buffer.from("a random prompt"),
198
+ mimeType: "text/plain",
204
199
  });
205
- builder.addAssertion('org.life.meaning', testAssertion);
206
- builder.addAssertion('org.life.meaning.json', testAssertion, 'Json');
200
+ builder.addAssertion("org.life.meaning", testAssertion);
201
+ builder.addAssertion("org.life.meaning.json", testAssertion, "Json");
207
202
  // Wait for any pending operations
208
203
  yield Promise.resolve();
209
204
  }));
210
- it('should sign data', () => __awaiter(void 0, void 0, void 0, function* () {
211
- const dest = { path: path_1.default.join(tempDir, 'signed.jpg') };
212
- const signer = index_1.LocalSigner.newSigner(publicKey, privateKey, 'es256');
205
+ it("should sign data", () => __awaiter(void 0, void 0, void 0, function* () {
206
+ const dest = { path: path_1.default.join(tempDir, "signed.jpg") };
207
+ const signer = Signer_1.LocalSigner.newSigner(publicKey, privateKey, "es256");
213
208
  const bytes = builder.sign(signer, source, dest);
214
209
  expect(bytes.length).toBeGreaterThan(0);
215
- const reader = yield index_1.Reader.fromAsset(dest);
210
+ const reader = yield Reader_1.Reader.fromAsset(dest);
216
211
  const manifestStore = reader.json();
217
212
  const activeManifest = reader.getActive();
218
213
  expect(manifestStore.validation_status).toBeUndefined();
219
214
  expect(manifestStore.active_manifest).not.toBeUndefined();
220
- expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe('Test_Manifest');
215
+ expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe("Test_Manifest");
221
216
  }));
222
- it('should archive and construct from archive', () => __awaiter(void 0, void 0, void 0, function* () {
217
+ it("should archive and construct from archive", () => __awaiter(void 0, void 0, void 0, function* () {
223
218
  const dest = {
224
219
  buffer: null,
225
220
  };
226
- const signer = index_1.LocalSigner.newSigner(publicKey, privateKey, 'es256');
227
- const outputPath = path_1.default.join(tempDir, 'archive.zip');
221
+ const signer = Signer_1.LocalSigner.newSigner(publicKey, privateKey, "es256");
222
+ const outputPath = path_1.default.join(tempDir, "archive.zip");
228
223
  const archive = { path: outputPath };
229
224
  yield builder.toArchive(archive);
230
- const builder2 = yield index_1.Builder.fromArchive(archive);
225
+ const builder2 = yield Builder_1.Builder.fromArchive(archive);
231
226
  builder2.sign(signer, source, dest);
232
- const reader = yield index_1.Reader.fromAsset({
227
+ const reader = yield Reader_1.Reader.fromAsset({
233
228
  buffer: dest.buffer,
234
- mimeType: 'jpeg',
229
+ mimeType: "jpeg",
235
230
  });
236
231
  const manifestStore = reader.json();
237
232
  const activeManifest = reader.getActive();
238
233
  expect(manifestStore.validation_status).toBeUndefined();
239
234
  expect(manifestStore.active_manifest).not.toBeUndefined();
240
- expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe('Test_Manifest');
235
+ expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe("Test_Manifest");
241
236
  }));
242
- it('should sign data with callback to file', () => __awaiter(void 0, void 0, void 0, function* () {
243
- const dest = { path: path_1.default.join(tempDir, 'callback_signed.jpg') };
237
+ it("should sign data with callback to file", () => __awaiter(void 0, void 0, void 0, function* () {
238
+ const dest = { path: path_1.default.join(tempDir, "callback_signed.jpg") };
244
239
  const signerConfig = {
245
- alg: 'es256',
240
+ alg: "es256",
246
241
  certs: [publicKey],
247
242
  reserveSize: 10000,
248
243
  tsaUrl: undefined,
@@ -250,19 +245,19 @@ describe('Builder', () => {
250
245
  const signer = new TestSigner(privateKey);
251
246
  const bytes = yield builder.signConfigAsync(signer.sign, signerConfig, source, dest);
252
247
  expect(bytes.length).toBeGreaterThan(0);
253
- const reader = yield index_1.Reader.fromAsset(dest);
248
+ const reader = yield Reader_1.Reader.fromAsset(dest);
254
249
  const manifestStore = reader.json();
255
250
  const activeManifest = reader.getActive();
256
251
  expect(manifestStore.validation_status).toBeUndefined();
257
252
  expect(manifestStore.active_manifest).not.toBeUndefined();
258
- expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe('Test_Manifest');
253
+ expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe("Test_Manifest");
259
254
  }));
260
- it('should sign data with callback to buffer', () => __awaiter(void 0, void 0, void 0, function* () {
255
+ it("should sign data with callback to buffer", () => __awaiter(void 0, void 0, void 0, function* () {
261
256
  const dest = {
262
257
  buffer: null,
263
258
  };
264
259
  const signerConfig = {
265
- alg: 'es256',
260
+ alg: "es256",
266
261
  certs: [publicKey],
267
262
  reserveSize: 10000,
268
263
  tsaUrl: undefined,
@@ -270,39 +265,39 @@ describe('Builder', () => {
270
265
  const signer = new TestSigner(privateKey);
271
266
  const bytes = yield builder.signConfigAsync(signer.sign, signerConfig, source, dest);
272
267
  expect(bytes.length).toBeGreaterThan(0);
273
- const reader = yield index_1.Reader.fromAsset({
268
+ const reader = yield Reader_1.Reader.fromAsset({
274
269
  buffer: dest.buffer,
275
- mimeType: 'jpeg',
270
+ mimeType: "jpeg",
276
271
  });
277
272
  const manifestStore = reader.json();
278
273
  const activeManifest = reader.getActive();
279
274
  expect(manifestStore.validation_status).toBeUndefined();
280
275
  expect(manifestStore.active_manifest).not.toBeUndefined();
281
- expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe('Test_Manifest');
276
+ expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe("Test_Manifest");
282
277
  }));
283
- it('should sign data with callback signer to buffer', () => __awaiter(void 0, void 0, void 0, function* () {
278
+ it("should sign data with callback signer to buffer", () => __awaiter(void 0, void 0, void 0, function* () {
284
279
  const dest = {
285
280
  buffer: null,
286
281
  };
287
282
  const signerConfig = {
288
- alg: 'es256',
283
+ alg: "es256",
289
284
  certs: [publicKey],
290
285
  reserveSize: 10000,
291
286
  tsaUrl: undefined,
292
287
  };
293
288
  const testSigner = new TestSigner(privateKey);
294
- const signer = index_1.CallbackSigner.newSigner(signerConfig, testSigner.sign);
289
+ const signer = Signer_1.CallbackSigner.newSigner(signerConfig, testSigner.sign);
295
290
  const bytes = yield builder.signAsync(signer, source, dest);
296
291
  expect(bytes.length).toBeGreaterThan(0);
297
- const reader = yield index_1.Reader.fromAsset({
292
+ const reader = yield Reader_1.Reader.fromAsset({
298
293
  buffer: dest.buffer,
299
- mimeType: 'jpeg',
294
+ mimeType: "jpeg",
300
295
  });
301
296
  const manifestStore = reader.json();
302
297
  const activeManifest = reader.getActive();
303
298
  expect(manifestStore.validation_status).toBeUndefined();
304
299
  expect(manifestStore.active_manifest).not.toBeUndefined();
305
- expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe('Test_Manifest');
300
+ expect(activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.title).toBe("Test_Manifest");
306
301
  }));
307
302
  });
308
303
  });
@@ -54,7 +54,7 @@ exports.IdentityAssertionSigner = exports.IdentityAssertionBuilder = void 0;
54
54
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
55
  // specific language governing permissions and limitations under
56
56
  // each license.
57
- const neon = __importStar(require("index.node"));
57
+ const neon = __importStar(require("./index.node"));
58
58
  class IdentityAssertionBuilder {
59
59
  constructor(_builder) {
60
60
  this._builder = _builder;
@@ -54,7 +54,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
54
54
  // specific language governing permissions and limitations under
55
55
  // each license.
56
56
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
57
- const index_1 = require("./index");
57
+ const Signer_1 = require("./Signer");
58
+ const Reader_1 = require("./Reader");
59
+ const Builder_1 = require("./Builder");
60
+ const IdentityAssertion_1 = require("./IdentityAssertion");
58
61
  const fs = __importStar(require("fs-extra"));
59
62
  const crypto = __importStar(require("crypto"));
60
63
  // TODO: move to a separate test file
@@ -65,73 +68,73 @@ class TestSigner {
65
68
  });
66
69
  this.privateKey = crypto.createPrivateKey({
67
70
  key: privateKey,
68
- format: 'pem',
71
+ format: "pem",
69
72
  });
70
73
  }
71
74
  }
72
- describe('IdentityAssertionBuilder', () => {
75
+ describe("IdentityAssertionBuilder", () => {
73
76
  const manifestDefinition = {
74
- vendor: 'test',
77
+ vendor: "test",
75
78
  claim_version: 2,
76
79
  claim_generator_info: [
77
80
  {
78
- name: 'c2pa_test',
79
- version: '2.0.0',
81
+ name: "c2pa_test",
82
+ version: "2.0.0",
80
83
  },
81
84
  ],
82
85
  metadata: [
83
86
  {
84
- dateTime: '1985-04-12T23:20:50.52Z',
85
- my_custom_metadata: 'my custom metatdata value',
87
+ dateTime: "1985-04-12T23:20:50.52Z",
88
+ my_custom_metadata: "my custom metatdata value",
86
89
  },
87
90
  ],
88
- title: 'Test_Manifest',
89
- format: 'image/jpeg',
90
- instance_id: '1234',
91
+ title: "Test_Manifest",
92
+ format: "image/jpeg",
93
+ instance_id: "1234",
91
94
  ingredients: [
92
95
  {
93
- title: 'Test',
94
- format: 'image/jpeg',
95
- instance_id: '12345',
96
- relationship: 'componentOf',
96
+ title: "Test",
97
+ format: "image/jpeg",
98
+ instance_id: "12345",
99
+ relationship: "componentOf",
97
100
  },
98
101
  ],
99
102
  assertions: [
100
103
  {
101
- label: 'c2pa.actions',
104
+ label: "c2pa.actions",
102
105
  data: {
103
106
  actions: [
104
107
  {
105
- action: 'c2pa.created',
106
- digitalSourceType: 'http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture',
108
+ action: "c2pa.created",
109
+ digitalSourceType: "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture",
107
110
  },
108
111
  ],
109
112
  },
110
113
  },
111
114
  {
112
- label: 'cawg.training-mining',
115
+ label: "cawg.training-mining",
113
116
  data: {
114
117
  entries: {
115
- 'cawg.ai_inference': {
116
- use: 'notAllowed',
118
+ "cawg.ai_inference": {
119
+ use: "notAllowed",
117
120
  },
118
- 'cawg.ai_generative_training': {
119
- use: 'notAllowed',
121
+ "cawg.ai_generative_training": {
122
+ use: "notAllowed",
120
123
  },
121
124
  },
122
125
  },
123
126
  },
124
127
  ],
125
128
  };
126
- it('should build an Identity Assertion Signer', () => __awaiter(void 0, void 0, void 0, function* () {
129
+ it("should build an Identity Assertion Signer", () => __awaiter(void 0, void 0, void 0, function* () {
127
130
  // Read certificate files once
128
- const c2paPrivateKey = yield fs.readFile('./tests/fixtures/certs/es256.pem');
129
- const c2paPublicKey = yield fs.readFile('./tests/fixtures/certs/es256.pub');
130
- const cawgPrivateKey = yield fs.readFile('./tests/fixtures/certs/ed25519.pem');
131
- const cawgPublicKey = yield fs.readFile('./tests/fixtures/certs/ed25519.pub');
131
+ const c2paPrivateKey = yield fs.readFile("./tests/fixtures/certs/es256.pem");
132
+ const c2paPublicKey = yield fs.readFile("./tests/fixtures/certs/es256.pub");
133
+ const cawgPrivateKey = yield fs.readFile("./tests/fixtures/certs/ed25519.pem");
134
+ const cawgPublicKey = yield fs.readFile("./tests/fixtures/certs/ed25519.pub");
132
135
  // Create signer configurations
133
136
  const c2paConfig = {
134
- alg: 'es256',
137
+ alg: "es256",
135
138
  certs: [c2paPublicKey],
136
139
  reserveSize: 10000,
137
140
  tsaUrl: undefined,
@@ -139,7 +142,7 @@ describe('IdentityAssertionBuilder', () => {
139
142
  tsaBody: undefined,
140
143
  };
141
144
  const cawgConfig = {
142
- alg: 'ed25519',
145
+ alg: "ed25519",
143
146
  certs: [cawgPublicKey],
144
147
  reserveSize: 10000,
145
148
  tsaUrl: undefined,
@@ -149,28 +152,28 @@ describe('IdentityAssertionBuilder', () => {
149
152
  // Create signers
150
153
  const c2paTestSigner = new TestSigner(c2paPrivateKey);
151
154
  const cawgTestSigner = new TestSigner(cawgPrivateKey);
152
- const c2paSigner = index_1.CallbackSigner.newSigner(c2paConfig, c2paTestSigner.sign);
153
- const cawgSigner = index_1.CallbackSigner.newSigner(cawgConfig, cawgTestSigner.sign);
155
+ const c2paSigner = Signer_1.CallbackSigner.newSigner(c2paConfig, c2paTestSigner.sign);
156
+ const cawgSigner = Signer_1.CallbackSigner.newSigner(cawgConfig, cawgTestSigner.sign);
154
157
  const source = {
155
- buffer: yield fs.readFile('./tests/fixtures/CA.jpg'),
156
- mimeType: 'jpeg',
158
+ buffer: yield fs.readFile("./tests/fixtures/CA.jpg"),
159
+ mimeType: "jpeg",
157
160
  };
158
161
  const dest = {
159
162
  buffer: null,
160
163
  };
161
164
  // Create the manifest builder
162
- const builder = index_1.Builder.withJson(manifestDefinition);
165
+ const builder = Builder_1.Builder.withJson(manifestDefinition);
163
166
  // Create and configure the identity assertion
164
- const ia_signer = index_1.IdentityAssertionSigner.new(c2paSigner);
165
- const iab = yield index_1.IdentityAssertionBuilder.identityBuilderForCredentialHolder(cawgSigner);
166
- iab.addReferencedAssertions(['cawg.training-mining']);
167
+ const ia_signer = IdentityAssertion_1.IdentityAssertionSigner.new(c2paSigner);
168
+ const iab = yield IdentityAssertion_1.IdentityAssertionBuilder.identityBuilderForCredentialHolder(cawgSigner);
169
+ iab.addReferencedAssertions(["cawg.training-mining"]);
167
170
  ia_signer.addIdentityAssertion(iab);
168
171
  // Sign the manifest
169
172
  yield builder.signAsync(c2paSigner, source, dest);
170
173
  // Verify the manifest
171
- const reader = yield index_1.Reader.fromAsset({
174
+ const reader = yield Reader_1.Reader.fromAsset({
172
175
  buffer: dest.buffer,
173
- mimeType: 'jpeg',
176
+ mimeType: "jpeg",
174
177
  });
175
178
  yield reader.postValidateCawg();
176
179
  }));
package/dist/Reader.js CHANGED
@@ -54,7 +54,7 @@ exports.Reader = void 0;
54
54
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
55
  // specific language governing permissions and limitations under
56
56
  // each license.
57
- const neon = __importStar(require("index.node"));
57
+ const neon = __importStar(require("./index.node"));
58
58
  class Reader {
59
59
  constructor(reader) {
60
60
  this.reader = reader;
@@ -56,7 +56,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
56
56
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
57
57
  // specific language governing permissions and limitations under
58
58
  // each license.
59
- const index_1 = require("./index");
59
+ const Reader_1 = require("./Reader");
60
60
  const path_1 = __importDefault(require("path"));
61
61
  const fs = __importStar(require("fs-extra"));
62
62
  const tempDir = path_1.default.join(__dirname, "tmp");
@@ -184,13 +184,18 @@ describe("Reader", () => {
184
184
  }));
185
185
  it("should read from an ArrayBuffer", () => __awaiter(void 0, void 0, void 0, function* () {
186
186
  const buffer = yield fs.readFile("./tests/fixtures/CAI.jpg");
187
- const reader = yield index_1.Reader.fromAsset({ buffer, mimeType: "jpeg" });
187
+ const reader = yield Reader_1.Reader.fromAsset({
188
+ buffer,
189
+ mimeType: "jpeg",
190
+ });
188
191
  const json = reader.json();
189
192
  expect(json.manifests).toEqual(manifestStore.manifests);
190
193
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
191
194
  }));
192
195
  it("should read from a file", () => __awaiter(void 0, void 0, void 0, function* () {
193
- const reader = yield index_1.Reader.fromAsset({ path: "./tests/fixtures/CAI.jpg" });
196
+ const reader = yield Reader_1.Reader.fromAsset({
197
+ path: "./tests/fixtures/CAI.jpg",
198
+ });
194
199
  const json = reader.json();
195
200
  expect(json.manifests).toEqual(manifestStore.manifests);
196
201
  expect(json.active_manifest).toEqual(manifestStore.active_manifest);
@@ -198,7 +203,7 @@ describe("Reader", () => {
198
203
  it("should read from manifest data and buffer", () => __awaiter(void 0, void 0, void 0, function* () {
199
204
  const manifestData = yield fs.readFile("./tests/fixtures/CAI/manifest_data.c2pa");
200
205
  const buffer = yield fs.readFile("./tests/fixtures/CAI.jpg");
201
- const reader = yield index_1.Reader.fromManifestDataAndAsset(manifestData, {
206
+ const reader = yield Reader_1.Reader.fromManifestDataAndAsset(manifestData, {
202
207
  buffer,
203
208
  mimeType: "jpeg",
204
209
  });
@@ -208,7 +213,7 @@ describe("Reader", () => {
208
213
  }));
209
214
  it("should read from manifest data and file", () => __awaiter(void 0, void 0, void 0, function* () {
210
215
  const manifestData = yield fs.readFile("./tests/fixtures/CAI/manifest_data.c2pa");
211
- const reader = yield index_1.Reader.fromManifestDataAndAsset(manifestData, {
216
+ const reader = yield Reader_1.Reader.fromManifestDataAndAsset(manifestData, {
212
217
  path: "./tests/fixtures/CAI.jpg",
213
218
  });
214
219
  const json = reader.json();
@@ -218,7 +223,9 @@ describe("Reader", () => {
218
223
  var _a;
219
224
  let bytesWritten = 0;
220
225
  const outputPath = path_1.default.join(tempDir, "thumbnail.jpg");
221
- const reader = yield index_1.Reader.fromAsset({ path: "./tests/fixtures/CAI.jpg" });
226
+ const reader = yield Reader_1.Reader.fromAsset({
227
+ path: "./tests/fixtures/CAI.jpg",
228
+ });
222
229
  const activeManifest = reader.getActive();
223
230
  const uri = (_a = activeManifest === null || activeManifest === void 0 ? void 0 : activeManifest.thumbnail) === null || _a === void 0 ? void 0 : _a.identifier;
224
231
  if (uri !== undefined) {
@@ -230,12 +237,14 @@ describe("Reader", () => {
230
237
  expect(fs.existsSync(outputPath));
231
238
  }));
232
239
  it("should report manifest is embedded", () => __awaiter(void 0, void 0, void 0, function* () {
233
- const reader = yield index_1.Reader.fromAsset({ path: "./tests/fixtures/CAI.jpg" });
240
+ const reader = yield Reader_1.Reader.fromAsset({
241
+ path: "./tests/fixtures/CAI.jpg",
242
+ });
234
243
  expect(reader.remoteUrl()).toEqual("");
235
244
  expect(reader.isEmbedded()).toBeTruthy();
236
245
  }));
237
246
  it("should report manifest is not embedded", () => __awaiter(void 0, void 0, void 0, function* () {
238
- const reader = yield index_1.Reader.fromAsset({
247
+ const reader = yield Reader_1.Reader.fromAsset({
239
248
  path: "./tests/fixtures/cloud.jpg",
240
249
  });
241
250
  expect(reader.remoteUrl()).toEqual("https://cai-manifests.adobe.com/manifests/adobe-urn-uuid-5f37e182-3687-462e-a7fb-573462780391");
package/dist/Signer.js CHANGED
@@ -54,7 +54,7 @@ exports.CallbackSigner = exports.LocalSigner = void 0;
54
54
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
55
  // specific language governing permissions and limitations under
56
56
  // each license.
57
- const neon = __importStar(require("index.node"));
57
+ const neon = __importStar(require("./index.node"));
58
58
  class LocalSigner {
59
59
  constructor(localSigner) {
60
60
  this.localSigner = localSigner;
@@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
54
54
  // specific language governing permissions and limitations under
55
55
  // each license.
56
- const index_1 = require("./index");
56
+ const Signer_1 = require("./Signer");
57
57
  const fs = __importStar(require("fs-extra"));
58
58
  const crypto = __importStar(require("crypto"));
59
59
  class TestSigner {
@@ -89,32 +89,32 @@ describe("CallbackSigner", () => {
89
89
  tsaBody: Buffer.from('{"test": "body"}'),
90
90
  };
91
91
  it("should create a new instance", () => {
92
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
92
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
93
93
  expect(signer).toBeDefined();
94
94
  });
95
95
  it("should sign data", () => __awaiter(void 0, void 0, void 0, function* () {
96
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
96
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
97
97
  const data = Buffer.from("test data");
98
98
  const signature = yield signer.sign(data);
99
99
  expect(signature).toBeDefined();
100
100
  }));
101
101
  it("should get algorithm", () => {
102
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
102
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
103
103
  const alg = signer.alg();
104
104
  expect(alg).toBe("es256");
105
105
  });
106
106
  it("should return certificates", () => {
107
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
107
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
108
108
  const certs = signer.certs();
109
109
  expect(Array.isArray(certs)).toBe(true);
110
110
  expect(certs.length).toBeGreaterThan(0);
111
111
  });
112
112
  it("should return reserve size", () => {
113
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
113
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
114
114
  expect(signer.reserveSize()).toBe(10000);
115
115
  });
116
116
  it("should return time authority URL when provided", () => {
117
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
117
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
118
118
  expect(signer.timeAuthorityUrl()).toBe("https://timestamp.digicert.com");
119
119
  });
120
120
  it("should return undefined for time authority URL when not provided", () => __awaiter(void 0, void 0, void 0, function* () {
@@ -126,7 +126,7 @@ describe("CallbackSigner", () => {
126
126
  tsaHeaders: undefined,
127
127
  tsaBody: undefined,
128
128
  };
129
- const signer = index_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
129
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
130
130
  expect(signer.timeAuthorityUrl()).toBeUndefined();
131
131
  }));
132
132
  });
package/dist/Trustmark.js CHANGED
@@ -54,7 +54,8 @@ exports.Trustmark = void 0;
54
54
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
55
  // specific language governing permissions and limitations under
56
56
  // each license.
57
- const neon = __importStar(require("index.node"));
57
+ //const neon = require("../index.node");
58
+ const neon = __importStar(require("./index.node"));
58
59
  class Trustmark {
59
60
  constructor(trustmark) {
60
61
  this.trustmark = trustmark;
@@ -56,7 +56,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
56
56
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
57
57
  // specific language governing permissions and limitations under
58
58
  // each license.
59
- const index_1 = require("./index");
59
+ const Trustmark_1 = require("./Trustmark");
60
60
  const path_1 = __importDefault(require("path"));
61
61
  const fs = __importStar(require("fs-extra"));
62
62
  const sharp_1 = __importDefault(require("sharp"));
@@ -100,7 +100,7 @@ describe("Trustmark", () => {
100
100
  beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
101
101
  // Note: In a real test environment, you would need a valid model file
102
102
  // For now, we'll mock the trustmark creation or handle the case where model doesn't exist
103
- trustmark = yield index_1.Trustmark.newTrustmark(trustmarkConfig);
103
+ trustmark = yield Trustmark_1.Trustmark.newTrustmark(trustmarkConfig);
104
104
  }));
105
105
  describe("newTrustmark", () => {
106
106
  it("should create a new trustmark instance with valid config", () => __awaiter(void 0, void 0, void 0, function* () {
@@ -114,7 +114,7 @@ describe("Trustmark", () => {
114
114
  variant: "X", // Invalid variant
115
115
  version: "BCH_3", // Valid version
116
116
  };
117
- yield expect(index_1.Trustmark.newTrustmark(invalidConfig)).rejects.toThrow("Watermark configuration error: invalid variant");
117
+ yield expect(Trustmark_1.Trustmark.newTrustmark(invalidConfig)).rejects.toThrow("Watermark configuration error: invalid variant");
118
118
  }));
119
119
  });
120
120
  describe("encode", () => {
package/dist/index.js CHANGED
@@ -4,29 +4,8 @@
4
4
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
5
  // or the MIT license (http://opensource.org/licenses/MIT),
6
6
  // 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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
7
  Object.defineProperty(exports, "__esModule", { value: true });
22
8
  exports.Trustmark = exports.IdentityAssertionSigner = exports.IdentityAssertionBuilder = exports.CallbackSigner = exports.LocalSigner = exports.Reader = exports.Builder = void 0;
23
- // Unless required by applicable law or agreed to in writing,
24
- // this software is distributed on an "AS IS" BASIS, WITHOUT
25
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
26
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
27
- // specific language governing permissions and limitations under
28
- // each license.
29
- __exportStar(require("index.node"), exports);
30
9
  var Builder_1 = require("./Builder");
31
10
  Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return Builder_1.Builder; } });
32
11
  var Reader_1 = require("./Reader");
package/dist/index.node CHANGED
Binary file
@@ -1,22 +1,22 @@
1
- import * as neon from "./types";
2
- import { CallbackSigner, IdentityAssertionSigner, LocalSigner } from './index';
3
- export declare class Builder implements neon.Builder {
1
+ import { IdentityAssertionSigner } from "./IdentityAssertion";
2
+ import type { BuilderInterface, CallbackSignerInterface, ClaimVersion, DestinationAsset, JsCallbackSignerConfig, LocalSignerInterface, ManifestAssertionKind, ManifestDefinition, SourceAsset } from "./types";
3
+ export declare class Builder implements BuilderInterface {
4
4
  private builder;
5
5
  private constructor();
6
6
  static new(): Builder;
7
- static withJson(json: neon.ManifestDefinition): Builder;
7
+ static withJson(json: ManifestDefinition): Builder;
8
8
  setNoEmbed(noEmbed?: boolean): void;
9
9
  setRemoteUrl(remoteUrl: string): void;
10
- addAssertion(label: string, assertion: string, assertionKind?: neon.ManifestAssertionKind): void;
11
- addResource(uri: string, resource: neon.SourceAsset): Promise<void>;
12
- addIngredient(ingredientJson: string, ingredient: neon.SourceAsset): Promise<void>;
13
- toArchive(asset: neon.DestinationAsset): Promise<void>;
14
- static fromArchive(asset: neon.SourceAsset): Promise<Builder>;
15
- sign(signer: LocalSigner, input: neon.SourceAsset, output: neon.DestinationAsset): Buffer;
16
- signFile(signer: LocalSigner, filePath: string, output: neon.DestinationAsset): Buffer;
17
- signConfigAsync(callback: (data: Buffer) => Promise<Buffer>, signerConfig: neon.JsCallbackSignerConfig, input: neon.SourceAsset, output: neon.DestinationAsset): Promise<Buffer>;
18
- signAsync(signer: CallbackSigner, input: neon.SourceAsset, output: neon.DestinationAsset): Promise<Buffer>;
19
- identitySignAsync(signer: IdentityAssertionSigner, input: neon.SourceAsset, output: neon.DestinationAsset): Promise<Buffer>;
20
- getManifestDefinition(): neon.ManifestDefinition;
21
- updateManifestProperty(property: string, value: neon.ClaimVersion): void;
10
+ addAssertion(label: string, assertion: string, assertionKind?: ManifestAssertionKind): void;
11
+ addResource(uri: string, resource: SourceAsset): Promise<void>;
12
+ addIngredient(ingredientJson: string, ingredient: SourceAsset): Promise<void>;
13
+ toArchive(asset: DestinationAsset): Promise<void>;
14
+ static fromArchive(asset: SourceAsset): Promise<Builder>;
15
+ sign(signer: LocalSignerInterface, input: SourceAsset, output: DestinationAsset): Buffer;
16
+ signFile(signer: LocalSignerInterface, filePath: string, output: DestinationAsset): Buffer;
17
+ signConfigAsync(callback: (data: Buffer) => Promise<Buffer>, signerConfig: JsCallbackSignerConfig, input: SourceAsset, output: DestinationAsset): Promise<Buffer>;
18
+ signAsync(signer: CallbackSignerInterface, input: SourceAsset, output: DestinationAsset): Promise<Buffer>;
19
+ identitySignAsync(signer: IdentityAssertionSigner, input: SourceAsset, output: DestinationAsset): Promise<Buffer>;
20
+ getManifestDefinition(): ManifestDefinition;
21
+ updateManifestProperty(property: string, value: ClaimVersion): void;
22
22
  }
@@ -1,17 +1,16 @@
1
- import * as neon from "./types";
2
- import { CallbackSigner } from './index';
3
- export declare class IdentityAssertionBuilder implements neon.IdentityAssertionBuilder {
1
+ import type { CallbackSignerInterface, IdentityAssertionBuilderInterface, IdentityAssertionSignerInterface } from "./types";
2
+ export declare class IdentityAssertionBuilder implements IdentityAssertionBuilderInterface {
4
3
  private _builder;
5
4
  private constructor();
6
- static identityBuilderForCredentialHolder(credentialHolder: CallbackSigner): Promise<IdentityAssertionBuilder>;
5
+ static identityBuilderForCredentialHolder(credentialHolder: CallbackSignerInterface): Promise<IdentityAssertionBuilder>;
7
6
  addReferencedAssertions(referencedAssertions: string[]): void;
8
7
  addRoles(roles: string[]): void;
9
- builder(): neon.IdentityAssertionBuilder;
8
+ builder(): IdentityAssertionBuilderInterface;
10
9
  }
11
- export declare class IdentityAssertionSigner implements neon.IdentityAssertionSigner {
10
+ export declare class IdentityAssertionSigner implements IdentityAssertionSignerInterface {
12
11
  private _signer;
13
12
  private constructor();
14
- static new(signer: CallbackSigner): IdentityAssertionSigner;
13
+ static new(signer: CallbackSignerInterface): IdentityAssertionSigner;
15
14
  addIdentityAssertion(identityAssertionBuilder: IdentityAssertionBuilder): void;
16
- signer(): neon.IdentityAssertionSigner;
15
+ signer(): IdentityAssertionSignerInterface;
17
16
  }
@@ -1,14 +1,14 @@
1
- import * as neon from "./types";
2
- export declare class Reader implements neon.Reader {
1
+ import type { DestinationAsset, Manifest, ManifestStore, ReaderInterface, SourceAsset } from "./types";
2
+ export declare class Reader implements ReaderInterface {
3
3
  private reader;
4
4
  private constructor();
5
- json(): neon.ManifestStore;
5
+ json(): ManifestStore;
6
6
  remoteUrl(): string;
7
7
  isEmbedded(): boolean;
8
- resourceToAsset(uri: string, asset: neon.DestinationAsset): Promise<number>;
9
- static fromAsset(asset: neon.SourceAsset): Promise<Reader>;
10
- static fromManifestDataAndAsset(manifestData: Buffer, asset: neon.SourceAsset): Promise<Reader>;
8
+ resourceToAsset(uri: string, asset: DestinationAsset): Promise<number>;
9
+ static fromAsset(asset: SourceAsset): Promise<Reader>;
10
+ static fromManifestDataAndAsset(manifestData: Buffer, asset: SourceAsset): Promise<Reader>;
11
11
  activeLabel(): string | undefined;
12
- getActive(): neon.Manifest | undefined;
12
+ getActive(): Manifest | undefined;
13
13
  postValidateCawg(): Promise<void>;
14
14
  }
@@ -1,22 +1,22 @@
1
- import * as neon from "./types";
2
- export declare class LocalSigner implements neon.LocalSigner {
1
+ import type { LocalSignerInterface, CallbackSignerInterface, SigningAlg, JsCallbackSignerConfig } from "./types";
2
+ export declare class LocalSigner implements LocalSignerInterface {
3
3
  private localSigner;
4
4
  private constructor();
5
- static newSigner(certificate: Buffer, privateKey: Buffer, algorithm: neon.SigningAlg, tsaUrl?: string): LocalSigner;
5
+ static newSigner(certificate: Buffer, privateKey: Buffer, algorithm: SigningAlg, tsaUrl?: string): LocalSigner;
6
6
  sign(data: Buffer): Buffer;
7
- alg(): neon.SigningAlg;
7
+ alg(): SigningAlg;
8
8
  certs(): Array<Buffer>;
9
9
  reserveSize(): number;
10
10
  timeAuthorityUrl(): string | undefined;
11
- signer(): neon.LocalSigner;
11
+ signer(): LocalSignerInterface;
12
12
  }
13
- export declare class CallbackSigner implements neon.CallbackSigner {
13
+ export declare class CallbackSigner implements CallbackSignerInterface {
14
14
  private callbackSigner;
15
15
  private constructor();
16
- signer(): neon.CallbackSigner;
17
- static newSigner(config: neon.JsCallbackSignerConfig, callback: (data: Buffer) => Promise<Buffer>): CallbackSigner;
16
+ signer(): CallbackSignerInterface;
17
+ static newSigner(config: JsCallbackSignerConfig, callback: (data: Buffer) => Promise<Buffer>): CallbackSigner;
18
18
  sign(data: Buffer): Promise<Buffer>;
19
- alg(): neon.SigningAlg;
19
+ alg(): SigningAlg;
20
20
  certs(): Array<Buffer>;
21
21
  reserveSize(): number;
22
22
  timeAuthorityUrl(): string | undefined;
@@ -1,8 +1,8 @@
1
- import * as neon from "./types";
2
- export declare class Trustmark implements neon.Trustmark {
1
+ import type { TrustmarkInterface as TrustmarkInterface, TrustmarkConfig } from "./types";
2
+ export declare class Trustmark implements TrustmarkInterface {
3
3
  private trustmark;
4
4
  private constructor();
5
- static newTrustmark(config: neon.TrustmarkConfig): Promise<Trustmark>;
5
+ static newTrustmark(config: TrustmarkConfig): Promise<Trustmark>;
6
6
  encode(image: Buffer, strength: number, watermark?: string): Promise<Buffer>;
7
7
  decode(image: Buffer): Promise<string>;
8
8
  }
@@ -1,4 +1,4 @@
1
- export * from "./types";
1
+ export type * from "./types";
2
2
  export { Builder } from "./Builder";
3
3
  export { Reader } from "./Reader";
4
4
  export { LocalSigner, CallbackSigner } from "./Signer";
@@ -521,25 +521,25 @@ export type DestinationAsset = DestinationBufferAsset | FileAsset;
521
521
  /**
522
522
  * A signer that uses a local certificate and private key to sign data
523
523
  */
524
- export interface LocalSigner {
524
+ export interface LocalSignerInterface {
525
525
  sign(data: Buffer): Buffer;
526
526
  alg(): SigningAlg;
527
527
  certs(): Array<Buffer>;
528
528
  reserveSize(): number;
529
529
  timeAuthorityUrl(): string | undefined;
530
- signer(): LocalSigner;
530
+ signer(): LocalSignerInterface;
531
531
  }
532
532
 
533
533
  /**
534
534
  * A signer that uses a callback to sign data.
535
535
  */
536
- export interface CallbackSigner {
536
+ export interface CallbackSignerInterface {
537
537
  sign(data: Buffer): Promise<Buffer>;
538
538
  alg(): SigningAlg;
539
539
  certs(): Array<Buffer>;
540
540
  reserveSize(): number;
541
541
  timeAuthorityUrl(): string | undefined;
542
- signer(): CallbackSigner;
542
+ signer(): CallbackSignerInterface;
543
543
  }
544
544
 
545
545
  /**
@@ -561,7 +561,7 @@ export interface JsCallbackSignerConfig {
561
561
  tsaBody?: Buffer;
562
562
  }
563
563
 
564
- export interface Builder {
564
+ export interface BuilderInterface {
565
565
  /**
566
566
  * Set the no embed flag of the manifest
567
567
  * @param noEmbed The no embed flag of the manifest
@@ -594,10 +594,7 @@ export interface Builder {
594
594
  * @param ingredientJson The JSON representation of the ingredient
595
595
  * @param ingredient The source and format of the ingredient
596
596
  */
597
- addIngredient(
598
- ingredientJson: string,
599
- ingredient: SourceAsset,
600
- ): Promise<void>;
597
+ addIngredient(ingredientJson: string, ingredient: SourceAsset): Promise<void>;
601
598
 
602
599
  /**
603
600
  * Convert the Builder into a archive formatted buffer or file
@@ -613,7 +610,7 @@ export interface Builder {
613
610
  * @returns the bytes of the c2pa_manifest that was embedded
614
611
  */
615
612
  sign(
616
- signer: LocalSigner,
613
+ signer: LocalSignerInterface,
617
614
  input: SourceAsset,
618
615
  output: DestinationAsset,
619
616
  ): Buffer;
@@ -643,7 +640,7 @@ export interface Builder {
643
640
  * @returns the bytes of the c2pa_manifest that was embedded
644
641
  */
645
642
  signAsync(
646
- callbackSigner: CallbackSigner,
643
+ callbackSigner: CallbackSignerInterface,
647
644
  input: SourceAsset,
648
645
  output: DestinationAsset,
649
646
  ): Promise<Buffer>;
@@ -656,7 +653,7 @@ export interface Builder {
656
653
  * @returns the bytes of the c2pa_manifest that was embedded
657
654
  */
658
655
  signFile(
659
- signer: LocalSigner,
656
+ signer: LocalSignerInterface,
660
657
  filePath: string,
661
658
  output: DestinationAsset,
662
659
  ): Buffer;
@@ -670,7 +667,7 @@ export interface Builder {
670
667
  * @returns the bytes of the c2pa_manifest that was embedded
671
668
  */
672
669
  identitySignAsync(
673
- callbackSigner: IdentityAssertionSigner,
670
+ callbackSigner: IdentityAssertionSignerInterface,
674
671
  input: SourceAsset,
675
672
  output: DestinationAsset,
676
673
  ): Promise<Buffer>;
@@ -685,13 +682,10 @@ export interface Builder {
685
682
  * Update a string property of the manifest
686
683
  * @returns The manifest definition
687
684
  */
688
- updateManifestProperty(
689
- property: string,
690
- value: string | ClaimVersion,
691
- ): void;
685
+ updateManifestProperty(property: string, value: string | ClaimVersion): void;
692
686
  }
693
687
 
694
- export interface Reader {
688
+ export interface ReaderInterface {
695
689
  /**
696
690
  * Get the JSON representation of the manifest
697
691
  */
@@ -720,7 +714,7 @@ export interface Reader {
720
714
  postValidateCawg(): Promise<void>;
721
715
  }
722
716
 
723
- export interface IdentityAssertionSigner {
717
+ export interface IdentityAssertionSignerInterface {
724
718
  /** Add a IdentityAssertionBuilder to be used when signing the
725
719
  * next Manifest
726
720
  *
@@ -728,11 +722,11 @@ export interface IdentityAssertionSigner {
728
722
  * IdentityAssertionBuilders will be cleared.
729
723
  */
730
724
  addIdentityAssertion(
731
- identityAssertionBuilder: IdentityAssertionBuilder,
725
+ identityAssertionBuilder: IdentityAssertionBuilderInterface,
732
726
  ): void;
733
727
  }
734
728
 
735
- export interface IdentityAssertionBuilder {
729
+ export interface IdentityAssertionBuilderInterface {
736
730
  /**
737
731
  * Add assertion labels to consider as referenced_assertions.
738
732
  * If any of these labels match assertions that are present in the partial
@@ -750,10 +744,10 @@ export interface IdentityAssertionBuilder {
750
744
  /**
751
745
  * Get the underlying IdentityAssertionBuilder
752
746
  */
753
- builder(): IdentityAssertionBuilder;
747
+ builder(): IdentityAssertionBuilderInterface;
754
748
  }
755
749
 
756
- export interface Trustmark {
750
+ export interface TrustmarkInterface {
757
751
  /**
758
752
  * Encode a watermark into an image.
759
753
  * @param image image to be watermarked
@@ -761,11 +755,7 @@ export interface Trustmark {
761
755
  * @param watermark optional bitstring to be encoded, automatically generated if not provided
762
756
  * @returns raw pixel data in RGB8 format (width * height * 3 bytes)
763
757
  */
764
- encode(
765
- image: Buffer,
766
- strength: number,
767
- watermark?: string,
768
- ): Promise<Buffer>;
758
+ encode(image: Buffer, strength: number, watermark?: string): Promise<Buffer>;
769
759
 
770
760
  /**
771
761
  * Decode a watermark from an image.
@@ -779,115 +769,3 @@ export interface TrustmarkConfig {
779
769
  version: TrustmarkVersion;
780
770
  modelPath?: string;
781
771
  }
782
-
783
- // Builder methods
784
- export function builderNew(): Builder;
785
- export function builderWithJson(json: string): Builder;
786
- export function builderSetNoEmbed(noEmbed: boolean): void;
787
- export function builderSetRemoteUrl(url: string): void;
788
- export function builderAddAssertion(
789
- label: string,
790
- assertion: string,
791
- assertionKind?: ManifestAssertionKind,
792
- ): void;
793
- export function builderAddResource(
794
- uri: string,
795
- resource: SourceAsset,
796
- ): Promise<void>;
797
- export function builderAddIngredient(
798
- ingredientJson: string,
799
- resource: SourceAsset,
800
- ): Promise<void>;
801
- export function builderToArchive(asset: DestinationAsset): Promise<void>;
802
- export function builderFromArchive(asset: SourceAsset): Promise<Builder>;
803
- export function builderSign(
804
- signer: LocalSigner,
805
- input: SourceAsset,
806
- output: DestinationAsset,
807
- ): Buffer;
808
- export function builderSignConfigAsync(
809
- callback: (data: Buffer) => Promise<Buffer>,
810
- signerConfig: JsCallbackSignerConfig,
811
- input: SourceAsset,
812
- output: DestinationAsset,
813
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
814
- export function builderSignAsync(
815
- signer: CallbackSigner,
816
- input: SourceAsset,
817
- output: DestinationAsset,
818
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
819
- export function builderIdentitySignAsync(
820
- signer: IdentityAssertionSigner,
821
- input: SourceAsset,
822
- output: DestinationAsset,
823
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
824
- export function builderManifestDefinition(): string;
825
- export function builderUpdateManifestProperty(
826
- property: string,
827
- value: string | ClaimVersion,
828
- ): void;
829
-
830
- // Reader methods
831
- export function readerFromAsset(asset: SourceAsset): Promise<Reader>;
832
- export function readerFromManifestDataAndAsset(
833
- manifestData: Buffer,
834
- asset: SourceAsset,
835
- ): Promise<Reader>;
836
- export function readerJson(): string;
837
- export function readerRemoteUrl(): string;
838
- export function readerIsEmbedded(): boolean;
839
- export function readerResourceToAsset(
840
- uri: string,
841
- output: DestinationAsset,
842
- ): Promise<number>;
843
- export function readerPostValidateCawg(): Promise<void>;
844
-
845
- // Signers
846
- export function localSignerNew(
847
- signcert: Buffer,
848
- pkey: Buffer,
849
- signingAlg: SigningAlg,
850
- tsaUrl?: string,
851
- ): LocalSigner;
852
- export function localSignerSign(data: Buffer): Buffer;
853
- export function localSignerAlg(): SigningAlg;
854
- export function localSignerCerts(): Array<Buffer>;
855
- export function localSignerReserveSize(): number;
856
- export function localSignerTimeAuthorityUrl(): string | undefined;
857
-
858
- export function callbackSignerFromConfig(
859
- config: CallbackSignerConfig,
860
- callback: (data: Buffer) => Promise<Buffer>,
861
- ): CallbackSigner;
862
- export function callbackSignerConfigFromJs(
863
- config: JsCallbackSignerConfig,
864
- ): CallbackSignerConfig;
865
- export function callbackSignerSign(data: Buffer): Promise<Buffer>;
866
- export function callbackSignerAlg(): SigningAlg;
867
- export function callbackSignerCerts(): Array<Buffer>;
868
- export function callbackSignerReserveSize(): number;
869
- export function callbackSignerTimeAuthorityUrl(): string | undefined;
870
-
871
- // CAWG Identity
872
- export function identitySignerNew(
873
- signer: CallbackSigner,
874
- ): IdentityAssertionSigner;
875
- export function identitySignerAddIdentityAssertion(
876
- identityAssertionBuilder: IdentityAssertionBuilder,
877
- ): void;
878
- export function identityBuilderForCredentialHolder(
879
- credentialHolder: CallbackSigner,
880
- ): IdentityAssertionBuilder;
881
- export function identityBuilderAddReferencedAssertions(
882
- referenced_assertions: Array<string>,
883
- ): void;
884
- export function identityBuilderAddRoles(roles: Array<string>): void;
885
-
886
- // Trustmark
887
- export function trustmarkNew(config: TrustmarkConfig): Promise<Trustmark>;
888
- export function trustmarkEncode(
889
- image: Buffer,
890
- strength: number,
891
- watermark?: string,
892
- ): Promise<Buffer>;
893
- export function trustmarkDecode(image: Buffer): Promise<string>;
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.2",
7
+ "version": "0.1.3",
8
8
  "description": "Node.js bindings for C2PA",
9
9
  "main": "dist/index.js",
10
10
  "types": "dist/types/index.d.ts",
@@ -49,12 +49,12 @@
49
49
  "debug": "^4.4.1"
50
50
  },
51
51
  "scripts": {
52
- "build": "run-s build:rust build:ts build:docs",
52
+ "build": "run-s build:rust build:ts",
53
53
  "build:debug": "run-s build:rust-debug build:ts",
54
54
  "build:docs": "rimraf docs && typedoc --plugin typedoc-plugin-markdown --readme none --out docs js-src/index.ts",
55
55
  "build:rust": "pnpm run build:rust-debug --release",
56
56
  "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 && node scripts/fix-types.js",
57
+ "build:ts": "tsc -b && cpy index.node dist && cpy --flat js-src/types.d.ts dist/types",
58
58
  "changeset:publish": "changeset publish",
59
59
  "ci": "run-s build:rust-debug build:ts test",
60
60
  "clean": "rimraf dist generated target",
@@ -1,16 +0,0 @@
1
- // Copyright 2024 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
-
7
- // Unless required by applicable law or agreed to in writing,
8
- // this software is distributed on an "AS IS" BASIS, WITHOUT
9
- // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10
- // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11
- // specific language governing permissions and limitations under
12
- // each license.
13
-
14
- // This file provides type declarations for the native index.node module
15
- // It re-exports all types from the types file
16
- export * from "./types";