@contentauth/c2pa-node 0.1.0 → 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.
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ // Copyright 2024 Adobe. All rights reserved.
3
+ // This file is licensed to you under the Apache License,
4
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
+ // or the MIT license (http://opensource.org/licenses/MIT),
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 __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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ // Unless required by applicable law or agreed to in writing,
51
+ // this software is distributed on an "AS IS" BASIS, WITHOUT
52
+ // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
53
+ // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
54
+ // specific language governing permissions and limitations under
55
+ // each license.
56
+ const Signer_1 = require("./Signer");
57
+ const fs = __importStar(require("fs-extra"));
58
+ const crypto = __importStar(require("crypto"));
59
+ class TestSigner {
60
+ constructor(privateKey) {
61
+ this.sign = (bytes) => __awaiter(this, void 0, void 0, function* () {
62
+ const sign = crypto.createSign("SHA256");
63
+ sign.update(bytes);
64
+ sign.end();
65
+ const signature = sign.sign(this.privateKey);
66
+ return signature;
67
+ });
68
+ this.privateKey = crypto.createPrivateKey({
69
+ key: privateKey,
70
+ format: "pem",
71
+ });
72
+ }
73
+ }
74
+ describe("TestSigner", () => {
75
+ it("should sign data", () => __awaiter(void 0, void 0, void 0, function* () {
76
+ const signer = new TestSigner(yield fs.readFile("./tests/fixtures/certs/es256.pem"));
77
+ const bytes = Buffer.from("Hello, World!");
78
+ const signature = yield signer.sign(bytes);
79
+ expect(signature.length).toBeGreaterThan(0);
80
+ }));
81
+ });
82
+ describe("CallbackSigner", () => {
83
+ const config = {
84
+ alg: "es256",
85
+ certs: [fs.readFileSync("./tests/fixtures/certs/es256.pub")],
86
+ reserveSize: 10000,
87
+ tsaUrl: "https://timestamp.digicert.com",
88
+ tsaHeaders: [["Content-Type", "application/json"]],
89
+ tsaBody: Buffer.from('{"test": "body"}'),
90
+ };
91
+ 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; }));
93
+ expect(signer).toBeDefined();
94
+ });
95
+ 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; }));
97
+ const data = Buffer.from("test data");
98
+ const signature = yield signer.sign(data);
99
+ expect(signature).toBeDefined();
100
+ }));
101
+ it("should get algorithm", () => {
102
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
103
+ const alg = signer.alg();
104
+ expect(alg).toBe("es256");
105
+ });
106
+ it("should return certificates", () => {
107
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
108
+ const certs = signer.certs();
109
+ expect(Array.isArray(certs)).toBe(true);
110
+ expect(certs.length).toBeGreaterThan(0);
111
+ });
112
+ it("should return reserve size", () => {
113
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
114
+ expect(signer.reserveSize()).toBe(10000);
115
+ });
116
+ 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; }));
118
+ expect(signer.timeAuthorityUrl()).toBe("https://timestamp.digicert.com");
119
+ });
120
+ it("should return undefined for time authority URL when not provided", () => __awaiter(void 0, void 0, void 0, function* () {
121
+ const config = {
122
+ alg: "es256",
123
+ certs: [yield fs.readFile("./tests/fixtures/certs/es256.pub")],
124
+ reserveSize: 10000,
125
+ tsaUrl: undefined,
126
+ tsaHeaders: undefined,
127
+ tsaBody: undefined,
128
+ };
129
+ const signer = Signer_1.CallbackSigner.newSigner(config, (data) => __awaiter(void 0, void 0, void 0, function* () { return data; }));
130
+ expect(signer.timeAuthorityUrl()).toBeUndefined();
131
+ }));
132
+ });
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ // Copyright 2025 Adobe. All rights reserved.
3
+ // This file is licensed to you under the Apache License,
4
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
+ // or the MIT license (http://opensource.org/licenses/MIT),
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 __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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.Trustmark = void 0;
51
+ // Unless required by applicable law or agreed to in writing,
52
+ // this software is distributed on an "AS IS" BASIS, WITHOUT
53
+ // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
54
+ // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
55
+ // specific language governing permissions and limitations under
56
+ // each license.
57
+ //const neon = require("../index.node");
58
+ const neon = __importStar(require("./index.node"));
59
+ class Trustmark {
60
+ constructor(trustmark) {
61
+ this.trustmark = trustmark;
62
+ }
63
+ static newTrustmark(config) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const trustmark = yield neon.trustmarkNew(config);
66
+ return new Trustmark(trustmark);
67
+ });
68
+ }
69
+ encode(image, strength, watermark) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ return neon.trustmarkEncode.call(this.trustmark, image, strength, watermark);
72
+ });
73
+ }
74
+ decode(image) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ return neon.trustmarkDecode.call(this.trustmark, image);
77
+ });
78
+ }
79
+ }
80
+ exports.Trustmark = Trustmark;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ // Copyright 2024 Adobe. All rights reserved.
3
+ // This file is licensed to you under the Apache License,
4
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
+ // or the MIT license (http://opensource.org/licenses/MIT),
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 __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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
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
+ const Trustmark_1 = require("./Trustmark");
60
+ const path_1 = __importDefault(require("path"));
61
+ const fs = __importStar(require("fs-extra"));
62
+ const sharp_1 = __importDefault(require("sharp"));
63
+ const tempDir = path_1.default.join(__dirname, "..", "tmp");
64
+ // Helper function to convert raw RGB pixel data to JPEG format
65
+ function rawRgbToJpeg(rawRgbData, width, height) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ // Create a sharp image from raw RGB data
68
+ const image = (0, sharp_1.default)(rawRgbData, {
69
+ raw: {
70
+ width,
71
+ height,
72
+ channels: 3, // RGB
73
+ },
74
+ });
75
+ // Convert to JPEG format
76
+ return yield image.jpeg().toBuffer();
77
+ });
78
+ }
79
+ describe("Trustmark", () => {
80
+ let trustmark;
81
+ let testImage;
82
+ let testImageWidth;
83
+ let testImageHeight;
84
+ const trustmarkConfig = {
85
+ variant: "B", // Original Trustmark model
86
+ version: "BCH_3", // Tolerates 3 bit flips
87
+ modelPath: path_1.default.join(tempDir, "trustmark_models"), // Use temporary directory for model path
88
+ };
89
+ beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
90
+ yield fs.ensureDir(tempDir);
91
+ // Use an actual test image from fixtures directory
92
+ testImage = yield fs.readFile("./tests/fixtures/A.jpg");
93
+ // Get image dimensions for converting raw pixel data
94
+ const imageInfo = yield (0, sharp_1.default)(testImage).metadata();
95
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
+ testImageWidth = imageInfo.width;
97
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
98
+ testImageHeight = imageInfo.height;
99
+ }));
100
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
101
+ // Note: In a real test environment, you would need a valid model file
102
+ // For now, we'll mock the trustmark creation or handle the case where model doesn't exist
103
+ trustmark = yield Trustmark_1.Trustmark.newTrustmark(trustmarkConfig);
104
+ }));
105
+ describe("newTrustmark", () => {
106
+ it("should create a new trustmark instance with valid config", () => __awaiter(void 0, void 0, void 0, function* () {
107
+ // This test will be skipped if the model file doesn't exist
108
+ expect(trustmark).toBeDefined();
109
+ expect(typeof trustmark.encode).toBe("function");
110
+ expect(typeof trustmark.decode).toBe("function");
111
+ }));
112
+ it("should throw error with invalid config", () => __awaiter(void 0, void 0, void 0, function* () {
113
+ const invalidConfig = {
114
+ variant: "X", // Invalid variant
115
+ version: "BCH_3", // Valid version
116
+ };
117
+ yield expect(Trustmark_1.Trustmark.newTrustmark(invalidConfig)).rejects.toThrow("Watermark configuration error: invalid variant");
118
+ }));
119
+ });
120
+ describe("encode", () => {
121
+ it("should encode a watermark into an image with default watermark", () => __awaiter(void 0, void 0, void 0, function* () {
122
+ const strength = 0.9;
123
+ const encodedImage = yield trustmark.encode(testImage, strength);
124
+ expect(encodedImage).toBeDefined();
125
+ expect(Buffer.isBuffer(encodedImage)).toBe(true);
126
+ expect(encodedImage.length).toBeGreaterThan(0);
127
+ // The encoded image should be different from the original
128
+ expect(encodedImage).not.toEqual(testImage);
129
+ }));
130
+ it("should encode a watermark into an image with custom watermark", () => __awaiter(void 0, void 0, void 0, function* () {
131
+ const strength = 0.95;
132
+ const customWatermark = "0101000011001";
133
+ const encodedImage = yield trustmark.encode(testImage, strength, customWatermark);
134
+ expect(encodedImage).toBeDefined();
135
+ expect(Buffer.isBuffer(encodedImage)).toBe(true);
136
+ expect(encodedImage.length).toBeGreaterThan(0);
137
+ }));
138
+ it("should throw error with invalid strength values", () => __awaiter(void 0, void 0, void 0, function* () {
139
+ yield expect(trustmark.encode(testImage, -0.1)).rejects.toThrow("Watermark configuration error: strength must be between 0.0 and 1.0");
140
+ yield expect(trustmark.encode(testImage, 1.1)).rejects.toThrow("Watermark configuration error: strength must be between 0.0 and 1.0");
141
+ }));
142
+ it("should throw error with empty image buffer", () => __awaiter(void 0, void 0, void 0, function* () {
143
+ const emptyBuffer = Buffer.alloc(0);
144
+ yield expect(trustmark.encode(emptyBuffer, 0.5)).rejects.toThrow("The image format could not be determined");
145
+ }));
146
+ });
147
+ describe("decode", () => {
148
+ it("should decode a watermark from an encoded image", () => __awaiter(void 0, void 0, void 0, function* () {
149
+ const strength = 0.8;
150
+ const customWatermark = "0101000011001";
151
+ // First encode a watermark
152
+ const rawPixelData = yield trustmark.encode(testImage, strength, customWatermark);
153
+ // Convert raw pixel data to JPEG format for decoding
154
+ const encodedImage = yield rawRgbToJpeg(rawPixelData, testImageWidth, testImageHeight);
155
+ // Then decode it
156
+ const decodedWatermark = yield trustmark.decode(encodedImage);
157
+ expect(decodedWatermark).toBeDefined();
158
+ expect(typeof decodedWatermark).toBe("string");
159
+ expect(decodedWatermark.length).toBeGreaterThan(0);
160
+ // The decoded watermark should match the original
161
+ expect(decodedWatermark.startsWith(customWatermark)).toBeTruthy();
162
+ }));
163
+ it("should decode watermark from image with generated watermark", () => __awaiter(void 0, void 0, void 0, function* () {
164
+ const strength = 0.75;
165
+ // Encode with default watermark
166
+ const rawPixelData = yield trustmark.encode(testImage, strength);
167
+ // Convert raw pixel data to JPEG format for decoding
168
+ const encodedImage = yield rawRgbToJpeg(rawPixelData, testImageWidth, testImageHeight);
169
+ // Decode the watermark
170
+ const decodedWatermark = yield trustmark.decode(encodedImage);
171
+ expect(decodedWatermark).toBeDefined();
172
+ expect(typeof decodedWatermark).toBe("string");
173
+ expect(decodedWatermark.length).toBeGreaterThan(0);
174
+ }));
175
+ it("should throw error decoding from original image (no watermark)", () => __awaiter(void 0, void 0, void 0, function* () {
176
+ // Try to decode from an image that hasn't been watermarked
177
+ yield expect(trustmark.decode(testImage)).rejects.toThrow("watermark is corrupt or missing");
178
+ }));
179
+ it("should throw error with empty image buffer", () => __awaiter(void 0, void 0, void 0, function* () {
180
+ const emptyBuffer = Buffer.alloc(0);
181
+ yield expect(trustmark.decode(emptyBuffer)).rejects.toThrow("The image format could not be determined");
182
+ }));
183
+ });
184
+ });
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");
Binary file
@@ -0,0 +1,22 @@
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
+ private builder;
5
+ private constructor();
6
+ static new(): Builder;
7
+ static withJson(json: ManifestDefinition): Builder;
8
+ setNoEmbed(noEmbed?: boolean): void;
9
+ setRemoteUrl(remoteUrl: string): 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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { CallbackSignerInterface, IdentityAssertionBuilderInterface, IdentityAssertionSignerInterface } from "./types";
2
+ export declare class IdentityAssertionBuilder implements IdentityAssertionBuilderInterface {
3
+ private _builder;
4
+ private constructor();
5
+ static identityBuilderForCredentialHolder(credentialHolder: CallbackSignerInterface): Promise<IdentityAssertionBuilder>;
6
+ addReferencedAssertions(referencedAssertions: string[]): void;
7
+ addRoles(roles: string[]): void;
8
+ builder(): IdentityAssertionBuilderInterface;
9
+ }
10
+ export declare class IdentityAssertionSigner implements IdentityAssertionSignerInterface {
11
+ private _signer;
12
+ private constructor();
13
+ static new(signer: CallbackSignerInterface): IdentityAssertionSigner;
14
+ addIdentityAssertion(identityAssertionBuilder: IdentityAssertionBuilder): void;
15
+ signer(): IdentityAssertionSignerInterface;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { DestinationAsset, Manifest, ManifestStore, ReaderInterface, SourceAsset } from "./types";
2
+ export declare class Reader implements ReaderInterface {
3
+ private reader;
4
+ private constructor();
5
+ json(): ManifestStore;
6
+ remoteUrl(): string;
7
+ isEmbedded(): boolean;
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
+ activeLabel(): string | undefined;
12
+ getActive(): Manifest | undefined;
13
+ postValidateCawg(): Promise<void>;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { LocalSignerInterface, CallbackSignerInterface, SigningAlg, JsCallbackSignerConfig } from "./types";
2
+ export declare class LocalSigner implements LocalSignerInterface {
3
+ private localSigner;
4
+ private constructor();
5
+ static newSigner(certificate: Buffer, privateKey: Buffer, algorithm: SigningAlg, tsaUrl?: string): LocalSigner;
6
+ sign(data: Buffer): Buffer;
7
+ alg(): SigningAlg;
8
+ certs(): Array<Buffer>;
9
+ reserveSize(): number;
10
+ timeAuthorityUrl(): string | undefined;
11
+ signer(): LocalSignerInterface;
12
+ }
13
+ export declare class CallbackSigner implements CallbackSignerInterface {
14
+ private callbackSigner;
15
+ private constructor();
16
+ signer(): CallbackSignerInterface;
17
+ static newSigner(config: JsCallbackSignerConfig, callback: (data: Buffer) => Promise<Buffer>): CallbackSigner;
18
+ sign(data: Buffer): Promise<Buffer>;
19
+ alg(): SigningAlg;
20
+ certs(): Array<Buffer>;
21
+ reserveSize(): number;
22
+ timeAuthorityUrl(): string | undefined;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { TrustmarkInterface as TrustmarkInterface, TrustmarkConfig } from "./types";
2
+ export declare class Trustmark implements TrustmarkInterface {
3
+ private trustmark;
4
+ private constructor();
5
+ static newTrustmark(config: TrustmarkConfig): Promise<Trustmark>;
6
+ encode(image: Buffer, strength: number, watermark?: string): Promise<Buffer>;
7
+ decode(image: Buffer): Promise<string>;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export type * from "./types";
2
+ export { Builder } from "./Builder";
3
+ export { Reader } from "./Reader";
4
+ export { LocalSigner, CallbackSigner } from "./Signer";
5
+ export { IdentityAssertionBuilder, IdentityAssertionSigner, } from "./IdentityAssertion";
6
+ export { Trustmark } from "./Trustmark";