@enbox/crypto 0.0.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 (283) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +708 -0
  3. package/dist/browser.js +64 -0
  4. package/dist/browser.js.map +7 -0
  5. package/dist/browser.mjs +64 -0
  6. package/dist/browser.mjs.map +7 -0
  7. package/dist/cjs/algorithms/aes-ctr.js +188 -0
  8. package/dist/cjs/algorithms/aes-ctr.js.map +1 -0
  9. package/dist/cjs/algorithms/aes-gcm.js +196 -0
  10. package/dist/cjs/algorithms/aes-gcm.js.map +1 -0
  11. package/dist/cjs/algorithms/crypto-algorithm.js +13 -0
  12. package/dist/cjs/algorithms/crypto-algorithm.js.map +1 -0
  13. package/dist/cjs/algorithms/ecdsa.js +352 -0
  14. package/dist/cjs/algorithms/ecdsa.js.map +1 -0
  15. package/dist/cjs/algorithms/eddsa.js +325 -0
  16. package/dist/cjs/algorithms/eddsa.js.map +1 -0
  17. package/dist/cjs/algorithms/sha-2.js +119 -0
  18. package/dist/cjs/algorithms/sha-2.js.map +1 -0
  19. package/dist/cjs/index.js +41 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/jose/jwe.js +3 -0
  22. package/dist/cjs/jose/jwe.js.map +1 -0
  23. package/dist/cjs/jose/jwk.js +278 -0
  24. package/dist/cjs/jose/jwk.js.map +1 -0
  25. package/dist/cjs/jose/jws.js +3 -0
  26. package/dist/cjs/jose/jws.js.map +1 -0
  27. package/dist/cjs/jose/jwt.js +3 -0
  28. package/dist/cjs/jose/jwt.js.map +1 -0
  29. package/dist/cjs/jose/utils.js +60 -0
  30. package/dist/cjs/jose/utils.js.map +1 -0
  31. package/dist/cjs/local-key-manager.js +521 -0
  32. package/dist/cjs/local-key-manager.js.map +1 -0
  33. package/dist/cjs/package.json +1 -0
  34. package/dist/cjs/primitives/aes-ctr.js +398 -0
  35. package/dist/cjs/primitives/aes-ctr.js.map +1 -0
  36. package/dist/cjs/primitives/aes-gcm.js +425 -0
  37. package/dist/cjs/primitives/aes-gcm.js.map +1 -0
  38. package/dist/cjs/primitives/concat-kdf.js +215 -0
  39. package/dist/cjs/primitives/concat-kdf.js.map +1 -0
  40. package/dist/cjs/primitives/ed25519.js +651 -0
  41. package/dist/cjs/primitives/ed25519.js.map +1 -0
  42. package/dist/cjs/primitives/pbkdf2.js +120 -0
  43. package/dist/cjs/primitives/pbkdf2.js.map +1 -0
  44. package/dist/cjs/primitives/secp256k1.js +958 -0
  45. package/dist/cjs/primitives/secp256k1.js.map +1 -0
  46. package/dist/cjs/primitives/secp256r1.js +959 -0
  47. package/dist/cjs/primitives/secp256r1.js.map +1 -0
  48. package/dist/cjs/primitives/sha256.js +93 -0
  49. package/dist/cjs/primitives/sha256.js.map +1 -0
  50. package/dist/cjs/primitives/x25519.js +498 -0
  51. package/dist/cjs/primitives/x25519.js.map +1 -0
  52. package/dist/cjs/primitives/xchacha20-poly1305.js +340 -0
  53. package/dist/cjs/primitives/xchacha20-poly1305.js.map +1 -0
  54. package/dist/cjs/primitives/xchacha20.js +316 -0
  55. package/dist/cjs/primitives/xchacha20.js.map +1 -0
  56. package/dist/cjs/types/cipher.js +3 -0
  57. package/dist/cjs/types/cipher.js.map +1 -0
  58. package/dist/cjs/types/crypto-api.js +3 -0
  59. package/dist/cjs/types/crypto-api.js.map +1 -0
  60. package/dist/cjs/types/hasher.js +3 -0
  61. package/dist/cjs/types/hasher.js.map +1 -0
  62. package/dist/cjs/types/identifier.js +3 -0
  63. package/dist/cjs/types/identifier.js.map +1 -0
  64. package/dist/cjs/types/key-compressor.js +3 -0
  65. package/dist/cjs/types/key-compressor.js.map +1 -0
  66. package/dist/cjs/types/key-converter.js +3 -0
  67. package/dist/cjs/types/key-converter.js.map +1 -0
  68. package/dist/cjs/types/key-deriver.js +3 -0
  69. package/dist/cjs/types/key-deriver.js.map +1 -0
  70. package/dist/cjs/types/key-generator.js +3 -0
  71. package/dist/cjs/types/key-generator.js.map +1 -0
  72. package/dist/cjs/types/key-io.js +3 -0
  73. package/dist/cjs/types/key-io.js.map +1 -0
  74. package/dist/cjs/types/key-wrapper.js +3 -0
  75. package/dist/cjs/types/key-wrapper.js.map +1 -0
  76. package/dist/cjs/types/params-direct.js +3 -0
  77. package/dist/cjs/types/params-direct.js.map +1 -0
  78. package/dist/cjs/types/params-enclosed.js +3 -0
  79. package/dist/cjs/types/params-enclosed.js.map +1 -0
  80. package/dist/cjs/types/params-kms.js +3 -0
  81. package/dist/cjs/types/params-kms.js.map +1 -0
  82. package/dist/cjs/types/signer.js +3 -0
  83. package/dist/cjs/types/signer.js.map +1 -0
  84. package/dist/cjs/utils.js +173 -0
  85. package/dist/cjs/utils.js.map +1 -0
  86. package/dist/esm/algorithms/aes-ctr.js +124 -0
  87. package/dist/esm/algorithms/aes-ctr.js.map +1 -0
  88. package/dist/esm/algorithms/aes-gcm.js +132 -0
  89. package/dist/esm/algorithms/aes-gcm.js.map +1 -0
  90. package/dist/esm/algorithms/crypto-algorithm.js +6 -0
  91. package/dist/esm/algorithms/crypto-algorithm.js.map +1 -0
  92. package/dist/esm/algorithms/ecdsa.js +237 -0
  93. package/dist/esm/algorithms/ecdsa.js.map +1 -0
  94. package/dist/esm/algorithms/eddsa.js +213 -0
  95. package/dist/esm/algorithms/eddsa.js.map +1 -0
  96. package/dist/esm/algorithms/sha-2.js +57 -0
  97. package/dist/esm/algorithms/sha-2.js.map +1 -0
  98. package/dist/esm/index.js +25 -0
  99. package/dist/esm/index.js.map +1 -0
  100. package/dist/esm/jose/jwe.js +2 -0
  101. package/dist/esm/jose/jwe.js.map +1 -0
  102. package/dist/esm/jose/jwk.js +241 -0
  103. package/dist/esm/jose/jwk.js.map +1 -0
  104. package/dist/esm/jose/jws.js +2 -0
  105. package/dist/esm/jose/jws.js.map +1 -0
  106. package/dist/esm/jose/jwt.js +2 -0
  107. package/dist/esm/jose/jwt.js.map +1 -0
  108. package/dist/esm/jose/utils.js +34 -0
  109. package/dist/esm/jose/utils.js.map +1 -0
  110. package/dist/esm/local-key-manager.js +417 -0
  111. package/dist/esm/local-key-manager.js.map +1 -0
  112. package/dist/esm/primitives/aes-ctr.js +327 -0
  113. package/dist/esm/primitives/aes-ctr.js.map +1 -0
  114. package/dist/esm/primitives/aes-gcm.js +347 -0
  115. package/dist/esm/primitives/aes-gcm.js.map +1 -0
  116. package/dist/esm/primitives/concat-kdf.js +185 -0
  117. package/dist/esm/primitives/concat-kdf.js.map +1 -0
  118. package/dist/esm/primitives/ed25519.js +521 -0
  119. package/dist/esm/primitives/ed25519.js.map +1 -0
  120. package/dist/esm/primitives/pbkdf2.js +78 -0
  121. package/dist/esm/primitives/pbkdf2.js.map +1 -0
  122. package/dist/esm/primitives/secp256k1.js +805 -0
  123. package/dist/esm/primitives/secp256k1.js.map +1 -0
  124. package/dist/esm/primitives/secp256r1.js +806 -0
  125. package/dist/esm/primitives/secp256r1.js.map +1 -0
  126. package/dist/esm/primitives/sha256.js +55 -0
  127. package/dist/esm/primitives/sha256.js.map +1 -0
  128. package/dist/esm/primitives/x25519.js +392 -0
  129. package/dist/esm/primitives/x25519.js.map +1 -0
  130. package/dist/esm/primitives/xchacha20-poly1305.js +270 -0
  131. package/dist/esm/primitives/xchacha20-poly1305.js.map +1 -0
  132. package/dist/esm/primitives/xchacha20.js +246 -0
  133. package/dist/esm/primitives/xchacha20.js.map +1 -0
  134. package/dist/esm/types/cipher.js +2 -0
  135. package/dist/esm/types/cipher.js.map +1 -0
  136. package/dist/esm/types/crypto-api.js +2 -0
  137. package/dist/esm/types/crypto-api.js.map +1 -0
  138. package/dist/esm/types/hasher.js +2 -0
  139. package/dist/esm/types/hasher.js.map +1 -0
  140. package/dist/esm/types/identifier.js +2 -0
  141. package/dist/esm/types/identifier.js.map +1 -0
  142. package/dist/esm/types/key-compressor.js +2 -0
  143. package/dist/esm/types/key-compressor.js.map +1 -0
  144. package/dist/esm/types/key-converter.js +2 -0
  145. package/dist/esm/types/key-converter.js.map +1 -0
  146. package/dist/esm/types/key-deriver.js +2 -0
  147. package/dist/esm/types/key-deriver.js.map +1 -0
  148. package/dist/esm/types/key-generator.js +2 -0
  149. package/dist/esm/types/key-generator.js.map +1 -0
  150. package/dist/esm/types/key-io.js +2 -0
  151. package/dist/esm/types/key-io.js.map +1 -0
  152. package/dist/esm/types/key-wrapper.js +2 -0
  153. package/dist/esm/types/key-wrapper.js.map +1 -0
  154. package/dist/esm/types/params-direct.js +2 -0
  155. package/dist/esm/types/params-direct.js.map +1 -0
  156. package/dist/esm/types/params-enclosed.js +2 -0
  157. package/dist/esm/types/params-enclosed.js.map +1 -0
  158. package/dist/esm/types/params-kms.js +2 -0
  159. package/dist/esm/types/params-kms.js.map +1 -0
  160. package/dist/esm/types/signer.js +2 -0
  161. package/dist/esm/types/signer.js.map +1 -0
  162. package/dist/esm/utils.js +165 -0
  163. package/dist/esm/utils.js.map +1 -0
  164. package/dist/types/algorithms/aes-ctr.d.ts +121 -0
  165. package/dist/types/algorithms/aes-ctr.d.ts.map +1 -0
  166. package/dist/types/algorithms/aes-gcm.d.ts +152 -0
  167. package/dist/types/algorithms/aes-gcm.d.ts.map +1 -0
  168. package/dist/types/algorithms/crypto-algorithm.d.ts +6 -0
  169. package/dist/types/algorithms/crypto-algorithm.d.ts.map +1 -0
  170. package/dist/types/algorithms/ecdsa.d.ts +154 -0
  171. package/dist/types/algorithms/ecdsa.d.ts.map +1 -0
  172. package/dist/types/algorithms/eddsa.d.ts +151 -0
  173. package/dist/types/algorithms/eddsa.d.ts.map +1 -0
  174. package/dist/types/algorithms/sha-2.d.ts +51 -0
  175. package/dist/types/algorithms/sha-2.d.ts.map +1 -0
  176. package/dist/types/index.d.ts +39 -0
  177. package/dist/types/index.d.ts.map +1 -0
  178. package/dist/types/jose/jwe.d.ts +135 -0
  179. package/dist/types/jose/jwe.d.ts.map +1 -0
  180. package/dist/types/jose/jwk.d.ts +439 -0
  181. package/dist/types/jose/jwk.d.ts.map +1 -0
  182. package/dist/types/jose/jws.d.ts +67 -0
  183. package/dist/types/jose/jws.d.ts.map +1 -0
  184. package/dist/types/jose/jwt.d.ts +139 -0
  185. package/dist/types/jose/jwt.d.ts.map +1 -0
  186. package/dist/types/jose/utils.d.ts +14 -0
  187. package/dist/types/jose/utils.d.ts.map +1 -0
  188. package/dist/types/local-key-manager.d.ts +307 -0
  189. package/dist/types/local-key-manager.d.ts.map +1 -0
  190. package/dist/types/primitives/aes-ctr.d.ts +219 -0
  191. package/dist/types/primitives/aes-ctr.d.ts.map +1 -0
  192. package/dist/types/primitives/aes-gcm.d.ts +245 -0
  193. package/dist/types/primitives/aes-gcm.d.ts.map +1 -0
  194. package/dist/types/primitives/concat-kdf.d.ts +160 -0
  195. package/dist/types/primitives/concat-kdf.d.ts.map +1 -0
  196. package/dist/types/primitives/ed25519.d.ts +359 -0
  197. package/dist/types/primitives/ed25519.d.ts.map +1 -0
  198. package/dist/types/primitives/pbkdf2.d.ts +94 -0
  199. package/dist/types/primitives/pbkdf2.d.ts.map +1 -0
  200. package/dist/types/primitives/secp256k1.d.ts +598 -0
  201. package/dist/types/primitives/secp256k1.d.ts.map +1 -0
  202. package/dist/types/primitives/secp256r1.d.ts +599 -0
  203. package/dist/types/primitives/secp256r1.d.ts.map +1 -0
  204. package/dist/types/primitives/sha256.d.ts +42 -0
  205. package/dist/types/primitives/sha256.d.ts.map +1 -0
  206. package/dist/types/primitives/x25519.d.ts +283 -0
  207. package/dist/types/primitives/x25519.d.ts.map +1 -0
  208. package/dist/types/primitives/xchacha20-poly1305.d.ts +210 -0
  209. package/dist/types/primitives/xchacha20-poly1305.d.ts.map +1 -0
  210. package/dist/types/primitives/xchacha20.d.ts +186 -0
  211. package/dist/types/primitives/xchacha20.d.ts.map +1 -0
  212. package/dist/types/types/cipher.d.ts +49 -0
  213. package/dist/types/types/cipher.d.ts.map +1 -0
  214. package/dist/types/types/crypto-api.d.ts +40 -0
  215. package/dist/types/types/crypto-api.d.ts.map +1 -0
  216. package/dist/types/types/hasher.d.ts +33 -0
  217. package/dist/types/types/hasher.d.ts.map +1 -0
  218. package/dist/types/types/identifier.d.ts +16 -0
  219. package/dist/types/types/identifier.d.ts.map +1 -0
  220. package/dist/types/types/key-compressor.d.ts +28 -0
  221. package/dist/types/types/key-compressor.d.ts.map +1 -0
  222. package/dist/types/types/key-converter.d.ts +57 -0
  223. package/dist/types/types/key-converter.d.ts.map +1 -0
  224. package/dist/types/types/key-deriver.d.ts +39 -0
  225. package/dist/types/types/key-deriver.d.ts.map +1 -0
  226. package/dist/types/types/key-generator.d.ts +105 -0
  227. package/dist/types/types/key-generator.d.ts.map +1 -0
  228. package/dist/types/types/key-io.d.ts +37 -0
  229. package/dist/types/types/key-io.d.ts.map +1 -0
  230. package/dist/types/types/key-wrapper.d.ts +38 -0
  231. package/dist/types/types/key-wrapper.d.ts.map +1 -0
  232. package/dist/types/types/params-direct.d.ts +90 -0
  233. package/dist/types/types/params-direct.d.ts.map +1 -0
  234. package/dist/types/types/params-enclosed.d.ts +47 -0
  235. package/dist/types/types/params-enclosed.d.ts.map +1 -0
  236. package/dist/types/types/params-kms.d.ts +131 -0
  237. package/dist/types/types/params-kms.d.ts.map +1 -0
  238. package/dist/types/types/signer.d.ts +46 -0
  239. package/dist/types/types/signer.d.ts.map +1 -0
  240. package/dist/types/utils.d.ts +112 -0
  241. package/dist/types/utils.d.ts.map +1 -0
  242. package/dist/utils.js +7 -0
  243. package/dist/utils.js.map +7 -0
  244. package/package.json +103 -0
  245. package/src/algorithms/aes-ctr.ts +156 -0
  246. package/src/algorithms/aes-gcm.ts +187 -0
  247. package/src/algorithms/crypto-algorithm.ts +4 -0
  248. package/src/algorithms/ecdsa.ts +269 -0
  249. package/src/algorithms/eddsa.ts +243 -0
  250. package/src/algorithms/sha-2.ts +65 -0
  251. package/src/index.ts +42 -0
  252. package/src/jose/jwe.ts +196 -0
  253. package/src/jose/jwk.ts +632 -0
  254. package/src/jose/jws.ts +95 -0
  255. package/src/jose/jwt.ts +147 -0
  256. package/src/jose/utils.ts +34 -0
  257. package/src/local-key-manager.ts +540 -0
  258. package/src/primitives/aes-ctr.ts +352 -0
  259. package/src/primitives/aes-gcm.ts +378 -0
  260. package/src/primitives/concat-kdf.ts +240 -0
  261. package/src/primitives/ed25519.ts +548 -0
  262. package/src/primitives/pbkdf2.ts +122 -0
  263. package/src/primitives/secp256k1.ts +848 -0
  264. package/src/primitives/secp256r1.ts +850 -0
  265. package/src/primitives/sha256.ts +47 -0
  266. package/src/primitives/x25519.ts +403 -0
  267. package/src/primitives/xchacha20-poly1305.ts +274 -0
  268. package/src/primitives/xchacha20.ts +247 -0
  269. package/src/types/cipher.ts +53 -0
  270. package/src/types/crypto-api.ts +56 -0
  271. package/src/types/hasher.ts +32 -0
  272. package/src/types/identifier.ts +16 -0
  273. package/src/types/key-compressor.ts +25 -0
  274. package/src/types/key-converter.ts +53 -0
  275. package/src/types/key-deriver.ts +43 -0
  276. package/src/types/key-generator.ts +119 -0
  277. package/src/types/key-io.ts +42 -0
  278. package/src/types/key-wrapper.ts +42 -0
  279. package/src/types/params-direct.ts +106 -0
  280. package/src/types/params-enclosed.ts +50 -0
  281. package/src/types/params-kms.ts +156 -0
  282. package/src/types/signer.ts +50 -0
  283. package/src/utils.ts +181 -0
