@contentauth/c2pa-node 0.9.1 → 0.9.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.
@@ -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 * as fs from "fs-extra";
6
+ import fs from "fs-extra";
7
7
  import path from "path";
8
8
  import * as crypto from "crypto";
9
9
  import { isActionsAssertion } from "./assertions.js";
@@ -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 * as fs from "fs-extra";
6
+ import fs from "fs-extra";
7
7
  import * as crypto from "crypto";
8
8
  import { encode } from "cbor2";
9
9
  class TestSigner {
@@ -4,7 +4,7 @@
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
6
  import path from "path";
7
- import * as fs from "fs-extra";
7
+ import fs from "fs-extra";
8
8
  import { AssetTooLargeError } from "@contentauth/c2pa-utilities";
9
9
  import { Reader } from "./Reader.js";
10
10
  import { MAX_SIZE_IN_BYTES } from "./assetSize.js";
package/dist/Settings.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
10
10
  // specific language governing permissions and limitations under
11
11
  // each license.
12
- import * as fs from "fs-extra";
12
+ import fs from "fs-extra";
13
13
  /**
14
14
  * This file contains only Settings functions that are unique to the Node SDK.
15
15
  *
@@ -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 * as fs from "fs-extra";
6
+ import fs from "fs-extra";
7
7
  import * as path from "path";
8
8
  import * as os from "os";
9
9
  import { loadSettingsFromFile } from "./Settings.js";
@@ -10,7 +10,7 @@
10
10
  // specific language governing permissions and limitations under
11
11
  // each license.
12
12
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
13
- import * as fs from "fs-extra";
13
+ import fs from "fs-extra";
14
14
  import * as crypto from "crypto";
15
15
  import { CallbackSigner } from "./Signer.js";
16
16
  import { Builder } from "./Builder.js";
@@ -10,7 +10,7 @@
10
10
  // specific language governing permissions and limitations under
11
11
  // each license.
12
12
  import path from "path";
13
- import * as fs from "fs-extra";
13
+ import fs from "fs-extra";
14
14
  import sharp from "sharp";
15
15
  import { Trustmark } from "./Trustmark.js";
16
16
  const tempDir = path.join(__dirname, "..", "tmp");
package/dist/assetSize.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
10
10
  // specific language governing permissions and limitations under
11
11
  // each license.
12
- import * as fs from "fs-extra";
12
+ import fs from "fs-extra";
13
13
  import { validateAssetSize } from "@contentauth/c2pa-utilities";
14
14
  // c2pa-node runs server-side, so it can reasonably support larger assets than c2pa-web,
15
15
  // and may be less resource-constrained in comparison.
package/dist/index.node CHANGED
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/contentauth/c2pa-js.git",
6
6
  "directory": "packages/c2pa-node"
7
7
  },
8
- "version": "0.9.1",
8
+ "version": "0.9.3",
9
9
  "description": "Node.js bindings for C2PA",
10
10
  "main": "dist/index.js",
11
11
  "type": "module",
@@ -64,8 +64,8 @@
64
64
  "pkg-dir": "^8.0.0",
65
65
  "pretty-bytes": "^6.1.1",
66
66
  "unzipper": "^0.10.14",
67
- "@contentauth/c2pa-types": "0.7.3",
68
- "@contentauth/c2pa-utilities": "0.2.1"
67
+ "@contentauth/c2pa-types": "0.7.4",
68
+ "@contentauth/c2pa-utilities": "0.2.2"
69
69
  },
70
70
  "nx": {
71
71
  "tags": [
package/src/asset.rs CHANGED
@@ -11,14 +11,16 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::error::Error;
15
- use c2pa::format_from_path;
16
- use neon::prelude::*;
17
- use neon::types::buffer::TypedArray;
18
14
  use std::fs::{File, OpenOptions};
19
15
  use std::io::{BufReader, Cursor, Read, Seek, Write};
20
16
  use std::path::Path;
21
17
 
18
+ use c2pa::format_from_path;
19
+ use neon::prelude::*;
20
+ use neon::types::buffer::TypedArray;
21
+
22
+ use crate::error::Error;
23
+
22
24
  pub(crate) trait NeonReadStreamTrait: Read + Seek + Send {}
23
25
  pub(crate) trait NeonWriteStreamTrait: Write + Read + Seek + Send {}
24
26
 
@@ -11,6 +11,20 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
+ use std::io::Cursor;
15
+ use std::ops::Deref;
16
+ use std::sync::Arc;
17
+
18
+ use c2pa::{
19
+ assertions::{Action, Actions},
20
+ Builder, BuilderIntent, Ingredient, Reader,
21
+ };
22
+ use neon::context::Context as NeonContext;
23
+ use neon::prelude::*;
24
+ use neon_serde4;
25
+ use serde_json;
26
+ use tokio::sync::Mutex;
27
+
14
28
  use crate::asset::parse_asset;
15
29
  use crate::error::{as_js_error, Error};
16
30
  use crate::neon_identity_assertion_signer::NeonIdentityAssertionSigner;
@@ -18,15 +32,6 @@ use crate::neon_reader::NeonReader;
18
32
  use crate::neon_signer::{CallbackSignerConfig, NeonCallbackSigner, NeonLocalSigner};
19
33
  use crate::runtime::runtime;
20
34
  use crate::utils::parse_settings;
21
- use c2pa::{assertions::{Action, Actions}, Builder, BuilderIntent, Ingredient, Reader};
22
- use neon::context::Context as NeonContext;
23
- use neon::prelude::*;
24
- use neon_serde4;
25
- use serde_json;
26
- use std::io::Cursor;
27
- use std::ops::Deref;
28
- use std::sync::Arc;
29
- use tokio::sync::Mutex;
30
35
 
31
36
  pub struct NeonBuilder {
32
37
  builder: Arc<Mutex<Builder>>,
@@ -324,17 +329,11 @@ impl NeonBuilder {
324
329
  let promise = cx
325
330
  .task(move || {
326
331
  let source_stream = source.into_read_stream()?;
327
- let mut builder = if let Some(context) = context_opt {
332
+ let builder = if let Some(context) = context_opt {
328
333
  Builder::from_context(context).with_archive(source_stream)?
329
334
  } else {
330
335
  Builder::default().with_archive(source_stream)?
331
336
  };
332
- // The ARCHIVE_METADATA assertion is merely working-store bookkeeping
333
- // used to reconstruct a builder from an archive.
334
- builder
335
- .definition
336
- .assertions
337
- .retain(|a| a.label != c2pa::assertions::labels::ARCHIVE_METADATA);
338
337
  Ok(builder)
339
338
  })
340
339
  .promise(
@@ -11,13 +11,14 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
+ use std::sync::Arc;
15
+
14
16
  use async_trait::async_trait;
15
17
  use c2pa::identity::builder::{AsyncCredentialHolder, IdentityBuilderError};
16
18
  use c2pa::identity::SignerPayload;
17
19
  use neon::prelude::*;
18
20
  use neon::types::buffer::TypedArray;
19
21
  use neon_serde4;
20
- use std::sync::Arc;
21
22
  use tokio::sync::oneshot;
22
23
 
23
24
  /// NeonCallbackCredentialHolder allows JS to asynchronously sign a SignerPayload.
@@ -11,7 +11,9 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::neon_credential_holder::NeonCallbackCredentialHolder;
14
+ use std::ops::Deref;
15
+ use std::sync::RwLock;
16
+
15
17
  use c2pa::{
16
18
  dynamic_assertion::{AsyncDynamicAssertion, DynamicAssertionContent},
17
19
  identity::{builder::AsyncCredentialHolder, SignerPayload},
@@ -19,8 +21,8 @@ use c2pa::{
19
21
  use neon::prelude::*;
20
22
  use serde::{Deserialize, Serialize};
21
23
  use serde_bytes::ByteBuf;
22
- use std::ops::Deref;
23
- use std::sync::RwLock;
24
+
25
+ use crate::neon_credential_holder::NeonCallbackCredentialHolder;
24
26
 
25
27
  /// A `NeonIdentityAssertionBuilder` gathers the necessary components
26
28
  /// for an identity assertion using a Neon-based credential holder.
@@ -11,9 +11,9 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::{
15
- neon_identity_assertion_builder::NeonIdentityAssertionBuilder, neon_signer::NeonCallbackSigner,
16
- };
14
+ use std::ops::Deref;
15
+ use std::sync::RwLock;
16
+
17
17
  use async_trait::async_trait;
18
18
  use c2pa::{
19
19
  crypto::{
@@ -25,8 +25,10 @@ use c2pa::{
25
25
  };
26
26
  use neon::prelude::FunctionContext;
27
27
  use neon::prelude::*;
28
- use std::ops::Deref;
29
- use std::sync::RwLock;
28
+
29
+ use crate::{
30
+ neon_identity_assertion_builder::NeonIdentityAssertionBuilder, neon_signer::NeonCallbackSigner,
31
+ };
30
32
 
31
33
  pub struct NeonIdentityAssertionSigner {
32
34
  signer: RwLock<NeonCallbackSigner>,
@@ -11,17 +11,19 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::asset::parse_asset;
15
- use crate::error::{as_js_error, Error, Result};
16
- use crate::runtime::runtime;
17
- use crate::utils::parse_settings;
14
+ use std::sync::Arc;
15
+
18
16
  use c2pa::Reader;
19
17
  use neon::context::Context as NeonContext;
20
18
  use neon::prelude::*;
21
19
  use neon::types::buffer::TypedArray;
22
- use std::sync::Arc;
23
20
  use tokio::sync::Mutex;
24
21
 
22
+ use crate::asset::parse_asset;
23
+ use crate::error::{as_js_error, Error, Result};
24
+ use crate::runtime::runtime;
25
+ use crate::utils::parse_settings;
26
+
25
27
  #[derive(Debug)]
26
28
  pub struct NeonReader {
27
29
  reader: Arc<Mutex<Reader>>,
@@ -11,7 +11,9 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::runtime::runtime;
14
+ use std::ops::Deref;
15
+ use std::{boxed::Box, str::FromStr, sync::Arc};
16
+
15
17
  use async_trait::async_trait;
16
18
  use c2pa::{
17
19
  create_signer,
@@ -25,11 +27,10 @@ use c2pa::{
25
27
  };
26
28
  use neon::prelude::*;
27
29
  use neon::types::buffer::TypedArray;
28
- use std::ops::Deref;
29
- use std::{boxed::Box, str::FromStr, sync::Arc};
30
30
  use tokio::sync::oneshot;
31
31
 
32
32
  use crate::error::Error;
33
+ use crate::runtime::runtime;
33
34
 
34
35
  #[derive(Debug, Clone)]
35
36
  pub struct CallbackSignerConfig {
@@ -11,13 +11,6 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
- use crate::error::{as_js_error, as_js_error_fn, Error, Result};
15
- use crate::runtime::runtime;
16
- use neon::prelude::*;
17
- use neon::result::{JsResult, NeonResult};
18
- use neon::types::{buffer::TypedArray, Finalize, JsObject};
19
- use rand::{distributions::Standard, prelude::Distribution as _};
20
- use reqwest::Client;
21
14
  use std::{
22
15
  fs::OpenOptions,
23
16
  io::Write,
@@ -25,8 +18,17 @@ use std::{
25
18
  sync::{Arc, Mutex},
26
19
  time::Duration,
27
20
  };
21
+
22
+ use neon::prelude::*;
23
+ use neon::result::{JsResult, NeonResult};
24
+ use neon::types::{buffer::TypedArray, Finalize, JsObject};
25
+ use rand::{distributions::Standard, prelude::Distribution as _};
26
+ use reqwest::Client;
28
27
  use trustmark::{Trustmark, Variant, Version};
29
28
 
29
+ use crate::error::{as_js_error, as_js_error_fn, Error, Result};
30
+ use crate::runtime::runtime;
31
+
30
32
  #[derive(Clone)]
31
33
  pub struct WatermarkConfig {
32
34
  variant: Variant,
package/src/runtime.rs CHANGED
@@ -6,6 +6,7 @@
6
6
  // it.
7
7
 
8
8
  use std::sync::{Arc, OnceLock};
9
+
9
10
  use tokio::runtime::{Builder, Runtime};
10
11
 
11
12
  // Runtime singleton - no longer needs reload functionality since settings are per-instance
package/src/utils.rs CHANGED
@@ -49,7 +49,7 @@ pub fn parse_settings(
49
49
  .downcast::<JsString, _>(cx)
50
50
  .map_err(|_| {
51
51
  Error::Signing(format!("{error_prefix}: Expected settings string"))
52
- })?
52
+ })?
53
53
  .value(cx);
54
54
 
55
55
  // Create context with settings