@@ -64,23 +64,23 @@ export function decorateProperties<S extends SupportedAlgorithmSuites> (
64
64
}
65
65
66
66
export function getEncryptionMaterials < S extends SupportedAlgorithmSuites > (
67
- { buildEncryptionResponseCacheKey } : CryptographicMaterialsCacheKeyHelpersInterface < S >
67
+ { buildEncryptionMaterialCacheKey } : CryptographicMaterialsCacheKeyHelpersInterface < S >
68
68
) : GetEncryptionMaterials < S > {
69
69
return async function getEncryptionMaterials (
70
70
this : CachingMaterialsManager < S > ,
71
71
request : EncryptionRequest < S >
72
72
) : Promise < EncryptionMaterial < S > > {
73
73
const { suite, encryptionContext, frameLength, plaintextLength } = request
74
- /* Check for early return (Postcondition): If I can not cache the EncryptionResponse , do not even look. */
74
+ /* Check for early return (Postcondition): If I can not cache the EncryptionMaterial , do not even look. */
75
75
if ( ( suite && ! suite . cacheSafe ) || typeof plaintextLength !== 'number' || plaintextLength < 0 ) {
76
76
return this
77
77
. _backingMaterialsManager
78
78
. getEncryptionMaterials ( request )
79
79
}
80
80
81
- const cacheKey = await buildEncryptionResponseCacheKey ( this . _partition , { suite, encryptionContext } )
82
- const entry = this . _cache . getEncryptionResponse ( cacheKey , plaintextLength )
83
- /* Check for early return (Postcondition): If I have a valid EncryptionResponse , return it. */
81
+ const cacheKey = await buildEncryptionMaterialCacheKey ( this . _partition , { suite, encryptionContext } )
82
+ const entry = this . _cache . getEncryptionMaterial ( cacheKey , plaintextLength )
83
+ /* Check for early return (Postcondition): If I have a valid EncryptionMaterial , return it. */
84
84
if ( entry && ! this . _cacheEntryHasExceededLimits ( entry ) ) {
85
85
return cloneResponse ( entry . response )
86
86
} else {
@@ -94,7 +94,7 @@ export function getEncryptionMaterials<S extends SupportedAlgorithmSuites> (
94
94
*/
95
95
. getEncryptionMaterials ( { suite, encryptionContext, frameLength } )
96
96
97
- /* Check for early return (Postcondition): If I can not cache the EncryptionResponse , just return it. */
97
+ /* Check for early return (Postcondition): If I can not cache the EncryptionMaterial , just return it. */
98
98
if ( ! material . suite . cacheSafe ) return material
99
99
100
100
/* It is possible for an entry to exceed limits immediately.
@@ -109,31 +109,31 @@ export function getEncryptionMaterials<S extends SupportedAlgorithmSuites> (
109
109
bytesEncrypted : plaintextLength
110
110
}
111
111
if ( ! this . _cacheEntryHasExceededLimits ( testEntry ) ) {
112
- this . _cache . putEncryptionResponse ( cacheKey , material , plaintextLength , this . _maxAge )
112
+ this . _cache . putEncryptionMaterial ( cacheKey , material , plaintextLength , this . _maxAge )
113
113
}
114
114
115
115
return cloneResponse ( material )
116
116
}
117
117
}
118
118
119
119
export function decryptMaterials < S extends SupportedAlgorithmSuites > (
120
- { buildDecryptionResponseCacheKey } : CryptographicMaterialsCacheKeyHelpersInterface < S >
120
+ { buildDecryptionMaterialCacheKey } : CryptographicMaterialsCacheKeyHelpersInterface < S >
121
121
) : GetDecryptMaterials < S > {
122
122
return async function decryptMaterials (
123
123
this : CachingMaterialsManager < S > ,
124
124
request : DecryptionRequest < S >
125
125
) : Promise < DecryptionMaterial < S > > {
126
126
const { suite } = request
127
- /* Check for early return (Postcondition): If I can not cache the DecryptionResponse , do not even look. */
127
+ /* Check for early return (Postcondition): If I can not cache the DecryptionMaterial , do not even look. */
128
128
if ( ! suite . cacheSafe ) {
129
129
return this
130
130
. _backingMaterialsManager
131
131
. decryptMaterials ( request )
132
132
}
133
133
134
- const cacheKey = await buildDecryptionResponseCacheKey ( this . _partition , request )
135
- const entry = this . _cache . getDecryptionResponse ( cacheKey )
136
- /* Check for early return (Postcondition): If I have a valid DecryptionResponse , return it. */
134
+ const cacheKey = await buildDecryptionMaterialCacheKey ( this . _partition , request )
135
+ const entry = this . _cache . getDecryptionMaterial ( cacheKey )
136
+ /* Check for early return (Postcondition): If I have a valid DecryptionMaterial , return it. */
137
137
if ( entry && ! this . _cacheEntryHasExceededLimits ( entry ) ) {
138
138
return cloneResponse ( entry . response )
139
139
} else {
@@ -144,7 +144,7 @@ export function decryptMaterials<S extends SupportedAlgorithmSuites> (
144
144
. _backingMaterialsManager
145
145
. decryptMaterials ( request )
146
146
147
- this . _cache . putDecryptionResponse ( cacheKey , material , this . _maxAge )
147
+ this . _cache . putDecryptionMaterial ( cacheKey , material , this . _maxAge )
148
148
return cloneResponse ( material )
149
149
}
150
150
}
@@ -166,8 +166,8 @@ export function cacheEntryHasExceededLimits<S extends SupportedAlgorithmSuites>
166
166
* Because when the Encryption SDK is done with material, it will zero it out.
167
167
* Plucking off the material and cloning just that and then returning the rest of the response
168
168
* can just be handled in one place.
169
- * @param material EncryptionResponse|DecryptionResponse
170
- * @return EncryptionResponse|DecryptionResponse
169
+ * @param material EncryptionMaterial|DecryptionMaterial
170
+ * @return EncryptionMaterial|DecryptionMaterial
171
171
*/
172
172
function cloneResponse < S extends SupportedAlgorithmSuites , M extends EncryptionMaterial < S > | DecryptionMaterial < S > > (
173
173
material : M
0 commit comments