@contentauth/c2pa-node 0.2.1 → 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/package.json CHANGED
@@ -4,12 +4,17 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/contentauth/c2pa-node-v2.git"
6
6
  },
7
- "version": "0.2.1",
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
- "dist"
13
+ "dist",
14
+ "scripts",
15
+ "src",
16
+ "Cargo.toml",
17
+ "Cargo.lock"
13
18
  ],
14
19
  "engines": {
15
20
  "node": ">=18.20.2"
@@ -21,17 +26,18 @@
21
26
  "@contentauth/c2pa-types": "^0.2.1",
22
27
  "@eslint/js": "^9.33.0",
23
28
  "@neon-rs/cli": "0.1.82",
29
+ "@types/cli-progress": "^3.11.6",
24
30
  "@types/debug": "^4.1.12",
25
31
  "@types/fs-extra": "^11.0.4",
26
32
  "@types/jest": "^29.5.14",
27
33
  "@types/node": "^22.17.1",
34
+ "@types/unzipper": "^0.10.11",
28
35
  "@typescript-eslint/eslint-plugin": "^8.39.1",
29
36
  "@typescript-eslint/parser": "^8.39.1",
30
37
  "@vitest/ui": "^3.2.4",
31
38
  "cbor2": "^2.0.1",
32
39
  "cpy-cli": "^5.0.0",
33
40
  "eslint": "^9.33.0",
34
- "fs-extra": "^11.3.1",
35
41
  "npm-run-all": "^4.1.5",
36
42
  "rimraf": "^6.0.1",
37
43
  "sharp": "^0.34.3",
@@ -49,8 +55,15 @@
49
55
  },
50
56
  "homepage": "https://github.com/contentauth/c2pa-node-v2#readme",
51
57
  "dependencies": {
58
+ "cargo-cp-artifact": "^0.1.0",
59
+ "cli-progress": "^3.2.0",
52
60
  "debug": "^4.4.1",
53
- "node-fetch": "^3.3.2"
61
+ "fs-extra": "^11.3.1",
62
+ "mkdirp": "^3.0.0",
63
+ "node-fetch": "^3.3.2",
64
+ "pkg-dir": "^8.0.0",
65
+ "pretty-bytes": "^6.0.0",
66
+ "unzipper": "^0.10.0"
54
67
  },
