@opentdf/sdk 0.1.0-beta.1701
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 +52 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/src/access.js +155 -0
- package/dist/cjs/src/auth/Eas.js +60 -0
- package/dist/cjs/src/auth/auth.js +79 -0
- package/dist/cjs/src/auth/oidc-clientcredentials-provider.js +26 -0
- package/dist/cjs/src/auth/oidc-externaljwt-provider.js +33 -0
- package/dist/cjs/src/auth/oidc-refreshtoken-provider.js +34 -0
- package/dist/cjs/src/auth/oidc.js +222 -0
- package/dist/cjs/src/auth/providers.js +143 -0
- package/dist/cjs/src/encodings/base64.js +154 -0
- package/dist/cjs/src/encodings/hex.js +70 -0
- package/dist/cjs/src/encodings/index.js +29 -0
- package/dist/cjs/src/errors.js +138 -0
- package/dist/cjs/src/index.js +344 -0
- package/dist/cjs/src/nanotdf/Client.js +296 -0
- package/dist/cjs/src/nanotdf/NanoTDF.js +94 -0
- package/dist/cjs/src/nanotdf/browser-entry.js +19 -0
- package/dist/cjs/src/nanotdf/constants.js +5 -0
- package/dist/cjs/src/nanotdf/decrypt.js +17 -0
- package/dist/cjs/src/nanotdf/encrypt-dataset.js +38 -0
- package/dist/cjs/src/nanotdf/encrypt.js +132 -0
- package/dist/cjs/src/nanotdf/enum/CipherEnum.js +13 -0
- package/dist/cjs/src/nanotdf/enum/CurveNameEnum.js +15 -0
- package/dist/cjs/src/nanotdf/enum/EncodingEnum.js +8 -0
- package/dist/cjs/src/nanotdf/enum/PolicyTypeEnum.js +11 -0
- package/dist/cjs/src/nanotdf/enum/ProtocolEnum.js +10 -0
- package/dist/cjs/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +11 -0
- package/dist/cjs/src/nanotdf/helpers/calculateByCurve.js +29 -0
- package/dist/cjs/src/nanotdf/helpers/getHkdfSalt.js +11 -0
- package/dist/cjs/src/nanotdf/index.js +25 -0
- package/dist/cjs/src/nanotdf/interfaces/PolicyInterface.js +3 -0
- package/dist/cjs/src/nanotdf/models/Ciphers.js +61 -0
- package/dist/cjs/src/nanotdf/models/DefaultParams.js +27 -0
- package/dist/cjs/src/nanotdf/models/EcCurves.js +39 -0
- package/dist/cjs/src/nanotdf/models/Header.js +255 -0
- package/dist/cjs/src/nanotdf/models/Payload.js +158 -0
- package/dist/cjs/src/nanotdf/models/Policy/AbstractPolicy.js +73 -0
- package/dist/cjs/src/nanotdf/models/Policy/EmbeddedPolicy.js +82 -0
- package/dist/cjs/src/nanotdf/models/Policy/PolicyFactory.js +38 -0
- package/dist/cjs/src/nanotdf/models/Policy/RemotePolicy.js +62 -0
- package/dist/cjs/src/nanotdf/models/ResourceLocator.js +211 -0
- package/dist/cjs/src/nanotdf/models/Signature.js +77 -0
- package/dist/cjs/src/nanotdf-crypto/ciphers.js +17 -0
- package/dist/cjs/src/nanotdf-crypto/decrypt.js +24 -0
- package/dist/cjs/src/nanotdf-crypto/digest.js +7 -0
- package/dist/cjs/src/nanotdf-crypto/ecdsaSignature.js +83 -0
- package/dist/cjs/src/nanotdf-crypto/encrypt.js +24 -0
- package/dist/cjs/src/nanotdf-crypto/enums.js +52 -0
- package/dist/cjs/src/nanotdf-crypto/exportCryptoKey.js +20 -0
- package/dist/cjs/src/nanotdf-crypto/generateKeyPair.js +13 -0
- package/dist/cjs/src/nanotdf-crypto/generateRandomNumber.js +12 -0
- package/dist/cjs/src/nanotdf-crypto/importRawKey.js +18 -0
- package/dist/cjs/src/nanotdf-crypto/index.js +52 -0
- package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +91 -0
- package/dist/cjs/src/nanotdf-crypto/pemPublicToCrypto.js +225 -0
- package/dist/cjs/src/policy/api.js +58 -0
- package/dist/cjs/src/policy/attributes.js +3 -0
- package/dist/cjs/src/policy/granter.js +146 -0
- package/dist/cjs/src/tdf/AttributeObject.js +15 -0
- package/dist/cjs/src/tdf/AttributeObjectJwt.js +3 -0
- package/dist/cjs/src/tdf/Crypto.js +47 -0
- package/dist/cjs/src/tdf/EntityObject.js +3 -0
- package/dist/cjs/src/tdf/NanoTDF/NanoTDF.js +38 -0
- package/dist/cjs/src/tdf/Policy.js +50 -0
- package/dist/cjs/src/tdf/PolicyObject.js +3 -0
- package/dist/cjs/src/tdf/TypedArray.js +3 -0
- package/dist/cjs/src/tdf/index.js +35 -0
- package/dist/cjs/src/types/index.js +3 -0
- package/dist/cjs/src/utils.js +147 -0
- package/dist/cjs/src/version.js +12 -0
- package/dist/cjs/tdf3/index.js +57 -0
- package/dist/cjs/tdf3/src/assertions.js +118 -0
- package/dist/cjs/tdf3/src/binary.js +153 -0
- package/dist/cjs/tdf3/src/ciphers/aes-gcm-cipher.js +56 -0
- package/dist/cjs/tdf3/src/ciphers/algorithms.js +8 -0
- package/dist/cjs/tdf3/src/ciphers/index.js +8 -0
- package/dist/cjs/tdf3/src/ciphers/symmetric-cipher-base.js +22 -0
- package/dist/cjs/tdf3/src/client/DecoratedReadableStream.js +116 -0
- package/dist/cjs/tdf3/src/client/builders.js +561 -0
- package/dist/cjs/tdf3/src/client/index.js +460 -0
- package/dist/cjs/tdf3/src/client/validation.js +63 -0
- package/dist/cjs/tdf3/src/crypto/crypto-utils.js +116 -0
- package/dist/cjs/tdf3/src/crypto/declarations.js +8 -0
- package/dist/cjs/tdf3/src/crypto/index.js +315 -0
- package/dist/cjs/tdf3/src/index.js +34 -0
- package/dist/cjs/tdf3/src/models/attribute-set.js +122 -0
- package/dist/cjs/tdf3/src/models/encryption-information.js +90 -0
- package/dist/cjs/tdf3/src/models/index.js +25 -0
- package/dist/cjs/tdf3/src/models/key-access.js +103 -0
- package/dist/cjs/tdf3/src/models/manifest.js +3 -0
- package/dist/cjs/tdf3/src/models/payload.js +3 -0
- package/dist/cjs/tdf3/src/models/policy.js +24 -0
- package/dist/cjs/tdf3/src/models/upsert-response.js +3 -0
- package/dist/cjs/tdf3/src/tdf.js +907 -0
- package/dist/cjs/tdf3/src/templates/default.html.js +98 -0
- package/dist/cjs/tdf3/src/templates/escaper.js +15 -0
- package/dist/cjs/tdf3/src/templates/index.js +12 -0
- package/dist/cjs/tdf3/src/utils/buffer-crc32.js +48 -0
- package/dist/cjs/tdf3/src/utils/chunkers.js +106 -0
- package/dist/cjs/tdf3/src/utils/index.js +296 -0
- package/dist/cjs/tdf3/src/utils/keysplit.js +61 -0
- package/dist/cjs/tdf3/src/utils/zip-reader.js +253 -0
- package/dist/cjs/tdf3/src/utils/zip-writer.js +308 -0
- package/dist/cjs/tdf3/src/version.js +6 -0
- package/dist/types/src/access.d.ts +47 -0
- package/dist/types/src/access.d.ts.map +1 -0
- package/dist/types/src/auth/Eas.d.ts +34 -0
- package/dist/types/src/auth/Eas.d.ts.map +1 -0
- package/dist/types/src/auth/auth.d.ts +86 -0
- package/dist/types/src/auth/auth.d.ts.map +1 -0
- package/dist/types/src/auth/oidc-clientcredentials-provider.d.ts +9 -0
- package/dist/types/src/auth/oidc-clientcredentials-provider.d.ts.map +1 -0
- package/dist/types/src/auth/oidc-externaljwt-provider.d.ts +10 -0
- package/dist/types/src/auth/oidc-externaljwt-provider.d.ts.map +1 -0
- package/dist/types/src/auth/oidc-refreshtoken-provider.d.ts +10 -0
- package/dist/types/src/auth/oidc-refreshtoken-provider.d.ts.map +1 -0
- package/dist/types/src/auth/oidc.d.ts +104 -0
- package/dist/types/src/auth/oidc.d.ts.map +1 -0
- package/dist/types/src/auth/providers.d.ts +67 -0
- package/dist/types/src/auth/providers.d.ts.map +1 -0
- package/dist/types/src/encodings/base64.d.ts +18 -0
- package/dist/types/src/encodings/base64.d.ts.map +1 -0
- package/dist/types/src/encodings/hex.d.ts +5 -0
- package/dist/types/src/encodings/hex.d.ts.map +1 -0
- package/dist/types/src/encodings/index.d.ts +3 -0
- package/dist/types/src/encodings/index.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +72 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +138 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/nanotdf/Client.d.ts +95 -0
- package/dist/types/src/nanotdf/Client.d.ts.map +1 -0
- package/dist/types/src/nanotdf/NanoTDF.d.ts +25 -0
- package/dist/types/src/nanotdf/NanoTDF.d.ts.map +1 -0
- package/dist/types/src/nanotdf/browser-entry.d.ts +17 -0
- package/dist/types/src/nanotdf/browser-entry.d.ts.map +1 -0
- package/dist/types/src/nanotdf/constants.d.ts +2 -0
- package/dist/types/src/nanotdf/constants.d.ts.map +1 -0
- package/dist/types/src/nanotdf/decrypt.d.ts +9 -0
- package/dist/types/src/nanotdf/decrypt.d.ts.map +1 -0
- package/dist/types/src/nanotdf/encrypt-dataset.d.ts +12 -0
- package/dist/types/src/nanotdf/encrypt-dataset.d.ts.map +1 -0
- package/dist/types/src/nanotdf/encrypt.d.ts +14 -0
- package/dist/types/src/nanotdf/encrypt.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/CipherEnum.d.ts +10 -0
- package/dist/types/src/nanotdf/enum/CipherEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts +12 -0
- package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts +5 -0
- package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts +8 -0
- package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts +7 -0
- package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts +8 -0
- package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts.map +1 -0
- package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts +20 -0
- package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts.map +1 -0
- package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts +9 -0
- package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts.map +1 -0
- package/dist/types/src/nanotdf/index.d.ts +9 -0
- package/dist/types/src/nanotdf/index.d.ts.map +1 -0
- package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts +17 -0
- package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Ciphers.d.ts +14 -0
- package/dist/types/src/nanotdf/models/Ciphers.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/DefaultParams.d.ts +21 -0
- package/dist/types/src/nanotdf/models/DefaultParams.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/EcCurves.d.ts +15 -0
- package/dist/types/src/nanotdf/models/EcCurves.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Header.d.ts +73 -0
- package/dist/types/src/nanotdf/models/Header.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Payload.d.ts +47 -0
- package/dist/types/src/nanotdf/models/Payload.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts +52 -0
- package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts +35 -0
- package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts +11 -0
- package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts +31 -0
- package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/ResourceLocator.d.ts +65 -0
- package/dist/types/src/nanotdf/models/ResourceLocator.d.ts.map +1 -0
- package/dist/types/src/nanotdf/models/Signature.d.ts +33 -0
- package/dist/types/src/nanotdf/models/Signature.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/ciphers.d.ts +8 -0
- package/dist/types/src/nanotdf-crypto/ciphers.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/decrypt.d.ts +14 -0
- package/dist/types/src/nanotdf-crypto/decrypt.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/digest.d.ts +3 -0
- package/dist/types/src/nanotdf-crypto/digest.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/ecdsaSignature.d.ts +35 -0
- package/dist/types/src/nanotdf-crypto/ecdsaSignature.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/encrypt.d.ts +14 -0
- package/dist/types/src/nanotdf-crypto/encrypt.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/enums.d.ts +42 -0
- package/dist/types/src/nanotdf-crypto/enums.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/exportCryptoKey.d.ts +7 -0
- package/dist/types/src/nanotdf-crypto/exportCryptoKey.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts +10 -0
- package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts +5 -0
- package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/importRawKey.d.ts +13 -0
- package/dist/types/src/nanotdf-crypto/importRawKey.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/index.d.ts +12 -0
- package/dist/types/src/nanotdf-crypto/index.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts +28 -0
- package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts.map +1 -0
- package/dist/types/src/nanotdf-crypto/pemPublicToCrypto.d.ts +28 -0
- package/dist/types/src/nanotdf-crypto/pemPublicToCrypto.d.ts.map +1 -0
- package/dist/types/src/policy/api.d.ts +4 -0
- package/dist/types/src/policy/api.d.ts.map +1 -0
- package/dist/types/src/policy/attributes.d.ts +95 -0
- package/dist/types/src/policy/attributes.d.ts.map +1 -0
- package/dist/types/src/policy/granter.d.ts +23 -0
- package/dist/types/src/policy/granter.d.ts.map +1 -0
- package/dist/types/src/tdf/AttributeObject.d.ts +13 -0
- package/dist/types/src/tdf/AttributeObject.d.ts.map +1 -0
- package/dist/types/src/tdf/AttributeObjectJwt.d.ts +4 -0
- package/dist/types/src/tdf/AttributeObjectJwt.d.ts.map +1 -0
- package/dist/types/src/tdf/Crypto.d.ts +37 -0
- package/dist/types/src/tdf/Crypto.d.ts.map +1 -0
- package/dist/types/src/tdf/EntityObject.d.ts +18 -0
- package/dist/types/src/tdf/EntityObject.d.ts.map +1 -0
- package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts +99 -0
- package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts.map +1 -0
- package/dist/types/src/tdf/Policy.d.ts +28 -0
- package/dist/types/src/tdf/Policy.d.ts.map +1 -0
- package/dist/types/src/tdf/PolicyObject.d.ts +11 -0
- package/dist/types/src/tdf/PolicyObject.d.ts.map +1 -0
- package/dist/types/src/tdf/TypedArray.d.ts +3 -0
- package/dist/types/src/tdf/TypedArray.d.ts.map +1 -0
- package/dist/types/src/tdf/index.d.ts +7 -0
- package/dist/types/src/tdf/index.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +45 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/utils.d.ts +45 -0
- package/dist/types/src/utils.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +9 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/dist/types/tdf3/index.d.ts +16 -0
- package/dist/types/tdf3/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/assertions.d.ts +63 -0
- package/dist/types/tdf3/src/assertions.d.ts.map +1 -0
- package/dist/types/tdf3/src/binary.d.ts +38 -0
- package/dist/types/tdf3/src/binary.d.ts.map +1 -0
- package/dist/types/tdf3/src/ciphers/aes-gcm-cipher.d.ts +18 -0
- package/dist/types/tdf3/src/ciphers/aes-gcm-cipher.d.ts.map +1 -0
- package/dist/types/tdf3/src/ciphers/algorithms.d.ts +4 -0
- package/dist/types/tdf3/src/ciphers/algorithms.d.ts.map +1 -0
- package/dist/types/tdf3/src/ciphers/index.d.ts +3 -0
- package/dist/types/tdf3/src/ciphers/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/ciphers/symmetric-cipher-base.d.ts +14 -0
- package/dist/types/tdf3/src/ciphers/symmetric-cipher-base.d.ts.map +1 -0
- package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts +53 -0
- package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts.map +1 -0
- package/dist/types/tdf3/src/client/builders.d.ts +436 -0
- package/dist/types/tdf3/src/client/builders.d.ts.map +1 -0
- package/dist/types/tdf3/src/client/index.d.ts +139 -0
- package/dist/types/tdf3/src/client/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/client/validation.d.ts +8 -0
- package/dist/types/tdf3/src/client/validation.d.ts.map +1 -0
- package/dist/types/tdf3/src/crypto/crypto-utils.d.ts +34 -0
- package/dist/types/tdf3/src/crypto/crypto-utils.d.ts.map +1 -0
- package/dist/types/tdf3/src/crypto/declarations.d.ts +60 -0
- package/dist/types/tdf3/src/crypto/declarations.d.ts.map +1 -0
- package/dist/types/tdf3/src/crypto/index.d.ts +103 -0
- package/dist/types/tdf3/src/crypto/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/index.d.ts +5 -0
- package/dist/types/tdf3/src/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/attribute-set.d.ts +65 -0
- package/dist/types/tdf3/src/models/attribute-set.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/encryption-information.d.ts +49 -0
- package/dist/types/tdf3/src/models/encryption-information.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/index.d.ts +9 -0
- package/dist/types/tdf3/src/models/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/key-access.d.ts +42 -0
- package/dist/types/tdf3/src/models/key-access.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/manifest.d.ts +9 -0
- package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/payload.d.ts +7 -0
- package/dist/types/tdf3/src/models/payload.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/policy.d.ts +13 -0
- package/dist/types/tdf3/src/models/policy.d.ts.map +1 -0
- package/dist/types/tdf3/src/models/upsert-response.d.ts +16 -0
- package/dist/types/tdf3/src/models/upsert-response.d.ts.map +1 -0
- package/dist/types/tdf3/src/tdf.d.ts +152 -0
- package/dist/types/tdf3/src/tdf.d.ts.map +1 -0
- package/dist/types/tdf3/src/templates/default.html.d.ts +8 -0
- package/dist/types/tdf3/src/templates/default.html.d.ts.map +1 -0
- package/dist/types/tdf3/src/templates/escaper.d.ts +6 -0
- package/dist/types/tdf3/src/templates/escaper.d.ts.map +1 -0
- package/dist/types/tdf3/src/templates/index.d.ts +3 -0
- package/dist/types/tdf3/src/templates/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/buffer-crc32.d.ts +2 -0
- package/dist/types/tdf3/src/utils/buffer-crc32.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/chunkers.d.ts +29 -0
- package/dist/types/tdf3/src/utils/chunkers.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/index.d.ts +36 -0
- package/dist/types/tdf3/src/utils/index.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/keysplit.d.ts +19 -0
- package/dist/types/tdf3/src/utils/keysplit.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/zip-reader.d.ts +63 -0
- package/dist/types/tdf3/src/utils/zip-reader.d.ts.map +1 -0
- package/dist/types/tdf3/src/utils/zip-writer.d.ts +35 -0
- package/dist/types/tdf3/src/utils/zip-writer.d.ts.map +1 -0
- package/dist/types/tdf3/src/version.d.ts +3 -0
- package/dist/types/tdf3/src/version.d.ts.map +1 -0
- package/dist/web/package.json +3 -0
- package/dist/web/src/access.js +147 -0
- package/dist/web/src/auth/Eas.js +55 -0
- package/dist/web/src/auth/auth.js +71 -0
- package/dist/web/src/auth/oidc-clientcredentials-provider.js +22 -0
- package/dist/web/src/auth/oidc-externaljwt-provider.js +29 -0
- package/dist/web/src/auth/oidc-refreshtoken-provider.js +30 -0
- package/dist/web/src/auth/oidc.js +215 -0
- package/dist/web/src/auth/providers.js +119 -0
- package/dist/web/src/encodings/base64.js +147 -0
- package/dist/web/src/encodings/hex.js +63 -0
- package/dist/web/src/encodings/index.js +3 -0
- package/dist/web/src/errors.js +123 -0
- package/dist/web/src/index.js +313 -0
- package/dist/web/src/nanotdf/Client.js +268 -0
- package/dist/web/src/nanotdf/NanoTDF.js +89 -0
- package/dist/web/src/nanotdf/browser-entry.js +14 -0
- package/dist/web/src/nanotdf/constants.js +2 -0
- package/dist/web/src/nanotdf/decrypt.js +14 -0
- package/dist/web/src/nanotdf/encrypt-dataset.js +32 -0
- package/dist/web/src/nanotdf/encrypt.js +126 -0
- package/dist/web/src/nanotdf/enum/CipherEnum.js +11 -0
- package/dist/web/src/nanotdf/enum/CurveNameEnum.js +13 -0
- package/dist/web/src/nanotdf/enum/EncodingEnum.js +6 -0
- package/dist/web/src/nanotdf/enum/PolicyTypeEnum.js +9 -0
- package/dist/web/src/nanotdf/enum/ProtocolEnum.js +8 -0
- package/dist/web/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +9 -0
- package/dist/web/src/nanotdf/helpers/calculateByCurve.js +24 -0
- package/dist/web/src/nanotdf/helpers/getHkdfSalt.js +8 -0
- package/dist/web/src/nanotdf/index.js +11 -0
- package/dist/web/src/nanotdf/interfaces/PolicyInterface.js +2 -0
- package/dist/web/src/nanotdf/models/Ciphers.js +54 -0
- package/dist/web/src/nanotdf/models/DefaultParams.js +22 -0
- package/dist/web/src/nanotdf/models/EcCurves.js +32 -0
- package/dist/web/src/nanotdf/models/Header.js +250 -0
- package/dist/web/src/nanotdf/models/Payload.js +156 -0
- package/dist/web/src/nanotdf/models/Policy/AbstractPolicy.js +71 -0
- package/dist/web/src/nanotdf/models/Policy/EmbeddedPolicy.js +77 -0
- package/dist/web/src/nanotdf/models/Policy/PolicyFactory.js +33 -0
- package/dist/web/src/nanotdf/models/Policy/RemotePolicy.js +57 -0
- package/dist/web/src/nanotdf/models/ResourceLocator.js +206 -0
- package/dist/web/src/nanotdf/models/Signature.js +74 -0
- package/dist/web/src/nanotdf-crypto/ciphers.js +14 -0
- package/dist/web/src/nanotdf-crypto/decrypt.js +21 -0
- package/dist/web/src/nanotdf-crypto/digest.js +4 -0
- package/dist/web/src/nanotdf-crypto/ecdsaSignature.js +77 -0
- package/dist/web/src/nanotdf-crypto/encrypt.js +21 -0
- package/dist/web/src/nanotdf-crypto/enums.js +49 -0
- package/dist/web/src/nanotdf-crypto/exportCryptoKey.js +17 -0
- package/dist/web/src/nanotdf-crypto/generateKeyPair.js +10 -0
- package/dist/web/src/nanotdf-crypto/generateRandomNumber.js +9 -0
- package/dist/web/src/nanotdf-crypto/importRawKey.js +15 -0
- package/dist/web/src/nanotdf-crypto/index.js +12 -0
- package/dist/web/src/nanotdf-crypto/keyAgreement.js +87 -0
- package/dist/web/src/nanotdf-crypto/pemPublicToCrypto.js +197 -0
- package/dist/web/src/policy/api.js +54 -0
- package/dist/web/src/policy/attributes.js +2 -0
- package/dist/web/src/policy/granter.js +141 -0
- package/dist/web/src/tdf/AttributeObject.js +11 -0
- package/dist/web/src/tdf/AttributeObjectJwt.js +2 -0
- package/dist/web/src/tdf/Crypto.js +44 -0
- package/dist/web/src/tdf/EntityObject.js +2 -0
- package/dist/web/src/tdf/NanoTDF/NanoTDF.js +35 -0
- package/dist/web/src/tdf/Policy.js +48 -0
- package/dist/web/src/tdf/PolicyObject.js +2 -0
- package/dist/web/src/tdf/TypedArray.js +2 -0
- package/dist/web/src/tdf/index.js +4 -0
- package/dist/web/src/types/index.js +2 -0
- package/dist/web/src/utils.js +133 -0
- package/dist/web/src/version.js +9 -0
- package/dist/web/tdf3/index.js +13 -0
- package/dist/web/tdf3/src/assertions.js +111 -0
- package/dist/web/tdf3/src/binary.js +149 -0
- package/dist/web/tdf3/src/ciphers/aes-gcm-cipher.js +52 -0
- package/dist/web/tdf3/src/ciphers/algorithms.js +5 -0
- package/dist/web/tdf3/src/ciphers/index.js +3 -0
- package/dist/web/tdf3/src/ciphers/symmetric-cipher-base.js +18 -0
- package/dist/web/tdf3/src/client/DecoratedReadableStream.js +107 -0
- package/dist/web/tdf3/src/client/builders.js +557 -0
- package/dist/web/tdf3/src/client/index.js +423 -0
- package/dist/web/tdf3/src/client/validation.js +58 -0
- package/dist/web/tdf3/src/crypto/crypto-utils.js +107 -0
- package/dist/web/tdf3/src/crypto/declarations.js +5 -0
- package/dist/web/tdf3/src/crypto/index.js +296 -0
- package/dist/web/tdf3/src/index.js +5 -0
- package/dist/web/tdf3/src/models/attribute-set.js +118 -0
- package/dist/web/tdf3/src/models/encryption-information.js +86 -0
- package/dist/web/tdf3/src/models/index.js +9 -0
- package/dist/web/tdf3/src/models/key-access.js +74 -0
- package/dist/web/tdf3/src/models/manifest.js +2 -0
- package/dist/web/tdf3/src/models/payload.js +2 -0
- package/dist/web/tdf3/src/models/policy.js +20 -0
- package/dist/web/tdf3/src/models/upsert-response.js +2 -0
- package/dist/web/tdf3/src/tdf.js +866 -0
- package/dist/web/tdf3/src/templates/default.html.js +96 -0
- package/dist/web/tdf3/src/templates/escaper.js +10 -0
- package/dist/web/tdf3/src/templates/index.js +3 -0
- package/dist/web/tdf3/src/utils/buffer-crc32.js +44 -0
- package/dist/web/tdf3/src/utils/chunkers.js +96 -0
- package/dist/web/tdf3/src/utils/index.js +248 -0
- package/dist/web/tdf3/src/utils/keysplit.js +55 -0
- package/dist/web/tdf3/src/utils/zip-reader.js +247 -0
- package/dist/web/tdf3/src/utils/zip-writer.js +302 -0
- package/dist/web/tdf3/src/version.js +3 -0
- package/package.json +126 -0
- package/src/access.ts +198 -0
- package/src/auth/Eas.ts +79 -0
- package/src/auth/auth.ts +141 -0
- package/src/auth/oidc-clientcredentials-provider.ts +32 -0
- package/src/auth/oidc-externaljwt-provider.ts +41 -0
- package/src/auth/oidc-refreshtoken-provider.ts +41 -0
- package/src/auth/oidc.ts +307 -0
- package/src/auth/providers.ts +139 -0
- package/src/encodings/base64.ts +160 -0
- package/src/encodings/hex.ts +69 -0
- package/src/encodings/index.ts +2 -0
- package/src/errors.ts +113 -0
- package/src/index.ts +441 -0
- package/src/nanotdf/Client.ts +349 -0
- package/src/nanotdf/NanoTDF.ts +121 -0
- package/src/nanotdf/browser-entry.ts +20 -0
- package/src/nanotdf/constants.ts +1 -0
- package/src/nanotdf/decrypt.ts +19 -0
- package/src/nanotdf/encrypt-dataset.ts +52 -0
- package/src/nanotdf/encrypt.ts +197 -0
- package/src/nanotdf/enum/CipherEnum.ts +10 -0
- package/src/nanotdf/enum/CurveNameEnum.ts +12 -0
- package/src/nanotdf/enum/EncodingEnum.ts +5 -0
- package/src/nanotdf/enum/PolicyTypeEnum.ts +8 -0
- package/src/nanotdf/enum/ProtocolEnum.ts +7 -0
- package/src/nanotdf/enum/ResourceLocatorIdentifierEnum.ts +8 -0
- package/src/nanotdf/helpers/calculateByCurve.ts +26 -0
- package/src/nanotdf/helpers/getHkdfSalt.ts +15 -0
- package/src/nanotdf/index.ts +10 -0
- package/src/nanotdf/interfaces/PolicyInterface.ts +27 -0
- package/src/nanotdf/models/Ciphers.ts +67 -0
- package/src/nanotdf/models/DefaultParams.ts +24 -0
- package/src/nanotdf/models/EcCurves.ts +40 -0
- package/src/nanotdf/models/Header.ts +322 -0
- package/src/nanotdf/models/Payload.ts +196 -0
- package/src/nanotdf/models/Policy/AbstractPolicy.ts +90 -0
- package/src/nanotdf/models/Policy/EmbeddedPolicy.ts +101 -0
- package/src/nanotdf/models/Policy/PolicyFactory.ts +48 -0
- package/src/nanotdf/models/Policy/RemotePolicy.ts +74 -0
- package/src/nanotdf/models/ResourceLocator.ts +212 -0
- package/src/nanotdf/models/Signature.ts +85 -0
- package/src/nanotdf-crypto/ciphers.ts +13 -0
- package/src/nanotdf-crypto/decrypt.ts +30 -0
- package/src/nanotdf-crypto/digest.ts +8 -0
- package/src/nanotdf-crypto/ecdsaSignature.ts +109 -0
- package/src/nanotdf-crypto/encrypt.ts +30 -0
- package/src/nanotdf-crypto/enums.ts +47 -0
- package/src/nanotdf-crypto/exportCryptoKey.ts +17 -0
- package/src/nanotdf-crypto/generateKeyPair.ts +19 -0
- package/src/nanotdf-crypto/generateRandomNumber.ts +8 -0
- package/src/nanotdf-crypto/importRawKey.ts +19 -0
- package/src/nanotdf-crypto/index.ts +11 -0
- package/src/nanotdf-crypto/keyAgreement.ts +139 -0
- package/src/nanotdf-crypto/pemPublicToCrypto.ts +232 -0
- package/src/package-lock.json +6 -0
- package/src/package.json +3 -0
- package/src/platform/authorization/authorization_connect.d.ts +44 -0
- package/src/platform/authorization/authorization_connect.js +44 -0
- package/src/platform/authorization/authorization_pb.d.ts +707 -0
- package/src/platform/authorization/authorization_pb.js +372 -0
- package/src/platform/common/common_pb.d.ts +129 -0
- package/src/platform/common/common_pb.js +58 -0
- package/src/platform/entityresolution/entity_resolution_connect.d.ts +35 -0
- package/src/platform/entityresolution/entity_resolution_connect.js +35 -0
- package/src/platform/entityresolution/entity_resolution_pb.d.ts +242 -0
- package/src/platform/entityresolution/entity_resolution_pb.js +139 -0
- package/src/platform/kas/kas_connect.d.ts +59 -0
- package/src/platform/kas/kas_connect.js +59 -0
- package/src/platform/kas/kas_pb.d.ts +200 -0
- package/src/platform/kas/kas_pb.js +84 -0
- package/src/platform/policy/attributes/attributes_connect.d.ts +168 -0
- package/src/platform/policy/attributes/attributes_connect.js +168 -0
- package/src/platform/policy/attributes/attributes_pb.d.ts +929 -0
- package/src/platform/policy/attributes/attributes_pb.js +363 -0
- package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +62 -0
- package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +62 -0
- package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +283 -0
- package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +113 -0
- package/src/platform/policy/namespaces/namespaces_connect.d.ts +62 -0
- package/src/platform/policy/namespaces/namespaces_connect.js +62 -0
- package/src/platform/policy/namespaces/namespaces_pb.d.ts +270 -0
- package/src/platform/policy/namespaces/namespaces_pb.js +110 -0
- package/src/platform/policy/objects_pb.d.ts +725 -0
- package/src/platform/policy/objects_pb.js +288 -0
- package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +259 -0
- package/src/platform/policy/resourcemapping/resource_mapping_connect.js +259 -0
- package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +314 -0
- package/src/platform/policy/resourcemapping/resource_mapping_pb.js +142 -0
- package/src/platform/policy/selectors_pb.d.ts +269 -0
- package/src/platform/policy/selectors_pb.js +110 -0
- package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +118 -0
- package/src/platform/policy/subjectmapping/subject_mapping_connect.js +118 -0
- package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +672 -0
- package/src/platform/policy/subjectmapping/subject_mapping_pb.js +260 -0
- package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +26 -0
- package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +26 -0
- package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +75 -0
- package/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +35 -0
- package/src/policy/api.ts +61 -0
- package/src/policy/attributes.ts +117 -0
- package/src/policy/granter.ts +181 -0
- package/src/tdf/AttributeObject.ts +27 -0
- package/src/tdf/AttributeObjectJwt.ts +3 -0
- package/src/tdf/Crypto.ts +42 -0
- package/src/tdf/EntityObject.ts +18 -0
- package/src/tdf/NanoTDF/NanoTDF.ts +120 -0
- package/src/tdf/Policy.ts +51 -0
- package/src/tdf/PolicyObject.ts +12 -0
- package/src/tdf/TypedArray.ts +12 -0
- package/src/tdf/index.ts +6 -0
- package/src/types/index.ts +55 -0
- package/src/utils.ts +149 -0
- package/src/version.ts +9 -0
- package/tdf3/index.ts +91 -0
- package/tdf3/package-lock.json +6 -0
- package/tdf3/package.json +3 -0
- package/tdf3/src/assertions.ts +191 -0
- package/tdf3/src/binary.ts +195 -0
- package/tdf3/src/ciphers/aes-gcm-cipher.ts +76 -0
- package/tdf3/src/ciphers/algorithms.ts +9 -0
- package/tdf3/src/ciphers/index.ts +2 -0
- package/tdf3/src/ciphers/symmetric-cipher-base.ts +38 -0
- package/tdf3/src/client/DecoratedReadableStream.ts +148 -0
- package/tdf3/src/client/builders.ts +701 -0
- package/tdf3/src/client/index.ts +637 -0
- package/tdf3/src/client/validation.ts +79 -0
- package/tdf3/src/crypto/crypto-utils.ts +119 -0
- package/tdf3/src/crypto/declarations.ts +89 -0
- package/tdf3/src/crypto/index.ts +394 -0
- package/tdf3/src/index.ts +4 -0
- package/tdf3/src/models/attribute-set.ts +142 -0
- package/tdf3/src/models/encryption-information.ts +172 -0
- package/tdf3/src/models/index.ts +8 -0
- package/tdf3/src/models/key-access.ts +128 -0
- package/tdf3/src/models/manifest.ts +9 -0
- package/tdf3/src/models/payload.ts +6 -0
- package/tdf3/src/models/policy.ts +35 -0
- package/tdf3/src/models/upsert-response.ts +17 -0
- package/tdf3/src/tdf.ts +1351 -0
- package/tdf3/src/templates/default.html.ts +105 -0
- package/tdf3/src/templates/escaper.ts +10 -0
- package/tdf3/src/templates/index.ts +2 -0
- package/tdf3/src/utils/buffer-crc32.ts +46 -0
- package/tdf3/src/utils/chunkers.ts +118 -0
- package/tdf3/src/utils/index.ts +309 -0
- package/tdf3/src/utils/keysplit.ts +63 -0
- package/tdf3/src/utils/zip-reader.ts +341 -0
- package/tdf3/src/utils/zip-writer.ts +375 -0
- package/tdf3/src/version.ts +2 -0
- package/tdf3/types.d.ts +14 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { decodeJwt } from 'jose';
|
|
2
|
+
|
|
3
|
+
export type AttributeObject = {
|
|
4
|
+
attribute: string;
|
|
5
|
+
kasUrl?: string;
|
|
6
|
+
kid?: string;
|
|
7
|
+
pubKey?: string;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
isDefault?: boolean;
|
|
10
|
+
jwt?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export class AttributeSet {
|
|
14
|
+
attributes: AttributeObject[];
|
|
15
|
+
|
|
16
|
+
verbose: boolean = false;
|
|
17
|
+
|
|
18
|
+
defaultAttribute?: AttributeObject;
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
this.attributes = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Check if attribute is in the list
|
|
26
|
+
* @param attribute URL of the attribute
|
|
27
|
+
* @return if attribute is in the set
|
|
28
|
+
*/
|
|
29
|
+
has(attribute = ''): boolean {
|
|
30
|
+
// This could be much more elegant with something other than an
|
|
31
|
+
// array as the data structure. This is OK-ish only because the
|
|
32
|
+
// expected size of the data structure is small
|
|
33
|
+
// console.log(">>> ----- Has Attribute" + attribute);
|
|
34
|
+
return !!this.attributes.find((attrObj) => attrObj.attribute === attribute);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get an attribute by URL
|
|
39
|
+
* @param attribute URL of the attribute
|
|
40
|
+
* @return attribute in object form, if found
|
|
41
|
+
*/
|
|
42
|
+
get(attribute = ''): AttributeObject | null {
|
|
43
|
+
// This could be much more elegant with something other than an
|
|
44
|
+
// array as the data structure. This is OK-ish only because the
|
|
45
|
+
// expected size of the data structure is small
|
|
46
|
+
// console.log(">>> ----- Get Attribute" + attribute);
|
|
47
|
+
const result = this.attributes.filter((attrObj) => attrObj.attribute == attribute);
|
|
48
|
+
return result.length > 0 ? result[0] : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get all the attributes.
|
|
53
|
+
* @return default attribute in object form or null
|
|
54
|
+
*/
|
|
55
|
+
getDefault(): AttributeObject | null {
|
|
56
|
+
return this.defaultAttribute || null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the default attribute, if it exists.
|
|
61
|
+
* @return return all the attribute urls
|
|
62
|
+
*/
|
|
63
|
+
getUrls(): string[] {
|
|
64
|
+
return this.attributes.map((attr) => attr.attribute);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Add an attribute to the set. Should be idempotent.
|
|
69
|
+
* @param attrObj AttributeObject to add, in non-JWT form
|
|
70
|
+
* @return the attribute object if successful, or null
|
|
71
|
+
*/
|
|
72
|
+
addAttribute(attrObj: AttributeObject): AttributeObject | null {
|
|
73
|
+
// Check for duplicate entries to assure idempotency.
|
|
74
|
+
if (this.has(attrObj.attribute)) {
|
|
75
|
+
// This may be a common occurance, so only un-comment this log message
|
|
76
|
+
// if you want verbose mode.
|
|
77
|
+
// console.log(`Attribute ${attrObj.attribute} is already loaded.`);
|
|
78
|
+
return null; // reject silently
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (attrObj.isDefault === true) {
|
|
82
|
+
if (this.defaultAttribute && this.defaultAttribute.attribute !== attrObj.attribute) {
|
|
83
|
+
// Remove the existing default attribute to make room for the new one
|
|
84
|
+
this.deleteAttribute(this.defaultAttribute.attribute);
|
|
85
|
+
}
|
|
86
|
+
this.defaultAttribute = attrObj;
|
|
87
|
+
}
|
|
88
|
+
this.attributes.push(attrObj);
|
|
89
|
+
return attrObj;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Delete an attribute from the set. Should be idempotent.
|
|
94
|
+
* @param attrUrl - URL of Attribute object to delete.
|
|
95
|
+
* @return The attribute object if successful or null if not
|
|
96
|
+
*/
|
|
97
|
+
deleteAttribute(attrUrl = ''): AttributeObject | null {
|
|
98
|
+
const deleted = this.get(attrUrl);
|
|
99
|
+
if (deleted) {
|
|
100
|
+
this.attributes = this.attributes.filter((attrObj) => attrObj.attribute != attrUrl);
|
|
101
|
+
}
|
|
102
|
+
return deleted;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Add a list of attributes in object form
|
|
107
|
+
* @param attributes List of attribute objects as provided in an EntityObject
|
|
108
|
+
* @param easPublicKey EAS public key for decrypting the JWTs
|
|
109
|
+
* @return list of attribute objects
|
|
110
|
+
*/
|
|
111
|
+
addAttributes(attributes: AttributeObject[] = []): (AttributeObject | null)[] {
|
|
112
|
+
return attributes
|
|
113
|
+
.map((attrObj) => {
|
|
114
|
+
return this.addAttribute(attrObj); // Returns promise
|
|
115
|
+
})
|
|
116
|
+
.filter((x) => x);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Add an attribute in JWT form = { jwt: <string jwt> }
|
|
121
|
+
* @param {Object} jwtAttribute - Attribute object in JWT form.
|
|
122
|
+
* @return {Object} - Decrypted and added attribute object
|
|
123
|
+
*/
|
|
124
|
+
addJwtAttribute(jwtAttribute: { jwt: string }) {
|
|
125
|
+
const attrJwt = jwtAttribute?.jwt;
|
|
126
|
+
// Can't verify the JWT because the client does not have the easPublicKey,
|
|
127
|
+
// but the contents of the JWT can be decoded.
|
|
128
|
+
const attrObjPayload = attrJwt && decodeJwt(attrJwt);
|
|
129
|
+
if (!attrObjPayload) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
// JWT payloads contain many things, incluing .iat and .exp. This
|
|
133
|
+
// extraneous material should be stripped away before adding the
|
|
134
|
+
// attribute to the attributeSet.
|
|
135
|
+
const { attribute, displayName, pubKey, kasUrl } = attrObjPayload as AttributeObject;
|
|
136
|
+
const attrObj: AttributeObject = { attribute, displayName, pubKey, kasUrl, jwt: attrJwt };
|
|
137
|
+
if (attrObjPayload.isDefault) {
|
|
138
|
+
attrObj.isDefault = !!attrObjPayload.isDefault;
|
|
139
|
+
}
|
|
140
|
+
return this.addAttribute(attrObj);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { keySplit } from '../utils/index.js';
|
|
2
|
+
import { base64, hex } from '../../../src/encodings/index.js';
|
|
3
|
+
import { Binary } from '../binary.js';
|
|
4
|
+
import { type SymmetricCipher } from '../ciphers/symmetric-cipher-base.js';
|
|
5
|
+
import { type KeyAccess, type KeyAccessObject } from './key-access.js';
|
|
6
|
+
import { type Policy } from './policy.js';
|
|
7
|
+
import {
|
|
8
|
+
type CryptoService,
|
|
9
|
+
type DecryptResult,
|
|
10
|
+
type EncryptResult,
|
|
11
|
+
} from '../crypto/declarations.js';
|
|
12
|
+
import { IntegrityAlgorithm } from '../tdf.js';
|
|
13
|
+
import { ConfigurationError } from '../../../src/errors.js';
|
|
14
|
+
|
|
15
|
+
export type KeyInfo = {
|
|
16
|
+
readonly unwrappedKeyBinary: Binary;
|
|
17
|
+
readonly unwrappedKeyIvBinary: Binary;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type Segment = {
|
|
21
|
+
readonly hash: string;
|
|
22
|
+
// If not present, segmentSizeDefault must be defined and used.
|
|
23
|
+
readonly segmentSize?: number;
|
|
24
|
+
// If not present, encryptedSegmentSizeDefault must be defined and used.??
|
|
25
|
+
readonly encryptedSegmentSize?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SplitType = 'split';
|
|
29
|
+
|
|
30
|
+
export type EncryptionInformation = {
|
|
31
|
+
readonly type: SplitType;
|
|
32
|
+
readonly keyAccess: KeyAccessObject[];
|
|
33
|
+
readonly integrityInformation: {
|
|
34
|
+
readonly rootSignature: {
|
|
35
|
+
alg: IntegrityAlgorithm;
|
|
36
|
+
sig: string;
|
|
37
|
+
};
|
|
38
|
+
segmentHashAlg?: IntegrityAlgorithm;
|
|
39
|
+
segments: Segment[];
|
|
40
|
+
segmentSizeDefault?: number;
|
|
41
|
+
encryptedSegmentSizeDefault?: number;
|
|
42
|
+
};
|
|
43
|
+
readonly method: {
|
|
44
|
+
readonly algorithm: string;
|
|
45
|
+
isStreamable: boolean;
|
|
46
|
+
readonly iv: string;
|
|
47
|
+
};
|
|
48
|
+
policy: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export class SplitKey {
|
|
52
|
+
readonly cryptoService: CryptoService;
|
|
53
|
+
keyAccess: KeyAccess[];
|
|
54
|
+
|
|
55
|
+
constructor(public readonly cipher: SymmetricCipher) {
|
|
56
|
+
this.cryptoService = cipher.cryptoService;
|
|
57
|
+
this.keyAccess = [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async generateKey(): Promise<KeyInfo> {
|
|
61
|
+
const unwrappedKey = await this.cipher.generateKey();
|
|
62
|
+
const unwrappedKeyBinary = Binary.fromString(hex.decode(unwrappedKey));
|
|
63
|
+
const unwrappedKeyIvBinary = await this.generateIvBinary();
|
|
64
|
+
return { unwrappedKeyBinary, unwrappedKeyIvBinary };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async encrypt(
|
|
68
|
+
contentBinary: Binary,
|
|
69
|
+
keyBinary: Binary,
|
|
70
|
+
ivBinaryOptional?: Binary
|
|
71
|
+
): Promise<EncryptResult> {
|
|
72
|
+
const ivBinary = ivBinaryOptional || (await this.generateIvBinary());
|
|
73
|
+
return this.cipher.encrypt(contentBinary, keyBinary, ivBinary);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async decrypt(content: Uint8Array, keyBinary: Binary): Promise<DecryptResult> {
|
|
77
|
+
return this.cipher.decrypt(content, keyBinary);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async getKeyAccessObjects(policy: Policy, keyInfo: KeyInfo): Promise<KeyAccessObject[]> {
|
|
81
|
+
const splitIds = [...new Set(this.keyAccess.map(({ sid }) => sid))].sort((a, b) =>
|
|
82
|
+
a.localeCompare(b)
|
|
83
|
+
);
|
|
84
|
+
const unwrappedKeySplitBuffers = await keySplit(
|
|
85
|
+
new Uint8Array(keyInfo.unwrappedKeyBinary.asByteArray()),
|
|
86
|
+
splitIds.length,
|
|
87
|
+
this.cryptoService
|
|
88
|
+
);
|
|
89
|
+
const splitsByName = Object.fromEntries(
|
|
90
|
+
splitIds.map((sid, index) => [sid, unwrappedKeySplitBuffers[index]])
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const keyAccessObjects = [];
|
|
94
|
+
for (const item of this.keyAccess) {
|
|
95
|
+
// use the key split to encrypt metadata for each key access object
|
|
96
|
+
const unwrappedKeySplitBuffer = splitsByName[item.sid];
|
|
97
|
+
const unwrappedKeySplitBinary = Binary.fromArrayBuffer(unwrappedKeySplitBuffer.buffer);
|
|
98
|
+
|
|
99
|
+
const metadata = item.metadata || '';
|
|
100
|
+
const metadataStr = (
|
|
101
|
+
typeof metadata === 'object'
|
|
102
|
+
? JSON.stringify(metadata)
|
|
103
|
+
: typeof metadata === 'string'
|
|
104
|
+
? metadata
|
|
105
|
+
: () => {
|
|
106
|
+
throw new ConfigurationError(
|
|
107
|
+
"KAO generation failure: metadata isn't a string or object"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
) as string;
|
|
111
|
+
|
|
112
|
+
const metadataBinary = Binary.fromArrayBuffer(new TextEncoder().encode(metadataStr));
|
|
113
|
+
|
|
114
|
+
const encryptedMetadataResult = await this.encrypt(
|
|
115
|
+
metadataBinary,
|
|
116
|
+
unwrappedKeySplitBinary,
|
|
117
|
+
keyInfo.unwrappedKeyIvBinary
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const encryptedMetadataOb = {
|
|
121
|
+
ciphertext: base64.encode(encryptedMetadataResult.payload.asString()),
|
|
122
|
+
iv: base64.encode(keyInfo.unwrappedKeyIvBinary.asString()),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const encryptedMetadataStr = JSON.stringify(encryptedMetadataOb);
|
|
126
|
+
const keyAccessObject = await item.write(
|
|
127
|
+
policy,
|
|
128
|
+
unwrappedKeySplitBuffer,
|
|
129
|
+
encryptedMetadataStr
|
|
130
|
+
);
|
|
131
|
+
keyAccessObjects.push(keyAccessObject);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return keyAccessObjects;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async generateIvBinary(): Promise<Binary> {
|
|
138
|
+
const iv = await this.cipher.generateInitializationVector();
|
|
139
|
+
return Binary.fromString(hex.decode(iv));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async write(policy: Policy, keyInfo: KeyInfo): Promise<EncryptionInformation> {
|
|
143
|
+
const algorithm = this.cipher?.name;
|
|
144
|
+
if (!algorithm) {
|
|
145
|
+
// Hard coded as part of the cipher object. This should not be reachable.
|
|
146
|
+
throw new ConfigurationError('uninitialized cipher type');
|
|
147
|
+
}
|
|
148
|
+
const keyAccessObjects = await this.getKeyAccessObjects(policy, keyInfo);
|
|
149
|
+
|
|
150
|
+
// For now we're only concerned with a single (first) key access object
|
|
151
|
+
const policyForManifest = base64.encode(JSON.stringify(policy));
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
type: 'split',
|
|
155
|
+
keyAccess: keyAccessObjects,
|
|
156
|
+
method: {
|
|
157
|
+
algorithm,
|
|
158
|
+
isStreamable: false,
|
|
159
|
+
iv: base64.encode(keyInfo.unwrappedKeyIvBinary.asString()),
|
|
160
|
+
},
|
|
161
|
+
integrityInformation: {
|
|
162
|
+
rootSignature: {
|
|
163
|
+
alg: 'HS256',
|
|
164
|
+
sig: '',
|
|
165
|
+
},
|
|
166
|
+
segmentHashAlg: 'GMAC',
|
|
167
|
+
segments: [],
|
|
168
|
+
},
|
|
169
|
+
policy: policyForManifest,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './attribute-set.js';
|
|
2
|
+
export * from './encryption-information.js';
|
|
3
|
+
export * from './key-access.js';
|
|
4
|
+
export * from './manifest.js';
|
|
5
|
+
export * from './payload.js';
|
|
6
|
+
export * from './policy.js';
|
|
7
|
+
export * from './upsert-response.js';
|
|
8
|
+
export * from '../assertions.js';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Binary } from '../binary.js';
|
|
2
|
+
import { base64, hex } from '../../../src/encodings/index.js';
|
|
3
|
+
import * as cryptoService from '../crypto/index.js';
|
|
4
|
+
import { Policy } from './policy.js';
|
|
5
|
+
|
|
6
|
+
export type KeyAccessType = 'remote' | 'wrapped';
|
|
7
|
+
|
|
8
|
+
export function isRemote(keyAccessJSON: KeyAccess | KeyAccessObject): boolean {
|
|
9
|
+
return keyAccessJSON.type === 'remote';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class Wrapped {
|
|
13
|
+
readonly type = 'wrapped';
|
|
14
|
+
keyAccessObject?: KeyAccessObject;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
public readonly url: string,
|
|
18
|
+
public readonly kid: string | undefined,
|
|
19
|
+
public readonly publicKey: string,
|
|
20
|
+
public readonly metadata: unknown,
|
|
21
|
+
public readonly sid: string
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
async write(
|
|
25
|
+
policy: Policy,
|
|
26
|
+
keyBuffer: Uint8Array,
|
|
27
|
+
encryptedMetadataStr: string
|
|
28
|
+
): Promise<KeyAccessObject> {
|
|
29
|
+
const policyStr = JSON.stringify(policy);
|
|
30
|
+
const unwrappedKeyBinary = Binary.fromArrayBuffer(keyBuffer.buffer);
|
|
31
|
+
const wrappedKeyBinary = await cryptoService.encryptWithPublicKey(
|
|
32
|
+
unwrappedKeyBinary,
|
|
33
|
+
this.publicKey
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const policyBinding = await cryptoService.hmac(
|
|
37
|
+
hex.encodeArrayBuffer(keyBuffer),
|
|
38
|
+
base64.encode(policyStr)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
this.keyAccessObject = {
|
|
42
|
+
type: 'wrapped',
|
|
43
|
+
url: this.url,
|
|
44
|
+
protocol: 'kas',
|
|
45
|
+
wrappedKey: base64.encode(wrappedKeyBinary.asString()),
|
|
46
|
+
encryptedMetadata: base64.encode(encryptedMetadataStr),
|
|
47
|
+
policyBinding: {
|
|
48
|
+
alg: 'HS256',
|
|
49
|
+
hash: base64.encode(policyBinding),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
if (this.kid) {
|
|
53
|
+
this.keyAccessObject.kid = this.kid;
|
|
54
|
+
}
|
|
55
|
+
if (this.sid?.length) {
|
|
56
|
+
this.keyAccessObject.sid = this.sid;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.keyAccessObject;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class Remote {
|
|
64
|
+
readonly type = 'remote';
|
|
65
|
+
keyAccessObject?: KeyAccessObject;
|
|
66
|
+
wrappedKey?: string;
|
|
67
|
+
policyBinding?: string;
|
|
68
|
+
|
|
69
|
+
constructor(
|
|
70
|
+
public readonly url: string,
|
|
71
|
+
public readonly kid: string | undefined,
|
|
72
|
+
public readonly publicKey: string,
|
|
73
|
+
public readonly metadata: unknown,
|
|
74
|
+
public readonly sid: string
|
|
75
|
+
) {}
|
|
76
|
+
|
|
77
|
+
async write(
|
|
78
|
+
policy: Policy,
|
|
79
|
+
keyBuffer: Uint8Array,
|
|
80
|
+
encryptedMetadataStr: string
|
|
81
|
+
): Promise<KeyAccessObject> {
|
|
82
|
+
const policyStr = JSON.stringify(policy);
|
|
83
|
+
const policyBinding = await cryptoService.hmac(
|
|
84
|
+
hex.encodeArrayBuffer(keyBuffer),
|
|
85
|
+
base64.encode(policyStr)
|
|
86
|
+
);
|
|
87
|
+
const unwrappedKeyBinary = Binary.fromArrayBuffer(keyBuffer.buffer);
|
|
88
|
+
const wrappedKeyBinary = await cryptoService.encryptWithPublicKey(
|
|
89
|
+
unwrappedKeyBinary,
|
|
90
|
+
this.publicKey
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// this.wrappedKey = wrappedKeyBinary.asBuffer().toString('hex');
|
|
94
|
+
this.wrappedKey = base64.encode(wrappedKeyBinary.asString());
|
|
95
|
+
|
|
96
|
+
this.keyAccessObject = {
|
|
97
|
+
type: 'remote',
|
|
98
|
+
url: this.url,
|
|
99
|
+
protocol: 'kas',
|
|
100
|
+
wrappedKey: this.wrappedKey,
|
|
101
|
+
encryptedMetadata: base64.encode(encryptedMetadataStr),
|
|
102
|
+
policyBinding: {
|
|
103
|
+
alg: 'HS256',
|
|
104
|
+
hash: base64.encode(policyBinding),
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
if (this.kid) {
|
|
108
|
+
this.keyAccessObject.kid = this.kid;
|
|
109
|
+
}
|
|
110
|
+
return this.keyAccessObject;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type KeyAccess = Remote | Wrapped;
|
|
115
|
+
|
|
116
|
+
export type KeyAccessObject = {
|
|
117
|
+
sid?: string;
|
|
118
|
+
type: KeyAccessType;
|
|
119
|
+
url: string;
|
|
120
|
+
kid?: string;
|
|
121
|
+
protocol: 'kas';
|
|
122
|
+
wrappedKey?: string;
|
|
123
|
+
policyBinding?: {
|
|
124
|
+
alg: string;
|
|
125
|
+
hash: string;
|
|
126
|
+
};
|
|
127
|
+
encryptedMetadata?: string;
|
|
128
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Assertion } from '../assertions.js';
|
|
2
|
+
import { type Payload } from './payload.js';
|
|
3
|
+
import { type EncryptionInformation } from './encryption-information.js';
|
|
4
|
+
|
|
5
|
+
export type Manifest = {
|
|
6
|
+
payload: Payload;
|
|
7
|
+
encryptionInformation: EncryptionInformation;
|
|
8
|
+
assertions: Assertion[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ConfigurationError } from '../../../src/errors.js';
|
|
2
|
+
import { AttributeObject } from './attribute-set.js';
|
|
3
|
+
|
|
4
|
+
export const CURRENT_VERSION = '1.1.0';
|
|
5
|
+
|
|
6
|
+
export type PolicyBody = {
|
|
7
|
+
dataAttributes: AttributeObject[];
|
|
8
|
+
dissem: string[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Policy = {
|
|
12
|
+
tdf_spec_version?: string;
|
|
13
|
+
uuid?: string;
|
|
14
|
+
body?: PolicyBody;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function validatePolicyObject(policyMaybe: unknown): policyMaybe is Policy {
|
|
18
|
+
if (typeof policyMaybe !== 'object') {
|
|
19
|
+
throw new ConfigurationError(
|
|
20
|
+
`The given policy reference must be an object, not: ${policyMaybe}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const policy = policyMaybe as Policy;
|
|
24
|
+
const missingFields = [];
|
|
25
|
+
if (!policy.uuid) missingFields.push('uuid');
|
|
26
|
+
if (!policy.body) missingFields.push('body', 'body.dissem');
|
|
27
|
+
if (policy.body && !policy.body.dissem) missingFields.push('body.dissem');
|
|
28
|
+
|
|
29
|
+
if (missingFields.length) {
|
|
30
|
+
throw new ConfigurationError(
|
|
31
|
+
`The given policy object requires the following properties: ${missingFields}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ArtifactFinder = {
|
|
2
|
+
upload?: string;
|
|
3
|
+
// Download URL for the payload. This can be a direct link to the file (S3), or a proxy URL.
|
|
4
|
+
download: string;
|
|
5
|
+
key?: string;
|
|
6
|
+
bucket?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type UpsertResponse = {
|
|
10
|
+
uuid: string;
|
|
11
|
+
storageLinks: {
|
|
12
|
+
payload: ArtifactFinder & {
|
|
13
|
+
proxy?: boolean | string;
|
|
14
|
+
};
|
|
15
|
+
metadata?: ArtifactFinder;
|
|
16
|
+
};
|
|
17
|
+
}[][];
|