@opentdf/sdk 0.1.0-beta.1718 → 0.2.0-beta.1941
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 +45 -38
- package/dist/cjs/src/access.js +99 -62
- package/dist/cjs/src/auth/auth.js +5 -26
- package/dist/cjs/src/auth/oidc-clientcredentials-provider.js +1 -1
- package/dist/cjs/src/auth/oidc-externaljwt-provider.js +1 -1
- package/dist/cjs/src/auth/oidc-refreshtoken-provider.js +1 -1
- package/dist/cjs/src/auth/oidc.js +1 -1
- package/dist/cjs/src/auth/providers.js +1 -1
- package/dist/cjs/src/concurrency.js +3 -4
- package/dist/cjs/src/encodings/base64.js +4 -4
- package/dist/cjs/src/encodings/hex.js +5 -6
- package/dist/cjs/src/encodings/index.js +18 -8
- package/dist/cjs/src/errors.js +1 -1
- package/dist/cjs/src/index.js +28 -320
- package/dist/cjs/src/nanoclients.js +285 -0
- package/dist/cjs/src/nanoindex.js +47 -0
- package/dist/cjs/src/nanotdf/Client.js +35 -30
- package/dist/cjs/src/nanotdf/NanoTDF.js +1 -1
- package/dist/cjs/src/nanotdf/decrypt.js +2 -2
- package/dist/cjs/src/nanotdf/encrypt-dataset.js +2 -2
- package/dist/cjs/src/nanotdf/encrypt.js +2 -2
- package/dist/cjs/src/nanotdf/helpers/calculateByCurve.js +3 -4
- package/dist/cjs/src/nanotdf/helpers/getHkdfSalt.js +2 -2
- package/dist/cjs/src/nanotdf/models/Ciphers.js +3 -3
- package/dist/cjs/src/nanotdf/models/EcCurves.js +3 -3
- package/dist/cjs/src/nanotdf/models/Header.js +1 -1
- package/dist/cjs/src/nanotdf/models/Payload.js +1 -1
- package/dist/cjs/src/nanotdf/models/Policy/AbstractPolicy.js +1 -1
- package/dist/cjs/src/nanotdf/models/Policy/EmbeddedPolicy.js +1 -1
- package/dist/cjs/src/nanotdf/models/Policy/PolicyFactory.js +1 -1
- package/dist/cjs/src/nanotdf/models/ResourceLocator.js +1 -1
- package/dist/cjs/src/nanotdf/models/Signature.js +1 -1
- package/dist/cjs/src/nanotdf-crypto/ciphers.js +1 -1
- package/dist/cjs/src/nanotdf-crypto/decrypt.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/digest.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/ecdsaSignature.js +4 -5
- package/dist/cjs/src/nanotdf-crypto/encrypt.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/exportCryptoKey.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/generateKeyPair.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/generateRandomNumber.js +2 -2
- package/dist/cjs/src/nanotdf-crypto/index.js +21 -13
- package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +10 -8
- package/dist/cjs/src/nanotdf-crypto/pemPublicToCrypto.js +20 -11
- package/dist/cjs/src/opentdf.js +243 -0
- package/dist/cjs/src/policy/api.js +2 -3
- package/dist/cjs/src/policy/granter.js +3 -4
- package/dist/cjs/src/seekable.js +157 -0
- package/dist/cjs/src/tdf/AttributeObject.js +2 -4
- package/dist/cjs/src/tdf/Policy.js +3 -3
- package/dist/cjs/src/utils.js +13 -21
- package/dist/cjs/src/version.js +7 -3
- package/dist/cjs/tdf3/index.js +27 -16
- package/dist/cjs/tdf3/src/assertions.js +25 -11
- package/dist/cjs/tdf3/src/binary.js +1 -1
- package/dist/cjs/tdf3/src/ciphers/aes-gcm-cipher.js +1 -1
- package/dist/cjs/tdf3/src/ciphers/symmetric-cipher-base.js +1 -1
- package/dist/cjs/tdf3/src/client/DecoratedReadableStream.js +7 -74
- package/dist/cjs/tdf3/src/client/builders.js +26 -22
- package/dist/cjs/tdf3/src/client/index.js +91 -117
- package/dist/cjs/tdf3/src/client/validation.js +3 -3
- package/dist/cjs/tdf3/src/crypto/crypto-utils.js +1 -1
- package/dist/cjs/tdf3/src/crypto/index.js +18 -18
- package/dist/cjs/tdf3/src/index.js +22 -11
- package/dist/cjs/tdf3/src/models/attribute-set.js +1 -1
- package/dist/cjs/tdf3/src/models/encryption-information.js +3 -3
- package/dist/cjs/tdf3/src/models/index.js +1 -2
- package/dist/cjs/tdf3/src/models/key-access.js +67 -35
- package/dist/cjs/tdf3/src/models/policy.js +3 -3
- package/dist/cjs/tdf3/src/tdf.js +180 -395
- package/dist/cjs/tdf3/src/utils/buffer-crc32.js +2 -3
- package/dist/cjs/tdf3/src/utils/index.js +48 -38
- package/dist/cjs/tdf3/src/utils/keysplit.js +4 -5
- package/dist/cjs/tdf3/src/utils/unwrap.js +21 -0
- package/dist/cjs/tdf3/src/utils/zip-reader.js +4 -4
- package/dist/cjs/tdf3/src/utils/zip-writer.js +4 -4
- package/dist/types/src/access.d.ts +10 -4
- package/dist/types/src/access.d.ts.map +1 -1
- package/dist/types/src/auth/auth.d.ts +1 -28
- package/dist/types/src/auth/auth.d.ts.map +1 -1
- package/dist/types/src/auth/providers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -136
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/nanoclients.d.ts +107 -0
- package/dist/types/src/nanoclients.d.ts.map +1 -0
- package/dist/types/src/nanoindex.d.ts +5 -0
- package/dist/types/src/nanoindex.d.ts.map +1 -0
- package/dist/types/src/nanotdf/Client.d.ts +1 -13
- package/dist/types/src/nanotdf/Client.d.ts.map +1 -1
- package/dist/types/src/nanotdf/NanoTDF.d.ts +1 -1
- package/dist/types/src/nanotdf/NanoTDF.d.ts.map +1 -1
- package/dist/types/src/nanotdf/encrypt-dataset.d.ts +1 -1
- package/dist/types/src/nanotdf/encrypt-dataset.d.ts.map +1 -1
- package/dist/types/src/nanotdf/encrypt.d.ts +1 -1
- package/dist/types/src/nanotdf/encrypt.d.ts.map +1 -1
- package/dist/types/src/nanotdf/enum/CipherEnum.d.ts +1 -1
- package/dist/types/src/nanotdf/enum/CipherEnum.d.ts.map +1 -1
- package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts +1 -1
- package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts.map +1 -1
- package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts +1 -1
- package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts.map +1 -1
- package/dist/types/src/nanotdf/models/DefaultParams.d.ts +1 -1
- package/dist/types/src/nanotdf/models/ResourceLocator.d.ts.map +1 -1
- package/dist/types/src/nanotdf-crypto/digest.d.ts +1 -1
- package/dist/types/src/nanotdf-crypto/digest.d.ts.map +1 -1
- package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts +1 -1
- package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts.map +1 -1
- package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts +1 -1
- package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts.map +1 -1
- package/dist/types/src/nanotdf-crypto/index.d.ts +2 -3
- package/dist/types/src/nanotdf-crypto/index.d.ts.map +1 -1
- package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts.map +1 -1
- package/dist/types/src/opentdf.d.ts +106 -0
- package/dist/types/src/opentdf.d.ts.map +1 -0
- package/dist/types/src/seekable.d.ts +39 -0
- package/dist/types/src/seekable.d.ts.map +1 -0
- package/dist/types/src/tdf/AttributeObject.d.ts +0 -2
- package/dist/types/src/tdf/AttributeObject.d.ts.map +1 -1
- package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts +2 -2
- package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts.map +1 -1
- package/dist/types/src/tdf/Policy.d.ts +1 -1
- package/dist/types/src/tdf/Policy.d.ts.map +1 -1
- package/dist/types/src/tdf/PolicyObject.d.ts +1 -2
- package/dist/types/src/tdf/PolicyObject.d.ts.map +1 -1
- package/dist/types/src/tdf/TypedArray.d.ts +1 -2
- package/dist/types/src/tdf/TypedArray.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts +1 -3
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +5 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/types/tdf3/index.d.ts +5 -4
- package/dist/types/tdf3/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/assertions.d.ts +3 -3
- package/dist/types/tdf3/src/assertions.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts +2 -15
- package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/builders.d.ts +43 -42
- package/dist/types/tdf3/src/client/builders.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/index.d.ts +12 -17
- package/dist/types/tdf3/src/client/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/client/validation.d.ts +3 -3
- package/dist/types/tdf3/src/client/validation.d.ts.map +1 -1
- package/dist/types/tdf3/src/crypto/crypto-utils.d.ts.map +1 -1
- package/dist/types/tdf3/src/index.d.ts +1 -1
- package/dist/types/tdf3/src/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/models/index.d.ts +0 -1
- package/dist/types/tdf3/src/models/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/models/key-access.d.ts +63 -15
- package/dist/types/tdf3/src/models/key-access.d.ts.map +1 -1
- package/dist/types/tdf3/src/models/manifest.d.ts +2 -0
- package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -1
- package/dist/types/tdf3/src/models/policy.d.ts +0 -1
- package/dist/types/tdf3/src/models/policy.d.ts.map +1 -1
- package/dist/types/tdf3/src/tdf.d.ts +24 -37
- package/dist/types/tdf3/src/tdf.d.ts.map +1 -1
- package/dist/types/tdf3/src/utils/index.d.ts +0 -4
- package/dist/types/tdf3/src/utils/index.d.ts.map +1 -1
- package/dist/types/tdf3/src/utils/unwrap.d.ts +2 -0
- package/dist/types/tdf3/src/utils/unwrap.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/zip-reader.d.ts +1 -1
- package/dist/types/tdf3/src/utils/zip-reader.d.ts.map +1 -1
- package/dist/types/tdf3/src/utils/zip-writer.d.ts +2 -2
- package/dist/web/src/access.js +93 -58
- package/dist/web/src/auth/auth.js +1 -21
- package/dist/web/src/auth/oidc-clientcredentials-provider.js +1 -1
- package/dist/web/src/auth/oidc-externaljwt-provider.js +1 -1
- package/dist/web/src/auth/oidc-refreshtoken-provider.js +1 -1
- package/dist/web/src/auth/oidc.js +1 -1
- package/dist/web/src/auth/providers.js +1 -1
- package/dist/web/src/concurrency.js +1 -1
- package/dist/web/src/encodings/base64.js +1 -1
- package/dist/web/src/encodings/hex.js +1 -1
- package/dist/web/src/errors.js +1 -1
- package/dist/web/src/index.js +6 -312
- package/dist/web/src/nanoclients.js +280 -0
- package/dist/web/src/nanoindex.js +5 -0
- package/dist/web/src/nanotdf/Client.js +18 -23
- package/dist/web/src/nanotdf/NanoTDF.js +1 -1
- package/dist/web/src/nanotdf/encrypt-dataset.js +1 -1
- package/dist/web/src/nanotdf/encrypt.js +1 -1
- package/dist/web/src/nanotdf/models/Ciphers.js +1 -1
- package/dist/web/src/nanotdf/models/EcCurves.js +1 -1
- package/dist/web/src/nanotdf/models/Header.js +1 -1
- package/dist/web/src/nanotdf/models/Payload.js +1 -1
- package/dist/web/src/nanotdf/models/Policy/AbstractPolicy.js +1 -1
- package/dist/web/src/nanotdf/models/Policy/EmbeddedPolicy.js +1 -1
- package/dist/web/src/nanotdf/models/Policy/PolicyFactory.js +1 -1
- package/dist/web/src/nanotdf/models/ResourceLocator.js +1 -1
- package/dist/web/src/nanotdf/models/Signature.js +1 -1
- package/dist/web/src/nanotdf-crypto/ciphers.js +1 -1
- package/dist/web/src/nanotdf-crypto/ecdsaSignature.js +1 -1
- package/dist/web/src/nanotdf-crypto/generateKeyPair.js +2 -2
- package/dist/web/src/nanotdf-crypto/generateRandomNumber.js +2 -2
- package/dist/web/src/nanotdf-crypto/index.js +3 -4
- package/dist/web/src/nanotdf-crypto/keyAgreement.js +9 -6
- package/dist/web/src/nanotdf-crypto/pemPublicToCrypto.js +1 -1
- package/dist/web/src/opentdf.js +234 -0
- package/dist/web/src/policy/api.js +1 -1
- package/dist/web/src/policy/granter.js +1 -1
- package/dist/web/src/seekable.js +148 -0
- package/dist/web/src/tdf/AttributeObject.js +1 -2
- package/dist/web/src/tdf/Policy.js +2 -4
- package/dist/web/src/utils.js +3 -10
- package/dist/web/src/version.js +6 -2
- package/dist/web/tdf3/index.js +5 -4
- package/dist/web/tdf3/src/assertions.js +21 -6
- package/dist/web/tdf3/src/binary.js +1 -1
- package/dist/web/tdf3/src/ciphers/aes-gcm-cipher.js +1 -1
- package/dist/web/tdf3/src/ciphers/symmetric-cipher-base.js +1 -1
- package/dist/web/tdf3/src/client/DecoratedReadableStream.js +4 -68
- package/dist/web/tdf3/src/client/builders.js +26 -22
- package/dist/web/tdf3/src/client/index.js +74 -105
- package/dist/web/tdf3/src/client/validation.js +1 -1
- package/dist/web/tdf3/src/crypto/crypto-utils.js +1 -1
- package/dist/web/tdf3/src/crypto/index.js +1 -1
- package/dist/web/tdf3/src/index.js +2 -2
- package/dist/web/tdf3/src/models/attribute-set.js +1 -1
- package/dist/web/tdf3/src/models/encryption-information.js +3 -3
- package/dist/web/tdf3/src/models/index.js +1 -2
- package/dist/web/tdf3/src/models/key-access.js +47 -24
- package/dist/web/tdf3/src/models/policy.js +1 -1
- package/dist/web/tdf3/src/tdf.js +153 -371
- package/dist/web/tdf3/src/utils/buffer-crc32.js +1 -1
- package/dist/web/tdf3/src/utils/index.js +19 -14
- package/dist/web/tdf3/src/utils/keysplit.js +1 -1
- package/dist/web/tdf3/src/utils/unwrap.js +18 -0
- package/dist/web/tdf3/src/utils/zip-reader.js +1 -1
- package/dist/web/tdf3/src/utils/zip-writer.js +1 -1
- package/package.json +45 -45
- package/src/access.ts +111 -54
- package/src/auth/auth.ts +1 -31
- package/src/index.ts +5 -440
- package/src/nanoclients.ts +405 -0
- package/src/nanoindex.ts +4 -0
- package/src/nanotdf/Client.ts +18 -25
- package/src/nanotdf/NanoTDF.ts +1 -1
- package/src/nanotdf/encrypt-dataset.ts +1 -1
- package/src/nanotdf/encrypt.ts +1 -1
- package/src/nanotdf/helpers/getHkdfSalt.ts +1 -1
- package/src/nanotdf-crypto/digest.ts +1 -1
- package/src/nanotdf-crypto/generateKeyPair.ts +1 -1
- package/src/nanotdf-crypto/generateRandomNumber.ts +1 -1
- package/src/nanotdf-crypto/index.ts +2 -3
- package/src/nanotdf-crypto/keyAgreement.ts +14 -7
- package/src/opentdf.ts +441 -0
- package/src/seekable.ts +180 -0
- package/src/tdf/AttributeObject.ts +0 -3
- package/src/tdf/Policy.ts +1 -2
- package/src/tdf/PolicyObject.ts +1 -2
- package/src/tdf/TypedArray.ts +1 -3
- package/src/utils.ts +3 -11
- package/src/version.ts +6 -1
- package/tdf3/index.ts +15 -10
- package/tdf3/src/assertions.ts +33 -8
- package/tdf3/src/client/DecoratedReadableStream.ts +3 -80
- package/tdf3/src/client/builders.ts +44 -28
- package/tdf3/src/client/index.ts +109 -165
- package/tdf3/src/index.ts +1 -1
- package/tdf3/src/models/encryption-information.ts +2 -2
- package/tdf3/src/models/index.ts +0 -1
- package/tdf3/src/models/key-access.ts +120 -38
- package/tdf3/src/models/manifest.ts +3 -0
- package/tdf3/src/models/policy.ts +0 -1
- package/tdf3/src/tdf.ts +266 -522
- package/tdf3/src/utils/index.ts +19 -18
- package/tdf3/src/utils/unwrap.ts +17 -0
- package/tdf3/src/utils/zip-reader.ts +1 -1
- package/dist/cjs/src/auth/Eas.js +0 -60
- package/dist/cjs/src/nanotdf-crypto/importRawKey.js +0 -18
- package/dist/cjs/src/tdf/Crypto.js +0 -47
- package/dist/cjs/src/tdf/EntityObject.js +0 -3
- package/dist/cjs/src/tdf/index.js +0 -35
- package/dist/cjs/tdf3/src/models/upsert-response.js +0 -3
- package/dist/cjs/tdf3/src/templates/default.html.js +0 -98
- package/dist/cjs/tdf3/src/templates/escaper.js +0 -15
- package/dist/cjs/tdf3/src/templates/index.js +0 -12
- package/dist/cjs/tdf3/src/utils/chunkers.js +0 -106
- package/dist/cjs/tdf3/src/version.js +0 -6
- package/dist/types/src/auth/Eas.d.ts +0 -34
- package/dist/types/src/auth/Eas.d.ts.map +0 -1
- package/dist/types/src/nanotdf-crypto/importRawKey.d.ts +0 -13
- package/dist/types/src/nanotdf-crypto/importRawKey.d.ts.map +0 -1
- package/dist/types/src/tdf/Crypto.d.ts +0 -37
- package/dist/types/src/tdf/Crypto.d.ts.map +0 -1
- package/dist/types/src/tdf/EntityObject.d.ts +0 -18
- package/dist/types/src/tdf/EntityObject.d.ts.map +0 -1
- package/dist/types/src/tdf/index.d.ts +0 -7
- package/dist/types/src/tdf/index.d.ts.map +0 -1
- package/dist/types/tdf3/src/models/upsert-response.d.ts +0 -16
- package/dist/types/tdf3/src/models/upsert-response.d.ts.map +0 -1
- package/dist/types/tdf3/src/templates/default.html.d.ts +0 -8
- package/dist/types/tdf3/src/templates/default.html.d.ts.map +0 -1
- package/dist/types/tdf3/src/templates/escaper.d.ts +0 -6
- package/dist/types/tdf3/src/templates/escaper.d.ts.map +0 -1
- package/dist/types/tdf3/src/templates/index.d.ts +0 -3
- package/dist/types/tdf3/src/templates/index.d.ts.map +0 -1
- package/dist/types/tdf3/src/utils/chunkers.d.ts +0 -29
- package/dist/types/tdf3/src/utils/chunkers.d.ts.map +0 -1
- package/dist/types/tdf3/src/version.d.ts +0 -3
- package/dist/types/tdf3/src/version.d.ts.map +0 -1
- package/dist/web/src/auth/Eas.js +0 -55
- package/dist/web/src/nanotdf-crypto/importRawKey.js +0 -15
- package/dist/web/src/tdf/Crypto.js +0 -44
- package/dist/web/src/tdf/EntityObject.js +0 -2
- package/dist/web/src/tdf/index.js +0 -4
- package/dist/web/tdf3/src/models/upsert-response.js +0 -2
- package/dist/web/tdf3/src/templates/default.html.js +0 -96
- package/dist/web/tdf3/src/templates/escaper.js +0 -10
- package/dist/web/tdf3/src/templates/index.js +0 -3
- package/dist/web/tdf3/src/utils/chunkers.js +0 -96
- package/dist/web/tdf3/src/version.js +0 -3
- package/src/auth/Eas.ts +0 -79
- package/src/nanotdf-crypto/importRawKey.ts +0 -19
- package/src/tdf/Crypto.ts +0 -42
- package/src/tdf/EntityObject.ts +0 -18
- package/src/tdf/index.ts +0 -6
- package/tdf3/src/models/upsert-response.ts +0 -17
- package/tdf3/src/templates/default.html.ts +0 -105
- package/tdf3/src/templates/escaper.ts +0 -10
- package/tdf3/src/templates/index.ts +0 -2
- package/tdf3/src/utils/chunkers.ts +0 -118
- package/tdf3/src/version.ts +0 -2
package/tdf3/src/client/index.ts
CHANGED
|
@@ -1,51 +1,34 @@
|
|
|
1
1
|
import { v4 } from 'uuid';
|
|
2
|
-
import axios from 'axios';
|
|
3
2
|
import {
|
|
4
3
|
ZipReader,
|
|
5
|
-
fromBuffer,
|
|
6
|
-
fromDataSource,
|
|
7
4
|
streamToBuffer,
|
|
8
|
-
isAppIdProviderCheck,
|
|
9
|
-
type Chunker,
|
|
10
5
|
keyMiddleware as defaultKeyMiddleware,
|
|
11
6
|
} from '../utils/index.js';
|
|
12
7
|
import { base64 } from '../../../src/encodings/index.js';
|
|
13
8
|
import {
|
|
14
9
|
buildKeyAccess,
|
|
15
|
-
EncryptConfiguration,
|
|
10
|
+
type EncryptConfiguration,
|
|
16
11
|
fetchKasPublicKey,
|
|
17
12
|
loadTDFStream,
|
|
18
|
-
unwrapHtml,
|
|
19
13
|
validatePolicyObject,
|
|
20
14
|
readStream,
|
|
21
|
-
wrapHtml,
|
|
22
15
|
writeStream,
|
|
23
16
|
} from '../tdf.js';
|
|
17
|
+
import { unwrapHtml } from '../utils/unwrap.js';
|
|
24
18
|
import { OIDCRefreshTokenProvider } from '../../../src/auth/oidc-refreshtoken-provider.js';
|
|
25
19
|
import { OIDCExternalJwtProvider } from '../../../src/auth/oidc-externaljwt-provider.js';
|
|
26
20
|
import { CryptoService } from '../crypto/declarations.js';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
AppIdAuthProvider,
|
|
30
|
-
HttpRequest,
|
|
31
|
-
withHeaders,
|
|
32
|
-
} from '../../../src/auth/auth.js';
|
|
33
|
-
import EAS from '../../../src/auth/Eas.js';
|
|
34
|
-
import {
|
|
35
|
-
cryptoPublicToPem,
|
|
36
|
-
pemToCryptoPublicKey,
|
|
37
|
-
rstrip,
|
|
38
|
-
validateSecureUrl,
|
|
39
|
-
} from '../../../src/utils.js';
|
|
21
|
+
import { type AuthProvider, HttpRequest, withHeaders } from '../../../src/auth/auth.js';
|
|
22
|
+
import { pemToCryptoPublicKey, rstrip, validateSecureUrl } from '../../../src/utils.js';
|
|
40
23
|
|
|
41
24
|
import {
|
|
42
|
-
EncryptParams,
|
|
43
|
-
DecryptParams,
|
|
25
|
+
type EncryptParams,
|
|
26
|
+
type DecryptParams,
|
|
44
27
|
type Scope,
|
|
45
|
-
DecryptStreamMiddleware,
|
|
46
|
-
EncryptKeyMiddleware,
|
|
47
|
-
EncryptStreamMiddleware,
|
|
48
|
-
SplitStep,
|
|
28
|
+
type DecryptStreamMiddleware,
|
|
29
|
+
type EncryptKeyMiddleware,
|
|
30
|
+
type EncryptStreamMiddleware,
|
|
31
|
+
type SplitStep,
|
|
49
32
|
} from './builders.js';
|
|
50
33
|
import { DecoratedReadableStream } from './DecoratedReadableStream.js';
|
|
51
34
|
|
|
@@ -55,48 +38,51 @@ import {
|
|
|
55
38
|
type DecryptSource,
|
|
56
39
|
EncryptParamsBuilder,
|
|
57
40
|
} from './builders.js';
|
|
58
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
type KasPublicKeyInfo,
|
|
43
|
+
keyAlgorithmToPublicKeyAlgorithm,
|
|
44
|
+
OriginAllowList,
|
|
45
|
+
} from '../../../src/access.js';
|
|
59
46
|
import { ConfigurationError } from '../../../src/errors.js';
|
|
60
|
-
import { EntityObject } from '../../../src/tdf/EntityObject.js';
|
|
61
47
|
import { Binary } from '../binary.js';
|
|
62
48
|
import { AesGcmCipher } from '../ciphers/aes-gcm-cipher.js';
|
|
63
49
|
import { toCryptoKeyPair } from '../crypto/crypto-utils.js';
|
|
64
50
|
import * as defaultCryptoService from '../crypto/index.js';
|
|
65
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
type AttributeObject,
|
|
53
|
+
type KeyAccessType,
|
|
54
|
+
type Policy,
|
|
55
|
+
SplitKey,
|
|
56
|
+
} from '../models/index.js';
|
|
66
57
|
import { plan } from '../../../src/policy/granter.js';
|
|
67
58
|
import { attributeFQNsAsValues } from '../../../src/policy/api.js';
|
|
68
59
|
import { type Value } from '../../../src/policy/attributes.js';
|
|
60
|
+
import { type Chunker, fromBuffer, fromSource } from '../../../src/seekable.js';
|
|
69
61
|
|
|
70
62
|
const GLOBAL_BYTE_LIMIT = 64 * 1000 * 1000 * 1000; // 64 GB, see WS-9363.
|
|
71
|
-
const HTML_BYTE_LIMIT = 100 * 1000 * 1000; // 100 MB, see WS-9476.
|
|
72
63
|
|
|
73
64
|
// No default config for now. Delegate to Virtru wrapper for endpoints.
|
|
74
65
|
const defaultClientConfig = { oidcOrigin: '', cryptoService: defaultCryptoService };
|
|
75
66
|
|
|
76
|
-
export const uploadBinaryToS3 = async function (
|
|
77
|
-
stream: ReadableStream<Uint8Array>,
|
|
78
|
-
uploadUrl: string,
|
|
79
|
-
fileSize: number
|
|
80
|
-
) {
|
|
81
|
-
try {
|
|
82
|
-
const body: Uint8Array = await streamToBuffer(stream);
|
|
83
|
-
|
|
84
|
-
await axios.put(uploadUrl, body, {
|
|
85
|
-
headers: {
|
|
86
|
-
'Content-Length': fileSize,
|
|
87
|
-
'content-type': 'application/zip',
|
|
88
|
-
'cache-control': 'no-store',
|
|
89
|
-
},
|
|
90
|
-
maxContentLength: Infinity,
|
|
91
|
-
maxBodyLength: Infinity,
|
|
92
|
-
});
|
|
93
|
-
} catch (e) {
|
|
94
|
-
console.error(e);
|
|
95
|
-
throw e;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
67
|
const getFirstTwoBytes = async (chunker: Chunker) => new TextDecoder().decode(await chunker(0, 2));
|
|
99
68
|
|
|
69
|
+
// Convert a PEM string to a CryptoKey
|
|
70
|
+
export const resolveKasInfo = async (
|
|
71
|
+
pem: string,
|
|
72
|
+
uri: string,
|
|
73
|
+
kid?: string
|
|
74
|
+
): Promise<KasPublicKeyInfo> => {
|
|
75
|
+
const k: CryptoKey = await pemToCryptoPublicKey(pem);
|
|
76
|
+
const algorithm = keyAlgorithmToPublicKeyAlgorithm(k.algorithm);
|
|
77
|
+
return {
|
|
78
|
+
key: Promise.resolve(k),
|
|
79
|
+
publicKey: pem,
|
|
80
|
+
url: uri,
|
|
81
|
+
algorithm,
|
|
82
|
+
kid: kid,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
100
86
|
const makeChunkable = async (source: DecryptSource) => {
|
|
101
87
|
if (!source) {
|
|
102
88
|
throw new ConfigurationError('invalid source');
|
|
@@ -118,7 +104,7 @@ const makeChunkable = async (source: DecryptSource) => {
|
|
|
118
104
|
initialChunker = source.location;
|
|
119
105
|
break;
|
|
120
106
|
default:
|
|
121
|
-
initialChunker = await
|
|
107
|
+
initialChunker = await fromSource(source);
|
|
122
108
|
}
|
|
123
109
|
|
|
124
110
|
const magic: string = await getFirstTwoBytes(initialChunker);
|
|
@@ -135,7 +121,7 @@ const makeChunkable = async (source: DecryptSource) => {
|
|
|
135
121
|
|
|
136
122
|
export interface ClientConfig {
|
|
137
123
|
cryptoService?: CryptoService;
|
|
138
|
-
|
|
124
|
+
/// oauth client id; used to generate oauth authProvider
|
|
139
125
|
clientId?: string;
|
|
140
126
|
dpopEnabled?: boolean;
|
|
141
127
|
dpopKeys?: Promise<CryptoKeyPair>;
|
|
@@ -160,7 +146,7 @@ export interface ClientConfig {
|
|
|
160
146
|
kasPublicKey?: string;
|
|
161
147
|
oidcOrigin?: string;
|
|
162
148
|
externalJwt?: string;
|
|
163
|
-
authProvider?: AuthProvider
|
|
149
|
+
authProvider?: AuthProvider;
|
|
164
150
|
readerUrl?: string;
|
|
165
151
|
entityObjectEndpoint?: string;
|
|
166
152
|
fileStreamServiceWorker?: string;
|
|
@@ -179,7 +165,7 @@ export async function createSessionKeys({
|
|
|
179
165
|
cryptoService,
|
|
180
166
|
dpopKeys,
|
|
181
167
|
}: {
|
|
182
|
-
authProvider?: AuthProvider
|
|
168
|
+
authProvider?: AuthProvider;
|
|
183
169
|
cryptoService: CryptoService;
|
|
184
170
|
dpopKeys?: Promise<CryptoKeyPair>;
|
|
185
171
|
}): Promise<CryptoKeyPair> {
|
|
@@ -197,7 +183,7 @@ export async function createSessionKeys({
|
|
|
197
183
|
// Note that we base64 encode the PEM string here as a quick workaround, simply because
|
|
198
184
|
// a formatted raw PEM string isn't a valid header value and sending it raw makes keycloak's
|
|
199
185
|
// header parser barf. There are more subtle ways to solve this, but this works for now.
|
|
200
|
-
if (authProvider
|
|
186
|
+
if (authProvider) {
|
|
201
187
|
await authProvider?.updateClientPublicKey(signingKeys);
|
|
202
188
|
}
|
|
203
189
|
return signingKeys;
|
|
@@ -253,13 +239,13 @@ export class Client {
|
|
|
253
239
|
*/
|
|
254
240
|
readonly allowedKases: OriginAllowList;
|
|
255
241
|
|
|
256
|
-
readonly kasKeys: Record<string, Promise<KasPublicKeyInfo
|
|
242
|
+
readonly kasKeys: Record<string, Promise<KasPublicKeyInfo>[]> = {};
|
|
257
243
|
|
|
258
244
|
readonly easEndpoint?: string;
|
|
259
245
|
|
|
260
246
|
readonly clientId?: string;
|
|
261
247
|
|
|
262
|
-
readonly authProvider?: AuthProvider
|
|
248
|
+
readonly authProvider?: AuthProvider;
|
|
263
249
|
|
|
264
250
|
readonly readerUrl?: string;
|
|
265
251
|
|
|
@@ -270,8 +256,6 @@ export class Client {
|
|
|
270
256
|
*/
|
|
271
257
|
readonly dpopKeys: Promise<CryptoKeyPair>;
|
|
272
258
|
|
|
273
|
-
readonly eas?: EAS;
|
|
274
|
-
|
|
275
259
|
readonly dpopEnabled: boolean;
|
|
276
260
|
|
|
277
261
|
readonly clientConfig: ClientConfig;
|
|
@@ -330,14 +314,6 @@ export class Client {
|
|
|
330
314
|
this.authProvider = config.authProvider;
|
|
331
315
|
this.clientConfig = clientConfig;
|
|
332
316
|
|
|
333
|
-
if (this.authProvider && isAppIdProviderCheck(this.authProvider)) {
|
|
334
|
-
this.eas = new EAS({
|
|
335
|
-
authProvider: this.authProvider,
|
|
336
|
-
endpoint:
|
|
337
|
-
clientConfig.entityObjectEndpoint ?? `${clientConfig.easEndpoint}/api/entityobject`,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
317
|
this.clientId = clientConfig.clientId;
|
|
342
318
|
if (!this.authProvider) {
|
|
343
319
|
if (!clientConfig.clientId) {
|
|
@@ -369,12 +345,9 @@ export class Client {
|
|
|
369
345
|
dpopKeys: clientConfig.dpopKeys,
|
|
370
346
|
});
|
|
371
347
|
if (clientConfig.kasPublicKey) {
|
|
372
|
-
this.kasKeys[this.kasEndpoint] =
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
key: pemToCryptoPublicKey(clientConfig.kasPublicKey),
|
|
376
|
-
publicKey: clientConfig.kasPublicKey,
|
|
377
|
-
});
|
|
348
|
+
this.kasKeys[this.kasEndpoint] = [
|
|
349
|
+
resolveKasInfo(clientConfig.kasPublicKey, this.kasEndpoint),
|
|
350
|
+
];
|
|
378
351
|
}
|
|
379
352
|
}
|
|
380
353
|
|
|
@@ -383,38 +356,39 @@ export class Client {
|
|
|
383
356
|
*
|
|
384
357
|
* @param scope dissem and attributes for constructing the policy
|
|
385
358
|
* @param source source object of unencrypted data
|
|
386
|
-
* @param [asHtml] If we should wrap the TDF data in a self-opening HTML wrapper. Defaults to false
|
|
387
359
|
* @param [autoconfigure] If we should use scope.attributes to configure KAOs
|
|
388
360
|
* @param [metadata] Additional non-secret data to store with the TDF
|
|
389
361
|
* @param [opts] Test only
|
|
390
362
|
* @param [mimeType] mime type of source. defaults to `unknown`
|
|
391
|
-
* @param [offline] Where to store the policy. Defaults to `false` - which results in `upsert` events to store/update a policy
|
|
392
363
|
* @param [windowSize] - segment size in bytes. Defaults to a a million bytes.
|
|
393
364
|
* @param [keyMiddleware] - function that handle keys
|
|
394
365
|
* @param [streamMiddleware] - function that handle stream
|
|
395
366
|
* @param [eo] - (deprecated) entity object
|
|
396
367
|
* @return a {@link https://nodejs.org/api/stream.html#stream_class_stream_readable|Readable} a new stream containing the TDF ciphertext
|
|
397
368
|
*/
|
|
398
|
-
async encrypt({
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
asHtml
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
offline = false,
|
|
406
|
-
windowSize = DEFAULT_SEGMENT_SIZE,
|
|
407
|
-
eo,
|
|
408
|
-
keyMiddleware = defaultKeyMiddleware,
|
|
409
|
-
streamMiddleware = async (stream: DecoratedReadableStream) => stream,
|
|
410
|
-
splitPlan,
|
|
411
|
-
assertionConfigs = [],
|
|
412
|
-
}: EncryptParams): Promise<DecoratedReadableStream> {
|
|
369
|
+
async encrypt(opts: EncryptParams): Promise<DecoratedReadableStream> {
|
|
370
|
+
if (opts.offline === false) {
|
|
371
|
+
throw new ConfigurationError('online mode not supported');
|
|
372
|
+
}
|
|
373
|
+
if (opts.asHtml) {
|
|
374
|
+
throw new ConfigurationError('html mode not supported');
|
|
375
|
+
}
|
|
413
376
|
const dpopKeys = await this.dpopKeys;
|
|
377
|
+
const {
|
|
378
|
+
autoconfigure,
|
|
379
|
+
metadata,
|
|
380
|
+
mimeType = 'unknown',
|
|
381
|
+
windowSize = DEFAULT_SEGMENT_SIZE,
|
|
382
|
+
keyMiddleware = defaultKeyMiddleware,
|
|
383
|
+
streamMiddleware = async (stream: DecoratedReadableStream) => stream,
|
|
384
|
+
wrappingKeyAlgorithm = 'rsa:2048',
|
|
385
|
+
} = opts;
|
|
386
|
+
const scope = opts.scope ?? { attributes: [], dissem: [] };
|
|
414
387
|
|
|
415
388
|
const policyObject = asPolicy(scope);
|
|
416
389
|
validatePolicyObject(policyObject);
|
|
417
390
|
|
|
391
|
+
let splitPlan = opts.splitPlan;
|
|
418
392
|
if (!splitPlan && autoconfigure) {
|
|
419
393
|
let avs: Value[] = scope.attributeValues ?? [];
|
|
420
394
|
const fqns: string[] = scope.attributes
|
|
@@ -440,7 +414,7 @@ export class Client {
|
|
|
440
414
|
}
|
|
441
415
|
}
|
|
442
416
|
if (
|
|
443
|
-
avs.length != scope.attributes?.length ||
|
|
417
|
+
avs.length != (scope.attributes?.length || 0) ||
|
|
444
418
|
!avs.map(({ fqn }) => fqn).every((a) => fqns.indexOf(a) >= 0)
|
|
445
419
|
) {
|
|
446
420
|
throw new ConfigurationError(
|
|
@@ -453,18 +427,9 @@ export class Client {
|
|
|
453
427
|
splitPlan = detailedPlan.map((kat) => {
|
|
454
428
|
const { kas, sid } = kat;
|
|
455
429
|
if (kas?.publicKey?.cached?.keys && !(kas.uri in this.kasKeys)) {
|
|
456
|
-
const keys = kas.publicKey.cached.keys
|
|
457
|
-
({ alg }) => alg == 'KAS_PUBLIC_KEY_ALG_ENUM_RSA_2048'
|
|
458
|
-
);
|
|
430
|
+
const keys = kas.publicKey.cached.keys;
|
|
459
431
|
if (keys?.length) {
|
|
460
|
-
|
|
461
|
-
this.kasKeys[kas.uri] = Promise.resolve({
|
|
462
|
-
key: pemToCryptoPublicKey(key.pem),
|
|
463
|
-
publicKey: key.pem,
|
|
464
|
-
url: kas.uri,
|
|
465
|
-
algorithm: 'rsa:2048',
|
|
466
|
-
kid: key.kid,
|
|
467
|
-
});
|
|
432
|
+
this.kasKeys[kas.uri] = keys.map((key) => resolveKasInfo(key.pem, kas.uri, key.kid));
|
|
468
433
|
}
|
|
469
434
|
}
|
|
470
435
|
return { kas: kas.uri, sid };
|
|
@@ -473,27 +438,40 @@ export class Client {
|
|
|
473
438
|
|
|
474
439
|
// TODO: Refactor underlying builder to remove some of this unnecessary config.
|
|
475
440
|
|
|
476
|
-
const
|
|
441
|
+
const maxByteLimit = GLOBAL_BYTE_LIMIT;
|
|
442
|
+
const byteLimit =
|
|
443
|
+
opts.byteLimit === undefined || opts.byteLimit <= 0 || opts.byteLimit > maxByteLimit
|
|
444
|
+
? maxByteLimit
|
|
445
|
+
: opts.byteLimit;
|
|
477
446
|
const encryptionInformation = new SplitKey(new AesGcmCipher(this.cryptoService));
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
entity = eo;
|
|
482
|
-
const s = new AttributeSet();
|
|
483
|
-
eo.attributes.forEach((attr) => s.addJwtAttribute(attr));
|
|
484
|
-
attributeSet = s;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
const splits: SplitStep[] = splitPlan?.length ? splitPlan : [{ kas: this.kasEndpoint }];
|
|
447
|
+
const splits: SplitStep[] = splitPlan?.length
|
|
448
|
+
? splitPlan
|
|
449
|
+
: [{ kas: opts.defaultKASEndpoint ?? this.kasEndpoint }];
|
|
488
450
|
encryptionInformation.keyAccess = await Promise.all(
|
|
489
451
|
splits.map(async ({ kas, sid }) => {
|
|
490
452
|
if (!(kas in this.kasKeys)) {
|
|
491
|
-
this.kasKeys[kas] = fetchKasPublicKey(kas);
|
|
453
|
+
this.kasKeys[kas] = [fetchKasPublicKey(kas, wrappingKeyAlgorithm)];
|
|
454
|
+
}
|
|
455
|
+
const kasPublicKey = await Promise.any(this.kasKeys[kas]);
|
|
456
|
+
if (kasPublicKey.algorithm !== wrappingKeyAlgorithm) {
|
|
457
|
+
console.warn(
|
|
458
|
+
`Mismatched wrapping key algorithm: [${kasPublicKey.algorithm}] is not requested type, [${wrappingKeyAlgorithm}]`
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
let type: KeyAccessType;
|
|
462
|
+
switch (kasPublicKey.algorithm) {
|
|
463
|
+
case 'rsa:2048':
|
|
464
|
+
type = 'wrapped';
|
|
465
|
+
break;
|
|
466
|
+
case 'ec:secp256r1':
|
|
467
|
+
type = 'ec-wrapped';
|
|
468
|
+
break;
|
|
469
|
+
default:
|
|
470
|
+
throw new ConfigurationError(`Unsupported algorithm ${kasPublicKey.algorithm}`);
|
|
492
471
|
}
|
|
493
|
-
const kasPublicKey = await this.kasKeys[kas];
|
|
494
472
|
return buildKeyAccess({
|
|
495
|
-
|
|
496
|
-
type
|
|
473
|
+
alg: kasPublicKey.algorithm,
|
|
474
|
+
type,
|
|
497
475
|
url: kasPublicKey.url,
|
|
498
476
|
kid: kasPublicKey.kid,
|
|
499
477
|
publicKey: kasPublicKey.publicKey,
|
|
@@ -505,43 +483,24 @@ export class Client {
|
|
|
505
483
|
const { keyForEncryption, keyForManifest } = await (keyMiddleware as EncryptKeyMiddleware)();
|
|
506
484
|
const ecfg: EncryptConfiguration = {
|
|
507
485
|
allowList: this.allowedKases,
|
|
508
|
-
attributeSet,
|
|
509
486
|
byteLimit,
|
|
510
487
|
cryptoService: this.cryptoService,
|
|
511
488
|
dpopKeys,
|
|
512
489
|
encryptionInformation,
|
|
513
|
-
entity,
|
|
514
490
|
segmentSizeDefault: windowSize,
|
|
515
491
|
integrityAlgorithm: 'HS256',
|
|
516
492
|
segmentIntegrityAlgorithm: 'GMAC',
|
|
517
|
-
contentStream: source,
|
|
493
|
+
contentStream: opts.source,
|
|
518
494
|
mimeType,
|
|
519
495
|
policy: policyObject,
|
|
520
496
|
authProvider: this.authProvider,
|
|
521
497
|
progressHandler: this.clientConfig.progressHandler,
|
|
522
498
|
keyForEncryption,
|
|
523
499
|
keyForManifest,
|
|
524
|
-
assertionConfigs,
|
|
500
|
+
assertionConfigs: opts.assertionConfigs,
|
|
525
501
|
};
|
|
526
502
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (!asHtml) {
|
|
530
|
-
return stream;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// Wrap if it's html.
|
|
534
|
-
if (!stream.manifest) {
|
|
535
|
-
throw new Error('internal: missing manifest in encrypt function');
|
|
536
|
-
}
|
|
537
|
-
const htmlBuf = wrapHtml(await stream.toBuffer(), stream.manifest, this.readerUrl ?? '');
|
|
538
|
-
|
|
539
|
-
return new DecoratedReadableStream({
|
|
540
|
-
pull(controller: ReadableStreamDefaultController) {
|
|
541
|
-
controller.enqueue(htmlBuf);
|
|
542
|
-
controller.close();
|
|
543
|
-
},
|
|
544
|
-
});
|
|
503
|
+
return (streamMiddleware as EncryptStreamMiddleware)(await writeStream(ecfg));
|
|
545
504
|
}
|
|
546
505
|
|
|
547
506
|
/**
|
|
@@ -556,47 +515,40 @@ export class Client {
|
|
|
556
515
|
* @see DecryptParamsBuilder
|
|
557
516
|
*/
|
|
558
517
|
async decrypt({
|
|
559
|
-
eo,
|
|
560
518
|
source,
|
|
519
|
+
allowList,
|
|
561
520
|
keyMiddleware = async (key: Binary) => key,
|
|
562
521
|
streamMiddleware = async (stream: DecoratedReadableStream) => stream,
|
|
563
522
|
assertionVerificationKeys,
|
|
564
523
|
noVerifyAssertions,
|
|
565
524
|
concurrencyLimit = 1,
|
|
525
|
+
wrappingKeyAlgorithm,
|
|
566
526
|
}: DecryptParams): Promise<DecoratedReadableStream> {
|
|
567
527
|
const dpopKeys = await this.dpopKeys;
|
|
568
|
-
let entityObject;
|
|
569
|
-
if (this.eas || eo) {
|
|
570
|
-
const sessionPublicKey = await cryptoPublicToPem(dpopKeys.publicKey);
|
|
571
|
-
if (eo && eo.publicKey == sessionPublicKey) {
|
|
572
|
-
entityObject = eo;
|
|
573
|
-
} else if (this.eas) {
|
|
574
|
-
entityObject = await this.eas.fetchEntityObject({
|
|
575
|
-
publicKey: sessionPublicKey,
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
528
|
if (!this.authProvider) {
|
|
580
529
|
throw new ConfigurationError('AuthProvider missing');
|
|
581
530
|
}
|
|
582
531
|
const chunker = await makeChunkable(source);
|
|
532
|
+
if (!allowList) {
|
|
533
|
+
allowList = this.allowedKases;
|
|
534
|
+
}
|
|
583
535
|
|
|
584
536
|
// Await in order to catch any errors from this call.
|
|
585
537
|
// TODO: Write error event to stream and don't await.
|
|
586
538
|
return await (streamMiddleware as DecryptStreamMiddleware)(
|
|
587
539
|
await readStream({
|
|
588
|
-
allowList
|
|
540
|
+
allowList,
|
|
589
541
|
authProvider: this.authProvider,
|
|
590
542
|
chunker,
|
|
591
543
|
concurrencyLimit,
|
|
592
544
|
cryptoService: this.cryptoService,
|
|
593
545
|
dpopKeys,
|
|
594
|
-
entity: entityObject,
|
|
595
546
|
fileStreamServiceWorker: this.clientConfig.fileStreamServiceWorker,
|
|
596
547
|
keyMiddleware,
|
|
597
548
|
progressHandler: this.clientConfig.progressHandler,
|
|
598
549
|
assertionVerificationKeys,
|
|
599
550
|
noVerifyAssertions,
|
|
551
|
+
wrappingKeyAlgorithm,
|
|
600
552
|
})
|
|
601
553
|
);
|
|
602
554
|
}
|
|
@@ -628,12 +580,4 @@ export class Client {
|
|
|
628
580
|
|
|
629
581
|
export type { AuthProvider };
|
|
630
582
|
|
|
631
|
-
export {
|
|
632
|
-
AppIdAuthProvider,
|
|
633
|
-
DecryptParamsBuilder,
|
|
634
|
-
DecryptSource,
|
|
635
|
-
EncryptParamsBuilder,
|
|
636
|
-
HttpRequest,
|
|
637
|
-
fromDataSource,
|
|
638
|
-
withHeaders,
|
|
639
|
-
};
|
|
583
|
+
export { DecryptParamsBuilder, DecryptSource, EncryptParamsBuilder, HttpRequest, withHeaders };
|
package/tdf3/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as Client from './client/index.js';
|
|
2
2
|
export { Client as TDF3Client } from './client/index.js';
|
|
3
3
|
export * as Errors from '../../src/errors.js';
|
|
4
|
-
export {
|
|
4
|
+
export { clientType, tdfSpecVersion, version } from '../../src/version.js';
|
|
@@ -78,7 +78,7 @@ export class SplitKey {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async getKeyAccessObjects(policy: Policy, keyInfo: KeyInfo): Promise<KeyAccessObject[]> {
|
|
81
|
-
const splitIds = [...new Set(this.keyAccess.map(({ sid }) => sid))].sort((a, b) =>
|
|
81
|
+
const splitIds = [...new Set(this.keyAccess.map(({ sid }) => sid))].sort((a = '', b = '') =>
|
|
82
82
|
a.localeCompare(b)
|
|
83
83
|
);
|
|
84
84
|
const unwrappedKeySplitBuffers = await keySplit(
|
|
@@ -93,7 +93,7 @@ export class SplitKey {
|
|
|
93
93
|
const keyAccessObjects = [];
|
|
94
94
|
for (const item of this.keyAccess) {
|
|
95
95
|
// use the key split to encrypt metadata for each key access object
|
|
96
|
-
const unwrappedKeySplitBuffer = splitsByName[item.sid];
|
|
96
|
+
const unwrappedKeySplitBuffer = splitsByName[item.sid || ''];
|
|
97
97
|
const unwrappedKeySplitBinary = Binary.fromArrayBuffer(unwrappedKeySplitBuffer.buffer);
|
|
98
98
|
|
|
99
99
|
const metadata = item.metadata || '';
|