@bedrock/record-cipher 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/RecordCipher.js +9 -7
- package/package.json +1 -1
package/lib/RecordCipher.js
CHANGED
|
@@ -169,14 +169,16 @@ export class RecordCipher {
|
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
171
|
* Creates a `RecordCipher` instance for encrypting and/or decrypting
|
|
172
|
-
* record `secrets
|
|
173
|
-
*
|
|
174
|
-
* can alternatively be set to
|
|
175
|
-
* modules that previously encoded
|
|
172
|
+
* record `secrets` (usually secret "keys" of some sort). The default
|
|
173
|
+
* encoding mode for the `secrets` is `cbor`, which supports any binary
|
|
174
|
+
* subfields present in `secrets`. The encoding can alternatively be set to
|
|
175
|
+
* `json` for backwards compatiblity with modules that previously encoded
|
|
176
|
+
* using JSON, not CBOR.
|
|
176
177
|
*
|
|
177
178
|
* @param {object} options - The options to use.
|
|
178
|
-
* @param {string} [options.currentKekId] - The ID of the KEK
|
|
179
|
-
*
|
|
179
|
+
* @param {string} [options.currentKekId] - The ID of the KEK (Key Encryption
|
|
180
|
+
* Key, i.e., a key used to encrypt secrets, usually other "keys") to use
|
|
181
|
+
* for new encryptions; may be set to `null` to disable encryption; if not
|
|
180
182
|
* set, it will be automatically set to the first KEK ID in the `keks`
|
|
181
183
|
* array if it is not empty (otherwise it will be set to `null`).
|
|
182
184
|
* @param {Array} [options.keks=[]] - An array of objects, each with an `id`
|
|
@@ -193,7 +195,7 @@ export class RecordCipher {
|
|
|
193
195
|
*/
|
|
194
196
|
static async create({currentKekId, keks = [], encoding = 'cbor'} = {}) {
|
|
195
197
|
if(!(currentKekId === undefined || currentKekId === null ||
|
|
196
|
-
typeof currentKekId
|
|
198
|
+
typeof currentKekId === 'string')) {
|
|
197
199
|
throw new TypeError('"currentKekId" must be a string or null.');
|
|
198
200
|
}
|
|
199
201
|
if(!Array.isArray(keks)) {
|