@opentdf/sdk 0.4.0-beta.27 → 0.4.0-beta.29
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/cjs/tdf3/src/assertions.js +36 -1
- package/dist/cjs/tdf3/src/client/builders.js +13 -1
- package/dist/cjs/tdf3/src/client/index.js +2 -1
- package/dist/cjs/tdf3/src/tdf.js +13 -1
- package/dist/cjs/tdf3/src/utils/unwrap.js +2 -2
- package/dist/types/tdf3/src/assertions.d.ts +4 -0
- package/dist/types/tdf3/src/assertions.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/builders.d.ts +11 -0
- package/dist/types/tdf3/src/client/builders.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/tdf.d.ts +1 -0
- package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
- package/dist/types/tdf3/src/utils/unwrap.d.ts.map +1 -1
- package/dist/web/tdf3/src/assertions.js +35 -1
- package/dist/web/tdf3/src/client/builders.js +13 -1
- package/dist/web/tdf3/src/client/index.js +2 -1
- package/dist/web/tdf3/src/tdf.js +13 -1
- package/dist/web/tdf3/src/utils/unwrap.js +2 -2
- package/package.json +1 -1
- package/tdf3/src/assertions.ts +49 -0
- package/tdf3/src/client/builders.ts +14 -0
- package/tdf3/src/client/index.ts +1 -0
- package/tdf3/src/tdf.ts +18 -1
- package/tdf3/src/utils/unwrap.ts +2 -1
|
@@ -51,6 +51,7 @@ export type EncryptParams = {
|
|
|
51
51
|
splitPlan?: SplitStep[];
|
|
52
52
|
streamMiddleware?: EncryptStreamMiddleware;
|
|
53
53
|
assertionConfigs?: AssertionConfig[];
|
|
54
|
+
systemMetadataAssertion?: boolean;
|
|
54
55
|
defaultKASEndpoint?: string;
|
|
55
56
|
|
|
56
57
|
// Preferred wrapping key algorithm. Used when KID resolution is not available.
|
|
@@ -500,6 +501,19 @@ class EncryptParamsBuilder {
|
|
|
500
501
|
this._params.assertionConfigs = assertionConfigs;
|
|
501
502
|
return this;
|
|
502
503
|
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Specifies whether a default system metadata assertion should be automatically
|
|
507
|
+
* included during the encryption process.
|
|
508
|
+
*
|
|
509
|
+
* @param {boolean} systemMetadataAssertion - True to include the system metadata assertion, false otherwise.
|
|
510
|
+
* @returns {EncryptParamsBuilder} The current instance of the EncryptParamsBuilder for method chaining.
|
|
511
|
+
* @see {@link getSystemMetadataAssertionConfig}
|
|
512
|
+
*/
|
|
513
|
+
withSystemMetadataAssertion(systemMetadataAssertion: boolean): EncryptParamsBuilder {
|
|
514
|
+
this._params.systemMetadataAssertion = systemMetadataAssertion;
|
|
515
|
+
return this;
|
|
516
|
+
}
|
|
503
517
|
}
|
|
504
518
|
|
|
505
519
|
export type DecryptKeyMiddleware = (key: Binary) => Promise<Binary>;
|
package/tdf3/src/client/index.ts
CHANGED
package/tdf3/src/tdf.ts
CHANGED
|
@@ -147,6 +147,7 @@ export type EncryptConfiguration = {
|
|
|
147
147
|
keyForEncryption: KeyInfo;
|
|
148
148
|
keyForManifest: KeyInfo;
|
|
149
149
|
assertionConfigs?: AssertionConfig[];
|
|
150
|
+
systemMetadataAssertion?: boolean;
|
|
150
151
|
tdfSpecVersion?: string;
|
|
151
152
|
};
|
|
152
153
|
|
|
@@ -534,8 +535,24 @@ export async function writeStream(cfg: EncryptConfiguration): Promise<DecoratedR
|
|
|
534
535
|
manifest.encryptionInformation.integrityInformation.segments = segmentInfos;
|
|
535
536
|
|
|
536
537
|
manifest.encryptionInformation.method.isStreamable = true;
|
|
537
|
-
|
|
538
538
|
const signedAssertions: assertions.Assertion[] = [];
|
|
539
|
+
if (cfg.systemMetadataAssertion) {
|
|
540
|
+
const systemMetadataConfigBase = assertions.getSystemMetadataAssertionConfig();
|
|
541
|
+
const signingKeyForSystemMetadata: AssertionKey = {
|
|
542
|
+
alg: 'HS256', // Default algorithm, can be configured if needed
|
|
543
|
+
key: new Uint8Array(cfg.keyForEncryption.unwrappedKeyBinary.asArrayBuffer()),
|
|
544
|
+
};
|
|
545
|
+
signedAssertions.push(
|
|
546
|
+
await assertions.CreateAssertion(
|
|
547
|
+
aggregateHash,
|
|
548
|
+
{
|
|
549
|
+
...systemMetadataConfigBase, // Spread the properties from the base config
|
|
550
|
+
signingKey: signingKeyForSystemMetadata, // Add the signing key
|
|
551
|
+
},
|
|
552
|
+
cfg.tdfSpecVersion // Pass the TDF spec version
|
|
553
|
+
)
|
|
554
|
+
);
|
|
555
|
+
}
|
|
539
556
|
if (cfg.assertionConfigs && cfg.assertionConfigs.length > 0) {
|
|
540
557
|
await Promise.all(
|
|
541
558
|
cfg.assertionConfigs.map(async (assertionConfig) => {
|
package/tdf3/src/utils/unwrap.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { InvalidFileError } from '../../../src/errors.js';
|
|
|
3
3
|
|
|
4
4
|
export function unwrapHtml(htmlPayload: Uint8Array): Uint8Array {
|
|
5
5
|
const html = new TextDecoder().decode(htmlPayload);
|
|
6
|
-
const payloadRe =
|
|
6
|
+
const payloadRe =
|
|
7
|
+
/<input\s+[^>]*id=(?:['"]?)data-input(?:['"]?)[^>]*value=(?:['"]?)([a-zA-Z0-9+/=\-_]+)(?:['"]?)/;
|
|
7
8
|
const reResult = payloadRe.exec(html);
|
|
8
9
|
if (!reResult) {
|
|
9
10
|
throw new InvalidFileError('Payload is missing');
|