@contentauth/c2pa-node 0.2.2 → 0.2.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 +19 -25
- package/dist/Builder.spec.js +4 -4
- package/dist/IdentityAssertion.js +10 -10
- package/dist/Reader.js +8 -14
- package/dist/Reader.spec.js +1 -7
- package/dist/Settings.js +10 -10
- package/dist/Settings.spec.js +1 -1
- package/dist/Signer.js +14 -14
- package/dist/Signer.spec.js +1 -1
- package/dist/Trustmark.js +4 -4
- package/dist/Trustmark.spec.js +1 -1
- package/dist/binary.js +24 -0
- package/dist/index.js +7 -7
- package/dist/types/Builder.d.ts +1 -1
- package/dist/types/IdentityAssertion.d.ts +1 -1
- package/dist/types/Reader.d.ts +1 -1
- package/dist/types/Settings.d.ts +1 -1
- package/dist/types/Signer.d.ts +1 -1
- package/dist/types/Trustmark.d.ts +1 -1
- package/dist/types/binary.d.ts +1 -0
- package/dist/types/index.d.ts +8 -8
- package/package.json +6 -3
- package/scripts/{postinstall.js → postinstall.cjs} +12 -14
package/dist/Builder.js
CHANGED
|
@@ -12,20 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
|
|
18
|
-
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
|
-
// specific language governing permissions and limitations under
|
|
20
|
-
// each license.
|
|
21
|
-
const neon = require("./index.node");
|
|
22
|
-
import { IdentityAssertionSigner } from "./IdentityAssertion";
|
|
15
|
+
import { getNeonBinary } from "./binary.js";
|
|
16
|
+
import { IdentityAssertionSigner } from "./IdentityAssertion.js";
|
|
23
17
|
export class Builder {
|
|
24
18
|
constructor(builder) {
|
|
25
19
|
this.builder = builder;
|
|
26
20
|
}
|
|
27
21
|
static new() {
|
|
28
|
-
const builder =
|
|
22
|
+
const builder = getNeonBinary().builderNew();
|
|
29
23
|
return new Builder(builder);
|
|
30
24
|
}
|
|
31
25
|
static withJson(json) {
|
|
@@ -40,49 +34,49 @@ export class Builder {
|
|
|
40
34
|
}
|
|
41
35
|
throw new Error("Failed to stringify JSON Manifest Definition: Unknown error");
|
|
42
36
|
}
|
|
43
|
-
const builder =
|
|
37
|
+
const builder = getNeonBinary().builderWithJson(jsonString);
|
|
44
38
|
return new Builder(builder);
|
|
45
39
|
}
|
|
46
40
|
setNoEmbed(noEmbed = true) {
|
|
47
|
-
|
|
41
|
+
getNeonBinary().builderSetNoEmbed.call(this.builder, noEmbed);
|
|
48
42
|
}
|
|
49
43
|
setRemoteUrl(remoteUrl) {
|
|
50
|
-
|
|
44
|
+
getNeonBinary().builderSetRemoteUrl.call(this.builder, remoteUrl);
|
|
51
45
|
}
|
|
52
46
|
addAssertion(label, assertion, assertionKind) {
|
|
53
|
-
return
|
|
47
|
+
return getNeonBinary().builderAddAssertion.call(this.builder, label, assertion, assertionKind);
|
|
54
48
|
}
|
|
55
49
|
addResource(uri, resource) {
|
|
56
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return
|
|
51
|
+
return getNeonBinary().builderAddResource.call(this.builder, uri, resource);
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
54
|
addIngredient(ingredientJson, ingredient) {
|
|
61
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
return
|
|
56
|
+
return getNeonBinary().builderAddIngredient.call(this.builder, ingredientJson, ingredient);
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
59
|
toArchive(asset) {
|
|
66
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return
|
|
61
|
+
return getNeonBinary().builderToArchive.call(this.builder, asset);
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
static fromArchive(asset) {
|
|
71
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return new Builder(yield
|
|
66
|
+
return new Builder(yield getNeonBinary().builderFromArchive(asset));
|
|
73
67
|
});
|
|
74
68
|
}
|
|
75
69
|
sign(signer, input, output) {
|
|
76
|
-
return
|
|
70
|
+
return getNeonBinary().builderSign.call(this.builder, signer.signer(), input, output);
|
|
77
71
|
}
|
|
78
72
|
signFile(signer, filePath, output) {
|
|
79
73
|
const input = { path: filePath };
|
|
80
|
-
return
|
|
74
|
+
return getNeonBinary().builderSign.call(this.builder, signer.signer(), input, output);
|
|
81
75
|
}
|
|
82
76
|
signConfigAsync(callback, signerConfig, input, output) {
|
|
83
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return
|
|
85
|
-
.call(this.builder, callback, signerConfig, input, output)
|
|
78
|
+
return getNeonBinary()
|
|
79
|
+
.builderSignConfigAsync.call(this.builder, callback, signerConfig, input, output)
|
|
86
80
|
.then((result) => {
|
|
87
81
|
// output is a buffer and result is the manifest and the signed asset.
|
|
88
82
|
if ("buffer" in output) {
|
|
@@ -109,8 +103,8 @@ export class Builder {
|
|
|
109
103
|
const neonHandle = signer.signer();
|
|
110
104
|
const isIdentity = signer instanceof IdentityAssertionSigner;
|
|
111
105
|
const neonFn = isIdentity
|
|
112
|
-
?
|
|
113
|
-
:
|
|
106
|
+
? getNeonBinary().builderIdentitySignAsync
|
|
107
|
+
: getNeonBinary().builderSignAsync;
|
|
114
108
|
return neonFn
|
|
115
109
|
.call(this.builder, neonHandle, input, output)
|
|
116
110
|
.then((result) => {
|
|
@@ -135,9 +129,9 @@ export class Builder {
|
|
|
135
129
|
});
|
|
136
130
|
}
|
|
137
131
|
getManifestDefinition() {
|
|
138
|
-
return JSON.parse(
|
|
132
|
+
return JSON.parse(getNeonBinary().builderManifestDefinition.call(this.builder));
|
|
139
133
|
}
|
|
140
134
|
updateManifestProperty(property, value) {
|
|
141
|
-
|
|
135
|
+
getNeonBinary().builderUpdateManifestProperty.call(this.builder, property, value);
|
|
142
136
|
}
|
|
143
137
|
}
|
package/dist/Builder.spec.js
CHANGED
|
@@ -12,13 +12,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
import { isActionsAssertion } from "./assertions";
|
|
16
|
-
import { CallbackSigner, LocalSigner } from "./Signer";
|
|
17
|
-
import { Reader } from "./Reader";
|
|
18
|
-
import { Builder } from "./Builder";
|
|
19
15
|
import * as fs from "fs-extra";
|
|
20
16
|
import path from "path";
|
|
21
17
|
import * as crypto from "crypto";
|
|
18
|
+
import { isActionsAssertion } from "./assertions.js";
|
|
19
|
+
import { CallbackSigner, LocalSigner } from "./Signer.js";
|
|
20
|
+
import { Reader } from "./Reader.js";
|
|
21
|
+
import { Builder } from "./Builder.js";
|
|
22
22
|
const tempDir = path.join(__dirname, "tmp");
|
|
23
23
|
class TestSigner {
|
|
24
24
|
constructor(privateKey) {
|
|
@@ -18,22 +18,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
|
|
21
|
+
import { getNeonBinary } from "./binary.js";
|
|
22
22
|
export class IdentityAssertionBuilder {
|
|
23
23
|
constructor(_builder) {
|
|
24
24
|
this._builder = _builder;
|
|
25
25
|
}
|
|
26
26
|
static identityBuilderForCredentialHolder(credentialHolder) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const builder =
|
|
28
|
+
const builder = getNeonBinary().identityBuilderForCredentialHolder(credentialHolder.signer());
|
|
29
29
|
return new IdentityAssertionBuilder(builder);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
addReferencedAssertions(referencedAssertions) {
|
|
33
|
-
|
|
33
|
+
getNeonBinary().identityBuilderAddReferencedAssertions.call(this._builder, referencedAssertions);
|
|
34
34
|
}
|
|
35
35
|
addRoles(roles) {
|
|
36
|
-
|
|
36
|
+
getNeonBinary().identityBuilderAddRoles.call(this._builder, roles);
|
|
37
37
|
}
|
|
38
38
|
builder() {
|
|
39
39
|
return this._builder;
|
|
@@ -44,11 +44,11 @@ export class IdentityAssertionSigner {
|
|
|
44
44
|
this._signer = _signer;
|
|
45
45
|
}
|
|
46
46
|
static new(signer) {
|
|
47
|
-
const identitySigner =
|
|
47
|
+
const identitySigner = getNeonBinary().identitySignerNew(signer);
|
|
48
48
|
return new IdentityAssertionSigner(identitySigner);
|
|
49
49
|
}
|
|
50
50
|
addIdentityAssertion(identityAssertionBuilder) {
|
|
51
|
-
|
|
51
|
+
getNeonBinary().identitySignerAddIdentityAssertion.call(this._signer, identityAssertionBuilder.builder());
|
|
52
52
|
}
|
|
53
53
|
signer() {
|
|
54
54
|
return this._signer;
|
|
@@ -62,18 +62,18 @@ export class CallbackCredentialHolder {
|
|
|
62
62
|
return this.callbackCredentialHolder;
|
|
63
63
|
}
|
|
64
64
|
static newCallbackCredentialHolder(reserveSize, sigType, callback) {
|
|
65
|
-
const credentialHolder =
|
|
65
|
+
const credentialHolder = getNeonBinary().newCallbackCredentialHolder(reserveSize, sigType, callback);
|
|
66
66
|
return new CallbackCredentialHolder(credentialHolder);
|
|
67
67
|
}
|
|
68
68
|
sign(payload) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
return
|
|
70
|
+
return getNeonBinary().callbackSignerSignPayload.call(this.callbackCredentialHolder, payload);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
reserveSize() {
|
|
74
|
-
return
|
|
74
|
+
return getNeonBinary().callbackCredentialHolderReserveSize.call(this.callbackCredentialHolder);
|
|
75
75
|
}
|
|
76
76
|
sigType() {
|
|
77
|
-
return
|
|
77
|
+
return getNeonBinary().callbackCredentialHolderSigType.call(this.callbackCredentialHolder);
|
|
78
78
|
}
|
|
79
79
|
}
|
package/dist/Reader.js
CHANGED
|
@@ -12,40 +12,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
// this software is distributed on an "AS IS" BASIS, WITHOUT
|
|
17
|
-
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
|
|
18
|
-
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
|
-
// specific language governing permissions and limitations under
|
|
20
|
-
// each license.
|
|
21
|
-
const neon = require("./index.node");
|
|
15
|
+
import { getNeonBinary } from "./binary.js";
|
|
22
16
|
export class Reader {
|
|
23
17
|
constructor(reader) {
|
|
24
18
|
this.reader = reader;
|
|
25
19
|
}
|
|
26
20
|
json() {
|
|
27
|
-
return JSON.parse(
|
|
21
|
+
return JSON.parse(getNeonBinary().readerJson.call(this.reader));
|
|
28
22
|
}
|
|
29
23
|
remoteUrl() {
|
|
30
|
-
return
|
|
24
|
+
return getNeonBinary().readerRemoteUrl.call(this.reader);
|
|
31
25
|
}
|
|
32
26
|
isEmbedded() {
|
|
33
|
-
return
|
|
27
|
+
return getNeonBinary().readerIsEmbedded.call(this.reader);
|
|
34
28
|
}
|
|
35
29
|
resourceToAsset(uri, asset) {
|
|
36
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return
|
|
31
|
+
return getNeonBinary().readerResourceToAsset.call(this.reader, uri, asset);
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
static fromAsset(asset) {
|
|
41
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const reader = yield
|
|
36
|
+
const reader = yield getNeonBinary().readerFromAsset(asset);
|
|
43
37
|
return new Reader(reader);
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
static fromManifestDataAndAsset(manifestData, asset) {
|
|
47
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const reader = yield
|
|
42
|
+
const reader = yield getNeonBinary().readerFromManifestDataAndAsset(manifestData, asset);
|
|
49
43
|
return new Reader(reader);
|
|
50
44
|
});
|
|
51
45
|
}
|
|
@@ -65,7 +59,7 @@ export class Reader {
|
|
|
65
59
|
}
|
|
66
60
|
postValidateCawg() {
|
|
67
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return
|
|
62
|
+
return getNeonBinary().readerPostValidateCawg.call(this.reader);
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
}
|
package/dist/Reader.spec.js
CHANGED
|
@@ -12,15 +12,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
// Unless required by applicable law or agreed to in writing,
|
|
16
|
-
// this software is distributed on an "AS IS" BASIS, WITHOUT
|
|
17
|
-
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
|
|
18
|
-
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
|
-
// specific language governing permissions and limitations under
|
|
20
|
-
// each license.
|
|
21
|
-
import { Reader } from "./Reader";
|
|
22
15
|
import path from "path";
|
|
23
16
|
import * as fs from "fs-extra";
|
|
17
|
+
import { Reader } from "./Reader.js";
|
|
24
18
|
const tempDir = path.join(__dirname, "tmp");
|
|
25
19
|
describe("Reader", () => {
|
|
26
20
|
const manifestStore = JSON.parse(`{
|
package/dist/Settings.js
CHANGED
|
@@ -18,23 +18,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
const neon = require("./index.node");
|
|
22
21
|
import * as fs from "fs-extra";
|
|
23
22
|
import path from "path";
|
|
24
23
|
import fetch from "node-fetch";
|
|
24
|
+
import { getNeonBinary } from "./binary.js";
|
|
25
25
|
/**
|
|
26
26
|
* Load settings from a JSON string and apply them globally.
|
|
27
27
|
* @param json The JSON string containing the settings configuration
|
|
28
28
|
*/
|
|
29
29
|
export function loadC2paSettings(json) {
|
|
30
|
-
|
|
30
|
+
getNeonBinary().loadSettings(json);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Load settings from a TOML string and apply them globally.
|
|
34
34
|
* @param toml The TOML string containing the settings configuration
|
|
35
35
|
*/
|
|
36
36
|
export function loadC2paSettingsToml(toml) {
|
|
37
|
-
|
|
37
|
+
getNeonBinary().loadSettingsToml(toml);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Load settings from a TOML or JSON file path and apply them globally.
|
|
@@ -81,7 +81,7 @@ export function loadSettingsFromUrl(url) {
|
|
|
81
81
|
* @returns The JSON representation of the current settings
|
|
82
82
|
*/
|
|
83
83
|
export function getSettingsJson() {
|
|
84
|
-
return
|
|
84
|
+
return getNeonBinary().getSettingsJson();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Load trust configuration into the main trust settings.
|
|
@@ -98,7 +98,7 @@ export function loadTrustConfig(trustConfig) {
|
|
|
98
98
|
trust_config: (_c = trustConfig.trustConfig) !== null && _c !== void 0 ? _c : null,
|
|
99
99
|
allowed_list: (_d = trustConfig.allowedList) !== null && _d !== void 0 ? _d : null,
|
|
100
100
|
};
|
|
101
|
-
|
|
101
|
+
getNeonBinary().loadTrustConfig(JSON.stringify(config));
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Load trust configuration into the CAWG trust settings.
|
|
@@ -115,7 +115,7 @@ export function loadCawgTrustConfig(trustConfig) {
|
|
|
115
115
|
trust_config: (_c = trustConfig.trustConfig) !== null && _c !== void 0 ? _c : null,
|
|
116
116
|
allowed_list: (_d = trustConfig.allowedList) !== null && _d !== void 0 ? _d : null,
|
|
117
117
|
};
|
|
118
|
-
|
|
118
|
+
getNeonBinary().loadCawgTrustConfig(JSON.stringify(config));
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Get the current trust configuration.
|
|
@@ -123,7 +123,7 @@ export function loadCawgTrustConfig(trustConfig) {
|
|
|
123
123
|
*/
|
|
124
124
|
export function getTrustConfig() {
|
|
125
125
|
var _a, _b, _c, _d;
|
|
126
|
-
const json =
|
|
126
|
+
const json = getNeonBinary().getTrustConfig();
|
|
127
127
|
const parsed = JSON.parse(json);
|
|
128
128
|
// Convert snake_case to camelCase to match TrustConfig interface
|
|
129
129
|
// Handle undefined values by converting them to null
|
|
@@ -141,7 +141,7 @@ export function getTrustConfig() {
|
|
|
141
141
|
*/
|
|
142
142
|
export function getCawgTrustConfig() {
|
|
143
143
|
var _a, _b, _c, _d;
|
|
144
|
-
const json =
|
|
144
|
+
const json = getNeonBinary().getCawgTrustConfig();
|
|
145
145
|
const parsed = JSON.parse(json);
|
|
146
146
|
// Convert snake_case to camelCase to match TrustConfig interface
|
|
147
147
|
// Handle undefined values by converting them to null
|
|
@@ -170,7 +170,7 @@ export function loadVerifyConfig(verifyConfig) {
|
|
|
170
170
|
skip_ingredient_conflict_resolution: verifyConfig.skipIngredientConflictResolution,
|
|
171
171
|
strict_v1_validation: verifyConfig.strictV1Validation,
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
getNeonBinary().loadVerifyConfig(JSON.stringify(config));
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Patch the verify configuration with any subset of fields.
|
|
@@ -186,7 +186,7 @@ export function patchVerifyConfig(patch) {
|
|
|
186
186
|
* @returns The current verify configuration object
|
|
187
187
|
*/
|
|
188
188
|
export function getVerifyConfig() {
|
|
189
|
-
const json =
|
|
189
|
+
const json = getNeonBinary().getVerifyConfig();
|
|
190
190
|
const parsed = JSON.parse(json);
|
|
191
191
|
// Convert snake_case to camelCase to match VerifyConfig interface
|
|
192
192
|
return {
|
package/dist/Settings.spec.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
4
4
|
// or the MIT license (http://opensource.org/licenses/MIT),
|
|
5
5
|
// at your option.
|
|
6
|
-
import { loadC2paSettings, loadTrustConfig, loadCawgTrustConfig, getSettingsJson, getTrustConfig, getCawgTrustConfig, loadVerifyConfig, getVerifyConfig, patchVerifyConfig, } from "./Settings";
|
|
6
|
+
import { loadC2paSettings, loadTrustConfig, loadCawgTrustConfig, getSettingsJson, getTrustConfig, getCawgTrustConfig, loadVerifyConfig, getVerifyConfig, patchVerifyConfig, } from "./Settings.js";
|
|
7
7
|
describe("Settings", () => {
|
|
8
8
|
it("loads a trustlist-shaped JSON and returns JSON via getSettingsJson", () => {
|
|
9
9
|
var _a, _b;
|
package/dist/Signer.js
CHANGED
|
@@ -18,29 +18,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
|
|
21
|
+
import { getNeonBinary } from "./binary.js";
|
|
22
22
|
export class LocalSigner {
|
|
23
23
|
constructor(localSigner) {
|
|
24
24
|
this.localSigner = localSigner;
|
|
25
25
|
}
|
|
26
26
|
static newSigner(certificate, privateKey, algorithm, tsaUrl) {
|
|
27
|
-
const signer =
|
|
27
|
+
const signer = getNeonBinary().localSignerNew(certificate, privateKey, algorithm, tsaUrl);
|
|
28
28
|
return new LocalSigner(signer);
|
|
29
29
|
}
|
|
30
30
|
sign(data) {
|
|
31
|
-
return
|
|
31
|
+
return getNeonBinary().localSignerSign.call(this.localSigner, data);
|
|
32
32
|
}
|
|
33
33
|
alg() {
|
|
34
|
-
return
|
|
34
|
+
return getNeonBinary().localSignerAlg.call(this.localSigner);
|
|
35
35
|
}
|
|
36
36
|
certs() {
|
|
37
|
-
return
|
|
37
|
+
return getNeonBinary().localSignerCerts.call(this.localSigner);
|
|
38
38
|
}
|
|
39
39
|
reserveSize() {
|
|
40
|
-
return
|
|
40
|
+
return getNeonBinary().localSignerReserveSize.call(this.localSigner);
|
|
41
41
|
}
|
|
42
42
|
timeAuthorityUrl() {
|
|
43
|
-
return
|
|
43
|
+
return getNeonBinary().localSignerTimeAuthorityUrl.call(this.localSigner);
|
|
44
44
|
}
|
|
45
45
|
signer() {
|
|
46
46
|
return this.localSigner;
|
|
@@ -55,25 +55,25 @@ export class CallbackSigner {
|
|
|
55
55
|
}
|
|
56
56
|
static newSigner(config, callback) {
|
|
57
57
|
// Convert the config object to a JsBox<CallbackSignerConfig>
|
|
58
|
-
const configBox =
|
|
59
|
-
const signer =
|
|
58
|
+
const configBox = getNeonBinary().callbackSignerConfigFromJs(config);
|
|
59
|
+
const signer = getNeonBinary().callbackSignerFromConfig(configBox, callback);
|
|
60
60
|
return new CallbackSigner(signer);
|
|
61
61
|
}
|
|
62
62
|
sign(data) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return
|
|
64
|
+
return getNeonBinary().callbackSignerSign.call(this.callbackSigner, data);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
alg() {
|
|
68
|
-
return
|
|
68
|
+
return getNeonBinary().callbackSignerAlg.call(this.callbackSigner);
|
|
69
69
|
}
|
|
70
70
|
certs() {
|
|
71
|
-
return
|
|
71
|
+
return getNeonBinary().callbackSignerCerts.call(this.callbackSigner);
|
|
72
72
|
}
|
|
73
73
|
reserveSize() {
|
|
74
|
-
return
|
|
74
|
+
return getNeonBinary().callbackSignerReserveSize.call(this.callbackSigner);
|
|
75
75
|
}
|
|
76
76
|
timeAuthorityUrl() {
|
|
77
|
-
return
|
|
77
|
+
return getNeonBinary().callbackSignerTimeAuthorityUrl.call(this.callbackSigner);
|
|
78
78
|
}
|
|
79
79
|
}
|
package/dist/Signer.spec.js
CHANGED
|
@@ -18,9 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
import { CallbackSigner } from "./Signer";
|
|
22
21
|
import * as fs from "fs-extra";
|
|
23
22
|
import * as crypto from "crypto";
|
|
23
|
+
import { CallbackSigner } from "./Signer.js";
|
|
24
24
|
class TestSigner {
|
|
25
25
|
constructor(privateKey) {
|
|
26
26
|
this.sign = (bytes) => __awaiter(this, void 0, void 0, function* () {
|
package/dist/Trustmark.js
CHANGED
|
@@ -18,25 +18,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
|
|
21
|
+
import { getNeonBinary } from "./binary.js";
|
|
22
22
|
export class Trustmark {
|
|
23
23
|
constructor(trustmark) {
|
|
24
24
|
this.trustmark = trustmark;
|
|
25
25
|
}
|
|
26
26
|
static newTrustmark(config) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const trustmark = yield
|
|
28
|
+
const trustmark = yield getNeonBinary().trustmarkNew(config);
|
|
29
29
|
return new Trustmark(trustmark);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
encode(image, strength, watermark) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return
|
|
34
|
+
return getNeonBinary().trustmarkEncode.call(this.trustmark, image, strength, watermark);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
decode(image) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
return
|
|
39
|
+
return getNeonBinary().trustmarkDecode.call(this.trustmark, image);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
}
|
package/dist/Trustmark.spec.js
CHANGED
|
@@ -18,10 +18,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
19
19
|
// specific language governing permissions and limitations under
|
|
20
20
|
// each license.
|
|
21
|
-
import { Trustmark } from "./Trustmark";
|
|
22
21
|
import path from "path";
|
|
23
22
|
import * as fs from "fs-extra";
|
|
24
23
|
import sharp from "sharp";
|
|
24
|
+
import { Trustmark } from "./Trustmark.js";
|
|
25
25
|
const tempDir = path.join(__dirname, "..", "tmp");
|
|
26
26
|
// Helper function to convert raw RGB pixel data to JPEG format
|
|
27
27
|
function rawRgbToJpeg(rawRgbData, width, height) {
|
package/dist/binary.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
// Unless required by applicable law or agreed to in writing,
|
|
7
|
+
// this software is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
|
|
9
|
+
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
|
|
10
|
+
// specific language governing permissions and limitations under
|
|
11
|
+
// each license.
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
// Create a require function for the current module to load the .node file
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
// Dynamically import the binary module
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
let neon = null;
|
|
18
|
+
// Get the binary module (loads synchronously on first access)
|
|
19
|
+
export function getNeonBinary() {
|
|
20
|
+
if (neon === null) {
|
|
21
|
+
neon = require("./index.node");
|
|
22
|
+
}
|
|
23
|
+
return neon;
|
|
24
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
4
4
|
// or the MIT license (http://opensource.org/licenses/MIT),
|
|
5
5
|
// at your option.
|
|
6
|
-
export { Builder } from "./Builder";
|
|
7
|
-
export { Reader } from "./Reader";
|
|
8
|
-
export { LocalSigner, CallbackSigner } from "./Signer";
|
|
9
|
-
export { IdentityAssertionBuilder, IdentityAssertionSigner, CallbackCredentialHolder, } from "./IdentityAssertion";
|
|
10
|
-
export { Trustmark } from "./Trustmark";
|
|
11
|
-
export { isActionsAssertion } from "./assertions";
|
|
12
|
-
export * from "./Settings";
|
|
6
|
+
export { Builder } from "./Builder.js";
|
|
7
|
+
export { Reader } from "./Reader.js";
|
|
8
|
+
export { LocalSigner, CallbackSigner } from "./Signer.js";
|
|
9
|
+
export { IdentityAssertionBuilder, IdentityAssertionSigner, CallbackCredentialHolder, } from "./IdentityAssertion.js";
|
|
10
|
+
export { Trustmark } from "./Trustmark.js";
|
|
11
|
+
export { isActionsAssertion } from "./assertions.js";
|
|
12
|
+
export * from "./Settings.js";
|
package/dist/types/Builder.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BuilderInterface, CallbackSignerInterface, ClaimVersion, DestinationAsset, IdentityAssertionSignerInterface, JsCallbackSignerConfig, LocalSignerInterface, ManifestAssertionKind, SourceAsset } from "./types";
|
|
2
1
|
import type { Manifest } from "@contentauth/c2pa-types";
|
|
2
|
+
import type { BuilderInterface, CallbackSignerInterface, ClaimVersion, DestinationAsset, IdentityAssertionSignerInterface, JsCallbackSignerConfig, LocalSignerInterface, ManifestAssertionKind, SourceAsset } from "./types.d.ts";
|
|
3
3
|
export declare class Builder implements BuilderInterface {
|
|
4
4
|
private builder;
|
|
5
5
|
private constructor();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallbackCredentialHolderInterface, IdentityAssertionBuilderInterface, IdentityAssertionSignerInterface, NeonCallbackCredentialHolderHandle, NeonIdentityAssertionSignerHandle, NeonIdentityAssertionBuilderHandle, SignerPayload, NeonCallbackSignerHandle } from "./types";
|
|
1
|
+
import type { CallbackCredentialHolderInterface, IdentityAssertionBuilderInterface, IdentityAssertionSignerInterface, NeonCallbackCredentialHolderHandle, NeonIdentityAssertionSignerHandle, NeonIdentityAssertionBuilderHandle, SignerPayload, NeonCallbackSignerHandle } from "./types.d.ts";
|
|
2
2
|
export declare class IdentityAssertionBuilder implements IdentityAssertionBuilderInterface {
|
|
3
3
|
private _builder;
|
|
4
4
|
constructor(_builder: NeonIdentityAssertionBuilderHandle);
|
package/dist/types/Reader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DestinationAsset, ReaderInterface, SourceAsset, NeonReaderHandle } from "./types";
|
|
2
1
|
import type { Manifest, ManifestStore } from "@contentauth/c2pa-types";
|
|
2
|
+
import type { DestinationAsset, ReaderInterface, SourceAsset, NeonReaderHandle } from "./types.d.ts";
|
|
3
3
|
export declare class Reader implements ReaderInterface {
|
|
4
4
|
private reader;
|
|
5
5
|
constructor(reader: NeonReaderHandle);
|
package/dist/types/Settings.d.ts
CHANGED
package/dist/types/Signer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallbackSignerInterface, JsCallbackSignerConfig, NeonCallbackSignerHandle, NeonLocalSignerHandle, LocalSignerInterface, SigningAlg } from "./types";
|
|
1
|
+
import type { CallbackSignerInterface, JsCallbackSignerConfig, NeonCallbackSignerHandle, NeonLocalSignerHandle, LocalSignerInterface, SigningAlg } from "./types.d.ts";
|
|
2
2
|
export declare class LocalSigner implements LocalSignerInterface {
|
|
3
3
|
private localSigner;
|
|
4
4
|
constructor(localSigner: NeonLocalSignerHandle);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TrustmarkInterface, TrustmarkConfig, NeonTrustmarkHandle } from "./types";
|
|
1
|
+
import type { TrustmarkInterface, TrustmarkConfig, NeonTrustmarkHandle } from "./types.d.ts";
|
|
2
2
|
export declare class Trustmark implements TrustmarkInterface {
|
|
3
3
|
private trustmark;
|
|
4
4
|
constructor(trustmark: NeonTrustmarkHandle);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNeonBinary(): any;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, CallbackCredentialHolder, } from "./IdentityAssertion";
|
|
6
|
-
export { Trustmark } from "./Trustmark";
|
|
7
|
-
export { isActionsAssertion } from "./assertions";
|
|
8
|
-
export * from "./Settings";
|
|
1
|
+
export type * from "./types.d.ts";
|
|
2
|
+
export { Builder } from "./Builder.js";
|
|
3
|
+
export { Reader } from "./Reader.js";
|
|
4
|
+
export { LocalSigner, CallbackSigner } from "./Signer.js";
|
|
5
|
+
export { IdentityAssertionBuilder, IdentityAssertionSigner, CallbackCredentialHolder, } from "./IdentityAssertion.js";
|
|
6
|
+
export { Trustmark } from "./Trustmark.js";
|
|
7
|
+
export { isActionsAssertion } from "./assertions.js";
|
|
8
|
+
export * from "./Settings.js";
|
package/package.json
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "git+https://github.com/contentauth/c2pa-node-v2.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.3",
|
|
8
8
|
"description": "Node.js bindings for C2PA",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
|
+
"type": "module",
|
|
10
11
|
"types": "dist/types/index.d.ts",
|
|
11
12
|
"files": [
|
|
12
13
|
"dist",
|
|
@@ -25,10 +26,12 @@
|
|
|
25
26
|
"@contentauth/c2pa-types": "^0.2.1",
|
|
26
27
|
"@eslint/js": "^9.33.0",
|
|
27
28
|
"@neon-rs/cli": "0.1.82",
|
|
29
|
+
"@types/cli-progress": "^3.11.6",
|
|
28
30
|
"@types/debug": "^4.1.12",
|
|
29
31
|
"@types/fs-extra": "^11.0.4",
|
|
30
32
|
"@types/jest": "^29.5.14",
|
|
31
33
|
"@types/node": "^22.17.1",
|
|
34
|
+
"@types/unzipper": "^0.10.11",
|
|
32
35
|
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
33
36
|
"@typescript-eslint/parser": "^8.39.1",
|
|
34
37
|
"@vitest/ui": "^3.2.4",
|
|
@@ -72,14 +75,14 @@
|
|
|
72
75
|
"changeset:publish": "changeset publish",
|
|
73
76
|
"ci": "run-s build:rust-debug build:ts test",
|
|
74
77
|
"ci:release": "pnpm run build && changeset tag && pnpm publish --access=public --no-git-checks",
|
|
75
|
-
"clean": "rimraf dist
|
|
78
|
+
"clean": "rimraf dist target",
|
|
76
79
|
"cross": "pnpm run cross-build --release",
|
|
77
80
|
"cross-build": "cross build --message-format=json-render-diagnostics > cross.log",
|
|
78
81
|
"debug": "pnpm run cargo-build --",
|
|
79
82
|
"lint": "cargo clippy && pnpm eslint",
|
|
80
83
|
"postbuild:rust-debug": "neon dist < cargo.log",
|
|
81
84
|
"postcross-build": "neon dist -m /target < cross.log",
|
|
82
|
-
"postinstall": "node scripts/postinstall.
|
|
85
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
83
86
|
"release": "run-s build changeset:publish",
|
|
84
87
|
"test": "pnpm build:debug && vitest run",
|
|
85
88
|
"test:watch": "pnpm build:debug && vitest",
|
|
@@ -17,6 +17,9 @@ const { mkdirp } = require('mkdirp');
|
|
|
17
17
|
const { resolve } = require('node:path');
|
|
18
18
|
const { exec } = require('node:child_process');
|
|
19
19
|
const { promisify } = require('node:util');
|
|
20
|
+
// node-fetch v3 is ES module only, so we'll import it dynamically
|
|
21
|
+
// pretty-bytes is ES module only, so we'll import it dynamically
|
|
22
|
+
// pkg-dir is ES module only, so we'll import it dynamically
|
|
20
23
|
|
|
21
24
|
const pExec = promisify(exec);
|
|
22
25
|
|
|
@@ -69,19 +72,16 @@ function getPlatform() {
|
|
|
69
72
|
|
|
70
73
|
async function downloadFromUrl(appRoot, url) {
|
|
71
74
|
console.log(`Checking for a release at: ${url}`);
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const fetch = fetchModule.default;
|
|
75
|
+
const { default: fetch } = await import('node-fetch');
|
|
76
|
+
const { default: prettyBytes } = await import('pretty-bytes');
|
|
75
77
|
const res = await fetch(url);
|
|
76
78
|
|
|
77
79
|
if (res.ok) {
|
|
78
|
-
// Dynamic import for ES module
|
|
79
|
-
const { default: prettyBytes } = await import('pretty-bytes');
|
|
80
80
|
|
|
81
|
-
const destDir = resolve(appRoot, 'dist'
|
|
81
|
+
const destDir = resolve(appRoot, 'dist');
|
|
82
82
|
const totalSize = parseInt(res.headers.get('Content-Length'), 10);
|
|
83
83
|
await mkdirp(destDir);
|
|
84
|
-
const destPath = resolve(destDir, '
|
|
84
|
+
const destPath = resolve(destDir, 'index.node');
|
|
85
85
|
const destStream = createWriteStream(destPath);
|
|
86
86
|
const progress = new PassThrough();
|
|
87
87
|
const bar = new cliProgress.SingleBar(
|
|
@@ -157,10 +157,10 @@ async function rustExists() {
|
|
|
157
157
|
|
|
158
158
|
async function buildRust(root) {
|
|
159
159
|
console.log('🦀 Building Rust...');
|
|
160
|
-
const
|
|
161
|
-
const bindingsPath = resolve(
|
|
160
|
+
const distDir = resolve(root, 'dist');
|
|
161
|
+
const bindingsPath = resolve(distDir, 'index.node');
|
|
162
162
|
const cargoPath = resolve(root, 'Cargo.toml');
|
|
163
|
-
await mkdirp(
|
|
163
|
+
await mkdirp(distDir);
|
|
164
164
|
return new Promise((resolve, reject) => {
|
|
165
165
|
const result = exec(
|
|
166
166
|
`npx cargo-cp-artifact -nc "${bindingsPath}" -- cargo build --message-format=json-render-diagnostics --release --manifest-path="${cargoPath}"`,
|
|
@@ -173,10 +173,8 @@ async function buildRust(root) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
async function main() {
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const pkgDir = pkgDirModule.packageDirectory;
|
|
179
|
-
const appRoot = await pkgDir(__dirname);
|
|
176
|
+
const { packageDirectory } = await import('pkg-dir');
|
|
177
|
+
const appRoot = await packageDirectory(__filename);
|
|
180
178
|
const distRoot = resolve(appRoot, 'dist');
|
|
181
179
|
const cargoDistPath = resolve(distRoot, 'Cargo.toml');
|
|
182
180
|
const libraryOverridePath = process.env.C2PA_LIBRARY_PATH;
|