@substrate-system/keys 0.2.13 → 0.2.14

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.
@@ -4202,7 +4202,14 @@
4202
4202
  __name(importAesKey, "importAesKey");
4203
4203
  async function encrypt(data, cryptoKey, format2, iv) {
4204
4204
  const key = isCryptoKey(cryptoKey) ? cryptoKey : await importAesKey(cryptoKey);
4205
- const encrypted = iv ? await webcrypto.subtle.encrypt({ name: AES_GCM, iv: toArrayBuffer2(iv) }, key, toArrayBuffer2(data)) : await encryptBytes(data, key);
4205
+ const encrypted = iv ? await webcrypto.subtle.encrypt(
4206
+ {
4207
+ name: AES_GCM,
4208
+ iv: toArrayBuffer2(iv)
4209
+ },
4210
+ key,
4211
+ toArrayBuffer2(data)
4212
+ ) : await encryptBytes(data, key);
4206
4213
  if (format2 && format2 === "arraybuffer") return encrypted;
4207
4214
  return new Uint8Array(encrypted);
4208
4215
  }
@@ -4932,6 +4939,8 @@
4932
4939
  * @param {CryptoKey|string} [publicKey] The public key used to generate
4933
4940
  * the AES key used on this message. If omitted, decrypt with our own
4934
4941
  * public key.
4942
+ * @param {string} aesAlgorithm The algorithm. Default is AES-GCM.
4943
+ * @param {string} info Custom "info" parameter
4935
4944
  * @returns {Promise<ArrayBuffer>} The decrypted content.
4936
4945
  */
4937
4946
  async decrypt(msg, publicKey, aesAlgorithm, info) {
@@ -4960,6 +4969,15 @@
4960
4969
  }
4961
4970
  /**
4962
4971
  * Decrypt and return as string.
4972
+ * The encrypted message should be salt + iv + cipher text.
4973
+ *
4974
+ * @param msg The encrypted content
4975
+ * @param {CryptoKey|string} [publicKey] The public key used to generate
4976
+ * the AES key used on this message. If omitted, decrypt with our own
4977
+ * public key.
4978
+ * @param {string} aesAlgorithm The algorithm. Default is AES-GCM.
4979
+ * @param {string} info Custom "info" parameter
4980
+ * @returns {Promise<ArrayBuffer>} The decrypted content.
4963
4981
  */
4964
4982
  async decryptAsString(msg, publicKey, aesAlgorithm, info) {
4965
4983
  const dec = await this.decrypt(msg, publicKey, aesAlgorithm, info);