Skip to content

Commit 7f2c75c

Browse files
committed
kms-keyring-browser
1 parent e838024 commit 7f2c75c

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import {
3030
EncryptionContext, // eslint-disable-line no-unused-vars
3131
EncryptedDataKey, // eslint-disable-line no-unused-vars
3232
immutableClass,
33-
importCryptoKey
33+
importCryptoKey,
34+
WebCryptoKeyring
3435
} from '@aws-crypto/material-management-browser'
3536
import { getWebCryptoBackend } from '@aws-crypto/web-crypto-backend'
3637
import { KMS, KMSConfiguration } from '@aws-sdk/client-kms-browser' // eslint-disable-line no-unused-vars
@@ -48,7 +49,7 @@ export class KmsKeyringNode extends KmsKeyring<WebCryptoAlgorithmSuite, KMS> {
4849
kmsKeys,
4950
generatorKmsKey,
5051
grantTokens
51-
}: KmsKeyringWebCryptoInput) {
52+
}: KmsKeyringWebCryptoInput = {}) {
5253
super({ clientProvider, kmsKeys, generatorKmsKey, grantTokens })
5354
}
5455

@@ -87,6 +88,11 @@ export class KmsKeyringNode extends KmsKeyring<WebCryptoAlgorithmSuite, KMS> {
8788

8889
return _material.setCryptoKey(cryptoKey, trace)
8990
}
91+
92+
[Symbol.hasInstance] (obj: any) {
93+
return obj instanceof WebCryptoKeyring ||
94+
Function.prototype[Symbol.hasInstance].call(this, obj)
95+
}
9096
}
9197
immutableClass(KmsKeyringNode)
9298

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is
6+
* located at
7+
*
8+
* http://aws.amazon.com/apache2.0/
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
* implied. See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
/* eslint-env mocha */
17+
18+
import { expect } from 'chai'
19+
import 'mocha'
20+
import { KmsKeyringNode } from '../src/kms_keyring_browser'
21+
import { WebCryptoKeyring} from '@aws-crypto/material-management-browser'
22+
23+
describe('KmsKeyringNode', () => {
24+
it('instance of WebCryptoKeyring', () => {
25+
const test = new KmsKeyringNode()
26+
expect(test instanceof WebCryptoKeyring).to.equal(true)
27+
})
28+
})

0 commit comments

Comments
 (0)