@basmilius/apple-encryption 0.9.14 → 0.9.16

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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -10
  2. package/package.json +4 -3
package/dist/index.mjs CHANGED
@@ -335,7 +335,7 @@ const DIGEST_LENGTH = 16;
335
335
  * it should never repeat.
336
336
  */
337
337
  var Poly1305 = class {
338
- digestLength = DIGEST_LENGTH;
338
+ digestLength = 16;
339
339
  _buffer = new Uint8Array(16);
340
340
  _r = new Uint16Array(10);
341
341
  _h = new Uint16Array(10);
@@ -704,14 +704,14 @@ const ZEROS = new Uint8Array(16);
704
704
  * Defined in RFC7539.
705
705
  */
706
706
  var ChaCha20Poly1305 = class {
707
- nonceLength = NONCE_LENGTH;
708
- tagLength = TAG_LENGTH;
707
+ nonceLength = 12;
708
+ tagLength = 16;
709
709
  _key;
710
710
  /**
711
711
  * Creates a new instance with the given 32-byte key.
712
712
  */
713
713
  constructor(key) {
714
- if (key.length !== KEY_LENGTH) throw new Error("ChaCha20Poly1305 needs 32-byte key");
714
+ if (key.length !== 32) throw new Error("ChaCha20Poly1305 needs 32-byte key");
715
715
  this._key = new Uint8Array(key);
716
716
  }
717
717
  /**
@@ -804,8 +804,8 @@ var ChaCha20Poly1305 = class {
804
804
  //#endregion
805
805
  //#region src/chacha20.ts
806
806
  var chacha20_exports = /* @__PURE__ */ __exportAll({
807
- CHACHA20_AUTH_TAG_LENGTH: () => CHACHA20_AUTH_TAG_LENGTH,
808
- CHACHA20_NONCE_LENGTH: () => CHACHA20_NONCE_LENGTH,
807
+ CHACHA20_AUTH_TAG_LENGTH: () => 16,
808
+ CHACHA20_NONCE_LENGTH: () => 12,
809
809
  decrypt: () => decrypt,
810
810
  encrypt: () => encrypt,
811
811
  padNonce: () => padNonce
@@ -824,13 +824,13 @@ function encrypt(key, nonce, aad, plaintext) {
824
824
  nonce = padNonce(nonce);
825
825
  const sealed = new ChaCha20Poly1305(key).seal(nonce, plaintext, aad ?? void 0);
826
826
  return {
827
- ciphertext: Buffer.from(sealed.subarray(0, sealed.length - CHACHA20_AUTH_TAG_LENGTH)),
828
- authTag: Buffer.from(sealed.subarray(sealed.length - CHACHA20_AUTH_TAG_LENGTH))
827
+ ciphertext: Buffer.from(sealed.subarray(0, sealed.length - 16)),
828
+ authTag: Buffer.from(sealed.subarray(sealed.length - 16))
829
829
  };
830
830
  }
831
831
  function padNonce(nonce) {
832
- if (nonce.length >= CHACHA20_NONCE_LENGTH) return nonce;
833
- return Buffer.concat([Buffer.alloc(CHACHA20_NONCE_LENGTH - nonce.length, 0), nonce]);
832
+ if (nonce.length >= 12) return nonce;
833
+ return Buffer.concat([Buffer.alloc(12 - nonce.length, 0), nonce]);
834
834
  }
835
835
 
836
836
  //#endregion
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.14",
4
+ "version": "0.9.16",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -44,8 +44,9 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@stablelib/chacha20poly1305": "^2.0.1",
47
- "@types/bun": "^1.3.9",
48
- "tsdown": "^0.21.0-beta.2",
47
+ "@types/bun": "^1.3.11",
48
+ "@types/node": "^25.5.0",
49
+ "tsdown": "^0.21.4",
49
50
  "tweetnacl": "^1.0.3"
50
51
  }
51
52
  }