@contentauth/c2pa-web 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -12,14 +12,55 @@ npm install @contentauth/c2pa-web
12
12
 
13
13
  ## Quickstart
14
14
 
15
+ ### Importing
16
+
17
+ Due to [specific requirements](https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running) around handling WASM modules, there are two methods of importing the library. One optimizes for performance, the other for convenience.
18
+
19
+ #### With a separate WASM binary (performance)
20
+
21
+ The recommended method of using the library requires that the WASM binary be hosted separately, to be fetched over the network at runtime.
22
+
23
+ With Vite:
24
+
25
+ ```typescript
26
+ import { createC2pa } from '@contentauth/c2pa-web';
27
+
28
+ import wasmSrc from '@contentauth/c2pa-web/resources/c2pa.wasm?url';
29
+
30
+ const c2pa = createC2pa({ wasmSrc });
31
+ ```
32
+
33
+ Use a solution appropriate to your tooling. Alternatively, the binary can be requested from a CDN:
34
+
35
+ ```typescript
36
+ import { createC2pa } from '@contentauth/c2pa-web';
37
+
38
+ // Ensure that [PACKAGE VERSION] matches the currently-installed version of @contentauth/c2pa-web.
39
+ const c2pa = await createC2pa({
40
+ wasmSrc:
41
+ 'https://cdn.jsdelivr.net/npm/@contentauth/c2pa-web@[PACKAGE VERSION]/dist/resources/c2pa_bg.wasm',
42
+ });
43
+ ```
44
+
45
+ #### With an inlined WASM binary (convenience)
46
+
47
+ In environments where it is not possible or not convenient to request a separate resource over the network, the "inline" SDK can be used. The WASM binary is encoded as a base64 string and included in the JavaScript file, so no (additional) network request is necessary. However, this adds _significant_ size to the JavaScript bundle, and cannot take advantage of the higher-performance
48
+ [`WebAssembly.compileStreaming()`](https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/JavaScript_interface/compileStreaming_static) API.
49
+
15
50
  ```typescript
16
- import { createC2pa } from "@contentauth/c2pa-web";
51
+ import { createC2pa } from '@contentauth/c2pa-web/inline';
52
+
53
+ const c2pa = await createC2pa();
54
+ ```
55
+
56
+ ### Use
17
57
 
18
- // Using vite's ?url query parameter - use a solution appropriate to your tooling.
19
- // This resolves to a WASM binary that must be available for the library to fetch at runtime.
20
- import wasmSrc from "@contentauth/c2pa-web/resources/c2pa.wasm?url";
58
+ Fetch an image and provide it to the `Reader`:
21
59
 
22
- const response = await fetch("https://spec.c2pa.org/public-testfiles/image/jpeg/adobe-20220124-C.jpg");
60
+ ```typescript
61
+ const response = await fetch(
62
+ 'https://spec.c2pa.org/public-testfiles/image/jpeg/adobe-20220124-C.jpg'
63
+ );
23
64
  const blob = await response.blob();
24
65
 
25
66
  const reader = await c2pa.reader.fromBlob(blob.type, blob);
@@ -31,15 +72,16 @@ console.log(manifestStore);
31
72
 
32
73
  ## Development
33
74
 
34
- ### Prerequsities
75
+ ### Prerequsities
35
76
 
36
- Ensure the repo-wide prerequisites [NX](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/) are installed.
77
+ Ensure the repo-wide prerequisites [NX](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/) are installed.
37
78
 
38
79
  [`c2pa-wasm`'s prerequisites](https://github.com/contentauth/c2pa-js-v2/tree/main/packages/c2pa-wasm) must also be installed.
39
80
 
40
81
  ### Building
41
82
 
42
83
  To build the library:
84
+
43
85
  ```sh
44
86
  nx build c2pa-web
45
87
  ```
@@ -47,11 +89,13 @@ nx build c2pa-web
47
89
  ### Testing
48
90
 
49
91
  This library relies on [Vitest](https://vitest.dev/) to run its tests in a headless browser. Before the tests can be run, the test browser binaries must be installed:
92
+
50
93
  ```sh
51
94
  pnpx playwright install
52
95
  ```
53
96
 
54
97
  To run the tests:
98
+
55
99
  ```
56
100
  nx test c2pa-web
57
101
  ```
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright 2025 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
+ export type * from './lib/c2pa.js';
10
+ export type { Reader, ReaderFactory } from './lib/reader.js';
11
+ export { isSupportedReaderFormat, READER_SUPPORTED_FORMATS, } from './lib/supportedFormats.js';
12
+ export type { Settings, VerifySettings, TrustSettings, } from './lib/settings.js';
13
+ export type * from '@contentauth/c2pa-types';
14
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mBAAmB,eAAe,CAAC;AAEnC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,QAAQ,EACR,cAAc,EACd,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,mBAAmB,yBAAyB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -6,9 +6,6 @@
6
6
  * accordance with the terms of the Adobe license agreement accompanying
7
7
  * it.
8
8
  */
9
- export * from './lib/c2pa.js';
10
- export type { Reader, ReaderFactory } from './lib/reader.js';
11
- export { isSupportedReaderFormat, READER_SUPPORTED_FORMATS, } from './lib/supportedFormats.js';
12
- export type { Settings, VerifySettings, TrustSettings } from './lib/settings.js';
13
- export type * from '@contentauth/c2pa-types';
9
+ export { createC2pa } from './lib/c2pa.js';
10
+ export * from './common.js';
14
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAC;AAE9B,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGjF,mBAAmB,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,cAAc,aAAa,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Config } from './lib/c2pa.js';
2
+ export type InlineConfig = Omit<Config, 'wasmSrc'>;
3
+ /**
4
+ * Creates a new instance of c2pa-web by setting up a web worker and preparing a WASM binary.
5
+ *
6
+ * This is the "inline" version which compiles the WASM binary from an inlined, base64-encoded string.
7
+ *
8
+ * @param config - SDK configuration object.
9
+ * @returns An object providing access to factory methods for creating new reader objects.
10
+ *
11
+ * @example Creating a new SDK instance and reader:
12
+ * ```
13
+ * const c2pa = await createC2pa();
14
+ *
15
+ * const reader = await c2pa.reader.fromBlob(imageBlob.type, imageBlob);
16
+ * ```
17
+ */
18
+ export declare function createC2pa(config?: InlineConfig): Promise<import('./common.js').C2paSdk>;
19
+ export * from './common.js';
20
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../src/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAgC,MAAM,EAAE,MAAM,eAAe,CAAC;AAGrE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,0CAOrD;AAED,cAAc,aAAa,CAAC"}