@basmilius/apple-encryption 0.9.17 → 0.9.19

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/dist/index.d.mts CHANGED
@@ -1,5 +1,8 @@
1
1
  declare namespace chacha20_d_exports {
2
- export { CHACHA20_AUTH_TAG_LENGTH, CHACHA20_NONCE_LENGTH, EncryptedData, decrypt, encrypt, padNonce };
2
+ export { CHACHA20_AUTH_TAG_LENGTH, CHACHA20_NONCE_LENGTH, DecryptionError, EncryptedData, decrypt, encrypt, padNonce };
3
+ }
4
+ declare class DecryptionError extends Error {
5
+ constructor(message?: string);
3
6
  }
4
7
  declare const CHACHA20_AUTH_TAG_LENGTH = 16;
5
8
  declare const CHACHA20_NONCE_LENGTH = 12;
package/dist/index.mjs CHANGED
@@ -828,10 +828,17 @@ var ChaCha20Poly1305 = class {
828
828
  var chacha20_exports = /* @__PURE__ */ __exportAll({
829
829
  CHACHA20_AUTH_TAG_LENGTH: () => 16,
830
830
  CHACHA20_NONCE_LENGTH: () => 12,
831
+ DecryptionError: () => DecryptionError,
831
832
  decrypt: () => decrypt,
832
833
  encrypt: () => encrypt,
833
834
  padNonce: () => padNonce
834
835
  });
836
+ var DecryptionError = class extends Error {
837
+ constructor(message = "Decryption failed: authentication tag mismatch") {
838
+ super(message);
839
+ this.name = "DecryptionError";
840
+ }
841
+ };
835
842
  const CHACHA20_AUTH_TAG_LENGTH = 16;
836
843
  const CHACHA20_NONCE_LENGTH = 12;
837
844
  function decrypt(key, nonce, aad, ciphertext, authTag) {
@@ -839,7 +846,7 @@ function decrypt(key, nonce, aad, ciphertext, authTag) {
839
846
  const chacha = new ChaCha20Poly1305(key);
840
847
  const sealed = Buffer.concat([ciphertext, authTag]);
841
848
  const plaintext = chacha.open(nonce, sealed, aad ?? void 0);
842
- if (!plaintext) throw new Error("Decryption failed: authentication tag mismatch");
849
+ if (!plaintext) throw new DecryptionError();
843
850
  return Buffer.from(plaintext);
844
851
  }
845
852
  function encrypt(key, nonce, aad, plaintext) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-encryption",
3
3
  "description": "Common encryption utilities for Apple Protocols.",
4
- "version": "0.9.17",
4
+ "version": "0.9.19",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {