@basmilius/apple-encryption 0.10.1 → 0.12.0

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,3 +1,28 @@
1
+ declare namespace aes_d_exports {
2
+ export { decrypt$1 as decrypt, encrypt$1 as encrypt };
3
+ }
4
+ /**
5
+ * Encrypts data using AES-128-CTR.
6
+ *
7
+ * Used as a fallback encryption mode for HAP pair-setup/pair-verify when the
8
+ * accessory does not support ChaCha20-Poly1305. AES-CTR has no authentication
9
+ * tag — integrity is ensured by the Ed25519 signature in the TLV payload.
10
+ *
11
+ * @param key - 16-byte AES key.
12
+ * @param iv - 16-byte initialization vector.
13
+ * @param plaintext - The data to encrypt.
14
+ * @returns The encrypted ciphertext.
15
+ */
16
+ declare function encrypt$1(key: Buffer, iv: Buffer, plaintext: Buffer): Buffer;
17
+ /**
18
+ * Decrypts data using AES-128-CTR.
19
+ *
20
+ * @param key - 16-byte AES key.
21
+ * @param iv - 16-byte initialization vector.
22
+ * @param ciphertext - The data to decrypt.
23
+ * @returns The decrypted plaintext.
24
+ */
25
+ declare function decrypt$1(key: Buffer, iv: Buffer, ciphertext: Buffer): Buffer;
1
26
  declare namespace chacha20_d_exports {
2
27
  export { CHACHA20_AUTH_TAG_LENGTH, CHACHA20_NONCE_LENGTH, DecryptionError, EncryptedData, decrypt, encrypt, padNonce };
3
28
  }
@@ -128,4 +153,4 @@ type HKDFOptions = {
128
153
  readonly info: Buffer;
129
154
  };
130
155
  //#endregion
131
- export { chacha20_d_exports as Chacha20, curve25519_d_exports as Curve25519, ed25519_d_exports as Ed25519, KeyPair, export_default as hkdf };
156
+ export { aes_d_exports as Aes, chacha20_d_exports as Chacha20, curve25519_d_exports as Curve25519, ed25519_d_exports as Ed25519, KeyPair, export_default as hkdf };
package/dist/index.mjs CHANGED
@@ -1,6 +1,41 @@
1
1
  import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
2
- import { hkdfSync } from "node:crypto";
2
+ import { createCipheriv, createDecipheriv, hkdfSync } from "node:crypto";
3
3
 
4
+ //#region src/aes.ts
5
+ var aes_exports = /* @__PURE__ */ __exportAll({
6
+ decrypt: () => decrypt$1,
7
+ encrypt: () => encrypt$1
8
+ });
9
+ /**
10
+ * Encrypts data using AES-128-CTR.
11
+ *
12
+ * Used as a fallback encryption mode for HAP pair-setup/pair-verify when the
13
+ * accessory does not support ChaCha20-Poly1305. AES-CTR has no authentication
14
+ * tag — integrity is ensured by the Ed25519 signature in the TLV payload.
15
+ *
16
+ * @param key - 16-byte AES key.
17
+ * @param iv - 16-byte initialization vector.
18
+ * @param plaintext - The data to encrypt.
19
+ * @returns The encrypted ciphertext.
20
+ */
21
+ function encrypt$1(key, iv, plaintext) {
22
+ const cipher = createCipheriv("aes-128-ctr", key, iv);
23
+ return Buffer.concat([cipher.update(plaintext), cipher.final()]);
24
+ }
25
+ /**
26
+ * Decrypts data using AES-128-CTR.
27
+ *
28
+ * @param key - 16-byte AES key.
29
+ * @param iv - 16-byte initialization vector.
30
+ * @param ciphertext - The data to decrypt.
31
+ * @returns The decrypted plaintext.
32
+ */
33
+ function decrypt$1(key, iv, ciphertext) {
34
+ const decipher = createDecipheriv("aes-128-ctr", key, iv);
35
+ return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
36
+ }
37
+
38
+ //#endregion
4
39
  //#region ../../node_modules/.bun/@stablelib+int@2.0.1/node_modules/@stablelib/int/lib/int.js
5
40
  /**
6
41
  * Returns true if the argument is an integer number.
@@ -3058,4 +3093,4 @@ function hkdf_default(options) {
3058
3093
  }
3059
3094
 
3060
3095
  //#endregion
3061
- export { chacha20_exports as Chacha20, curve25519_exports as Curve25519, ed25519_exports as Ed25519, hkdf_default as hkdf };
3096
+ export { aes_exports as Aes, chacha20_exports as Chacha20, curve25519_exports as Curve25519, ed25519_exports as Ed25519, hkdf_default as hkdf };
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.10.1",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -48,6 +48,6 @@
48
48
  "@stablelib/x25519": "^2.0.1",
49
49
  "@types/bun": "^1.3.11",
50
50
  "@types/node": "^25.5.0",
51
- "tsdown": "^0.21.4"
51
+ "tsdown": "^0.21.6"
52
52
  }
53
53
  }