55
68
  "scripts": {
56
69
  "build": "run-s build:rust build:ts",
@@ -62,13 +75,14 @@
62
75
  "changeset:publish": "changeset publish",
63
76
  "ci": "run-s build:rust-debug build:ts test",
64
77
  "ci:release": "pnpm run build && changeset tag && pnpm publish --access=public --no-git-checks",
65
- "clean": "rimraf dist generated target",
78
+ "clean": "rimraf dist target",
66
79
  "cross": "pnpm run cross-build --release",
67
80
  "cross-build": "cross build --message-format=json-render-diagnostics > cross.log",
68
81
  "debug": "pnpm run cargo-build --",
69
82
  "lint": "cargo clippy && pnpm eslint",
70
83
  "postbuild:rust-debug": "neon dist < cargo.log",
71
84
  "postcross-build": "neon dist -m /target < cross.log",
85
+ "postinstall": "node scripts/postinstall.cjs",
72
86
  "release": "run-s build changeset:publish",
73
87
  "test": "pnpm build:debug && vitest run",
74
88
  "test:watch": "pnpm build:debug && vitest",
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Copyright 2023 Adobe
3
+ * All Rights Reserved.
4
+ *
5
+ * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
+ * accordance with the terms of the Adobe license agreement accompanying
7
+ * it.
8
+ */
9
+
10
+ const { stat, readFile } = require('node:fs/promises');
11
+ const { createWriteStream } = require('node:fs');
12
+ const { PassThrough } = require('node:stream');
13
+ const cliProgress = require('cli-progress');
14
+ const unzipper = require('unzipper');
15
+ const os = require('node:os');
16
+ const { mkdirp } = require('mkdirp');
17
+ const { resolve } = require('node:path');
18
+ const { exec } = require('node:child_process');
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
23
+
24
+ const pExec = promisify(exec);
25
+
26
+ const execCallback = (err, stdout, stderr) => {
27
+ if (err) {
28
+ console.error(`ERROR: ${err}`);
29
+ } else if (stdout) {
30
+ console.log(stdout);
31
+ } else if (stderr) {
32
+ console.error(stderr);
33
+ }
34
+ };
35
+
36
+ async function fileExists(path) {
37
+ try {
38
+ await stat(path);
39
+ return true;
40
+ } catch (err) {
41
+ if (err.code === 'ENOENT') {
42
+ return false;
43
+ }
44
+ throw err;
45
+ }
46
+ }
47
+
48
+ function getPlatform() {
49
+ const arch = os.arch();
50
+ const platform = os.platform();
51
+
52
+ console.debug('Detected', { arch, platform });
53
+
54
+ if (arch === 'arm64' && platform === 'linux') {
55
+ return 'aarch64-unknown-linux-gnu';
56
+ } else if (arch === 'x64' && platform === 'linux') {
57
+ return 'x86_64-unknown-linux-gnu';
58
+ } else if (arch === 'arm64' && platform === 'darwin') {
59
+ return 'aarch64-apple-darwin';
60
+ } else if (arch === 'x64' && platform === 'darwin') {
61
+ return 'x86_64-apple-darwin';
62
+ } else if (platform === 'win32') {
63
+ return 'x86_64-pc-windows-msvc';
64
+ }
65
+
66
+ console.log(
67
+ `Can not find binary for architecture: ${arch} and platform: ${platform}, attempting to build Rust`,
68
+ );
69
+
70
+ return null;
71
+ }
72
+
73
+ async function downloadFromUrl(appRoot, url) {
74
+ console.log(`Checking for a release at: ${url}`);
75
+ const { default: fetch } = await import('node-fetch');
76
+ const { default: prettyBytes } = await import('pretty-bytes');
77
+ const res = await fetch(url);
78
+
79
+ if (res.ok) {
80
+
81
+ const destDir = resolve(appRoot, 'dist');
82
+ const totalSize = parseInt(res.headers.get('Content-Length'), 10);
83
+ await mkdirp(destDir);
84
+ const destPath = resolve(destDir, 'index.node');
85
+ const destStream = createWriteStream(destPath);
86
+ const progress = new PassThrough();
87
+ const bar = new cliProgress.SingleBar(
88
+ {
89
+ format:
90
+ 'Downloading | {bar} | {value_formatted} / {total_formatted} ({percentage}%) | ETA: {eta}s',
91
+ },
92
+ cliProgress.Presets.shades_classic,
93
+ );
94
+ let downloaded = 0;
95
+
96
+ bar.start(totalSize, 0, {
97
+ value_formatted: prettyBytes(0),
98
+ total_formatted: prettyBytes(totalSize),
99
+ });
100
+
101
+ progress.on('data', (chunk) => {
102
+ downloaded += chunk.length;
103
+ bar.update(downloaded, {
104
+ value_formatted: prettyBytes(downloaded),
105
+ total_formatted: prettyBytes(totalSize),
106
+ });
107
+ });
108
+
109
+ return new Promise((resolve, reject) => {
110
+ res.body
111
+ .pipe(progress)
112
+ .pipe(unzipper.ParseOne())
113
+ .pipe(destStream)
114
+ .on('finish', () => {
115
+ bar.stop();
116
+ console.log(`Downloaded to ${destPath}`);
117
+ resolve(true);
118
+ })
119
+ .on('error', reject);
120
+ });
121
+ }
122
+
123
+ return false;
124
+ }
125
+
126
+ async function downloadBinary(appRoot) {
127
+ const pkgPath = resolve(appRoot, 'package.json');
128
+ const pkg = JSON.parse(await readFile(pkgPath));
129
+ const repo = pkg.repository?.url ?? pkg.repository;
130
+ const repoBase = (repo ?? '').replace(/^git\+/, '').replace(/\.git$/i, '');
131
+ const version = pkg.version;
132
+ const platform = getPlatform();
133
+
134
+ if (repoBase && version && platform) {
135
+ const fileName = `c2pa-node_${platform}-v${version}.zip`;
136
+ const downloadUrl = [
137
+ repoBase,
138
+ 'releases',
139
+ 'download',
140
+ `v${version}`,
141
+ fileName,
142
+ ].join('/');
143
+ return downloadFromUrl(appRoot, downloadUrl);
144
+ }
145
+
146
+ return false;
147
+ }
148
+
149
+ async function rustExists() {
150
+ try {
151
+ await Promise.all([pExec('rustc --version'), pExec('cargo --version')]);
152
+ return true;
153
+ } catch {
154
+ return false;
155
+ }
156
+ }
157
+
158
+ async function buildRust(root) {
159
+ console.log('🦀 Building Rust...');
160
+ const distDir = resolve(root, 'dist');
161
+ const bindingsPath = resolve(distDir, 'index.node');
162
+ const cargoPath = resolve(root, 'Cargo.toml');
163
+ await mkdirp(distDir);
164
+ return new Promise((resolve, reject) => {
165
+ const result = exec(
166
+ `npx cargo-cp-artifact -nc "${bindingsPath}" -- cargo build --message-format=json-render-diagnostics --release --manifest-path="${cargoPath}"`,
167
+ execCallback,
168
+ );
169
+ result.on('exit', (code) => {
170
+ code === 0 ? resolve() : reject();
171
+ });
172
+ });
173
+ }
174
+
175
+ async function main() {
176
+ const { packageDirectory } = await import('pkg-dir');
177
+ const appRoot = await packageDirectory(__filename);
178
+ const distRoot = resolve(appRoot, 'dist');
179
+ const cargoDistPath = resolve(distRoot, 'Cargo.toml');
180
+ const libraryOverridePath = process.env.C2PA_LIBRARY_PATH;
181
+ const cargoDistPathExists = await fileExists(cargoDistPath);
182
+ const rustToolchainExists = await rustExists();
183
+
184
+ if (libraryOverridePath) {
185
+ console.log('Skipping Rust build since C2PA_LIBRARY_PATH is set');
186
+ return;
187
+ }
188
+
189
+ if (process.env.SKIP_BINARY_DOWNLOAD) {
190
+ console.log(
191
+ 'Skipping prebuilt binary download since SKIP_BINARY_DOWNLOAD is set',
192
+ );
193
+ } else if (await downloadBinary(appRoot)) {
194
+ return;
195
+ }
196
+
197
+ if (!rustToolchainExists) {
198
+ console.warn('Skipping Rust build since Rust and/or Cargo is not found');
199
+ } else if (cargoDistPathExists) {
200
+ await buildRust(distRoot);
201
+ } else {
202
+ await buildRust(appRoot);
203
+ }
204
+ }
205
+
206
+ if (!process.env.SKIP_RUST_BUILD) {
207
+ main();
208
+ } else {
209
+ console.log('Skipping Rust build since SKIP_RUST_BUILD is set');
210
+ }
package/src/asset.rs ADDED
@@ -0,0 +1,114 @@
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
+
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
+ use crate::error::Error;
15
+ use c2pa::format_from_path;
16
+ use neon::prelude::*;
17
+ use neon::types::buffer::TypedArray;
18
+ use std::fs::{File, OpenOptions};
19
+ use std::io::{BufReader, Cursor, Read, Seek, Write};
20
+ use std::path::Path;
21
+
22
+ pub(crate) trait NeonReadStreamTrait: Read + Seek + Send {}
23
+ pub(crate) trait NeonWriteStreamTrait: Write + Read + Seek + Send {}
24
+
25
+ impl NeonReadStreamTrait for Cursor<Vec<u8>> {}
26
+ impl NeonReadStreamTrait for BufReader<File> {}
27
+
28
+ impl NeonWriteStreamTrait for Cursor<Vec<u8>> {}
29
+ impl NeonWriteStreamTrait for File {}
30
+
31
+ pub enum Asset {
32
+ SourceBuffer(Vec<u8>, String),
33
+ File(String, Option<String>),
34
+ DestinationBuffer(Vec<u8>),
35
+ }
36
+
37
+ impl Asset {
38
+ pub fn mime_type(&self) -> Option<String> {
39
+ match self {
40
+ Asset::SourceBuffer(_, mime_type) => Some(mime_type.to_string()),
41
+ Asset::File(path, mime_type) => match mime_type {
42
+ Some(mime_type) => Some(mime_type.to_string()),
43
+ None => format_from_path(Path::new(&path)),
44
+ },
45
+ _ => None,
46
+ }
47
+ }
48
+ pub fn into_read_stream(self) -> Result<Box<dyn NeonReadStreamTrait>, Error> {
49
+ match self {
50
+ Asset::SourceBuffer(buffer, _) => Ok(Box::new(Cursor::new(buffer))),
51
+ Asset::File(path, _) => {
52
+ let file = File::open(Path::new(&path)).map_err(Error::from)?;
53
+ Ok(Box::new(BufReader::new(file)))
54
+ }
55
+ _ => Err(Error::Asset("Cannot write to source buffer".to_string())),
56
+ }
57
+ }
58
+
59
+ pub fn write_stream(&self) -> Result<Box<dyn NeonWriteStreamTrait>, Error> {
60
+ match self {
61
+ Asset::File(path, _) => {
62
+ let file = OpenOptions::new()
63
+ .read(true)
64
+ .write(true)
65
+ .create(true)
66
+ .truncate(true)
67
+ .open(Path::new(&path))
68
+ .map_err(Error::from)?;
69
+ Ok(Box::new(file))
70
+ }
71
+ Asset::DestinationBuffer(buffer) => Ok(Box::new(Cursor::new(buffer.to_owned()))),
72
+ _ => Err(Error::Asset("Cannot write to source buffer".to_string())),
73
+ }
74
+ }
75
+
76
+ pub fn name(&self) -> &str {
77
+ match self {
78
+ Asset::File(_, _) => "file",
79
+ Asset::DestinationBuffer(_) => "destination_buffer",
80
+ Asset::SourceBuffer(_, _) => "source_buffer",
81
+ }
82
+ }
83
+ }
84
+
85
+ pub fn parse_asset(cx: &mut FunctionContext, obj: Handle<JsObject>) -> NeonResult<Asset> {
86
+ let mime_type = obj
87
+ .get_opt::<JsString, _, _>(cx, "mimeType")?
88
+ .map(|val| val.value(cx))
89
+ .or(None);
90
+ let path = obj
91
+ .get_opt::<JsString, _, _>(cx, "path")?
92
+ .map(|val| val.value(cx))
93
+ .or(None);
94
+ let buffer_value = obj.get::<JsValue, _, _>(cx, "buffer")?;
95
+ let buffer = if buffer_value.is_a::<JsBuffer, _>(cx) {
96
+ Some(
97
+ buffer_value
98
+ .downcast_or_throw::<JsBuffer, _>(cx)?
99
+ .as_slice(cx)
100
+ .to_vec(),
101
+ )
102
+ } else {
103
+ None
104
+ };
105
+
106
+ match (buffer, mime_type.clone(), path) {
107
+ (Some(buffer), Some(mime_type), _) => Ok(Asset::SourceBuffer(buffer, mime_type)),
108
+ (None, _, Some(path)) => Ok(Asset::File(path, mime_type)),
109
+ (None, _, None) => Ok(Asset::DestinationBuffer(Vec::new())),
110
+ _ => cx.throw_error(
111
+ "Invalid asset data passed. Must contain either a buffer and mimeType or a path.",
112
+ ),
113
+ }
114
+ }
package/src/error.rs ADDED
@@ -0,0 +1,104 @@
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
+
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
+ use std::sync::PoisonError;
15
+
16
+ use neon::prelude::*;
17
+ use thiserror::Error;
18
+
19
+ #[derive(Error, Debug)]
20
+ pub enum Error {
21
+ #[error("Asset parsing failed: {0}")]
22
+ Asset(String),
23
+
24
+ #[error("Async signing failed {0}")]
25
+ AsyncSigning(String),
26
+
27
+ #[error(transparent)]
28
+ C2pa(#[from] c2pa::Error),
29
+
30
+ #[error(transparent)]
31
+ FileIO(#[from] std::io::Error),
32
+
33
+ #[error(transparent)]
34
+ Image(#[from] image::ImageError),
35
+
36
+ #[error(transparent)]
37
+ Json(#[from] serde_json::Error),
38
+
39
+ #[error("Lock acquisition failed: {0}")]
40
+ Lock(String),
41
+
42
+ #[error(transparent)]
43
+ NeonSerde(#[from] neon_serde4::errors::Error),
44
+
45
+ #[error("Trustmark model download failed")]
46
+ ModelDownload(String),
47
+
48
+ #[error(transparent)]
49
+ RemoteManifestFetch(#[from] reqwest::Error),
50
+
51
+ #[error("Settings handling failed: {0}")]
52
+ Settings(String),
53
+
54
+ #[error("Signing failed: {0}")]
55
+ Signing(String),
56
+
57
+ #[error(transparent)]
58
+ TokioJoin(#[from] tokio::task::JoinError),
59
+
60
+ #[error(transparent)]
61
+ TokioTimeout(#[from] tokio::time::error::Elapsed),
62
+
63
+ #[error(transparent)]
64
+ TokioLock(#[from] tokio::sync::TryLockError),
65
+
66
+ #[error(transparent)]
67
+ Watermark(#[from] trustmark::Error),
68
+
69
+ #[error("Watermark configuration error: {0}")]
70
+ WatermarkConfiguration(String),
71
+
72
+ #[error(transparent)]
73
+ UTF8(#[from] std::str::Utf8Error),
74
+ }
75
+
76
+ impl<T> From<PoisonError<T>> for Error {
77
+ fn from(err: PoisonError<T>) -> Self {
78
+ Error::Lock(err.to_string())
79
+ }
80
+ }
81
+
82
+ // Implement Send for Error
83
+ unsafe impl Send for Error {}
84
+ unsafe impl Sync for Error {}
85
+
86
+ #[allow(dead_code)]
87
+ pub type Result<T> = std::result::Result<T, Error>;
88
+
89
+ pub fn as_js_error<'a>(cx: &mut TaskContext<'a>, err: Error) -> JsResult<'a, JsError> {
90
+ cx.execute_scoped(|mut cx| {
91
+ let js_err = cx.error(err.to_string())?;
92
+ let js_err_name = cx.string(format!("{err:?}"));
93
+ js_err.set(&mut cx, "name", js_err_name)?;
94
+
95
+ Ok(js_err)
96
+ })
97
+ }
98
+
99
+ pub fn as_js_error_fn<'a>(cx: &mut FunctionContext<'a>, err: Error) -> JsResult<'a, JsError> {
100
+ let js_err = cx.error(err.to_string())?;
101
+ let js_err_name = cx.string(format!("{err:?}"));
102
+ js_err.set(cx, "name", js_err_name)?;
103
+ Ok(js_err)
104
+ }
package/src/lib.rs ADDED
@@ -0,0 +1,185 @@
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
+
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
+ use neon::prelude::*;
15
+
16
+ mod asset;
17
+ mod error;
18
+ mod runtime;
19
+ mod settings;
20
+ mod utils;
21
+
22
+ pub mod neon_builder;
23
+ pub mod neon_credential_holder;
24
+ pub mod neon_identity_assertion_builder;
25
+ pub mod neon_identity_assertion_signer;
26
+ pub mod neon_reader;
27
+ pub mod neon_signer;
28
+ pub mod neon_trustmark;
29
+
30
+ #[neon::main]
31
+ fn main(mut cx: ModuleContext) -> NeonResult<()> {
32
+ // Builder
33
+ cx.export_function("builderNew", neon_builder::NeonBuilder::new)?;
34
+ cx.export_function("builderWithJson", neon_builder::NeonBuilder::with_json)?;
35
+ cx.export_function("builderSetNoEmbed", neon_builder::NeonBuilder::set_no_embed)?;
36
+ cx.export_function(
37
+ "builderSetRemote_url",
38
+ neon_builder::NeonBuilder::set_remote_url,
39
+ )?;
40
+ cx.export_function(
41
+ "builderAddAssertion",
42
+ neon_builder::NeonBuilder::add_assertion,
43
+ )?;
44
+ cx.export_function(
45
+ "builderAddResource",
46
+ neon_builder::NeonBuilder::add_resource,
47
+ )?;
48
+ cx.export_function(
49
+ "builderAddIngredient",
50
+ neon_builder::NeonBuilder::add_ingredient,
51
+ )?;
52
+ cx.export_function("builderToArchive", neon_builder::NeonBuilder::to_archive)?;
53
+ cx.export_function(
54
+ "builderFromArchive",
55
+ neon_builder::NeonBuilder::from_archive,
56
+ )?;
57
+ cx.export_function("builderSign", neon_builder::NeonBuilder::sign)?;
58
+ cx.export_function(
59
+ "builderSignConfigAsync",
60
+ neon_builder::NeonBuilder::sign_config_async,
61
+ )?;
62
+ cx.export_function("builderSignAsync", neon_builder::NeonBuilder::sign_async)?;
63
+ cx.export_function(
64
+ "builderIdentitySignAsync",
65
+ neon_builder::NeonBuilder::identity_sign_async,
66
+ )?;
67
+ cx.export_function(
68
+ "builderManifestDefinition",
69
+ neon_builder::NeonBuilder::manifest_definition,
70
+ )?;
71
+ cx.export_function(
72
+ "builderUpdateManifestProperty",
73
+ neon_builder::NeonBuilder::update_manifest_property,
74
+ )?;
75
+
76
+ // Reader
77
+ cx.export_function("readerNew", neon_reader::NeonReader::new)?;
78
+ cx.export_function("readerFromAsset", neon_reader::NeonReader::from_stream)?;
79
+ cx.export_function(
80
+ "readerFromManifestDataAndAsset",
81
+ neon_reader::NeonReader::from_manifest_data_and_asset,
82
+ )?;
83
+ cx.export_function(
84
+ "readerFromManifestDataAndFile",
85
+ neon_reader::NeonReader::from_manifest_data_and_asset,
86
+ )?;
87
+ cx.export_function("readerJson", neon_reader::NeonReader::json)?;
88
+ cx.export_function("readerRemoteUrl", neon_reader::NeonReader::remote_url)?;
89
+ cx.export_function("readerIsEmbedded", neon_reader::NeonReader::is_embedded)?;
90
+ cx.export_function(
91
+ "readerResourceToAsset",
92
+ neon_reader::NeonReader::resource_to_asset,
93
+ )?;
94
+ cx.export_function(
95
+ "readerPostValidateCawg",
96
+ neon_reader::NeonReader::post_validate_cawg,
97
+ )?;
98
+
99
+ // Signers
100
+ cx.export_function("localSignerNew", neon_signer::NeonLocalSigner::new)?;
101
+ cx.export_function("localSignerSign", neon_signer::NeonLocalSigner::sign)?;
102
+ cx.export_function("localSignerAlg", neon_signer::NeonLocalSigner::alg)?;
103
+ cx.export_function("localSignerCerts", neon_signer::NeonLocalSigner::certs)?;
104
+ cx.export_function(
105
+ "localSignerReserveSize",
106
+ neon_signer::NeonLocalSigner::reserve_size,
107
+ )?;
108
+ cx.export_function(
109
+ "localSignerTimeAuthorityUrl",
110
+ neon_signer::NeonLocalSigner::time_authority_url,
111
+ )?;
112
+ cx.export_function(
113
+ "callbackSignerFromConfig",
114
+ neon_signer::NeonCallbackSigner::from_config,
115
+ )?;
116
+ cx.export_function(
117
+ "callbackSignerConfigFromJs",
118
+ neon_signer::callback_signer_config_from_js,
119
+ )?;
120
+ cx.export_function("callbackSignerSign", neon_signer::NeonCallbackSigner::sign)?;
121
+ cx.export_function("callbackSignerAlg", neon_signer::NeonCallbackSigner::alg)?;
122
+ cx.export_function(
123
+ "callbackSignerCerts",
124
+ neon_signer::NeonCallbackSigner::certs,
125
+ )?;
126
+ cx.export_function(
127
+ "callbackSignerReserveSize",
128
+ neon_signer::NeonCallbackSigner::reserve_size,
129
+ )?;
130
+ cx.export_function(
131
+ "callbackSignerTimeAuthorityUrl",
132
+ neon_signer::NeonCallbackSigner::time_authority_url,
133
+ )?;
134
+
135
+ // Identity Assertions
136
+ cx.export_function(
137
+ "identitySignerNew",
138
+ neon_identity_assertion_signer::NeonIdentityAssertionSigner::new,
139
+ )?;
140
+ cx.export_function(
141
+ "identitySignerAddIdentityAssertion",
142
+ neon_identity_assertion_signer::NeonIdentityAssertionSigner::add_identity_assertion,
143
+ )?;
144
+ cx.export_function(
145
+ "identityBuilderForCredentialHolder",
146
+ neon_identity_assertion_builder::NeonIdentityAssertionBuilder::for_credential_holder,
147
+ )?;
148
+ cx.export_function(
149
+ "identityBuilderAddReferencedAssertions",
150
+ neon_identity_assertion_builder::NeonIdentityAssertionBuilder::add_referenced_assertions,
151
+ )?;
152
+ cx.export_function(
153
+ "identityBuilderAddRoles",
154
+ neon_identity_assertion_builder::NeonIdentityAssertionBuilder::add_roles,
155
+ )?;
156
+ cx.export_function(
157
+ "newCallbackCredentialHolder",
158
+ neon_credential_holder::NeonCallbackCredentialHolder::from_js,
159
+ )?;
160
+
161
+ // Trustmark
162
+ cx.export_function(
163
+ "trustmarkNew",
164
+ neon_trustmark::NeonTrustmark::new_from_config,
165
+ )?;
166
+ cx.export_function("trustmarkEncode", neon_trustmark::NeonTrustmark::encode)?;
167
+ cx.export_function("trustmarkDecode", neon_trustmark::NeonTrustmark::decode)?;
168
+
169
+ // Settings
170
+ cx.export_function("loadSettings", settings::load_settings)?;
171
+ cx.export_function("loadSettingsToml", settings::load_settings_toml)?;
172
+ cx.export_function("getSettingsJson", settings::get_settings_json)?;
173
+
174
+ // Trust Settings
175
+ cx.export_function("loadTrustConfig", settings::load_trust_config)?;
176
+ cx.export_function("loadCawgTrustConfig", settings::load_cawg_trust_config)?;
177
+ cx.export_function("getTrustConfig", settings::get_trust_config)?;
178
+ cx.export_function("getCawgTrustConfig", settings::get_cawg_trust_config)?;
179
+
180
+ // Verify Settings
181
+ cx.export_function("loadVerifyConfig", settings::load_verify_config)?;
182
+ cx.export_function("getVerifyConfig", settings::get_verify_config)?;
183
+
184
+ Ok(())
185
+ }