forked from aws/aws-encryption-sdk-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkms_keyring_node.ts
57 lines (53 loc) · 1.33 KB
/
kms_keyring_node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import {
KmsKeyringClass,
KeyRingConstructible,
KmsKeyringInput,
KMSConstructible,
KmsClientSupplier,
getClient,
limitRegions,
excludeRegions,
cacheClients,
} from '@aws-crypto/kms-keyring'
import {
NodeAlgorithmSuite,
immutableClass,
KeyringNode,
} from '@aws-crypto/material-management-node'
import { KMS } from 'aws-sdk'
import { version } from './version'
const getKmsClient = getClient(KMS, {
customUserAgent: `AwsEncryptionSdkJavascriptNodejs/${version}`,
})
const cacheKmsClients = cacheClients(getKmsClient)
export type KmsKeyringNodeInput = Partial<KmsKeyringInput<KMS>>
export type KMSNodeConstructible = KMSConstructible<
KMS,
KMS.ClientConfiguration
>
export type KmsNodeClientSupplier = KmsClientSupplier<KMS>
export class KmsKeyringNode extends KmsKeyringClass(
KeyringNode as KeyRingConstructible<NodeAlgorithmSuite>
) {
constructor({
clientProvider = cacheKmsClients,
keyIds,
generatorKeyId,
grantTokens,
discovery,
}: KmsKeyringNodeInput = {}) {
super({ clientProvider, keyIds, generatorKeyId, grantTokens, discovery })
}
}
immutableClass(KmsKeyringNode)
export {
getKmsClient,
cacheKmsClients,
getClient,
limitRegions,
excludeRegions,
cacheClients,
KMS,
}