Skip to content

Commit 66ed55b

Browse files
committed
kms-keyring-browser
1 parent 11771a5 commit 66ed55b

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

modules/kms-keyring-browser/src/kms_keyring_browser.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
*/
1515

1616
import {
17-
KmsKeyring,
17+
KmsKeyringClass,
18+
KeyRingConstructible, // eslint-disable-line no-unused-vars
1819
KmsKeyringInput, // eslint-disable-line no-unused-vars
1920
KMSConstructible, // eslint-disable-line no-unused-vars
2021
KmsClientSupplier, // eslint-disable-line no-unused-vars
@@ -31,7 +32,7 @@ import {
3132
EncryptedDataKey, // eslint-disable-line no-unused-vars
3233
immutableClass,
3334
importCryptoKey,
34-
WebCryptoKeyring
35+
KeyringWebCrypto // eslint-disable-line no-unused-vars
3536
} from '@aws-crypto/material-management-browser'
3637
import { getWebCryptoBackend } from '@aws-crypto/web-crypto-backend'
3738
import { KMS, KMSConfiguration } from '@aws-sdk/client-kms-browser' // eslint-disable-line no-unused-vars
@@ -43,14 +44,14 @@ export type KmsKeyringWebCryptoInput = Partial<KmsKeyringInput<KMS>>
4344
export type KMSWebCryptoConstructible = KMSConstructible<KMS, KMSConfiguration>
4445
export type KmsWebCryptoClientSupplier = KmsClientSupplier<KMS>
4546

46-
export class KmsKeyringNode extends KmsKeyring<WebCryptoAlgorithmSuite, KMS> {
47+
export class KmsKeyringBrowser extends KmsKeyringClass(KeyringWebCrypto as KeyRingConstructible<WebCryptoAlgorithmSuite>) {
4748
constructor ({
4849
clientProvider = cacheKmsClients,
49-
kmsKeys,
50-
generatorKmsKey,
50+
keyIds,
51+
generatorKeyId,
5152
grantTokens
5253
}: KmsKeyringWebCryptoInput = {}) {
53-
super({ clientProvider, kmsKeys, generatorKmsKey, grantTokens })
54+
super({ clientProvider, keyIds, generatorKeyId, grantTokens })
5455
}
5556

5657
async _onEncrypt (material: WebCryptoEncryptionMaterial, context?: EncryptionContext) {
@@ -88,12 +89,7 @@ export class KmsKeyringNode extends KmsKeyring<WebCryptoAlgorithmSuite, KMS> {
8889

8990
return _material.setCryptoKey(cryptoKey, trace)
9091
}
91-
92-
[Symbol.hasInstance] (obj: any) {
93-
return obj instanceof WebCryptoKeyring ||
94-
Function.prototype[Symbol.hasInstance].call(this, obj)
95-
}
9692
}
97-
immutableClass(KmsKeyringNode)
93+
immutableClass(KmsKeyringBrowser)
9894

9995
export { getClient, cacheKmsClients, limitRegions, excludeRegions, cacheClients }

modules/kms-keyring-browser/test/kms_keyring_browser.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
import { expect } from 'chai'
1919
import 'mocha'
20-
import { KmsKeyringNode } from '../src/kms_keyring_browser'
21-
import { WebCryptoKeyring } from '@aws-crypto/material-management-browser'
20+
import { KmsKeyringBrowser } from '../src/kms_keyring_browser'
21+
import { KeyringWebCrypto } from '@aws-crypto/material-management-browser'
2222

2323
describe('KmsKeyringNode', () => {
24-
it('instance of WebCryptoKeyring', () => {
25-
const test = new KmsKeyringNode()
26-
expect(test instanceof WebCryptoKeyring).to.equal(true)
24+
it('instance of KeyringWebCrypto', () => {
25+
const test = new KmsKeyringBrowser()
26+
expect(test instanceof KeyringWebCrypto).to.equal(true)
2727
})
2828
})

0 commit comments

Comments
 (0)