@contentauth/c2pa-web 0.16.1 → 0.17.0

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
@@ -104,22 +104,23 @@ const reader2 = await Reader.fromBlob(
104
104
 
105
105
  Each `Context` holds whatever single `Settings` object was passed to its constructor and does not handle any merging of settings. To combine more than one `Settings` source, merge them first with `mergeSettings()`, then construct a `Context` from the single, merged result. See [`c2pa-utilities`'s README](../c2pa-utilities/README.md#combining-settings) for details.
106
106
 
107
- A `Context`'s settings are resolved once upon creation and then memoized for re-use. Passing the same `Context` instance to multiple `Reader`/`Builder` calls doesn't re-fetch trust-anchor URLs on every call.
107
+ A `Context`'s settings are resolved on its first use and then memoized for re-use. Passing the same `Context` instance to multiple `Reader`/`Builder` calls doesn't re-fetch trust-anchor URLs on every call.
108
108
 
109
- ### Factory API (deprecated)
109
+ `Context` is defined in `@contentauth/c2pa-utilities` and re-exported unchanged by `@contentauth/c2pa-node`, `@contentauth/c2pa-web` and `@contentauth/c2pa-web/inline`. These entry points share constructor identity and types, including for subclasses. Application bundlers should resolve a single compatible utilities version rather than embedding separate copies.
110
110
 
111
- Earlier versions of `c2pa-web` configured the SDK once via `createC2pa({ settings })`, and created `Reader`/`Builder` objects through `c2pa.reader`/`c2pa.builder` factory methods that took a raw `Settings` object per call, merged over those top-level settings. This is still supported, but deprecated in favor of `Reader`/`Builder`'s static methods with an explicit `Context`, shown above, and will be removed in a future version:
111
+ ### Migrating from the deprecated factory API
112
112
 
113
- ```typescript
114
- const c2pa = await createC2pa({ wasmSrc, settings: { verify: { verifyTrust: true } } });
113
+ `createC2pa({ settings })`, `c2pa.reader` and `c2pa.builder` have been removed, including from `/inline`. Use the static Reader/Builder methods with a `Context` instead:
115
114
 
116
- // Settings passed here are merged over, and take precedence over, the top-level settings above.
117
- const reader = await c2pa.reader.fromBlob(blob.type, blob, {
118
- trust: { trustAnchors: 'https://example.com/trust-anchors.pem' }
119
- });
120
- const builder = await c2pa.builder.new();
115
+ ```typescript
116
+ const c2pa = await createC2pa({ wasmSrc });
117
+ const context = new Context(mergeSettings(baseSettings, perInstanceSettings));
118
+ const reader = await Reader.fromBlob(c2pa, blob.type, blob, context);
119
+ const builder = await Builder.new(c2pa, context);
121
120
  ```
122
121
 
122
+ Import `mergeSettings` from the same SDK entry point to preserve the old top-level/per-call merge precedence explicitly. Use `Reader.fromBlobFragment`, `Builder.fromDefinition` and `Builder.fromArchive` for the corresponding removed factory methods. Omit the context argument, or pass `new Context()`, to use defaults. Raw settings objects and `null` are not Context arguments.
123
+
123
124
  ## Using the library
124
125
 
125
126
  See also the [versioned API reference documentation](https://contentauth.github.io/c2pa-js/web/).