diff --git a/modules/cache-material/src/clone_cryptographic_material.ts b/modules/cache-material/src/clone_cryptographic_material.ts index a62d84636..a3958be2e 100644 --- a/modules/cache-material/src/clone_cryptographic_material.ts +++ b/modules/cache-material/src/clone_cryptographic_material.ts @@ -37,12 +37,15 @@ export function cloneMaterial (source: M): M { ? new WebCryptoEncryptionMaterial(suite, encryptionContext) : new WebCryptoDecryptionMaterial(suite, encryptionContext) - const udk = new Uint8Array(source.getUnencryptedDataKey()) - clone.setUnencryptedDataKey(udk, source.keyringTrace[0]) + if (source.hasUnencryptedDataKey) { + const udk = new Uint8Array(source.getUnencryptedDataKey()) + clone.setUnencryptedDataKey(udk, source.keyringTrace[0]) + } + if ((source).hasCryptoKey) { const cryptoKey = (source).getCryptoKey() ;(clone) - .setCryptoKey(cryptoKey, clone.keyringTrace[0]) + .setCryptoKey(cryptoKey, source.keyringTrace[0]) } if (isEncryptionMaterial(source) && isEncryptionMaterial(clone)) { diff --git a/modules/cache-material/src/index.ts b/modules/cache-material/src/index.ts index cc048d2a9..7cf622b61 100644 --- a/modules/cache-material/src/index.ts +++ b/modules/cache-material/src/index.ts @@ -17,3 +17,4 @@ export * from './cryptographic_materials_cache' export * from './caching_cryptographic_materials_decorators' export * from './build_cryptographic_materials_cache_key_helpers' export * from './clone_cryptographic_material' +export * from './get_local_cryptographic_materials_cache' diff --git a/modules/cache-material/test/clone_cryptographic_material.test.ts b/modules/cache-material/test/clone_cryptographic_material.test.ts index 91f94862c..49e89d737 100644 --- a/modules/cache-material/test/clone_cryptographic_material.test.ts +++ b/modules/cache-material/test/clone_cryptographic_material.test.ts @@ -87,13 +87,12 @@ describe('cloneMaterial', () => { }) it('clone WebCryptoDecryptionMaterial', () => { + /* WebCryptoDecryptionMaterial do not have an unencrypted data key. */ const material = new WebCryptoDecryptionMaterial(webCryptoSuite, { some: 'context' }) - .setUnencryptedDataKey(udk128, trace) .setCryptoKey(cryptoKey, trace) const test = cloneMaterial(material) expect(test).to.be.instanceOf(WebCryptoDecryptionMaterial) - expect(test.getUnencryptedDataKey()).to.deep.equal(udk128) expect(test.getCryptoKey()).to.deep.equal(cryptoKey) expect(test.keyringTrace).to.deep.equal(material.keyringTrace) expect(test.encryptionContext).to.deep.equal(material.encryptionContext) diff --git a/modules/caching-materials-manager-browser/src/index.ts b/modules/caching-materials-manager-browser/src/index.ts index 8839fe39c..5f561bfec 100644 --- a/modules/caching-materials-manager-browser/src/index.ts +++ b/modules/caching-materials-manager-browser/src/index.ts @@ -14,3 +14,4 @@ */ export * from './caching_materials_manager_browser' +export { getLocalCryptographicMaterialsCache } from '@aws-crypto/cache-material' diff --git a/modules/caching-materials-manager-node/src/index.ts b/modules/caching-materials-manager-node/src/index.ts index 40ad42123..9b90d05d7 100644 --- a/modules/caching-materials-manager-node/src/index.ts +++ b/modules/caching-materials-manager-node/src/index.ts @@ -14,3 +14,4 @@ */ export * from './caching_materials_manager_node' +export { getLocalCryptographicMaterialsCache } from '@aws-crypto/cache-material'