@@ -0,0 +1,38 @@
1
+ import type { Jwk } from '../jose/jwk.js';
2
+ /**
3
+ * The `KeyWrapper` interface provides methods for wrapping and unwrapping cryptographic keys.
4
+ * It includes `wrapKey()` for securely encapsulating a key within another key, and `unwrapKey()`
5
+ * for extracting the original key from its wrapped state.
6
+ *
7
+ * This interface is crucial in scenarios where secure key management and exchange are required,
8
+ * ensuring that keys remain protected during transit or storage.
9
+ */
10
+ export interface KeyWrapper<WrapKeyInput, UnwrapKeyInput> {
11
+ /**
12
+ * Wraps a cryptographic key using another key, typically for secure key transmission or storage.
13
+ *
14
+ * @remarks
15
+ * The `wrapKey()` method of the {@link KeyWrapper | `KeyWrapper`} interface secures a
16
+ * cryptographic key by encapsulating it within another key, producing a wrapped key represented
17
+ * as a `Uint8Array`.
18
+ *
19
+ * @param params - The parameters for the key wrapping operation.
20
+ *
21
+ * @returns A Promise resolving to the wrapped key as a `Uint8Array`.
22
+ */
23
+ wrapKey(params: WrapKeyInput): Promise<Uint8Array>;
24
+ /**
25
+ * Unwraps a previously wrapped cryptographic key, restoring it to its original form.
26
+ *
27
+ * @remarks
28
+ * The `unwrapKey()` method of the {@link KeyWrapper | `KeyWrapper`} interface reverses the
29
+ * wrapping process, extracting the original key from its wrapped state, typically for use in
30
+ * cryptographic operations.
31
+ *
32
+ * @param params - The parameters for the key unwrapping operation.
33
+ *
34
+ * @returns A Promise resolving to the unwrapped key in a cryptographic format, usually JWK.
35
+ */
36
+ unwrapKey(params: UnwrapKeyInput): Promise<Jwk>;
37
+ }
38
+ //# sourceMappingURL=key-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-wrapper.d.ts","sourceRoot":"","sources":["../../../src/types/key-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CACzB,YAAY,EACZ,cAAc;IAEd;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEnD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACjD"}
@@ -0,0 +1,90 @@
1
+ import type { Jwk } from '../jose/jwk.js';
2
+ import type { AlgorithmIdentifier } from './identifier.js';
3
+ /**
4
+ * Parameters for computing a public key.
5
+ */
6
+ export interface ComputePublicKeyParams extends GetPublicKeyParams {
7
+ }
8
+ /**
9
+ * Parameters for decrypting data.
10
+ */
11
+ export interface DecryptParams {
12
+ /** A {@link Jwk} containing the key to be used for decryption. */
13
+ key: Jwk;
14
+ /** Data to be decrypted. */
15
+ data: Uint8Array;
16
+ }
17
+ /**
18
+ * Parameters for deriving bits.
19
+ */
20
+ export interface DeriveBitsParams {
21
+ /** A {@link Jwk} containing the base key to be used for derivation. */
22
+ key: Jwk;
23
+ /**
24
+ * The number of bits to derive. To be compatible with all browsers, the number should be a
25
+ * multiple of 8.
26
+ */
27
+ length: number;
28
+ }
29
+ /**
30
+ * Parameters for deriving a key.
31
+ */
32
+ export interface DeriveKeyParams {
33
+ /** A {@link Jwk} containing the base key to be used for derivation. */
34
+ key: Jwk;
35
+ /** An object defining the algorithm-specific parameters for the derived key. */
36
+ derivedKeyParams: unknown;
37
+ }
38
+ /**
39
+ * Parameters for computing a hash digest.
40
+ */
41
+ export interface DigestParams {
42
+ /** The algorithm identifier. */
43
+ algorithm: AlgorithmIdentifier;
44
+ /** Data to be digested. */
45
+ data: Uint8Array;
46
+ }
47
+ /**
48
+ * Parameters for encrypting data.
49
+ */
50
+ export interface EncryptParams {
51
+ /** A {@link Jwk} containing the key to be used for encryption. */
52
+ key: Jwk;
53
+ /** Data to be encrypted. */
54
+ data: Uint8Array;
55
+ }
56
+ /**
57
+ * Parameters for generating a key.
58
+ */
59
+ export interface GenerateKeyParams {
60
+ /** The algorithm identifier. */
61
+ algorithm: AlgorithmIdentifier;
62
+ }
63
+ /**
64
+ * Parameters for retrieving a public key.
65
+ */
66
+ export interface GetPublicKeyParams {
67
+ /** A {@link Jwk} containing the key from which to derive the public key. */
68
+ key: Jwk;
69
+ }
70
+ /**
71
+ * Parameters for signing data.
72
+ */
73
+ export interface SignParams {
74
+ /** A {@link Jwk} containing the key used for signing. */
75
+ key: Jwk;
76
+ /** Data to be signed. */
77
+ data: Uint8Array;
78
+ }
79
+ /**
80
+ * Parameters for verifying a signature.
81
+ */
82
+ export interface VerifyParams {
83
+ /** A {@link Jwk} containing the key used for verification. */
84
+ key: Jwk;
85
+ /** The signature to verify. */
86
+ signature: Uint8Array;
87
+ /** The data associated with the signature. */
88
+ data: Uint8Array;
89
+ }
90
+ //# sourceMappingURL=params-direct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-direct.d.ts","sourceRoot":"","sources":["../../../src/types/params-direct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;CAAI;AAEtE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,GAAG,EAAE,GAAG,CAAC;IAET,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,GAAG,EAAE,GAAG,CAAC;IAET;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,GAAG,EAAE,GAAG,CAAC;IAET,gFAAgF;IAChF,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,SAAS,EAAE,mBAAmB,CAAC;IAE/B,2BAA2B;IAC3B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,GAAG,EAAE,GAAG,CAAC;IAET,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4EAA4E;IAC5E,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yDAAyD;IACzD,GAAG,EAAE,GAAG,CAAC;IAET,yBAAyB;IACzB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,GAAG,EAAE,GAAG,CAAC;IAET,+BAA+B;IAC/B,SAAS,EAAE,UAAU,CAAC;IAEtB,8CAA8C;IAC9C,IAAI,EAAE,UAAU,CAAC;CAClB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Parameters for enclosed decryption operations.
3
+ *
4
+ * Note: This interface is intended to be used with a closure that captures the key and
5
+ * algorithm-specific parameters so that arbitrary data can be decrypted without exposing the key or
6
+ * parameters to the caller.
7
+ */
8
+ export interface EnclosedDecryptParams {
9
+ /** Data to be decrypted. */
10
+ data: Uint8Array;
11
+ }
12
+ /**
13
+ * Parameters for enclosed encryption operations.
14
+ *
15
+ * Note: This interface is intended to be used with a closure that captures the key and
16
+ * algorithm-specific parameters so that arbitrary data can be encrypted without exposing the key or
17
+ * parameters to the caller.
18
+ */
19
+ export interface EnclosedEncryptParams {
20
+ /** Data to be encrypted. */
21
+ data: Uint8Array;
22
+ }
23
+ /**
24
+ * Parameters for enclosed signing operations.
25
+ *
26
+ * Note: This interface is intended to be used with a closure that captures the key and
27
+ * algorithm-specific parameters so that arbitrary data can be signed without exposing the key or
28
+ * parameters to the caller.
29
+ */
30
+ export interface EnclosedSignParams {
31
+ /** Data to be signed. */
32
+ data: Uint8Array;
33
+ }
34
+ /**
35
+ * Parameters for enclosed verification operations.
36
+ *
37
+ * Note: This interface is intended to be used with a closure that captures the key and
38
+ * algorithm-specific parameters so that signatures of arbitrary data can be verified without
39
+ * exposing the key or parameters to the caller.
40
+ */
41
+ export interface EnclosedVerifyParams {
42
+ /** Signature to be verified. */
43
+ signature: Uint8Array;
44
+ /** Data associated with the signature. */
45
+ data: Uint8Array;
46
+ }
47
+ //# sourceMappingURL=params-enclosed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-enclosed.d.ts","sourceRoot":"","sources":["../../../src/types/params-enclosed.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,SAAS,EAAE,UAAU,CAAC;IAEtB,0CAA0C;IAC1C,IAAI,EAAE,UAAU,CAAC;CAClB"}
@@ -0,0 +1,131 @@
1
+ import type { Jwk } from '../jose/jwk.js';
2
+ import type { AlgorithmIdentifier, KeyIdentifier } from './identifier.js';
3
+ /**
4
+ * Parameters for KMS-based decryption operations. Intended for use with a Key Management System.
5
+ */
6
+ export interface KmsDecryptParams {
7
+ /** Identifier for the private key in the KMS. */
8
+ keyUri: KeyIdentifier;
9
+ /** Data to be decrypted. */
10
+ data: Uint8Array;
11
+ }
12
+ /**
13
+ * Parameters for KMS-based derivation of bits. Intended for use with a Key Management System.
14
+ */
15
+ export interface KmsDeriveBitsParams {
16
+ /** Identifier for the key used in derivation in the KMS. */
17
+ keyUri: KeyIdentifier;
18
+ /**
19
+ * The number of bits to derive. To be compatible with all browsers, the number should be a
20
+ * multiple of 8.
21
+ */
22
+ length: number;
23
+ }
24
+ /**
25
+ * Parameters for KMS-based key derivation. Intended for use with a Key Management System.
26
+ */
27
+ export interface KmsDeriveKeyParams {
28
+ /** Identifier for the base key used in derivation in the KMS. */
29
+ keyUri: KeyIdentifier;
30
+ /** An object defining the algorithm-specific parameters for the derived key. */
31
+ derivedKeyParams: unknown;
32
+ }
33
+ /**
34
+ * Parameters for KMS-based digest computation. Intended for use with a Key Management System.
35
+ */
36
+ export interface KmsDigestParams {
37
+ /** The algorithm identifier. */
38
+ algorithm: AlgorithmIdentifier;
39
+ /** Data to be digested. */
40
+ data: Uint8Array;
41
+ }
42
+ /**
43
+ * Parameters for KMS-based encryption operations. Intended for use with a Key Management System.
44
+ */
45
+ export interface KmsEncryptParams {
46
+ /** Identifier for the private key in the KMS. */
47
+ keyUri: KeyIdentifier;
48
+ /** Data to be encrypted. */
49
+ data: Uint8Array;
50
+ }
51
+ /**
52
+ * Parameters for exporting a key from a KMS. Intended for use with a Key Management System.
53
+ */
54
+ export interface KmsExportKeyParams {
55
+ /** Identifier for the private key to be exported from the KMS. */
56
+ keyUri: KeyIdentifier;
57
+ }
58
+ /**
59
+ * Parameters for generating a key in a KMS. Intended for use with a Key Management System.
60
+ */
61
+ export interface KmsGenerateKeyParams {
62
+ /** The algorithm identifier. */
63
+ algorithm: AlgorithmIdentifier;
64
+ }
65
+ /**
66
+ * Parameters for computing the Key URI of a public key. Intended for use with a Key Management
67
+ * System.
68
+ */
69
+ export interface KmsGetKeyUriParams {
70
+ /** A {@link Jwk} containing the public key for which the Key URI will be computed. */
71
+ key: Jwk;
72
+ }
73
+ /**
74
+ * Parameters for retrieving a public key from a KMS using the private key's URI. Intended for use
75
+ * with a Key Management System.
76
+ */
77
+ export interface KmsGetPublicKeyParams {
78
+ /** Identifier for the private key in the KMS. */
79
+ keyUri: KeyIdentifier;
80
+ }
81
+ /**
82
+ * Parameters for importing a private key into a KMS. Intended for use with a Key Management System.
83
+ */
84
+ export interface KmsImportKeyParams {
85
+ /** A {@link Jwk} containing the key to be imported into the KMS. */
86
+ key: Jwk;
87
+ }
88
+ /**
89
+ * Parameters for KMS-based signing operations. Intended for use with a Key Management System.
90
+ */
91
+ export interface KmsSignParams {
92
+ /** Identifier for the signing private key in the KMS. */
93
+ keyUri: KeyIdentifier;
94
+ /** Data to be signed. */
95
+ data: Uint8Array;
96
+ }
97
+ /**
98
+ * Parameters for verifying a signature using a key from a KMS. Intended for use with a Key
99
+ * Management System.
100
+ */
101
+ export interface KmsVerifyParams {
102
+ /** A {@link Jwk} containing the public key to be used for verification. */
103
+ key: Jwk;
104
+ /** The signature to verify. */
105
+ signature: Uint8Array;
106
+ /** The data associated with the signature. */
107
+ data: Uint8Array;
108
+ }
109
+ /**
110
+ * Parameters for wrapping a key using a KMS. Intended for use with a Key Management System.
111
+ */
112
+ export interface KmsWrapKeyParams {
113
+ /** A {@link Jwk} containing the private key to be wrapped. */
114
+ key: Jwk;
115
+ /** Identifier for the private key in the KMS to be used for the wrapping operation. */
116
+ wrappingKeyId: KeyIdentifier;
117
+ /** Algorithm to be used for wrapping. */
118
+ wrapAlgorithm: AlgorithmIdentifier;
119
+ }
120
+ /**
121
+ * Parameters for unwrapping a key using a KMS. Intended for use with a Key Management System.
122
+ */
123
+ export interface KmsUnwrapKeyParams {
124
+ /** The wrapped key in a byte array. */
125
+ wrappedKey: Uint8Array;
126
+ /** Identifier for the private key in the KMS to be used for the unwrapping operation. */
127
+ unwrappingKeyId: KeyIdentifier;
128
+ /** Algorithm to be used for unwrapping. */
129
+ unwrapAlgorithm: AlgorithmIdentifier;
130
+ }
131
+ //# sourceMappingURL=params-kms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-kms.d.ts","sourceRoot":"","sources":["../../../src/types/params-kms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,MAAM,EAAE,aAAa,CAAC;IAEtB,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,MAAM,EAAE,aAAa,CAAC;IAEtB,gFAAgF;IAChF,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,SAAS,EAAE,mBAAmB,CAAC;IAE/B,2BAA2B;IAC3B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,MAAM,EAAE,aAAa,CAAC;IAEtB,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,MAAM,EAAE,aAAa,CAAC;IAEtB,yBAAyB;IACzB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,GAAG,EAAE,GAAG,CAAC;IAET,+BAA+B;IAC/B,SAAS,EAAE,UAAU,CAAC;IAEtB,8CAA8C;IAC9C,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,GAAG,EAAE,GAAG,CAAC;IAET,uFAAuF;IACvF,aAAa,EAAE,aAAa,CAAC;IAE7B,yCAAyC;IACzC,aAAa,EAAE,mBAAmB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,UAAU,EAAE,UAAU,CAAC;IAEvB,yFAAyF;IACzF,eAAe,EAAE,aAAa,CAAC;IAE/B,2CAA2C;IAC3C,eAAe,EAAE,mBAAmB,CAAC;CACtC"}
@@ -0,0 +1,46 @@
1
+ import type { EnclosedSignParams, EnclosedVerifyParams } from './params-enclosed.js';
2
+ /**
3
+ * The `Signer` interface provides methods for signing data and verifying signatures.
4
+ *
5
+ * It includes `sign()` for creating signatures and `verify()` for confirming the validity of
6
+ * signatures. The interface is designed to be flexible, accommodating various signing algorithms
7
+ * and their unique parameters.
8
+ *
9
+ * It defaults to using {@link EnclosedSignParams | `EnclosedSignParams`} and
10
+ * {@link EnclosedVerifyParams | `EnclosedVerifyParams`}, which are intended to be used with a
11
+ * closure that captures the key and algorithm-specific parameters so that arbitrary data can be
12
+ * signed and verified without exposing the key or parameters to the caller. However, the
13
+ * interface can be extended to support other parameter types, such as {@link SignParams |
14
+ * `SignParams`} and {@link VerifyParams | `VerifyParams`}, which are intended to be used when
15
+ * the key and algorithm-specific parameters are known to the caller.
16
+ */
17
+ export interface Signer<SignInput = EnclosedSignParams, VerifyInput = EnclosedVerifyParams> {
18
+ /**
19
+ * Signs the provided data.
20
+ *
21
+ * @remarks
22
+ * The `sign()` method of the {@link Signer | `Signer`} interface generates a digital signature
23
+ * for the given data using a cryptographic key. This signature can be used to verify the data's
24
+ * authenticity and integrity.
25
+ *
26
+ * @param params - The parameters for the signing operation.
27
+ *
28
+ * @returns A Promise resolving to the digital signature as a `Uint8Array`.
29
+ */
30
+ sign(params: SignInput): Promise<Uint8Array>;
31
+ /**
32
+ * Verifies a digital signature associated the provided data.
33
+ *
34
+ * @remarks
35
+ * The `verify()` method of the {@link Signer | `Signer`} interface checks the validity of a
36
+ * digital signature against the original data and a cryptographic key. It confirms whether the
37
+ * signature was created by the holder of the corresponding private key and that the data has not
38
+ * been tampered with.
39
+ *
40
+ * @param params - The parameters for the verification operation.
41
+ *
42
+ * @returns A Promise resolving to a boolean indicating whether the signature is valid.
43
+ */
44
+ verify(params: VerifyInput): Promise<boolean>;
45
+ }
46
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/types/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,MAAM,CACrB,SAAS,GAAG,kBAAkB,EAC9B,WAAW,GAAG,oBAAoB;IAElC;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE7C;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/C"}
@@ -0,0 +1,112 @@
1
+ import type { Jwk } from './jose/jwk.js';
2
+ /**
3
+ * A collection of cryptographic utility methods.
4
+ */
5
+ export declare class CryptoUtils {
6
+ /**
7
+ * Determines the JOSE algorithm identifier of the digital signature algorithm based on the `alg` or
8
+ * `crv` property of a {@link Jwk | JWK}.
9
+ *
10
+ * If the `alg` property is present, its value takes precedence and is returned. Otherwise, the
11
+ * `crv` property is used to determine the algorithm.
12
+ *
13
+ * @memberof CryptoUtils
14
+ * @see {@link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | JOSE Algorithms}
15
+ * @see {@link https://datatracker.ietf.org/doc/draft-ietf-jose-fully-specified-algorithms/ | Fully-Specified Algorithms for JOSE and COSE}
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const publicKey: Jwk = {
20
+ * "kty": "OKP",
21
+ * "crv": "Ed25519",
22
+ * "x": "FEJG7OakZi500EydXxuE8uMc8uaAzEJkmQeG8khXANw"
23
+ * }
24
+ * const algorithm = getJoseSignatureAlgorithmFromPublicKey(publicKey);
25
+ * console.log(algorithm); // Output: "EdDSA"
26
+ * ```
27
+ * @param publicKey - A JWK containing the `alg` and/or `crv` properties.
28
+ * @returns The name of the algorithm associated with the key.
29
+ * @throws Error if the algorithm cannot be determined from the provided input.
30
+ */
31
+ static getJoseSignatureAlgorithmFromPublicKey(publicKey: Jwk): string;
32
+ /**
33
+ * Generates secure pseudorandom values of the specified length using
34
+ * `crypto.getRandomValues`, which defers to the operating system.
35
+ *
36
+ * @memberof CryptoUtils
37
+ * @remarks
38
+ * This function is a wrapper around `randomBytes` from the '@noble/hashes'
39
+ * package. It's designed to be cryptographically strong, suitable for
40
+ * generating initialization vectors, nonces, and other random values.
41
+ *
42
+ * @see {@link https://www.npmjs.com/package/@noble/hashes | @noble/hashes on NPM} for more
43
+ * information about the underlying implementation.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const bytes = randomBytes(32); // Generates 32 random bytes
48
+ * ```
49
+ *
50
+ * @param bytesLength - The number of bytes to generate.
51
+ * @returns A Uint8Array containing the generated random bytes.
52
+ */
53
+ static randomBytes(bytesLength: number): Uint8Array;
54
+ /**
55
+ * Generates a UUID (Universally Unique Identifier) using a
56
+ * cryptographically strong random number generator following
57
+ * the version 4 format, as specified in RFC 4122.
58
+ *
59
+ * A version 4 UUID is a randomly generated UUID. The 13th character
60
+ * is set to '4' to denote version 4, and the 17th character is one
61
+ * of '8', '9', 'A', or 'B' to comply with the variant 1 format of
62
+ * UUIDs (the high bits are set to '10').
63
+ *
64
+ * The UUID is a 36 character string, including hyphens, and looks like this:
65
+ * xxxxxxxx-xxxx-4xxx-axxx-xxxxxxxxxxxx
66
+ *
67
+ * Note that while UUIDs are not guaranteed to be unique, they are
68
+ * practically unique" given the large number of possible UUIDs and
69
+ * the randomness of generation.
70
+ * @memberof CryptoUtils
71
+ * @example
72
+ * ```ts
73
+ * const uuid = randomUuid();
74
+ * console.log(uuid); // Outputs a version 4 UUID, e.g., '123e4567-e89b-12d3-a456-426655440000'
75
+ * ```
76
+ *
77
+ * @returns A string containing a randomly generated, 36 character long v4 UUID.
78
+ */
79
+ static randomUuid(): string;
80
+ /**
81
+ * Generates a secure random PIN (Personal Identification Number) of a
82
+ * specified length.
83
+ *
84
+ * This function ensures that the generated PIN is cryptographically secure and
85
+ * uniformly distributed by using rejection sampling. It repeatedly generates
86
+ * random numbers until it gets one in the desired range [0, max]. This avoids
87
+ * bias introduced by simply taking the modulus or truncating the number.
88
+ *
89
+ * Note: The function can generate PINs of 3 to 10 digits in length.
90
+ * Any request for a PIN outside this range will result in an error.
91
+ *
92
+ * Example usage:
93
+ *
94
+ * ```ts
95
+ * const pin = randomPin({ length: 4 });
96
+ * console.log(pin); // Outputs a 4-digit PIN, e.g., "0231"
97
+ * ```
98
+ * @memberof CryptoUtils
99
+ * @param options - The options object containing the desired length of the generated PIN.
100
+ * @param options.length - The desired length of the generated PIN. The value should be
101
+ * an integer between 3 and 8 inclusive.
102
+ *
103
+ * @returns A string representing the generated PIN. The PIN will be zero-padded
104
+ * to match the specified length, if necessary.
105
+ *
106
+ * @throws Will throw an error if the requested PIN length is less than 3 or greater than 8.
107
+ */
108
+ static randomPin({ length }: {
109
+ length: number;
110
+ }): string;
111
+ }
112
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKzC;;GAEG;AACH,qBAAa,WAAW;IAEtB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,sCAAsC,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM;IA2BrE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAInD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;IAO3B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;CAiCzD"}
package/dist/utils.js ADDED
@@ -0,0 +1,7 @@
1
+ var n=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var d=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var l={}.toString;function s(r=32){if(n&&typeof n.getRandomValues=="function")return n.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}var f=class r{static getJoseSignatureAlgorithmFromPublicKey(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}static randomBytes(t){return s(t)}static randomUuid(){return n.randomUUID()}static randomPin({length:t}){if(3>t||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,o;if(t<=6){let i=Math.pow(10,t);do{let c=r.randomBytes(Math.ceil(t/2));o=new DataView(c.buffer).getUint16(0,!1)%i}while(o>e)}else{let i=Math.pow(10,10);do{let c=r.randomBytes(4);o=new DataView(c.buffer).getUint32(0,!1)%i}while(o>e)}return o.toString().padStart(t,"0")}};export{f as CryptoUtils};
2
+ /*! Bundled license information:
3
+
4
+ @noble/hashes/esm/utils.js:
5
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
6
+ */
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/src/crypto.ts", "../../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/src/utils.ts", "../src/utils.ts"],
4
+ "sourcesContent": ["// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// See utils.ts for details.\ndeclare const globalThis: Record<string, any> | undefined;\nexport const crypto =\n typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n", "/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { bytes as abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a: unknown): a is Uint8Array {\n return (\n a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')\n );\n}\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n// Cast array to different type\nexport const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr: TypedArray) =>\n new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n\n// Cast array to view\nexport const createView = (arr: TypedArray) =>\n new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word: number, shift: number) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word: number, shift: number) =>\n (word << shift) | ((word >>> (32 - shift)) >>> 0);\n\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nexport const byteSwap = (word: number) =>\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n: number) => n : (n: number) => byteSwap(n);\n\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr: Uint32Array) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 } as const;\nfunction asciiToBase16(char: number): number | undefined {\n if (char >= asciis._0 && char <= asciis._9) return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F) return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f) return char - (asciis._a - 10);\n return;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => {};\n\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters: number, tick: number, cb: (i: number) => void) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n// For runtime check if class implements interface\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\nconst toStr = {}.toString;\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\nexport type CHash = ReturnType<typeof wrapConstructor>;\n\nexport function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>) {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "import type { Jwk } from './jose/jwk.js';\n\nimport { crypto } from '@noble/hashes/crypto';\nimport { randomBytes as nobleRandomBytes } from '@noble/hashes/utils';\n\n/**\n * A collection of cryptographic utility methods.\n */\nexport class CryptoUtils {\n\n /**\n * Determines the JOSE algorithm identifier of the digital signature algorithm based on the `alg` or\n * `crv` property of a {@link Jwk | JWK}.\n *\n * If the `alg` property is present, its value takes precedence and is returned. Otherwise, the\n * `crv` property is used to determine the algorithm.\n *\n * @memberof CryptoUtils\n * @see {@link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | JOSE Algorithms}\n * @see {@link https://datatracker.ietf.org/doc/draft-ietf-jose-fully-specified-algorithms/ | Fully-Specified Algorithms for JOSE and COSE}\n *\n * @example\n * ```ts\n * const publicKey: Jwk = {\n * \"kty\": \"OKP\",\n * \"crv\": \"Ed25519\",\n * \"x\": \"FEJG7OakZi500EydXxuE8uMc8uaAzEJkmQeG8khXANw\"\n * }\n * const algorithm = getJoseSignatureAlgorithmFromPublicKey(publicKey);\n * console.log(algorithm); // Output: \"EdDSA\"\n * ```\n * @param publicKey - A JWK containing the `alg` and/or `crv` properties.\n * @returns The name of the algorithm associated with the key.\n * @throws Error if the algorithm cannot be determined from the provided input.\n */\n static getJoseSignatureAlgorithmFromPublicKey(publicKey: Jwk): string {\n const curveToJoseAlgorithm: Record<string, string> = {\n 'Ed25519' : 'EdDSA',\n 'P-256' : 'ES256',\n 'P-384' : 'ES384',\n 'P-521' : 'ES512',\n 'secp256k1' : 'ES256K',\n };\n\n // If the key contains an `alg` property that matches a JOSE registered algorithm identifier,\n // return its value.\n if (publicKey.alg && Object.values(curveToJoseAlgorithm).includes(publicKey.alg)) {\n return publicKey.alg;\n }\n\n // If the key contains a `crv` property, return the corresponding algorithm.\n if (publicKey.crv && Object.keys(curveToJoseAlgorithm).includes(publicKey.crv)) {\n return curveToJoseAlgorithm[publicKey.crv];\n }\n\n throw new Error(\n `Unable to determine algorithm based on provided input: alg=${publicKey.alg}, crv=${publicKey.crv}. ` +\n `Supported 'alg' values: ${Object.values(curveToJoseAlgorithm).join(', ')}. ` +\n `Supported 'crv' values: ${Object.keys(curveToJoseAlgorithm).join(', ')}.`\n );\n }\n\n /**\n * Generates secure pseudorandom values of the specified length using\n * `crypto.getRandomValues`, which defers to the operating system.\n *\n * @memberof CryptoUtils\n * @remarks\n * This function is a wrapper around `randomBytes` from the '@noble/hashes'\n * package. It's designed to be cryptographically strong, suitable for\n * generating initialization vectors, nonces, and other random values.\n *\n * @see {@link https://www.npmjs.com/package/@noble/hashes | @noble/hashes on NPM} for more\n * information about the underlying implementation.\n *\n * @example\n * ```ts\n * const bytes = randomBytes(32); // Generates 32 random bytes\n * ```\n *\n * @param bytesLength - The number of bytes to generate.\n * @returns A Uint8Array containing the generated random bytes.\n */\n static randomBytes(bytesLength: number): Uint8Array {\n return nobleRandomBytes(bytesLength);\n }\n\n /**\n * Generates a UUID (Universally Unique Identifier) using a\n * cryptographically strong random number generator following\n * the version 4 format, as specified in RFC 4122.\n *\n * A version 4 UUID is a randomly generated UUID. The 13th character\n * is set to '4' to denote version 4, and the 17th character is one\n * of '8', '9', 'A', or 'B' to comply with the variant 1 format of\n * UUIDs (the high bits are set to '10').\n *\n * The UUID is a 36 character string, including hyphens, and looks like this:\n * xxxxxxxx-xxxx-4xxx-axxx-xxxxxxxxxxxx\n *\n * Note that while UUIDs are not guaranteed to be unique, they are\n * practically unique\" given the large number of possible UUIDs and\n * the randomness of generation.\n * @memberof CryptoUtils\n * @example\n * ```ts\n * const uuid = randomUuid();\n * console.log(uuid); // Outputs a version 4 UUID, e.g., '123e4567-e89b-12d3-a456-426655440000'\n * ```\n *\n * @returns A string containing a randomly generated, 36 character long v4 UUID.\n */\n static randomUuid(): string {\n const uuid = crypto.randomUUID();\n\n return uuid;\n }\n\n\n /**\n * Generates a secure random PIN (Personal Identification Number) of a\n * specified length.\n *\n * This function ensures that the generated PIN is cryptographically secure and\n * uniformly distributed by using rejection sampling. It repeatedly generates\n * random numbers until it gets one in the desired range [0, max]. This avoids\n * bias introduced by simply taking the modulus or truncating the number.\n *\n * Note: The function can generate PINs of 3 to 10 digits in length.\n * Any request for a PIN outside this range will result in an error.\n *\n * Example usage:\n *\n * ```ts\n * const pin = randomPin({ length: 4 });\n * console.log(pin); // Outputs a 4-digit PIN, e.g., \"0231\"\n * ```\n * @memberof CryptoUtils\n * @param options - The options object containing the desired length of the generated PIN.\n * @param options.length - The desired length of the generated PIN. The value should be\n * an integer between 3 and 8 inclusive.\n *\n * @returns A string representing the generated PIN. The PIN will be zero-padded\n * to match the specified length, if necessary.\n *\n * @throws Will throw an error if the requested PIN length is less than 3 or greater than 8.\n */\n static randomPin({ length }: { length: number }): string {\n if (3 > length || length > 10) {\n throw new Error('randomPin() can securely generate a PIN between 3 to 10 digits.');\n }\n\n const max = Math.pow(10, length) - 1;\n\n let pin;\n\n if (length <= 6) {\n const rejectionRange = Math.pow(10, length);\n do {\n // Adjust the byte generation based on length.\n const randomBuffer = CryptoUtils.randomBytes(Math.ceil(length / 2) ); // 2 digits per byte.\n const view = new DataView(randomBuffer.buffer);\n // Convert the buffer to integer and take modulus based on length.\n pin = view.getUint16(0, false) % rejectionRange;\n } while (pin > max);\n } else {\n const rejectionRange = Math.pow(10, 10); // For max 10 digit number.\n do {\n // Generates 4 random bytes.\n const randomBuffer = CryptoUtils.randomBytes(4);\n // Create a DataView to read from the randomBuffer.\n const view = new DataView(randomBuffer.buffer);\n // Transform bytes to number (big endian).\n pin = view.getUint32(0, false) % rejectionRange;\n } while (pin > max); // Reject if the number is outside the desired range.\n }\n\n // Pad the PIN with leading zeros to the desired length.\n return pin.toString().padStart(length, '0');\n }\n}\n"],
5
+ "mappings": "AAGO,IAAMA,EACX,OAAO,YAAe,UAAY,WAAY,WAAa,WAAW,OAAS,OCkC1E,IAAMC,EAAO,IAAI,WAAW,IAAI,YAAY,CAAC,SAAU,CAAC,EAAE,MAAM,EAAE,CAAC,IAAM,GAoKhF,IAAMC,EAAQ,CAAA,EAAG,SAgDX,SAAUC,EAAYC,EAAc,GAAE,CAC1C,GAAIC,GAAU,OAAOA,EAAO,iBAAoB,WAC9C,OAAOA,EAAO,gBAAgB,IAAI,WAAWD,CAAW,CAAC,EAE3D,MAAM,IAAI,MAAM,wCAAwC,CAC1D,CCvPO,IAAME,EAAN,MAAMC,CAAY,CA2BvB,OAAO,uCAAuCC,EAAwB,CACpE,IAAMC,EAA+C,CACnD,QAAc,QACd,QAAc,QACd,QAAc,QACd,QAAc,QACd,UAAc,QAChB,EAIA,GAAID,EAAU,KAAO,OAAO,OAAOC,CAAoB,EAAE,SAASD,EAAU,GAAG,EAC7E,OAAOA,EAAU,IAInB,GAAIA,EAAU,KAAO,OAAO,KAAKC,CAAoB,EAAE,SAASD,EAAU,GAAG,EAC3E,OAAOC,EAAqBD,EAAU,GAAG,EAG3C,MAAM,IAAI,MACR,8DAA8DA,EAAU,GAAG,SAASA,EAAU,GAAG,6BACtE,OAAO,OAAOC,CAAoB,EAAE,KAAK,IAAI,CAAC,6BAC9C,OAAO,KAAKA,CAAoB,EAAE,KAAK,IAAI,CAAC,GACzE,CACF,CAuBA,OAAO,YAAYC,EAAiC,CAClD,OAAOC,EAAiBD,CAAW,CACrC,CA2BA,OAAO,YAAqB,CAG1B,OAFaE,EAAO,WAAW,CAGjC,CA+BA,OAAO,UAAU,CAAE,OAAAC,CAAO,EAA+B,CACvD,GAAI,EAAIA,GAAUA,EAAS,GACzB,MAAM,IAAI,MAAM,iEAAiE,EAGnF,IAAMC,EAAM,KAAK,IAAI,GAAID,CAAM,EAAI,EAE/BE,EAEJ,GAAIF,GAAU,EAAG,CACf,IAAMG,EAAiB,KAAK,IAAI,GAAIH,CAAM,EAC1C,EAAG,CAED,IAAMI,EAAeV,EAAY,YAAY,KAAK,KAAKM,EAAS,CAAC,CAAE,EAGnEE,EAFa,IAAI,SAASE,EAAa,MAAM,EAElC,UAAU,EAAG,EAAK,EAAID,CACnC,OAASD,EAAMD,EACjB,KAAO,CACL,IAAME,EAAiB,KAAK,IAAI,GAAI,EAAE,EACtC,EAAG,CAED,IAAMC,EAAeV,EAAY,YAAY,CAAC,EAI9CQ,EAFa,IAAI,SAASE,EAAa,MAAM,EAElC,UAAU,EAAG,EAAK,EAAID,CACnC,OAASD,EAAMD,EACjB,CAGA,OAAOC,EAAI,SAAS,EAAE,SAASF,EAAQ,GAAG,CAC5C,CACF",
6
+ "names": ["crypto", "isLE", "toStr", "randomBytes", "bytesLength", "crypto", "CryptoUtils", "_CryptoUtils", "publicKey", "curveToJoseAlgorithm", "bytesLength", "randomBytes", "crypto", "length", "max", "pin", "rejectionRange", "randomBuffer"]
7
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@enbox/crypto",
3
+ "version": "0.0.1",
4
+ "description": "Web5 cryptographic library",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "scripts": {
10
+ "clean": "rimraf dist tests/compiled",
11
+ "build:esm": "rimraf dist/esm dist/types && pnpm tsc -p tsconfig.json",
12
+ "build:cjs": "rimraf dist/cjs && pnpm tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json",
13
+ "build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
14
+ "build:tests:node": "rimraf tests/compiled && pnpm tsc -p tests/tsconfig.json",
15
+ "build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
16
+ "build": "pnpm clean && pnpm build:esm && pnpm build:cjs && pnpm build:browser",
17
+ "lint": "eslint . --max-warnings 0",
18
+ "lint:fix": "eslint . --fix",
19
+ "test:node": "pnpm build:tests:node && pnpm c8 mocha",
20
+ "test:browser": "pnpm build:tests:browser && web-test-runner"
21
+ },
22
+ "homepage": "https://github.com/enboxorg/enbox/tree/main/packages/crypto#readme",
23
+ "bugs": "https://github.com/enboxorg/enbox/issues",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/enboxorg/enbox.git",
27
+ "directory": "packages/crypto"
28
+ },
29
+ "license": "Apache-2.0",
30
+ "contributors": [
31
+ {
32
+ "name": "Daniel Buchner",
33
+ "url": "https://github.com/csuwildcat"
34
+ },
35
+ {
36
+ "name": "Frank Hinek",
37
+ "url": "https://github.com/frankhinek"
38
+ },
39
+ {
40
+ "name": "Moe Jangda",
41
+ "url": "https://github.com/mistermoe"
42
+ }
43
+ ],
44
+ "files": [
45
+ "dist",
46
+ "src"
47
+ ],
48
+ "exports": {
49
+ ".": {
50
+ "types": "./dist/types/index.d.ts",
51
+ "import": "./dist/esm/index.js",
52
+ "require": "./dist/cjs/index.js"
53
+ }
54
+ },
55
+ "browser": {
56
+ "node:crypto": false
57
+ },
58
+ "react-native": "./dist/esm/index.js",
59
+ "keywords": [
60
+ "cryptography",
61
+ "ed25519",
62
+ "secp256k1",
63
+ "web5"
64
+ ],
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "engines": {
69
+ "node": ">=18.0.0"
70
+ },
71
+ "dependencies": {
72
+ "@noble/ciphers": "0.5.3",
73
+ "@noble/curves": "1.3.0",
74
+ "@noble/hashes": "1.4.0",
75
+ "@enbox/common": "workspace:*"
76
+ },
77
+ "devDependencies": {
78
+ "@playwright/test": "1.45.3",
79
+ "@types/chai": "4.3.16",
80
+ "@types/chai-as-promised": "7.1.8",
81
+ "@types/eslint": "8.56.10",
82
+ "@types/mocha": "10.0.6",
83
+ "@types/node": "20.14.8",
84
+ "@types/sinon": "17.0.3",
85
+ "@typescript-eslint/eslint-plugin": "7.14.1",
86
+ "@typescript-eslint/parser": "7.14.1",
87
+ "@web/test-runner": "0.18.2",
88
+ "@web/test-runner-playwright": "0.11.0",
89
+ "c8": "10.1.2",
90
+ "chai": "5.1.1",
91
+ "chai-as-promised": "8.0.0",
92
+ "esbuild": "0.23.0",
93
+ "eslint": "9.5.0",
94
+ "eslint-plugin-mocha": "10.4.3",
95
+ "mocha": "10.4.0",
96
+ "mocha-junit-reporter": "2.2.1",
97
+ "playwright": "1.45.3",
98
+ "rimraf": "5.0.7",
99
+ "sinon": "18.0.0",
100
+ "source-map-loader": "5.0.0",
101
+ "typescript": "5.4.5"
102
+ }
103
+ }