@@ -18,11 +18,7 @@ import {
18
18
importForWebCryptoDecryptionMaterial ,
19
19
AwsEsdkJsCryptoKey ,
20
20
} from '@aws-crypto/material-management-browser'
21
- import {
22
- serializeFactory ,
23
- concatBuffers ,
24
- SerializeOptions ,
25
- } from '@aws-crypto/serialize'
21
+ import { serializeFactory , concatBuffers } from '@aws-crypto/serialize'
26
22
import {
27
23
_onEncrypt ,
28
24
_onDecrypt ,
@@ -56,14 +52,15 @@ export type RawAesKeyringWebCryptoInput = {
56
52
keyName : string
57
53
masterKey : AwsEsdkJsCryptoKey
58
54
wrappingSuite : WrappingSuiteIdentifier
59
- utf8Sorting ?: boolean | true
55
+ utf8Sorting ?: boolean
60
56
}
61
57
62
58
export class RawAesKeyringWebCrypto extends KeyringWebCrypto {
63
59
public declare keyNamespace : string
64
60
public declare keyName : string
65
61
declare _wrapKey : WrapKey < WebCryptoAlgorithmSuite >
66
62
declare _unwrapKey : UnwrapKey < WebCryptoAlgorithmSuite >
63
+ public declare _utf8Sorting : boolean
67
64
68
65
constructor ( input : RawAesKeyringWebCryptoInput ) {
69
66
super ( )
@@ -83,12 +80,15 @@ export class RawAesKeyringWebCrypto extends KeyringWebCrypto {
83
80
flags : KeyringTraceFlag . WRAPPING_KEY_GENERATED_DATA_KEY ,
84
81
} )
85
82
86
- const maybeUtf8Sorting = utf8Sorting ?? true
87
- const serializeOptions : SerializeOptions = { utf8Sorting : maybeUtf8Sorting }
88
- const { serializeEncryptionContext } = serializeFactory (
89
- fromUtf8 ,
90
- serializeOptions
91
- )
83
+ if ( utf8Sorting === undefined ) {
84
+ readOnlyProperty ( this , '_utf8Sorting' , false )
85
+ } else {
86
+ readOnlyProperty ( this , '_utf8Sorting' , utf8Sorting )
87
+ }
88
+ // default will be false
89
+ const { serializeEncryptionContext } = serializeFactory ( fromUtf8 , {
90
+ utf8Sorting : this . _utf8Sorting ,
91
+ } )
92
92
const _wrapKey = async ( material : WebCryptoEncryptionMaterial ) => {
93
93
/* The AAD section is uInt16BE(length) + AAD
94
94
* see: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html#header-aad
0 commit comments