@lindorm/aes 0.6.5 → 0.7.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.
Files changed (264) hide show
  1. package/README.md +126 -231
  2. package/dist/classes/AesKit.d.ts +4 -4
  3. package/dist/classes/AesKit.d.ts.map +1 -1
  4. package/dist/classes/AesKit.js +29 -33
  5. package/dist/classes/AesKit.js.map +1 -1
  6. package/dist/classes/index.d.ts +1 -1
  7. package/dist/classes/index.d.ts.map +1 -1
  8. package/dist/classes/index.js +1 -17
  9. package/dist/classes/index.js.map +1 -1
  10. package/dist/errors/AesError.js +2 -6
  11. package/dist/errors/AesError.js.map +1 -1
  12. package/dist/errors/index.d.ts +1 -1
  13. package/dist/errors/index.d.ts.map +1 -1
  14. package/dist/errors/index.js +1 -17
  15. package/dist/errors/index.js.map +1 -1
  16. package/dist/index.d.ts +5 -6
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -22
  19. package/dist/index.js.map +1 -1
  20. package/dist/interfaces/AesKit.d.ts +3 -3
  21. package/dist/interfaces/AesKit.d.ts.map +1 -1
  22. package/dist/interfaces/AesKit.js +1 -2
  23. package/dist/interfaces/index.d.ts +1 -1
  24. package/dist/interfaces/index.d.ts.map +1 -1
  25. package/dist/interfaces/index.js +1 -17
  26. package/dist/interfaces/index.js.map +1 -1
  27. package/dist/internal/constants/version.js +3 -6
  28. package/dist/internal/constants/version.js.map +1 -1
  29. package/dist/internal/types/aes-data.d.ts +4 -4
  30. package/dist/internal/types/aes-data.d.ts.map +1 -1
  31. package/dist/internal/types/aes-data.js +1 -2
  32. package/dist/internal/types/aes-key-derivation.js +1 -2
  33. package/dist/internal/types/auth-tag.d.ts +2 -2
  34. package/dist/internal/types/auth-tag.d.ts.map +1 -1
  35. package/dist/internal/types/auth-tag.js +1 -2
  36. package/dist/internal/types/auth-tag.js.map +1 -1
  37. package/dist/internal/types/content-encryption-key.d.ts +2 -2
  38. package/dist/internal/types/content-encryption-key.d.ts.map +1 -1
  39. package/dist/internal/types/content-encryption-key.js +1 -2
  40. package/dist/internal/types/key-wrap.d.ts +1 -1
  41. package/dist/internal/types/key-wrap.d.ts.map +1 -1
  42. package/dist/internal/types/key-wrap.js +1 -2
  43. package/dist/internal/types/prepared-encryption.d.ts +3 -3
  44. package/dist/internal/types/prepared-encryption.d.ts.map +1 -1
  45. package/dist/internal/types/prepared-encryption.js +1 -2
  46. package/dist/internal/utils/aes-header.d.ts +3 -3
  47. package/dist/internal/utils/aes-header.d.ts.map +1 -1
  48. package/dist/internal/utils/aes-header.js +22 -30
  49. package/dist/internal/utils/aes-header.js.map +1 -1
  50. package/dist/internal/utils/calculate/calculate-aes-encryption.d.ts +2 -2
  51. package/dist/internal/utils/calculate/calculate-aes-encryption.d.ts.map +1 -1
  52. package/dist/internal/utils/calculate/calculate-aes-encryption.js +4 -8
  53. package/dist/internal/utils/calculate/calculate-aes-encryption.js.map +1 -1
  54. package/dist/internal/utils/calculate/calculate-content-encryption-key-size.d.ts +2 -2
  55. package/dist/internal/utils/calculate/calculate-content-encryption-key-size.d.ts.map +1 -1
  56. package/dist/internal/utils/calculate/calculate-content-encryption-key-size.js +4 -8
  57. package/dist/internal/utils/calculate/calculate-content-encryption-key-size.js.map +1 -1
  58. package/dist/internal/utils/calculate/calculate-key-wrap-encryption.d.ts +1 -1
  59. package/dist/internal/utils/calculate/calculate-key-wrap-encryption.d.ts.map +1 -1
  60. package/dist/internal/utils/calculate/calculate-key-wrap-encryption.js +3 -7
  61. package/dist/internal/utils/calculate/calculate-key-wrap-encryption.js.map +1 -1
  62. package/dist/internal/utils/calculate/calculate-key-wrap-size.d.ts +2 -2
  63. package/dist/internal/utils/calculate/calculate-key-wrap-size.d.ts.map +1 -1
  64. package/dist/internal/utils/calculate/calculate-key-wrap-size.js +3 -7
  65. package/dist/internal/utils/calculate/calculate-key-wrap-size.js.map +1 -1
  66. package/dist/internal/utils/calculate/calculate-pbkdf-hash.d.ts +2 -2
  67. package/dist/internal/utils/calculate/calculate-pbkdf-hash.d.ts.map +1 -1
  68. package/dist/internal/utils/calculate/calculate-pbkdf-hash.js +3 -7
  69. package/dist/internal/utils/calculate/calculate-pbkdf-hash.js.map +1 -1
  70. package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.d.ts +2 -2
  71. package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.d.ts.map +1 -1
  72. package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.js +3 -7
  73. package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.js.map +1 -1
  74. package/dist/internal/utils/content.d.ts +1 -1
  75. package/dist/internal/utils/content.d.ts.map +1 -1
  76. package/dist/internal/utils/content.js +11 -17
  77. package/dist/internal/utils/content.js.map +1 -1
  78. package/dist/internal/utils/data/auth-tag-hmac.d.ts +1 -1
  79. package/dist/internal/utils/data/auth-tag-hmac.d.ts.map +1 -1
  80. package/dist/internal/utils/data/auth-tag-hmac.js +9 -14
  81. package/dist/internal/utils/data/auth-tag-hmac.js.map +1 -1
  82. package/dist/internal/utils/data/auth-tag.d.ts +1 -1
  83. package/dist/internal/utils/data/auth-tag.d.ts.map +1 -1
  84. package/dist/internal/utils/data/auth-tag.js +9 -14
  85. package/dist/internal/utils/data/auth-tag.js.map +1 -1
  86. package/dist/internal/utils/data/get-initialisation-vector.d.ts +1 -1
  87. package/dist/internal/utils/data/get-initialisation-vector.d.ts.map +1 -1
  88. package/dist/internal/utils/data/get-initialisation-vector.js +6 -10
  89. package/dist/internal/utils/data/get-initialisation-vector.js.map +1 -1
  90. package/dist/internal/utils/data/split-content-encryption-key.d.ts +1 -1
  91. package/dist/internal/utils/data/split-content-encryption-key.d.ts.map +1 -1
  92. package/dist/internal/utils/data/split-content-encryption-key.js +4 -8
  93. package/dist/internal/utils/data/split-content-encryption-key.js.map +1 -1
  94. package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.d.ts +1 -1
  95. package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.d.ts.map +1 -1
  96. package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.js +20 -25
  97. package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.js.map +1 -1
  98. package/dist/internal/utils/diffie-hellman/diffie-hellman.d.ts +1 -1
  99. package/dist/internal/utils/diffie-hellman/diffie-hellman.d.ts.map +1 -1
  100. package/dist/internal/utils/diffie-hellman/diffie-hellman.js +16 -21
  101. package/dist/internal/utils/diffie-hellman/diffie-hellman.js.map +1 -1
  102. package/dist/internal/utils/diffie-hellman/shared-secret.d.ts +3 -3
  103. package/dist/internal/utils/diffie-hellman/shared-secret.d.ts.map +1 -1
  104. package/dist/internal/utils/diffie-hellman/shared-secret.js +22 -27
  105. package/dist/internal/utils/diffie-hellman/shared-secret.js.map +1 -1
  106. package/dist/internal/utils/encoded-aes.d.ts +2 -2
  107. package/dist/internal/utils/encoded-aes.d.ts.map +1 -1
  108. package/dist/internal/utils/encoded-aes.js +18 -23
  109. package/dist/internal/utils/encoded-aes.js.map +1 -1
  110. package/dist/internal/utils/encrypt-content.d.ts +1 -1
  111. package/dist/internal/utils/encrypt-content.d.ts.map +1 -1
  112. package/dist/internal/utils/encrypt-content.js +14 -18
  113. package/dist/internal/utils/encrypt-content.js.map +1 -1
  114. package/dist/internal/utils/encrypt-encoded.d.ts +2 -2
  115. package/dist/internal/utils/encrypt-encoded.d.ts.map +1 -1
  116. package/dist/internal/utils/encrypt-encoded.js +15 -19
  117. package/dist/internal/utils/encrypt-encoded.js.map +1 -1
  118. package/dist/internal/utils/encrypt-serialised.d.ts +3 -3
  119. package/dist/internal/utils/encrypt-serialised.d.ts.map +1 -1
  120. package/dist/internal/utils/encrypt-serialised.js +20 -24
  121. package/dist/internal/utils/encrypt-serialised.js.map +1 -1
  122. package/dist/internal/utils/encrypt-tokenised.d.ts +2 -2
  123. package/dist/internal/utils/encrypt-tokenised.d.ts.map +1 -1
  124. package/dist/internal/utils/encrypt-tokenised.js +18 -22
  125. package/dist/internal/utils/encrypt-tokenised.js.map +1 -1
  126. package/dist/internal/utils/encryption.d.ts +3 -3
  127. package/dist/internal/utils/encryption.d.ts.map +1 -1
  128. package/dist/internal/utils/encryption.js +22 -27
  129. package/dist/internal/utils/encryption.js.map +1 -1
  130. package/dist/internal/utils/get-key/get-decryption-key.d.ts +1 -1
  131. package/dist/internal/utils/get-key/get-decryption-key.d.ts.map +1 -1
  132. package/dist/internal/utils/get-key/get-decryption-key.js +11 -15
  133. package/dist/internal/utils/get-key/get-decryption-key.js.map +1 -1
  134. package/dist/internal/utils/get-key/get-encryption-key.d.ts +1 -1
  135. package/dist/internal/utils/get-key/get-encryption-key.d.ts.map +1 -1
  136. package/dist/internal/utils/get-key/get-encryption-key.js +11 -15
  137. package/dist/internal/utils/get-key/get-encryption-key.js.map +1 -1
  138. package/dist/internal/utils/key-derivation/concat-kdf.d.ts +1 -1
  139. package/dist/internal/utils/key-derivation/concat-kdf.d.ts.map +1 -1
  140. package/dist/internal/utils/key-derivation/concat-kdf.js +3 -7
  141. package/dist/internal/utils/key-derivation/concat-kdf.js.map +1 -1
  142. package/dist/internal/utils/key-derivation/pbkdf.d.ts +1 -1
  143. package/dist/internal/utils/key-derivation/pbkdf.d.ts.map +1 -1
  144. package/dist/internal/utils/key-derivation/pbkdf.js +7 -11
  145. package/dist/internal/utils/key-derivation/pbkdf.js.map +1 -1
  146. package/dist/internal/utils/key-types/get-ec-keys.d.ts +1 -1
  147. package/dist/internal/utils/key-types/get-ec-keys.d.ts.map +1 -1
  148. package/dist/internal/utils/key-types/get-ec-keys.js +11 -16
  149. package/dist/internal/utils/key-types/get-ec-keys.js.map +1 -1
  150. package/dist/internal/utils/key-types/get-oct-keys.d.ts +1 -1
  151. package/dist/internal/utils/key-types/get-oct-keys.d.ts.map +1 -1
  152. package/dist/internal/utils/key-types/get-oct-keys.js +14 -19
  153. package/dist/internal/utils/key-types/get-oct-keys.js.map +1 -1
  154. package/dist/internal/utils/key-types/get-okp-keys.d.ts +1 -1
  155. package/dist/internal/utils/key-types/get-okp-keys.d.ts.map +1 -1
  156. package/dist/internal/utils/key-types/get-okp-keys.js +11 -16
  157. package/dist/internal/utils/key-types/get-okp-keys.js.map +1 -1
  158. package/dist/internal/utils/key-types/get-rsa-keys.d.ts +1 -1
  159. package/dist/internal/utils/key-types/get-rsa-keys.d.ts.map +1 -1
  160. package/dist/internal/utils/key-types/get-rsa-keys.js +24 -29
  161. package/dist/internal/utils/key-types/get-rsa-keys.js.map +1 -1
  162. package/dist/internal/utils/key-wrap/ecb-key-wrap.d.ts +1 -1
  163. package/dist/internal/utils/key-wrap/ecb-key-wrap.d.ts.map +1 -1
  164. package/dist/internal/utils/key-wrap/ecb-key-wrap.js +12 -17
  165. package/dist/internal/utils/key-wrap/ecb-key-wrap.js.map +1 -1
  166. package/dist/internal/utils/key-wrap/gcm-key-wrap.d.ts +1 -1
  167. package/dist/internal/utils/key-wrap/gcm-key-wrap.d.ts.map +1 -1
  168. package/dist/internal/utils/key-wrap/gcm-key-wrap.js +14 -19
  169. package/dist/internal/utils/key-wrap/gcm-key-wrap.js.map +1 -1
  170. package/dist/internal/utils/key-wrap/key-wrap.d.ts +1 -1
  171. package/dist/internal/utils/key-wrap/key-wrap.d.ts.map +1 -1
  172. package/dist/internal/utils/key-wrap/key-wrap.js +11 -16
  173. package/dist/internal/utils/key-wrap/key-wrap.js.map +1 -1
  174. package/dist/internal/utils/oct/get-oct-dir-keys.d.ts +1 -1
  175. package/dist/internal/utils/oct/get-oct-dir-keys.d.ts.map +1 -1
  176. package/dist/internal/utils/oct/get-oct-dir-keys.js +13 -18
  177. package/dist/internal/utils/oct/get-oct-dir-keys.js.map +1 -1
  178. package/dist/internal/utils/oct/get-oct-key-key-wrap.d.ts +1 -1
  179. package/dist/internal/utils/oct/get-oct-key-key-wrap.d.ts.map +1 -1
  180. package/dist/internal/utils/oct/get-oct-key-key-wrap.js +19 -24
  181. package/dist/internal/utils/oct/get-oct-key-key-wrap.js.map +1 -1
  182. package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.d.ts +1 -1
  183. package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.d.ts.map +1 -1
  184. package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.js +25 -30
  185. package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.js.map +1 -1
  186. package/dist/internal/utils/prepare-encryption.d.ts +1 -1
  187. package/dist/internal/utils/prepare-encryption.d.ts.map +1 -1
  188. package/dist/internal/utils/prepare-encryption.js +5 -9
  189. package/dist/internal/utils/prepare-encryption.js.map +1 -1
  190. package/dist/internal/utils/serialised-aes.d.ts +2 -2
  191. package/dist/internal/utils/serialised-aes.d.ts.map +1 -1
  192. package/dist/internal/utils/serialised-aes.js +19 -24
  193. package/dist/internal/utils/serialised-aes.js.map +1 -1
  194. package/dist/internal/utils/tokenised-aes.d.ts +2 -2
  195. package/dist/internal/utils/tokenised-aes.d.ts.map +1 -1
  196. package/dist/internal/utils/tokenised-aes.js +22 -27
  197. package/dist/internal/utils/tokenised-aes.js.map +1 -1
  198. package/dist/internal/utils/validate-version.js +8 -12
  199. package/dist/internal/utils/validate-version.js.map +1 -1
  200. package/dist/mocks/create-mock-aes-kit.d.ts +4 -0
  201. package/dist/mocks/create-mock-aes-kit.d.ts.map +1 -0
  202. package/dist/mocks/create-mock-aes-kit.js +81 -0
  203. package/dist/mocks/create-mock-aes-kit.js.map +1 -0
  204. package/dist/mocks/jest.d.ts +5 -0
  205. package/dist/mocks/jest.d.ts.map +1 -0
  206. package/dist/mocks/jest.js +4 -0
  207. package/dist/mocks/jest.js.map +1 -0
  208. package/dist/mocks/vitest.d.ts +6 -0
  209. package/dist/mocks/vitest.d.ts.map +1 -0
  210. package/dist/mocks/vitest.js +5 -0
  211. package/dist/mocks/vitest.js.map +1 -0
  212. package/dist/types/aes-decryption-data.d.ts +3 -3
  213. package/dist/types/aes-decryption-data.d.ts.map +1 -1
  214. package/dist/types/aes-decryption-data.js +1 -2
  215. package/dist/types/aes-encryption-data.d.ts +3 -3
  216. package/dist/types/aes-encryption-data.d.ts.map +1 -1
  217. package/dist/types/aes-encryption-data.js +1 -2
  218. package/dist/types/aes-kit.d.ts +1 -1
  219. package/dist/types/aes-kit.d.ts.map +1 -1
  220. package/dist/types/aes-kit.js +1 -2
  221. package/dist/types/content.d.ts +1 -1
  222. package/dist/types/content.d.ts.map +1 -1
  223. package/dist/types/content.js +1 -2
  224. package/dist/types/curve.js +1 -2
  225. package/dist/types/index.d.ts +7 -7
  226. package/dist/types/index.d.ts.map +1 -1
  227. package/dist/types/index.js +6 -22
  228. package/dist/types/index.js.map +1 -1
  229. package/dist/types/types.d.ts +1 -1
  230. package/dist/types/types.d.ts.map +1 -1
  231. package/dist/types/types.js +1 -2
  232. package/dist/utils/index.d.ts +2 -2
  233. package/dist/utils/index.d.ts.map +1 -1
  234. package/dist/utils/index.js +2 -18
  235. package/dist/utils/index.js.map +1 -1
  236. package/dist/utils/is-aes.d.ts +1 -1
  237. package/dist/utils/is-aes.d.ts.map +1 -1
  238. package/dist/utils/is-aes.js +4 -10
  239. package/dist/utils/is-aes.js.map +1 -1
  240. package/dist/utils/parse-aes.d.ts +1 -1
  241. package/dist/utils/parse-aes.d.ts.map +1 -1
  242. package/dist/utils/parse-aes.js +15 -19
  243. package/dist/utils/parse-aes.js.map +1 -1
  244. package/package.json +22 -23
  245. package/CHANGELOG.md +0 -165
  246. package/MERMAID.md +0 -155
  247. package/__tests__/INTEROP-RESULTS.md +0 -66
  248. package/__tests__/esm-smoke.test.ts +0 -15
  249. package/__tests__/fixtures/keys.ts +0 -60
  250. package/__tests__/helpers/buffer-utils.ts +0 -11
  251. package/__tests__/helpers/index.ts +0 -2
  252. package/__tests__/helpers/jwe-adapter.ts +0 -123
  253. package/__tests__/jose-jwe.test.ts +0 -463
  254. package/__tests__/noble-ciphers.test.ts +0 -208
  255. package/dist/mocks/index.d.ts +0 -2
  256. package/dist/mocks/index.d.ts.map +0 -1
  257. package/dist/mocks/index.js +0 -6
  258. package/dist/mocks/index.js.map +0 -1
  259. package/dist/mocks/mock-aes-kit.d.ts +0 -4
  260. package/dist/mocks/mock-aes-kit.d.ts.map +0 -1
  261. package/dist/mocks/mock-aes-kit.js +0 -74
  262. package/dist/mocks/mock-aes-kit.js.map +0 -1
  263. package/jest.config.interop.mjs +0 -24
  264. package/tsconfig.interop.json +0 -9
