Skip to content

Commit 0ebe6dc

Browse files
nvobilisseebees
authored andcommitted
add plain interface (#595)
1 parent 1bc538e commit 0ebe6dc

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { EncryptionContext } from '@aws-crypto/material-management'
5+
6+
//= aws-encryption-sdk-specification/framework/aws-kms/aws-kms-hierarchical-keyring.md#branch-key-supplier
7+
//# The Branch Key Supplier is an interface containing the GetBranchKeyId
8+
//# operation. This operation MUST take in an encryption context as input, and
9+
//# return a branch key id (string) as output.
10+
export interface BranchKeyIdSupplier {
11+
getBranchKeyId(encryptionContext: EncryptionContext): string
12+
}

modules/kms-keyring/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export * from './region_from_kms_key_arn'
1616
export * from './kms_mrk_strict_multi_keyring'
1717
export * from './kms_mrk_discovery_multi_keyring'
1818
export { AwsEsdkKMSInterface } from './kms_types'
19+
export * from './branch_key_id_supplier'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { EncryptionContext } from '@aws-crypto/material-management'
5+
import { BranchKeyIdSupplier } from '../src'
6+
import { expect } from 'chai'
7+
8+
describe('Branch key id supplier', () => {
9+
//= aws-encryption-sdk-specification/framework/aws-kms/aws-kms-hierarchical-keyring.md#branch-key-supplier
10+
//= type=test
11+
//# The Branch Key Supplier is an interface containing the GetBranchKeyId
12+
//# operation. This operation MUST take in an encryption context as input, and
13+
//# return a branch key id (string) as output.
14+
it('Can implement the interface', () => {
15+
class Example implements BranchKeyIdSupplier {
16+
getBranchKeyId(encryptionContext: EncryptionContext): string {
17+
return '' in encryptionContext ? '' : ''
18+
}
19+
}
20+
21+
expect(new Example().getBranchKeyId({})).to.equal('')
22+
})
23+
})

0 commit comments

Comments
 (0)