forked from aws/aws-encryption-sdk-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkms_keyring_node.ts
56 lines (52 loc) · 1.41 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
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import {
KmsKeyringClass,
KmsKeyringInput,
KMSConstructible,
KmsClientSupplier,
getClient,
limitRegions,
excludeRegions,
cacheClients,
AwsEsdkKMSInterface,
} from '@aws-crypto/kms-keyring'
import {
immutableClass,
KeyringNode,
Newable,
NodeAlgorithmSuite,
} from '@aws-crypto/material-management-node'
import { KMS, KMSClientConfig } from '@aws-sdk/client-kms'
import { version } from './version'
const getKmsClient = getClient(KMS, {
customUserAgent: `AwsEncryptionSdkJavascriptNodejs/${version}`,
})
const cacheKmsClients = cacheClients(getKmsClient)
export type KmsKeyringNodeInput = Partial<KmsKeyringInput<AwsEsdkKMSInterface>>
export type KMSNodeConstructible = KMSConstructible<KMS, KMSClientConfig>
export type KmsNodeClientSupplier = KmsClientSupplier<AwsEsdkKMSInterface>
export class KmsKeyringNode extends KmsKeyringClass<
NodeAlgorithmSuite,
AwsEsdkKMSInterface
>(KeyringNode as Newable<KeyringNode>) {
constructor({
clientProvider = cacheKmsClients,
keyIds,
generatorKeyId,
grantTokens,
discovery,
}: KmsKeyringNodeInput = {}) {
super({ clientProvider, keyIds, generatorKeyId, grantTokens, discovery })
}
}
immutableClass(KmsKeyringNode)
export {
getKmsClient,
cacheKmsClients,
getClient,
limitRegions,
excludeRegions,
cacheClients,
KMS,
}