@@ -1,26 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseAes = void 0;
4
- const is_1 = require("@lindorm/is");
5
- const errors_1 = require("../errors");
6
- const is_aes_1 = require("./is-aes");
7
- const encoded_aes_1 = require("../internal/utils/encoded-aes");
8
- const serialised_aes_1 = require("../internal/utils/serialised-aes");
9
- const tokenised_aes_1 = require("../internal/utils/tokenised-aes");
10
- const parseAes = (data) => {
11
- if ((0, is_1.isString)(data) && (0, is_aes_1.isAesTokenised)(data)) {
12
- return (0, tokenised_aes_1.parseTokenisedAesString)(data);
1
+ import { isObject, isString } from "@lindorm/is";
2
+ import { AesError } from "../errors/index.js";
3
+ import { isAesBufferData, isAesSerialisedData, isAesTokenised } from "./is-aes.js";
4
+ import { parseEncodedAesString } from "../internal/utils/encoded-aes.js";
5
+ import { parseSerialisedAesRecord } from "../internal/utils/serialised-aes.js";
6
+ import { parseTokenisedAesString } from "../internal/utils/tokenised-aes.js";
7
+ export const parseAes = (data) => {
8
+ if (isString(data) && isAesTokenised(data)) {
9
+ return parseTokenisedAesString(data);
13
10
  }
14
- if ((0, is_1.isString)(data) && !(0, is_aes_1.isAesTokenised)(data)) {
15
- return (0, encoded_aes_1.parseEncodedAesString)(data);
11
+ if (isString(data) && !isAesTokenised(data)) {
12
+ return parseEncodedAesString(data);
16
13
  }
17
- if ((0, is_1.isObject)(data) && (0, is_aes_1.isAesBufferData)(data)) {
14
+ if (isObject(data) && isAesBufferData(data)) {
18
15
  return data;
19
16
  }
20
- if ((0, is_1.isObject)(data) && (0, is_aes_1.isAesSerialisedData)(data)) {
21
- return (0, serialised_aes_1.parseSerialisedAesRecord)(data);
17
+ if (isObject(data) && isAesSerialisedData(data)) {
18
+ return parseSerialisedAesRecord(data);
22
19
  }
23
- throw new errors_1.AesError("Invalid AES data");
20
+ throw new AesError("Invalid AES data");
24
21
  };
25
- exports.parseAes = parseAes;
26
22
  //# sourceMappingURL=parse-aes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-aes.js","sourceRoot":"","sources":["../../src/utils/parse-aes.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AACjD,sCAAqC;AAMrC,qCAAgF;AAChF,+DAAsE;AACtE,qEAA4E;AAC5E,mEAA0E;AASnE,MAAM,QAAQ,GAAa,CAChC,IAA4D,EACvD,EAAE;IACP,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,IAAI,IAAA,uBAAc,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAA,uCAAuB,EAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAA,mCAAqB,EAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,IAAI,IAAA,wBAAe,EAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,IAAI,IAAA,4BAAmB,EAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAO,IAAA,yCAAwB,EAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,IAAI,iBAAQ,CAAC,kBAAkB,CAAC,CAAC;AACzC,CAAC,CAAC;AApBW,QAAA,QAAQ,YAoBnB"}
1
+ {"version":3,"file":"parse-aes.js","sourceRoot":"","sources":["../../src/utils/parse-aes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAS7E,MAAM,CAAC,MAAM,QAAQ,GAAa,CAChC,IAA4D,EACvD,EAAE;IACP,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,IAAI,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AACzC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lindorm/aes",
3
- "version": "0.6.5",
3
+ "version": "0.7.1",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "author": "Jonn Nilsson",
6
6
  "repository": {
@@ -11,33 +11,32 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "main": "dist/index.js",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "type": "module",
15
18
  "typings": "dist/index.d.ts",
16
19
  "exports": {
17
20
  ".": {
18
21
  "types": "./dist/index.d.ts",
19
22
  "default": "./dist/index.js"
20
23
  },
21
- "./mocks": {
22
- "types": "./dist/mocks/index.d.ts",
23
- "default": "./dist/mocks/index.js"
24
- }
25
- },
26
- "typesVersions": {
27
- "*": {
28
- "mocks": [
29
- "dist/mocks/index.d.ts"
30
- ]
24
+ "./mocks/jest": {
25
+ "types": "./dist/mocks/jest.d.ts",
26
+ "default": "./dist/mocks/jest.js"
27
+ },
28
+ "./mocks/vitest": {
29
+ "types": "./dist/mocks/vitest.d.ts",
30
+ "default": "./dist/mocks/vitest.js"
31
31
  }
32
32
  },
33
33
  "scripts": {
34
34
  "build": "rimraf dist && tsc -b ./tsconfig.build.json",
35
35
  "example": "ts-node example",
36
36
  "prettier": "prettier --write ./src/*",
37
- "test": "jest",
38
- "test:ci": "jest",
39
- "test:interop": "NODE_OPTIONS='--experimental-vm-modules' jest --config jest.config.interop.mjs --no-coverage",
40
- "test:watch": "jest --watch --",
37
+ "test": "vitest run",
38
+ "test:unit": "vitest run --exclude '**/*.integration.test.ts'",
39
+ "test:watch": "vitest",
41
40
  "typecheck": "tsc",
42
41
  "typecheck:watch": "tsc --watch",
43
42
  "update": "ncu -i",
@@ -45,16 +44,16 @@
45
44
  "verify": "npm run typecheck && npm run build && npm test"
46
45
  },
47
46
  "dependencies": {
48
- "@lindorm/b64": "^0.1.10",
49
- "@lindorm/errors": "^0.1.18",
50
- "@lindorm/is": "^0.1.16",
51
- "@lindorm/kryptos": "^0.7.0",
52
- "@lindorm/utils": "^0.7.1"
47
+ "@lindorm/b64": "^0.2.1",
48
+ "@lindorm/errors": "^0.2.1",
49
+ "@lindorm/is": "^0.2.1",
50
+ "@lindorm/kryptos": "^0.8.1",
51
+ "@lindorm/types": "^0.6.1",
52
+ "@lindorm/utils": "^0.8.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@lindorm/types": "^0.5.0",
56
55
  "@noble/ciphers": "^2.1.1",
57
56
  "jose": "^6.2.1"
58
57
  },
59
- "gitHead": "2f258248c91376d768d11e26b72d26b57208007b"
58
+ "gitHead": "da067071d415e07d7d25bbac1621b9e02fcc3166"
60
59
  }
package/CHANGELOG.md DELETED
@@ -1,165 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.6.5](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.6.4...@lindorm/aes@0.6.5) (2026-04-19)
7
-
8
- **Note:** Version bump only for package @lindorm/aes
9
-
10
- ## [0.6.4](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.6.3...@lindorm/aes@0.6.4) (2026-04-15)
11
-
12
- **Note:** Version bump only for package @lindorm/aes
13
-
14
- ## [0.6.3](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.6.2...@lindorm/aes@0.6.3) (2026-04-01)
15
-
16
- ### Bug Fixes
17
-
18
- - **aes,amphora:** use relative imports for test fixtures ([5ebc484](https://github.com/lindorm-io/monorepo/commit/5ebc484e7dd664b85f40a57db0057364e8883ce9))
19
-
20
- ## [0.6.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.6.1...@lindorm/aes@0.6.2) (2026-03-13)
21
-
22
- **Note:** Version bump only for package @lindorm/aes
23
-
24
- ## [0.6.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.6.0...@lindorm/aes@0.6.1) (2026-03-13)
25
-
26
- **Note:** Version bump only for package @lindorm/aes
27
-
28
- # [0.6.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.5...@lindorm/aes@0.6.0) (2026-02-17)
29
-
30
- ### Bug Fixes
31
-
32
- - **aes:** add buffer boundary validation in encoded string parser ([579e8f7](https://github.com/lindorm-io/monorepo/commit/579e8f7eb40570f978cd52d1f87f7f8570474d6d))
33
- - **aes:** add GCM auth tag enforcement and key-wrap input validation ([1a8fd3c](https://github.com/lindorm-io/monorepo/commit/1a8fd3cb6f83cf59a3089a777fba4c8b7f1828fb))
34
- - **aes:** add missing @lindorm/utils dependency ([6d0ee2a](https://github.com/lindorm-io/monorepo/commit/6d0ee2ae68f91fb9eb04529c96e05ff1d843dfd0))
35
- - **aes:** make CBC HMAC auth tag compliant with RFC 7518 ([7877022](https://github.com/lindorm-io/monorepo/commit/7877022bebdf902ff13996b1032a991356f3760c))
36
- - **aes:** make PBES2 salt compliant with RFC 7518 ([2693afa](https://github.com/lindorm-io/monorepo/commit/2693afa88db535aeaff7fd5537885dd3a45bc09a))
37
- - **aes:** make verify/assert work with non-string content ([aa94c66](https://github.com/lindorm-io/monorepo/commit/aa94c66511326f70fdfc0245ce12953025aa4236))
38
- - **aes:** remove unnecessary g flag from tokenised regex ([5a989b1](https://github.com/lindorm-io/monorepo/commit/5a989b1d96b025b3180339294e8ea072d215c7d3))
39
- - **aes:** replace generic Error with AesError in all locations ([ff7a08d](https://github.com/lindorm-io/monorepo/commit/ff7a08d55e9b39755e059e31e99fb45b687bdde2))
40
- - **aes:** use Concat KDF per RFC 7518 for ECDH-ES key agreement ([8e92b8f](https://github.com/lindorm-io/monorepo/commit/8e92b8f60ee46c99f0c66af244fd1e7648130a9c))
41
- - **aes:** use crypto.randomInt for PBKDF2 iterations, fix RSA test fixture ([a5457aa](https://github.com/lindorm-io/monorepo/commit/a5457aa5973e4eab662dbc6e62c9470f7d6fabf2))
42
- - **aes:** use oct keys directly for AES key wrap per RFC 7518 ([c65ca49](https://github.com/lindorm-io/monorepo/commit/c65ca49d758f21e868e96512a96fc8df0559947e))
43
- - **aes:** use timingSafeEqual for ECB key unwrap integrity check ([dd27a65](https://github.com/lindorm-io/monorepo/commit/dd27a65c84eed068d6e9e5de34d0eaca6cda67fc))
44
- - **aes:** use timingSafeEqual for HMAC auth tag verification ([757bef5](https://github.com/lindorm-io/monorepo/commit/757bef5657a6d1366c222c9205a8f4cfe563e77d))
45
- - **lint:** add missing eslint-config-prettier and fix prettier formatting ([6899e39](https://github.com/lindorm-io/monorepo/commit/6899e39ad7700e373173b0a61b429b5536c13934))
46
- - **lint:** resolve eslint warnings and errors ([210ef3c](https://github.com/lindorm-io/monorepo/commit/210ef3c91c82521c4cec57bc2256324ba9c3f45a))
47
-
48
- ### Features
49
-
50
- - **aes:** accept optional AAD parameter for authenticated encryption ([011b67f](https://github.com/lindorm-io/monorepo/commit/011b67fb8ba18a361e2c31fd0e78298a89f89cd2))
51
- - **aes:** add prepareEncryption() for two-step JWE-compliant encryption ([56b3c54](https://github.com/lindorm-io/monorepo/commit/56b3c5435722b2b94f05d6483c7651ccdd5ea9dd))
52
- - **aes:** rewrite formats with unified model and always-on AAD ([bc1da71](https://github.com/lindorm-io/monorepo/commit/bc1da719d5ee5ee151d9220e6e738a9431e036b6))
53
-
54
- ## [0.5.5](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.4...@lindorm/aes@0.5.5) (2025-09-18)
55
-
56
- **Note:** Version bump only for package @lindorm/aes
57
-
58
- ## [0.5.4](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.3...@lindorm/aes@0.5.4) (2025-07-19)
59
-
60
- **Note:** Version bump only for package @lindorm/aes
61
-
62
- ## [0.5.3](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.2...@lindorm/aes@0.5.3) (2025-07-12)
63
-
64
- **Note:** Version bump only for package @lindorm/aes
65
-
66
- ## [0.5.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.1...@lindorm/aes@0.5.2) (2025-07-10)
67
-
68
- **Note:** Version bump only for package @lindorm/aes
69
-
70
- ## [0.5.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.0...@lindorm/aes@0.5.1) (2025-07-02)
71
-
72
- ### Bug Fixes
73
-
74
- - amend bug in aes utility ([7437e8e](https://github.com/lindorm-io/monorepo/commit/7437e8e0f047bb0995b8a8c0e6929c9cc368d592))
75
-
76
- # [0.5.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.4.2...@lindorm/aes@0.5.0) (2025-06-17)
77
-
78
- ### Bug Fixes
79
-
80
- - align with kryptos changes ([3f934a4](https://github.com/lindorm-io/monorepo/commit/3f934a4ec55eee3d4ebc6f0be55886d8f095af8b))
81
- - align with kryptos changes ([206eb38](https://github.com/lindorm-io/monorepo/commit/206eb38ae2a03b14973e706035c87a953cc753af))
82
- - improve and expose aes parsing ([ec6f271](https://github.com/lindorm-io/monorepo/commit/ec6f27179ec3d67146a50257cbff98fe253c3380))
83
- - improve types ([f6ce002](https://github.com/lindorm-io/monorepo/commit/f6ce002e8555c54ba4f12bd67222457fa2bcf90a))
84
- - update try catch ([7ebebe8](https://github.com/lindorm-io/monorepo/commit/7ebebe81f40851b0d1fcb05e6e6cc60b1c754a91))
85
-
86
- ### Features
87
-
88
- - add content type to aes data ([dfb3285](https://github.com/lindorm-io/monorepo/commit/dfb3285ddf20bc77cf8f3d2531e26032853b98a9))
89
-
90
- ## [0.4.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.4.1...@lindorm/aes@0.4.2) (2025-01-28)
91
-
92
- **Note:** Version bump only for package @lindorm/aes
93
-
94
- ## [0.4.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.4.0...@lindorm/aes@0.4.1) (2024-10-12)
95
-
96
- **Note:** Version bump only for package @lindorm/aes
97
-
98
- # [0.4.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.3.3...@lindorm/aes@0.4.0) (2024-10-09)
99
-
100
- ### Bug Fixes
101
-
102
- - move content to end of encoded array so that it can be any size ([b053924](https://github.com/lindorm-io/monorepo/commit/b05392484342976f519b32f943aac41271761df4))
103
-
104
- ### Features
105
-
106
- - add automatic b64 encoding ([f3ac64e](https://github.com/lindorm-io/monorepo/commit/f3ac64e7922528b1afe0f0acbc52b62aa7003d2d))
107
- - rename modes and add encoded ([b8c9d4c](https://github.com/lindorm-io/monorepo/commit/b8c9d4c26a069444fa7bff5a809308cecff971ef))
108
-
109
- ## [0.3.3](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.3.2...@lindorm/aes@0.3.3) (2024-09-25)
110
-
111
- **Note:** Version bump only for package @lindorm/aes
112
-
113
- ## [0.3.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.3.1...@lindorm/aes@0.3.2) (2024-09-23)
114
-
115
- **Note:** Version bump only for package @lindorm/aes
116
-
117
- ## [0.3.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.3.0...@lindorm/aes@0.3.1) (2024-09-20)
118
-
119
- **Note:** Version bump only for package @lindorm/aes
120
-
121
- # [0.3.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.2.0...@lindorm/aes@0.3.0) (2024-05-20)
122
-
123
- ### Features
124
-
125
- - add gcm keywrap ([8eefa5d](https://github.com/lindorm-io/monorepo/commit/8eefa5dd2914faba842c0a050a9317d2b6f5b197))
126
-
127
- # [0.2.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.1.3...@lindorm/aes@0.2.0) (2024-05-19)
128
-
129
- ### Bug Fixes
130
-
131
- - align curves to kryptos ([b9288a5](https://github.com/lindorm-io/monorepo/commit/b9288a54b6dbb520328aff77cd3c8d2818183ac5))
132
- - align with kryptos changes ([344c4e2](https://github.com/lindorm-io/monorepo/commit/344c4e2fad07e66c91f7e0820bfc929c1f8ffcab))
133
- - improve kryptos generate method ([9e7098d](https://github.com/lindorm-io/monorepo/commit/9e7098d4b219b11140e28e554ffd573204772249))
134
- - remove private key encryption ([be54916](https://github.com/lindorm-io/monorepo/commit/be54916a20de667e96826d6be0eb8d0fda67176e))
135
- - remove unnecessary code ([e44a056](https://github.com/lindorm-io/monorepo/commit/e44a0565e577fc23a827c9283839684c1e40d287))
136
- - rename interfaces ([3b1f457](https://github.com/lindorm-io/monorepo/commit/3b1f45736f88b8c2d4481cbeca6da87bf8443bde))
137
- - simplify interfaces with kryptos metadata ([c4075d2](https://github.com/lindorm-io/monorepo/commit/c4075d2e133c2fe0a1fafa548da68db34b3407c6))
138
- - use pbkdf2 key derivation for oct ([d068947](https://github.com/lindorm-io/monorepo/commit/d068947f70712fb71f57d5ec6947062219200155))
139
-
140
- ### Features
141
-
142
- - add okp encryption and clean up ec encryption ([4d3cbab](https://github.com/lindorm-io/monorepo/commit/4d3cbabe1968ab7f8a9ecc8e226ce91403342f0f))
143
- - implement missing encryption types ([c94b538](https://github.com/lindorm-io/monorepo/commit/c94b53823fcb7a24823b25535b83799f2bbdd250))
144
- - refine and improve oct encryption ([99db5a2](https://github.com/lindorm-io/monorepo/commit/99db5a290b7a081ab80c3811bcc04021e1ac9b4e))
145
- - use pbkdf with short oct keys ([d1d8e5e](https://github.com/lindorm-io/monorepo/commit/d1d8e5ea6dcac24b1b1402e841777a0affefcfff))
146
-
147
- ## [0.1.3](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.1.2...@lindorm/aes@0.1.3) (2024-05-12)
148
-
149
- **Note:** Version bump only for package @lindorm/aes
150
-
151
- ## [0.1.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.1.1...@lindorm/aes@0.1.2) (2024-05-11)
152
-
153
- **Note:** Version bump only for package @lindorm/aes
154
-
155
- ## [0.1.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.1.0...@lindorm/aes@0.1.1) (2024-05-11)
156
-
157
- ### Bug Fixes
158
-
159
- - amend wrong export path and rename ([87e6dd1](https://github.com/lindorm-io/monorepo/commit/87e6dd12057fe35c1c0b26a327a098015f041b44))
160
-
161
- # 0.1.0 (2024-05-11)
162
-
163
- ### Features
164
-
165
- - implement aes package ([4267f1f](https://github.com/lindorm-io/monorepo/commit/4267f1f2b368bcc42181f274872793897347e539))
package/MERMAID.md DELETED
@@ -1,155 +0,0 @@
1
- # Mermaid Diagram
2
-
3
- ```mermaid
4
-
5
- graph TB
6
- subgraph "External Dependencies"
7
- KRYPTOS["@lindorm/kryptos<br/>(Key Management)"]
8
- B64["@lindorm/b64<br/>(Base64 Encoding)"]
9
- IS["@lindorm/is<br/>(Type Guards)"]
10
- ERRORS["@lindorm/errors<br/>(Error Handling)"]
11
- end
12
-
13
- subgraph "Public API"
14
- AESKIT["AesKit Class<br/>Main Entry Point"]
15
- PARSE["parseAes()<br/>Parse any format"]
16
- ISAES["isAesTokenised()<br/>Type checking"]
17
- end
18
-
19
- subgraph "Encryption Flow"
20
- ENCRYPT["encrypt(data, mode)"]
21
- GET_ENC_KEY["getEncryptionKey()"]
22
-
23
- subgraph "Key Type Routing"
24
- EC_ENC["EC Keys<br/>(Elliptic Curve)"]
25
- OKP_ENC["OKP Keys<br/>(Edwards Curve)"]
26
- OCT_ENC["oct Keys<br/>(Symmetric)"]
27
- RSA_ENC["RSA Keys"]
28
- end
29
-
30
- subgraph "Key Derivation Methods"
31
- DIR["Direct Key<br/>(dir)"]
32
- ECDH["ECDH-ES<br/>(Diffie-Hellman)"]
33
- KEYWRAP["Key Wrap<br/>(AES-KW/GCM)"]
34
- PBKDF["PBKDF2<br/>(Password-based)"]
35
- end
36
-
37
- CEK["Content Encryption Key<br/>(Split into encKey + hashKey)"]
38
- AES_CIPHER["Node crypto.createCipheriv()<br/>(AES-128/192/256-CBC/GCM)"]
39
- AUTH_TAG["Generate Auth Tag<br/>(GCM or HMAC)"]
40
-
41
- subgraph "Output Modes"
42
- ENCODED["Encoded<br/>(base64 string)"]
43
- RECORD["Record<br/>(Buffer objects)"]
44
- SERIALISED["Serialised<br/>(JSON-safe strings)"]
45
- TOKENISED["Tokenised<br/>($enc$params$content$)"]
46
- end
47
- end
48
-
49
- subgraph "Decryption Flow"
50
- DECRYPT["decrypt(data)"]
51
- PARSE_INPUT["Parse Input<br/>(parseAes)"]
52
- GET_DEC_KEY["getDecryptionKey()"]
53
-
54
- subgraph "Key Type Decryption"
55
- EC_DEC["EC Keys"]
56
- OKP_DEC["OKP Keys"]
57
- OCT_DEC["oct Keys"]
58
- RSA_DEC["RSA Keys"]
59
- end
60
-
61
- CEK_DEC["Content Encryption Key"]
62
- AES_DECIPHER["Node crypto.createDecipheriv()"]
63
- VERIFY_TAG["Verify Auth Tag"]
64
- PARSE_CONTENT["Parse Content<br/>(by contentType)"]
65
- end
66
-
67
- subgraph "Data Types"
68
- CONTENT["AesContent<br/>string | Buffer | object | array | number"]
69
- CONTENT_TYPE["AesContentType<br/>text/plain | application/json | application/octet-stream"]
70
- end
71
-
72
- subgraph "Encryption Metadata"
73
- RECORD_TYPE["AesEncryptionRecord<br/>• algorithm<br/>• encryption<br/>• keyId<br/>• content<br/>•
74
- authTag<br/>• IV<br/>• contentType<br/>• pbkdfSalt/Iterations<br/>• publicEncryptionKey/Jwk"]
75
- end
76
-
77
- %% Main flow connections
78
- AESKIT --> ENCRYPT
79
- AESKIT --> DECRYPT
80
- AESKIT --> KRYPTOS
81
-
82
- ENCRYPT --> CONTENT
83
- ENCRYPT --> GET_ENC_KEY
84
- GET_ENC_KEY --> KRYPTOS
85
-
86
- GET_ENC_KEY --> EC_ENC
87
- GET_ENC_KEY --> OKP_ENC
88
- GET_ENC_KEY --> OCT_ENC
89
- GET_ENC_KEY --> RSA_ENC
90
-
91
- EC_ENC --> ECDH
92
- EC_ENC --> KEYWRAP
93
- OKP_ENC --> ECDH
94
- OKP_ENC --> KEYWRAP
95
- OCT_ENC --> DIR
96
- OCT_ENC --> KEYWRAP
97
- OCT_ENC --> PBKDF
98
- RSA_ENC --> KEYWRAP
99
-
100
- ECDH --> CEK
101
- KEYWRAP --> CEK
102
- PBKDF --> CEK
103
- DIR --> CEK
104
-
105
- CEK --> AES_CIPHER
106
- CONTENT --> AES_CIPHER
107
- AES_CIPHER --> AUTH_TAG
108
-
109
- AUTH_TAG --> RECORD_TYPE
110
-
111
- RECORD_TYPE --> ENCODED
112
- RECORD_TYPE --> RECORD
113
- RECORD_TYPE --> SERIALISED
114
- RECORD_TYPE --> TOKENISED
115
-
116
- %% Decryption flow
117
- DECRYPT --> PARSE_INPUT
118
- PARSE_INPUT --> ENCODED
119
- PARSE_INPUT --> RECORD
120
- PARSE_INPUT --> SERIALISED
121
- PARSE_INPUT --> TOKENISED
122
-
123
- PARSE_INPUT --> GET_DEC_KEY
124
- GET_DEC_KEY --> KRYPTOS
125
-
126
- GET_DEC_KEY --> EC_DEC
127
- GET_DEC_KEY --> OKP_DEC
128
- GET_DEC_KEY --> OCT_DEC
129
- GET_DEC_KEY --> RSA_DEC
130
-
131
- EC_DEC --> CEK_DEC
132
- OKP_DEC --> CEK_DEC
133
- OCT_DEC --> CEK_DEC
134
- RSA_DEC --> CEK_DEC
135
-
136
- CEK_DEC --> AES_DECIPHER
137
- RECORD_TYPE --> AES_DECIPHER
138
- AES_DECIPHER --> VERIFY_TAG
139
- VERIFY_TAG --> PARSE_CONTENT
140
- PARSE_CONTENT --> CONTENT_TYPE
141
-
142
- %% Utility connections
143
- B64 --> ENCODED
144
- B64 --> TOKENISED
145
- B64 --> SERIALISED
146
- IS --> PARSE_INPUT
147
- ERRORS --> AESKIT
148
-
149
- style AESKIT fill:#4a90e2,stroke:#2e5c8a,color:#fff
150
- style ENCRYPT fill:#50c878,stroke:#2d7a4a,color:#fff
151
- style DECRYPT fill:#e27d60,stroke:#a85a43,color:#fff
152
- style KRYPTOS fill:#9b59b6,stroke:#6c3a8a,color:#fff
153
- style CEK fill:#f39c12,stroke:#b87a0a,color:#fff
154
- style CEK_DEC fill:#f39c12,stroke:#b87a0a,color:#fff
155
- ```
@@ -1,66 +0,0 @@
1
- # AES Interop Test Results
2
-
3
- ## Summary
4
-
5
- All 59 interop tests pass. Zero divergences found between `@lindorm/aes`,
6
- `@noble/ciphers`, and `jose`.
7
-
8
- | Suite | Tests | Pass | Fail | Skip |
9
- | ------------- | ------ | ------ | ----- | ----- |
10
- | noble-ciphers | 21 | 21 | 0 | 0 |
11
- | jose-jwe | 38 | 38 | 0 | 0 |
12
- | **Total** | **59** | **59** | **0** | **0** |
13
-
14
- ## noble/ciphers Primitive Tests
15
-
16
- | Primitive | Key Sizes | Direction | Result |
17
- | ----------------- | ------------- | ------------------------------ | ------ |
18
- | AES-GCM | 128, 192, 256 | ours → noble | PASS |
19
- | AES-GCM | 128, 192, 256 | noble → ours | PASS |
20
- | AES-GCM | 128, 192, 256 | byte-identical (pinned IV) | PASS |
21
- | AES-KW (RFC 3394) | 128, 192, 256 | ours → noble | PASS |
22
- | AES-KW (RFC 3394) | 128, 192, 256 | noble → ours | PASS |
23
- | AES-KW (RFC 3394) | 128, 192, 256 | byte-identical (deterministic) | PASS |
24
- | AES-CBC (raw) | 128, 192, 256 | byte-identical (PKCS7) | PASS |
25
-
26
- ## jose JWE Tests
27
-
28
- | Algorithm | Encryption | Direction | Result |
29
- | ---------------------- | ------------------------------------------- | ----------- | ------ |
30
- | dir | A128GCM, A192GCM, A256GCM | ours → jose | PASS |
31
- | dir | A128GCM, A192GCM, A256GCM | jose → ours | PASS |
32
- | dir | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 | ours → jose | PASS |
33
- | dir | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 | jose → ours | PASS |
34
- | A128KW, A192KW, A256KW | A128GCM, A256GCM | ours → jose | PASS |
35
- | A128KW, A192KW, A256KW | A128GCM, A256GCM | jose → ours | PASS |
36
- | A128KW, A192KW, A256KW | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 | ours → jose | PASS |
37
- | A128KW, A192KW, A256KW | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 | jose → ours | PASS |
38
- | A128GCMKW, A256GCMKW | A256GCM | ours → jose | PASS |
39
- | A128GCMKW, A256GCMKW | A256GCM | jose → ours | PASS |
40
- | Pinned deterministic | A256GCM (byte-identical) | comparison | PASS |
41
- | Pinned deterministic | A256GCM (round-trip) | comparison | PASS |
42
- | Pinned deterministic | A128CBC-HS256 (byte-identical) | comparison | PASS |
43
- | Pinned deterministic | A128CBC-HS256 (round-trip) | comparison | PASS |
44
-
45
- ## Validated RFC Compliance
46
-
47
- - **RFC 7516** (JWE): AAD computation, flattened serialization format
48
- - **RFC 7518** (JWA): AES-GCM, AES-CBC-HMAC-SHA2, AES Key Wrap, AES-GCM Key Wrap
49
- - **RFC 3394**: AES Key Wrap (deterministic, AIV verification)
50
-
51
- ## Notes
52
-
53
- - GCMKW "ours → jose" direction uses a two-pass approach due to the circular
54
- dependency between key-wrap params and JWE AAD. Content is re-encrypted with
55
- the correct AAD after extracting key-wrap params from the first pass.
56
- - jose v6 rejects `setContentEncryptionKey()` with `alg: "dir"`, so deterministic
57
- pinned tests use A\*KW algorithms instead. Content encryption is identical
58
- regardless of key management algorithm.
59
- - `@noble/ciphers` GCM returns ciphertext with auth tag appended (last 16 bytes).
60
- Tests correctly split/concatenate when converting between formats.
61
-
62
- ## Environment
63
-
64
- - Node.js >= 24.4.0
65
- - `@noble/ciphers` ^1.2.1
66
- - `jose` ^6.1.3
@@ -1,15 +0,0 @@
1
- import { gcm, cbc, aeskw } from "@noble/ciphers/aes";
2
- import { FlattenedEncrypt, flattenedDecrypt } from "jose";
3
-
4
- describe("ESM import smoke test", () => {
5
- test("should import @noble/ciphers", () => {
6
- expect(gcm).toBeDefined();
7
- expect(cbc).toBeDefined();
8
- expect(aeskw).toBeDefined();
9
- });
10
-
11
- test("should import jose", () => {
12
- expect(FlattenedEncrypt).toBeDefined();
13
- expect(flattenedDecrypt).toBeDefined();
14
- });
15
- });
@@ -1,60 +0,0 @@
1
- import { randomUUID } from "crypto";
2
- import {
3
- Kryptos,
4
- KryptosAlgorithm,
5
- KryptosEncryption,
6
- KryptosKit,
7
- } from "@lindorm/kryptos";
8
-
9
- // Fixed raw symmetric keys for dir mode (CEK = key)
10
- export const RAW_KEY_128 = Buffer.from("000102030405060708090a0b0c0d0e0f", "hex");
11
- export const RAW_KEY_192 = Buffer.from(
12
- "000102030405060708090a0b0c0d0e0f1011121314151617",
13
- "hex",
14
- );
15
- export const RAW_KEY_256 = Buffer.from(
16
- "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
17
- "hex",
18
- );
19
-
20
- // CBC-HMAC composite keys (double-length: half for HMAC, half for AES-CBC)
21
- export const RAW_KEY_256_CBC = Buffer.from(
22
- "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f",
23
- "hex",
24
- );
25
- export const RAW_KEY_384_CBC = Buffer.from(
26
- "404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f",
27
- "hex",
28
- );
29
- export const RAW_KEY_512_CBC = Buffer.from(
30
- "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf",
31
- "hex",
32
- );
33
-
34
- // Key Encryption Keys for KW modes
35
- export const KEK_128 = Buffer.from("c0c1c2c3c4c5c6c7c8c9cacbcccdcecf", "hex");
36
- export const KEK_192 = Buffer.from(
37
- "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7",
38
- "hex",
39
- );
40
- export const KEK_256 = Buffer.from(
41
- "f0f1f2f3f4f5f6f7f8f9fafbfcfdfefff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
42
- "hex",
43
- );
44
-
45
- /**
46
- * Helper to create a Kryptos oct key from raw bytes.
47
- */
48
- export const createOctKryptos = (
49
- raw: Buffer,
50
- algorithm: KryptosAlgorithm,
51
- encryption?: KryptosEncryption,
52
- ): Kryptos =>
53
- KryptosKit.from.der({
54
- id: randomUUID(),
55
- algorithm,
56
- encryption,
57
- privateKey: raw,
58
- type: "oct",
59
- use: "enc",
60
- });
@@ -1,11 +0,0 @@
1
- /**
2
- * Convert Buffer to Uint8Array (zero-copy view).
3
- */
4
- export const toUint8Array = (buf: Buffer): Uint8Array =>
5
- new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
6
-
7
- /**
8
- * Convert Uint8Array to Buffer (zero-copy view).
9
- */
10
- export const toBuffer = (arr: Uint8Array): Buffer =>
11
- Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
@@ -1,2 +0,0 @@
1
- export * from "./buffer-utils";
2
- export * from "./jwe-adapter";