File tree 2 files changed +12
-19
lines changed
modules/branch-keystore-node
2 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -165,17 +165,18 @@ export function validateBranchKeyRecord(item: BranchKeyItem): BranchKeyRecord {
165
165
`Branch keystore record does not contain ${ HIERARCHY_VERSION_FIELD } field of type number`
166
166
)
167
167
168
+
169
+ // This requirement is around the construction of the encryption context.
170
+ // It is possible that customers will have constructed their own branch keys
171
+ // with a custom creation method.
172
+ // In this case encryption context may not be prefixed.
173
+ // The Dafny version of this code does not enforce
174
+ // that additional encryption context keys MUST be prefixed,
175
+ // therefore the JS release does not as well.
176
+
168
177
//= aws-encryption-sdk-specification/framework/key-store/dynamodb-key-storage.md#record-format
169
178
//# A branch key record MAY include [custom encryption context](../branch-key-store.md#custom-encryption-context) key-value pairs.
170
179
//# These attributes should be prefixed with `aws-crypto-ec:` the same way they are for [AWS KMS encryption context](../branch-key-store.md#encryption-context).
171
- for ( const field in item ) {
172
- if ( ! POTENTIAL_BRANCH_KEY_RECORD_FIELDS . includes ( field ) ) {
173
- needs (
174
- field . startsWith ( CUSTOM_ENCRYPTION_CONTEXT_FIELD_PREFIX ) ,
175
- `Custom encryption context key ${ field } should be prefixed with ${ CUSTOM_ENCRYPTION_CONTEXT_FIELD_PREFIX } `
176
- )
177
- }
178
- }
179
180
180
181
// serialize the DDB response item as a more well-defined and validated branch
181
182
// key record object
Original file line number Diff line number Diff line change @@ -333,26 +333,18 @@ describe('Test keystore helpers', () => {
333
333
} )
334
334
} )
335
335
336
- it ( 'Active & versioned items have additional fields prefixed improperly ' , ( ) => {
336
+ it ( 'Active & versioned items may have additional fields that are not prefixed ' , ( ) => {
337
337
const activeItem = {
338
338
...ACTIVE_BRANCH_KEY ,
339
339
...INVALID_CUSTOM_ENCRYPTION_CONTEXT_KV_PAIRS ,
340
340
}
341
- expect ( ( ) => validateBranchKeyRecord ( activeItem ) ) . to . throw (
342
- `Custom encryption context key ${
343
- Object . keys ( INVALID_CUSTOM_ENCRYPTION_CONTEXT_KV_PAIRS ) [ 0 ]
344
- } should be prefixed with ${ CUSTOM_ENCRYPTION_CONTEXT_FIELD_PREFIX } `
345
- )
341
+ expect ( ( ) => validateBranchKeyRecord ( activeItem ) ) . to . not . throw ( )
346
342
347
343
const versionedItem = {
348
344
...VERSION_BRANCH_KEY ,
349
345
...INVALID_CUSTOM_ENCRYPTION_CONTEXT_KV_PAIRS ,
350
346
}
351
- expect ( ( ) => validateBranchKeyRecord ( versionedItem ) ) . to . throw (
352
- `Custom encryption context key ${
353
- Object . keys ( INVALID_CUSTOM_ENCRYPTION_CONTEXT_KV_PAIRS ) [ 0 ]
354
- } should be prefixed with ${ CUSTOM_ENCRYPTION_CONTEXT_FIELD_PREFIX } `
355
- )
347
+ expect ( ( ) => validateBranchKeyRecord ( versionedItem ) ) . to . not . throw ( )
356
348
} )
357
349
} )
358
350
You can’t perform that action at this time.
0 commit comments