Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e668fe4

Browse files
committedMar 27, 2019
kms-keyring
1 parent 28751d2 commit e668fe4

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed
 

‎modules/kms-keyring/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function encrypt<Client extends KMS> (
4949
KeyId: string,
5050
EncryptionContext?: EncryptionContext,
5151
GrantTokens?: string
52-
) {
52+
): Promise<Required<EncryptOutput>|false> {
5353
const region = regionFromKmsKeyArn(KeyId)
5454
const client = clientProvider(region)
5555

‎modules/kms-keyring/src/kms_keyring.ts

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

1616
import { KmsClientSupplier } from './kms_client_supplier' // eslint-disable-line no-unused-vars
17-
import { needs, Keyring, EncryptionMaterial, DecryptionMaterial, SupportedAlgorithmSuites, EncryptionContext, KeyringTrace, KeyringTraceFlag, EncryptedDataKey, immutableClass } from '@aws-crypto/material-management' // eslint-disable-line no-unused-vars
17+
import {
18+
needs,
19+
Keyring,
20+
EncryptionMaterial, // eslint-disable-line no-unused-vars
21+
DecryptionMaterial, // eslint-disable-line no-unused-vars
22+
SupportedAlgorithmSuites, // eslint-disable-line no-unused-vars
23+
EncryptionContext, // eslint-disable-line no-unused-vars
24+
KeyringTrace, // eslint-disable-line no-unused-vars
25+
KeyringTraceFlag,
26+
EncryptedDataKey, // eslint-disable-line no-unused-vars
27+
immutableClass,
28+
readOnlyProperty
29+
} from '@aws-crypto/material-management'
1830
import { KMS_PROVIDER_ID, generateDataKey, encrypt, decrypt, kms2EncryptedDataKey } from './helpers'
1931
import { KMS } from './kms_types/KMS' // eslint-disable-line no-unused-vars
2032
import { DecryptOutput } from './kms_types/DecryptOutput' // eslint-disable-line no-unused-vars
@@ -28,9 +40,9 @@ export interface KmsKeyringInput<Client extends KMS> {
2840
}
2941

3042
export abstract class KmsKeyring<S extends SupportedAlgorithmSuites, Client extends KMS> extends Keyring<S> {
31-
public kmsKeys: string[] = []
43+
public kmsKeys!: string[]
3244
public generatorKmsKey?: string
33-
public clientProvider: KmsClientSupplier<Client>
45+
public clientProvider!: KmsClientSupplier<Client>
3446
public grantTokens?: string
3547

3648
constructor ({ clientProvider, generatorKmsKey, kmsKeys = [], grantTokens }: KmsKeyringInput<Client>) {
@@ -41,10 +53,10 @@ export abstract class KmsKeyring<S extends SupportedAlgorithmSuites, Client exte
4153
/* Precondition: clientProvider needs to be a callable function. */
4254
needs(typeof clientProvider === 'function', '')
4355

44-
this.clientProvider = clientProvider
45-
this.kmsKeys = kmsKeys
46-
this.generatorKmsKey = generatorKmsKey
47-
this.grantTokens = grantTokens
56+
readOnlyProperty(this, 'clientProvider', clientProvider)
57+
readOnlyProperty(this, 'kmsKeys', kmsKeys)
58+
readOnlyProperty(this, 'generatorKmsKey', generatorKmsKey)
59+
readOnlyProperty(this, 'grantTokens', grantTokens)
4860
}
4961

5062
/* Keyrings *must* preserve the order of EDK's. The generatorKmsKey is the first on this list. */

‎modules/kms-keyring/src/region_from_kms_key_arn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import { needs } from '@aws-crypto/material-management'
1717

18-
export function regionFromKmsKeyArn (kmsKeyArn: string) {
18+
export function regionFromKmsKeyArn (kmsKeyArn: string): string {
1919
/* Precondition: A KMS key arn must be a string. */
2020
needs(typeof kmsKeyArn === 'string', 'KMS key arn must be a string.')
2121

0 commit comments

Comments
 (0)
Please sign in to comment.