@enbox/agent 0.1.2 → 0.1.4

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 (224) hide show
  1. package/dist/browser.mjs +45 -52
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/crypto-api.js +6 -13
  4. package/dist/esm/crypto-api.js.map +1 -1
  5. package/dist/esm/dwn-api.js +80 -78
  6. package/dist/esm/dwn-api.js.map +1 -1
  7. package/dist/esm/hd-identity-vault.js +4 -5
  8. package/dist/esm/hd-identity-vault.js.map +1 -1
  9. package/dist/esm/identity-api.js +1 -1
  10. package/dist/esm/identity-api.js.map +1 -1
  11. package/dist/esm/index.js +0 -2
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/local-key-manager.js +31 -32
  14. package/dist/esm/local-key-manager.js.map +1 -1
  15. package/dist/esm/prototyping/crypto/jose/jwe-compact.js +1 -2
  16. package/dist/esm/prototyping/crypto/jose/jwe-compact.js.map +1 -1
  17. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js +15 -4
  18. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js.map +1 -1
  19. package/dist/esm/prototyping/crypto/jose/jwe.js +1 -1
  20. package/dist/esm/prototyping/crypto/jose/jwe.js.map +1 -1
  21. package/dist/esm/store-data.js +3 -3
  22. package/dist/esm/store-data.js.map +1 -1
  23. package/dist/esm/store-did.js +1 -1
  24. package/dist/esm/store-did.js.map +1 -1
  25. package/dist/esm/sync-engine-level.js +49 -11
  26. package/dist/esm/sync-engine-level.js.map +1 -1
  27. package/dist/esm/test-harness.js +24 -8
  28. package/dist/esm/test-harness.js.map +1 -1
  29. package/dist/esm/types/dwn.js +1 -1
  30. package/dist/esm/types/dwn.js.map +1 -1
  31. package/dist/esm/web5-user-agent.js +1 -1
  32. package/dist/esm/web5-user-agent.js.map +1 -1
  33. package/dist/types/crypto-api.d.ts +8 -12
  34. package/dist/types/crypto-api.d.ts.map +1 -1
  35. package/dist/types/dwn-api.d.ts +10 -10
  36. package/dist/types/dwn-api.d.ts.map +1 -1
  37. package/dist/types/hd-identity-vault.d.ts.map +1 -1
  38. package/dist/types/identity-api.d.ts.map +1 -1
  39. package/dist/types/index.d.ts +0 -2
  40. package/dist/types/index.d.ts.map +1 -1
  41. package/dist/types/local-key-manager.d.ts +15 -18
  42. package/dist/types/local-key-manager.d.ts.map +1 -1
  43. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts +1 -3
  44. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts.map +1 -1
  45. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts +1 -3
  46. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts.map +1 -1
  47. package/dist/types/prototyping/crypto/jose/jwe.d.ts +1 -3
  48. package/dist/types/prototyping/crypto/jose/jwe.d.ts.map +1 -1
  49. package/dist/types/store-data.d.ts +2 -2
  50. package/dist/types/store-did.d.ts.map +1 -1
  51. package/dist/types/sync-engine-level.d.ts +18 -6
  52. package/dist/types/sync-engine-level.d.ts.map +1 -1
  53. package/dist/types/test-harness.d.ts.map +1 -1
  54. package/dist/types/types/agent.d.ts +1 -1
  55. package/dist/types/types/agent.d.ts.map +1 -1
  56. package/dist/types/types/dwn.d.ts +2 -2
  57. package/dist/types/types/dwn.d.ts.map +1 -1
  58. package/dist/types/types/key-manager.d.ts +15 -22
  59. package/dist/types/types/key-manager.d.ts.map +1 -1
  60. package/dist/types/utils-internal.d.ts +1 -1
  61. package/dist/types/utils-internal.d.ts.map +1 -1
  62. package/dist/types/web5-user-agent.d.ts +1 -1
  63. package/dist/types/web5-user-agent.d.ts.map +1 -1
  64. package/package.json +13 -15
  65. package/src/crypto-api.ts +24 -20
  66. package/src/dwn-api.ts +109 -102
  67. package/src/hd-identity-vault.ts +4 -5
  68. package/src/identity-api.ts +2 -1
  69. package/src/index.ts +0 -2
  70. package/src/local-key-manager.ts +43 -44
  71. package/src/prototyping/crypto/jose/jwe-compact.ts +3 -7
  72. package/src/prototyping/crypto/jose/jwe-flattened.ts +20 -9
  73. package/src/prototyping/crypto/jose/jwe.ts +2 -6
  74. package/src/store-data.ts +3 -3
  75. package/src/store-did.ts +1 -1
  76. package/src/sync-engine-level.ts +59 -16
  77. package/src/test-harness.ts +23 -8
  78. package/src/types/agent.ts +1 -1
  79. package/src/types/dwn.ts +2 -2
  80. package/src/types/key-manager.ts +31 -22
  81. package/src/utils-internal.ts +1 -1
  82. package/src/web5-user-agent.ts +2 -2
  83. package/dist/browser.js +0 -2213
  84. package/dist/browser.js.map +0 -7
  85. package/dist/esm/dwn-registrar.js +0 -120
  86. package/dist/esm/dwn-registrar.js.map +0 -1
  87. package/dist/esm/prototyping/clients/dwn-rpc-types.js +0 -2
  88. package/dist/esm/prototyping/clients/dwn-rpc-types.js.map +0 -1
  89. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js +0 -74
  90. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js.map +0 -1
  91. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js +0 -112
  92. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js.map +0 -1
  93. package/dist/esm/prototyping/clients/json-rpc-socket.js +0 -167
  94. package/dist/esm/prototyping/clients/json-rpc-socket.js.map +0 -1
  95. package/dist/esm/prototyping/clients/json-rpc.js +0 -58
  96. package/dist/esm/prototyping/clients/json-rpc.js.map +0 -1
  97. package/dist/esm/prototyping/clients/server-info-types.js +0 -2
  98. package/dist/esm/prototyping/clients/server-info-types.js.map +0 -1
  99. package/dist/esm/prototyping/clients/web-socket-clients.js +0 -90
  100. package/dist/esm/prototyping/clients/web-socket-clients.js.map +0 -1
  101. package/dist/esm/prototyping/common/object.js +0 -14
  102. package/dist/esm/prototyping/common/object.js.map +0 -1
  103. package/dist/esm/prototyping/common/type-utils.js +0 -2
  104. package/dist/esm/prototyping/common/type-utils.js.map +0 -1
  105. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js +0 -147
  106. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js.map +0 -1
  107. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js +0 -136
  108. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js.map +0 -1
  109. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js +0 -311
  110. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js.map +0 -1
  111. package/dist/esm/prototyping/crypto/algorithms/eddsa.js +0 -268
  112. package/dist/esm/prototyping/crypto/algorithms/eddsa.js.map +0 -1
  113. package/dist/esm/prototyping/crypto/algorithms/hkdf.js +0 -38
  114. package/dist/esm/prototyping/crypto/algorithms/hkdf.js.map +0 -1
  115. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js +0 -40
  116. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js.map +0 -1
  117. package/dist/esm/prototyping/crypto/crypto-error.js +0 -41
  118. package/dist/esm/prototyping/crypto/crypto-error.js.map +0 -1
  119. package/dist/esm/prototyping/crypto/types/crypto-api.js +0 -2
  120. package/dist/esm/prototyping/crypto/types/crypto-api.js.map +0 -1
  121. package/dist/esm/prototyping/crypto/types/key-converter.js +0 -2
  122. package/dist/esm/prototyping/crypto/types/key-converter.js.map +0 -1
  123. package/dist/esm/prototyping/crypto/types/key-deriver.js +0 -2
  124. package/dist/esm/prototyping/crypto/types/key-deriver.js.map +0 -1
  125. package/dist/esm/prototyping/crypto/types/key-io.js +0 -2
  126. package/dist/esm/prototyping/crypto/types/key-io.js.map +0 -1
  127. package/dist/esm/prototyping/crypto/types/key-manager.js +0 -2
  128. package/dist/esm/prototyping/crypto/types/key-manager.js.map +0 -1
  129. package/dist/esm/prototyping/crypto/types/params-direct.js +0 -2
  130. package/dist/esm/prototyping/crypto/types/params-direct.js.map +0 -1
  131. package/dist/esm/prototyping/crypto/types/params-kms.js +0 -2
  132. package/dist/esm/prototyping/crypto/types/params-kms.js.map +0 -1
  133. package/dist/esm/prototyping/crypto/utils.js +0 -19
  134. package/dist/esm/prototyping/crypto/utils.js.map +0 -1
  135. package/dist/esm/prototyping/dids/resolver-cache-memory.js +0 -77
  136. package/dist/esm/prototyping/dids/resolver-cache-memory.js.map +0 -1
  137. package/dist/esm/prototyping/dids/utils.js +0 -9
  138. package/dist/esm/prototyping/dids/utils.js.map +0 -1
  139. package/dist/esm/rpc-client.js +0 -123
  140. package/dist/esm/rpc-client.js.map +0 -1
  141. package/dist/types/dwn-registrar.d.ts +0 -29
  142. package/dist/types/dwn-registrar.d.ts.map +0 -1
  143. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts +0 -45
  144. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts.map +0 -1
  145. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts +0 -57
  146. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts.map +0 -1
  147. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts +0 -13
  148. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts.map +0 -1
  149. package/dist/types/prototyping/clients/json-rpc-socket.d.ts +0 -43
  150. package/dist/types/prototyping/clients/json-rpc-socket.d.ts.map +0 -1
  151. package/dist/types/prototyping/clients/json-rpc.d.ts +0 -49
  152. package/dist/types/prototyping/clients/json-rpc.d.ts.map +0 -1
  153. package/dist/types/prototyping/clients/server-info-types.d.ts +0 -20
  154. package/dist/types/prototyping/clients/server-info-types.d.ts.map +0 -1
  155. package/dist/types/prototyping/clients/web-socket-clients.d.ts +0 -10
  156. package/dist/types/prototyping/clients/web-socket-clients.d.ts.map +0 -1
  157. package/dist/types/prototyping/common/object.d.ts +0 -2
  158. package/dist/types/prototyping/common/object.d.ts.map +0 -1
  159. package/dist/types/prototyping/common/type-utils.d.ts +0 -7
  160. package/dist/types/prototyping/common/type-utils.d.ts.map +0 -1
  161. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts +0 -151
  162. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts.map +0 -1
  163. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts +0 -108
  164. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts.map +0 -1
  165. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts +0 -160
  166. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts.map +0 -1
  167. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts +0 -157
  168. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts.map +0 -1
  169. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts +0 -20
  170. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts.map +0 -1
  171. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts +0 -20
  172. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts.map +0 -1
  173. package/dist/types/prototyping/crypto/crypto-error.d.ts +0 -29
  174. package/dist/types/prototyping/crypto/crypto-error.d.ts.map +0 -1
  175. package/dist/types/prototyping/crypto/types/crypto-api.d.ts +0 -34
  176. package/dist/types/prototyping/crypto/types/crypto-api.d.ts.map +0 -1
  177. package/dist/types/prototyping/crypto/types/key-converter.d.ts +0 -49
  178. package/dist/types/prototyping/crypto/types/key-converter.d.ts.map +0 -1
  179. package/dist/types/prototyping/crypto/types/key-deriver.d.ts +0 -50
  180. package/dist/types/prototyping/crypto/types/key-deriver.d.ts.map +0 -1
  181. package/dist/types/prototyping/crypto/types/key-io.d.ts +0 -49
  182. package/dist/types/prototyping/crypto/types/key-io.d.ts.map +0 -1
  183. package/dist/types/prototyping/crypto/types/key-manager.d.ts +0 -69
  184. package/dist/types/prototyping/crypto/types/key-manager.d.ts.map +0 -1
  185. package/dist/types/prototyping/crypto/types/params-direct.d.ts +0 -75
  186. package/dist/types/prototyping/crypto/types/params-direct.d.ts.map +0 -1
  187. package/dist/types/prototyping/crypto/types/params-kms.d.ts +0 -63
  188. package/dist/types/prototyping/crypto/types/params-kms.d.ts.map +0 -1
  189. package/dist/types/prototyping/crypto/utils.d.ts +0 -7
  190. package/dist/types/prototyping/crypto/utils.d.ts.map +0 -1
  191. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts +0 -57
  192. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts.map +0 -1
  193. package/dist/types/prototyping/dids/utils.d.ts +0 -3
  194. package/dist/types/prototyping/dids/utils.d.ts.map +0 -1
  195. package/dist/types/rpc-client.d.ts +0 -51
  196. package/dist/types/rpc-client.d.ts.map +0 -1
  197. package/src/dwn-registrar.ts +0 -127
  198. package/src/prototyping/clients/dwn-rpc-types.ts +0 -55
  199. package/src/prototyping/clients/dwn-server-info-cache-memory.ts +0 -79
  200. package/src/prototyping/clients/http-dwn-rpc-client.ts +0 -119
  201. package/src/prototyping/clients/json-rpc-socket.ts +0 -189
  202. package/src/prototyping/clients/json-rpc.ts +0 -113
  203. package/src/prototyping/clients/server-info-types.ts +0 -21
  204. package/src/prototyping/clients/web-socket-clients.ts +0 -103
  205. package/src/prototyping/common/object.ts +0 -15
  206. package/src/prototyping/common/type-utils.ts +0 -6
  207. package/src/prototyping/crypto/algorithms/aes-gcm.ts +0 -211
  208. package/src/prototyping/crypto/algorithms/aes-kw.ts +0 -160
  209. package/src/prototyping/crypto/algorithms/ecdsa.ts +0 -366
  210. package/src/prototyping/crypto/algorithms/eddsa.ts +0 -311
  211. package/src/prototyping/crypto/algorithms/hkdf.ts +0 -38
  212. package/src/prototyping/crypto/algorithms/pbkdf2.ts +0 -41
  213. package/src/prototyping/crypto/crypto-error.ts +0 -45
  214. package/src/prototyping/crypto/types/crypto-api.ts +0 -77
  215. package/src/prototyping/crypto/types/key-converter.ts +0 -53
  216. package/src/prototyping/crypto/types/key-deriver.ts +0 -56
  217. package/src/prototyping/crypto/types/key-io.ts +0 -51
  218. package/src/prototyping/crypto/types/key-manager.ts +0 -83
  219. package/src/prototyping/crypto/types/params-direct.ts +0 -95
  220. package/src/prototyping/crypto/types/params-kms.ts +0 -76
  221. package/src/prototyping/crypto/utils.ts +0 -41
  222. package/src/prototyping/dids/resolver-cache-memory.ts +0 -83
  223. package/src/prototyping/dids/utils.ts +0 -10
  224. package/src/rpc-client.ts +0 -160
@@ -1,157 +0,0 @@
1
- import type { AsymmetricKeyConverter, AsymmetricKeyGenerator, ComputePublicKeyParams, GenerateKeyParams, GetPublicKeyParams, Jwk, KeyConverter, Signer, SignParams, VerifyParams } from '@enbox/crypto';
2
- import { CryptoAlgorithm } from '@enbox/crypto';
3
- import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams } from '../types/params-direct.js';
4
- /**
5
- * The `EdDsaGenerateKeyParams` interface defines the algorithm-specific parameters that should be
6
- * passed into the `generateKey()` method when using the EdDSA algorithm.
7
- */
8
- export interface EdDsaGenerateKeyParams extends GenerateKeyParams {
9
- /**
10
- * A string defining the type of key to generate. The value must be one of the following:
11
- * - `"Ed25519"`: EdDSA using the Ed25519 curve.
12
- */
13
- algorithm: 'Ed25519';
14
- }
15
- /**
16
- * The `EdDsaAlgorithm` class provides a concrete implementation for cryptographic operations using
17
- * the Edwards-curve Digital Signature Algorithm (EdDSA). This class implements both
18
- * {@link Signer | `Signer`} and { @link AsymmetricKeyGenerator | `AsymmetricKeyGenerator`}
19
- * interfaces, providing private key generation, public key derivation, and creation/verification
20
- * of signatures.
21
- *
22
- * This class is typically accessed through implementations that extend the
23
- * {@link CryptoApi | `CryptoApi`} interface.
24
- */
25
- export declare class EdDsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EdDsaGenerateKeyParams, Jwk, GetPublicKeyParams>, KeyConverter, AsymmetricKeyConverter, Signer<SignParams, VerifyParams> {
26
- bytesToPrivateKey({ algorithm, privateKeyBytes }: BytesToPrivateKeyParams & {
27
- algorithm: 'Ed25519';
28
- }): Promise<Jwk>;
29
- bytesToPublicKey({ algorithm, publicKeyBytes }: BytesToPublicKeyParams & {
30
- algorithm: 'Ed25519';
31
- }): Promise<Jwk>;
32
- /**
33
- * Derives the public key in JWK format from a given private key.
34
- *
35
- * @remarks
36
- * This method takes a private key in JWK format and derives its corresponding public key,
37
- * also in JWK format. The process ensures that the derived public key correctly corresponds to
38
- * the given private key.
39
- *
40
- * @example
41
- * ```ts
42
- * const eddsa = new EdDsaAlgorithm();
43
- * const privateKey = { ... }; // A Jwk object representing a private key
44
- * const publicKey = await eddsa.computePublicKey({ key: privateKey });
45
- * ```
46
- *
47
- * @param params - The parameters for the public key derivation.
48
- * @param params.key - The private key in JWK format from which to derive the public key.
49
- *
50
- * @returns A Promise that resolves to the derived public key in JWK format.
51
- */
52
- computePublicKey({ key }: ComputePublicKeyParams): Promise<Jwk>;
53
- /**
54
- * Generates a new private key with the specified algorithm in JSON Web Key (JWK) format.
55
- *
56
- * @example
57
- * ```ts
58
- * const eddsa = new EdDsaAlgorithm();
59
- * const privateKey = await eddsa.generateKey({ algorithm: 'Ed25519' });
60
- * ```
61
- *
62
- * @param params - The parameters for key generation.
63
- * @param params.algorithm - The algorithm to use for key generation.
64
- *
65
- * @returns A Promise that resolves to the generated private key in JWK format.
66
- */
67
- generateKey({ algorithm }: EdDsaGenerateKeyParams): Promise<Jwk>;
68
- /**
69
- * Retrieves the public key properties from a given private key in JWK format.
70
- *
71
- * @remarks
72
- * This method extracts the public key portion from an EdDSA private key in JWK format. It does
73
- * so by removing the private key property 'd' and making a shallow copy, effectively yielding the
74
- * public key.
75
- *
76
- * Note: This method offers a significant performance advantage, being about 100 times faster
77
- * than `computePublicKey()`. However, it does not mathematically validate the private key, nor
78
- * does it derive the public key from the private key. It simply extracts existing public key
79
- * properties from the private key object. This makes it suitable for scenarios where speed is
80
- * critical and the private key's integrity is already assured.
81
- *
82
- * @example
83
- * ```ts
84
- * const eddsa = new EdDsaAlgorithm();
85
- * const privateKey = { ... }; // A Jwk object representing a private key
86
- * const publicKey = await eddsa.getPublicKey({ key: privateKey });
87
- * ```
88
- *
89
- * @param params - The parameters for retrieving the public key properties.
90
- * @param params.key - The private key in JWK format.
91
- *
92
- * @returns A Promise that resolves to the public key in JWK format.
93
- */
94
- getPublicKey({ key }: GetPublicKeyParams): Promise<Jwk>;
95
- privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
96
- publicKeyToBytes({ publicKey }: PublicKeyToBytesParams): Promise<Uint8Array>;
97
- /**
98
- * Generates an EdDSA signature of given data using a private key.
99
- *
100
- * @remarks
101
- * This method uses the signature algorithm determined by the given `algorithm` to sign the
102
- * provided data.
103
- *
104
- * The signature can later be verified by parties with access to the corresponding
105
- * public key, ensuring that the data has not been tampered with and was indeed signed by the
106
- * holder of the private key.
107
- *
108
- * @example
109
- * ```ts
110
- * const eddsa = new EdDsaAlgorithm();
111
- * const data = new TextEncoder().encode('Message');
112
- * const privateKey = { ... }; // A Jwk object representing a private key
113
- * const signature = await eddsa.sign({
114
- * key: privateKey,
115
- * data
116
- * });
117
- * ```
118
- *
119
- * @param params - The parameters for the signing operation.
120
- * @param params.key - The private key to use for signing, represented in JWK format.
121
- * @param params.data - The data to sign.
122
- *
123
- * @returns A Promise resolving to the digital signature as a `Uint8Array`.
124
- */
125
- sign({ key, data }: SignParams): Promise<Uint8Array>;
126
- /**
127
- * Verifies an EdDSA signature associated with the provided data using the provided key.
128
- *
129
- * @remarks
130
- * This method uses the signature algorithm determined by the `crv` property of the provided key
131
- * to check the validity of a digital signature against the original data. It confirms whether the
132
- * signature was created by the holder of the corresponding private key and that the data has not
133
- * been tampered with.
134
- *s
135
- * @example
136
- * ```ts
137
- * const eddsa = new EdDsaAlgorithm();
138
- * const publicKey = { ... }; // Public key in JWK format corresponding to the private key that signed the data
139
- * const signature = new Uint8Array([...]); // Signature to verify
140
- * const data = new TextEncoder().encode('Message');
141
- * const isValid = await eddsa.verify({
142
- * key: publicKey,
143
- * signature,
144
- * data
145
- * });
146
- * ```
147
- *
148
- * @param params - The parameters for the verification operation.
149
- * @param params.key - The key to use for verification.
150
- * @param params.signature - The signature to verify.
151
- * @param params.data - The data to verify.
152
- *
153
- * @returns A Promise resolving to a boolean indicating whether the signature is valid.
154
- */
155
- verify({ key, signature, data }: VerifyParams): Promise<boolean>;
156
- }
157
- //# sourceMappingURL=eddsa.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/eddsa.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,GAAG,EACH,YAAY,EACZ,MAAM,EACN,UAAU,EACV,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAA4C,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGlJ;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D;;;OAGG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,eAClC,YAAW,sBAAsB,CAAC,sBAAsB,EAAE,GAAG,EAAE,kBAAkB,CAAC,EACvE,YAAY,EAAE,sBAAsB,EACpC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;IAE9B,iBAAiB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,EAC3D,uBAAuB,GAAG;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,GACjD,OAAO,CAAC,GAAG,CAAC;IAeF,gBAAgB,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,EACzD,sBAAsB,GAAG;QAAE,SAAS,EAAE,SAAS,CAAA;KAAE,GAChD,OAAO,CAAC,GAAG,CAAC;IAef;;;;;;;;;;;;;;;;;;;OAmBG;IACU,gBAAgB,CAAC,EAAE,GAAG,EAAE,EACnC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAiBf;;;;;;;;;;;;;OAaG;IACG,WAAW,CAAC,EAAE,SAAS,EAAE,EAC7B,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAWf;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,EAAE,GAAG,EAAE,EAC/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAiBF,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;IAaT,gBAAgB,CAAC,EAAE,SAAS,EAAE,EACzC,sBAAsB,GACrB,OAAO,CAAC,UAAU,CAAC;IAatB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACU,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAC7B,UAAU,GACT,OAAO,CAAC,UAAU,CAAC;IAetB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACU,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1C,YAAY,GACX,OAAO,CAAC,OAAO,CAAC;CAcpB"}
@@ -1,20 +0,0 @@
1
- import type { KeyBytesDeriver } from '../types/key-deriver.js';
2
- import type { DeriveKeyBytesParams, HkdfParams } from '@enbox/crypto';
3
- import { CryptoAlgorithm } from '@enbox/crypto';
4
- /**
5
- * The `HkdfDeriveKeyBytesParams` interface defines the algorithm-specific parameters that should be
6
- * passed into the `deriveKeyBytes()` method when using the HKDF algorithm.
7
- */
8
- export interface HkdfDeriveKeyBytesParams extends DeriveKeyBytesParams {
9
- /** Specifies the algorithm variant for HKDF key derivation.
10
- * The value determines the hash function that will be used and must be one of the following:
11
- * - `"HKDF-256"`: HKDF with SHA-256.
12
- * - `"HKDF-384"`: HKDF with SHA-384.
13
- * - `"HKDF-512"`: HKDF with SHA-512.
14
- */
15
- algorithm: 'HKDF-256' | 'HKDF-384' | 'HKDF-512';
16
- }
17
- export declare class HkdfAlgorithm extends CryptoAlgorithm implements KeyBytesDeriver<HkdfDeriveKeyBytesParams, Uint8Array> {
18
- deriveKeyBytes({ algorithm, ...params }: HkdfDeriveKeyBytesParams & Omit<HkdfParams, 'hash'>): Promise<Uint8Array>;
19
- }
20
- //# sourceMappingURL=hkdf.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAQ,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE;;;;;OAKG;IACH,SAAS,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;CACjD;AAED,qBAAa,aAAc,SAAQ,eACjC,YAAW,eAAe,CAAC,wBAAwB,EAAE,UAAU,CAAC;IAEnD,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,wBAAwB,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC;CAavB"}
@@ -1,20 +0,0 @@
1
- import type { KeyBytesDeriver } from '../types/key-deriver.js';
2
- import type { DeriveKeyBytesParams, Pbkdf2Params } from '@enbox/crypto';
3
- import { CryptoAlgorithm } from '@enbox/crypto';
4
- /**
5
- * The `Pbkdf2DeriveKeyBytesParams` interface defines the algorithm-specific parameters that
6
- * should be passed into the `deriveKeyBytes()` method when using the PBKDF2 algorithm.
7
- */
8
- export interface Pbkdf2DeriveKeyBytesParams extends DeriveKeyBytesParams {
9
- /** Specifies the algorithm variant for PBKDF2 key derivation.
10
- * The value determines the hash function that will be used and must be one of the following:
11
- * - `"PBKDF2-HS256+A128KW"`: PBKDF2 with HMAC SHA-256 and A128KW key wrapping.
12
- * - `"PBKDF2-HS384+A192KW"`: PBKDF2 with HMAC SHA-384 and A192KW key wrapping.
13
- * - `"PBKDF2-HS512+A256KW"`: PBKDF2 with HMAC SHA-512 and A256KW key wrapping.
14
- */
15
- algorithm: 'PBES2-HS256+A128KW' | 'PBES2-HS384+A192KW' | 'PBES2-HS512+A256KW';
16
- }
17
- export declare class Pbkdf2Algorithm extends CryptoAlgorithm implements KeyBytesDeriver<Pbkdf2DeriveKeyBytesParams, Uint8Array> {
18
- deriveKeyBytes({ algorithm, ...params }: Pbkdf2DeriveKeyBytesParams & Omit<Pbkdf2Params, 'hash'>): Promise<Uint8Array>;
19
- }
20
- //# sourceMappingURL=pbkdf2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/pbkdf2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,eAAe,EAAU,MAAM,eAAe,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE;;;;;OAKG;IACH,SAAS,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;CAC/E;AAED,qBAAa,eAAgB,SAAQ,eACnC,YAAW,eAAe,CAAC,0BAA0B,EAAE,UAAU,CAAC;IAErD,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,0BAA0B,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GACtD,OAAO,CAAC,UAAU,CAAC;CAgBvB"}
@@ -1,29 +0,0 @@
1
- /**
2
- * A custom error class for Crypto-related errors.
3
- */
4
- export declare class CryptoError extends Error {
5
- code: CryptoErrorCode;
6
- /**
7
- * Constructs an instance of CryptoError, a custom error class for handling Crypto-related errors.
8
- *
9
- * @param code - A {@link CryptoErrorCode} representing the specific type of error encountered.
10
- * @param message - A human-readable description of the error.
11
- */
12
- constructor(code: CryptoErrorCode, message: string);
13
- }
14
- /**
15
- * An enumeration of possible Crypto error codes.
16
- */
17
- export declare enum CryptoErrorCode {
18
- /** The supplied algorithm identifier is not supported by the implementation. */
19
- AlgorithmNotSupported = "algorithmNotSupported",
20
- /** The encoding operation (either encoding or decoding) failed. */
21
- EncodingError = "encodingError",
22
- /** The JWE supplied does not conform to valid syntax. */
23
- InvalidJwe = "invalidJwe",
24
- /** The JWK supplied does not conform to valid syntax. */
25
- InvalidJwk = "invalidJwk",
26
- /** The requested operation is not supported by the implementation. */
27
- OperationNotSupported = "operationNotSupported"
28
- }
29
- //# sourceMappingURL=crypto-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-error.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/crypto/crypto-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAOjB,IAAI,EAAE,eAAe;IANxC;;;;;OAKG;gBACgB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAc1D;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,gFAAgF;IAChF,qBAAqB,0BAA0B;IAE/C,mEAAmE;IACnE,aAAa,kBAAkB;IAE/B,yDAAyD;IACzD,UAAU,eAAe;IAEzB,yDAAyD;IACzD,UAAU,eAAe;IAEzB,sEAAsE;IACtE,qBAAqB,0BAA0B;CAChD"}
@@ -1,34 +0,0 @@
1
- import type { Cipher, DigestParams, GenerateKeyParams, GetPublicKeyParams, Jwk, KeyWrapper, CryptoApi as OldCryptoApi, SignParams, VerifyParams } from '@enbox/crypto';
2
- import type { AsymmetricKeyConverter, KeyConverter } from './key-converter.js';
3
- import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, CipherParams, DeriveKeyBytesParams, DeriveKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams, UnwrapKeyParams, WrapKeyParams } from './params-direct.js';
4
- import type { KeyBytesDeriver, KeyDeriver } from './key-deriver.js';
5
- /**
6
- * The `DsaApi` interface integrates key generation, hashing, and signing functionalities,
7
- * designed for use with a Key Management System (KMS). It extends `AsymmetricKeyGenerator` for
8
- * generating asymmetric keys, `Hasher` for hash digest computations, and `Signer` for signing and
9
- * verifying operations.
10
- *
11
- * Concrete implementations of this interface are intended to be used with a KMS, which is
12
- * responsible for generating and storing cryptographic keys. The KMS is also responsible for
13
- * performing cryptographic operations using the keys it manages. The KMS is typically a cloud
14
- * service, but it can also be a hardware device or software application.
15
- *
16
- * Guidelines for implementing this interface:
17
- * - Must use JSON Web Keys ({@link Jwk | JWK}) as the key format.
18
- * - Must IANA registered JSON Object Signing and Encryption
19
- * {@ link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | (JOSE)}
20
- * names for algorithm, curves, etc. whenever possible.
21
- * - All I/O that interacts with private or secret keys must be done via reference using a
22
- * {@link KeyIdentifier | `KeyIdentifier`}. Implementations can use any string as the key
23
- * identifier (e.g. JWK thumbprint, UUID generated by hosted KMS, etc.).
24
- * - Must support key generation, hashing, signing, and verifying operations.
25
- * - May be extended to support other cryptographic operations.
26
- * - Implementations of the `DsaApi` interface can be passed as an argument to the public API
27
- * methods of Web5 libraries that involve key material (e.g., DID creation, VC signing, arbitrary
28
- * data signing/verification, etc.).
29
- */
30
- export interface DsaApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams> extends OldCryptoApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput> {
31
- }
32
- export interface CryptoApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams, EncryptInput = CipherParams, DecryptInput = CipherParams, BytesToPublicKeyInput = BytesToPublicKeyParams, PublicKeyToBytesInput = PublicKeyToBytesParams, BytesToPrivateKeyInput = BytesToPrivateKeyParams, PrivateKeyToBytesInput = PrivateKeyToBytesParams, DeriveKeyInput = DeriveKeyParams, DeriveKeyOutput = Jwk, DeriveKeyBytesInput = DeriveKeyBytesParams, DeriveKeyBytesOutput = Uint8Array, WrapKeyInput = WrapKeyParams, UnwrapKeyInput = UnwrapKeyParams> extends DsaApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput>, Cipher<EncryptInput, DecryptInput>, AsymmetricKeyConverter<BytesToPublicKeyInput, PublicKeyToBytesInput>, KeyConverter<BytesToPrivateKeyInput, PrivateKeyToBytesInput>, KeyDeriver<DeriveKeyInput, DeriveKeyOutput>, KeyBytesDeriver<DeriveKeyBytesInput, DeriveKeyBytesOutput>, KeyWrapper<WrapKeyInput, UnwrapKeyInput> {
33
- }
34
- //# sourceMappingURL=crypto-api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-api.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/crypto-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,GAAG,EACH,UAAU,EACV,SAAS,IAAI,YAAY,EACzB,UAAU,EACV,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAChO,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,MAAM,CACrB,gBAAgB,GAAG,iBAAiB,EACpC,iBAAiB,GAAG,GAAG,EACvB,iBAAiB,GAAG,kBAAkB,EACtC,WAAW,GAAG,YAAY,EAC1B,SAAS,GAAG,UAAU,EACtB,WAAW,GAAG,YAAY,CAC1B,SAAQ,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC;CAAG;AAEtH,MAAM,WAAW,SAAS,CACxB,gBAAgB,GAAG,iBAAiB,EACpC,iBAAiB,GAAG,GAAG,EACvB,iBAAiB,GAAG,kBAAkB,EACtC,WAAW,GAAG,YAAY,EAC1B,SAAS,GAAG,UAAU,EACtB,WAAW,GAAG,YAAY,EAC1B,YAAY,GAAG,YAAY,EAC3B,YAAY,GAAG,YAAY,EAC3B,qBAAqB,GAAG,sBAAsB,EAC9C,qBAAqB,GAAG,sBAAsB,EAC9C,sBAAsB,GAAG,uBAAuB,EAChD,sBAAsB,GAAG,uBAAuB,EAChD,cAAc,GAAG,eAAe,EAChC,eAAe,GAAG,GAAG,EACrB,mBAAmB,GAAG,oBAAoB,EAC1C,oBAAoB,GAAG,UAAU,EACjC,YAAY,GAAG,aAAa,EAC5B,cAAc,GAAG,eAAe,CAChC,SACA,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC,EACnG,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,EAClC,sBAAsB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,EACpE,YAAY,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,EAC5D,UAAU,CAAC,cAAc,EAAE,eAAe,CAAC,EAC3C,eAAe,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,EAC1D,UAAU,CAAC,YAAY,EAAE,cAAc,CAAC;CAAG"}
@@ -1,49 +0,0 @@
1
- import type { Jwk } from '@enbox/crypto';
2
- /**
3
- * `KeyConverter` interface for converting private keys between byte array and JWK formats.
4
- */
5
- export interface KeyConverter<BytesToPrivateKeyInput, PrivateKeyToBytesInput> {
6
- /**
7
- * Converts a private key from a byte array to JWK format.
8
- *
9
- * @param params - The parameters for the private key conversion.
10
- * @param params.privateKeyBytes - The raw private key as a Uint8Array.
11
- *
12
- * @returns A Promise that resolves to the private key in JWK format.
13
- */
14
- bytesToPrivateKey(params: BytesToPrivateKeyInput): Promise<Jwk>;
15
- /**
16
- * Converts a private key from JWK format to a byte array.
17
- *
18
- * @param params - The parameters for the private key conversion.
19
- * @param params.privateKey - The private key in JWK format.
20
- *
21
- * @returns A Promise that resolves to the private key as a Uint8Array.
22
- */
23
- privateKeyToBytes(params: PrivateKeyToBytesInput): Promise<Uint8Array>;
24
- }
25
- /**
26
- * `AsymmetricKeyConverter` interface extends {@link KeyConverter |`KeyConverter`}, adding support
27
- * for public key conversions.
28
- */
29
- export interface AsymmetricKeyConverter<BytesToPublicKeyInput, PublicKeyToBytesInput> {
30
- /**
31
- * Converts a public key from a byte array to JWK format.
32
- *
33
- * @param params - The parameters for the public key conversion.
34
- * @param params.publicKeyBytes - The raw public key as a Uint8Array.
35
- *
36
- * @returns A Promise that resolves to the public key in JWK format.
37
- */
38
- bytesToPublicKey(params: BytesToPublicKeyInput): Promise<Jwk>;
39
- /**
40
- * Converts a public key from JWK format to a byte array.
41
- *
42
- * @param params - The parameters for the public key conversion.
43
- * @param params.publicKey - The public key in JWK format.
44
- *
45
- * @returns A Promise that resolves to the public key as a Uint8Array.
46
- */
47
- publicKeyToBytes(params: PublicKeyToBytesInput): Promise<Uint8Array>;
48
- }
49
- //# sourceMappingURL=key-converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-converter.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/key-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,sBAAsB,EAAE,sBAAsB;IAE1E;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhE;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACxE;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,qBAAqB,EAAE,qBAAqB;IAClF;;;;;;;OAOG;IACH,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9D;;;;;;;OAOG;IACH,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACtE"}
@@ -1,50 +0,0 @@
1
- /**
2
- * The `KeyDeriver` interface provide a method for key derivation.
3
- *
4
- * The `deriveKey()` method derives a {@link Jwk | JWK} from input data using the specified key
5
- * derivation algorithm. This interface is designed to support various key derivation
6
- * algorithms, accommodating different input and output types.
7
- */
8
- export interface KeyDeriver<DeriveKeyInput, DeriveKeyOutput> {
9
- /**
10
- * Derives a cryptographic key in JWK format based on the provided input parameters.
11
- *
12
- * @remarks
13
- * The `deriveKey()` method of the {@link KeyDeriver | `KeyDeriver`} interface is utilized to
14
- * generate cryptographic keys for operations like encryption, decryption, or signing. The method
15
- * takes in parameters tailored to the key derivation algorithm being used and returns a promise
16
- * that resolves to the derived key.
17
- *
18
- * @param params - The parameters for the key derivation process, specific to the chosen
19
- * algorithm.
20
- *
21
- * @returns A Promise resolving to the derived key in the specified output format.
22
- */
23
- deriveKey(params: DeriveKeyInput): Promise<DeriveKeyOutput>;
24
- }
25
- /**
26
- * The `KeyBytesDeriver` interface provide a method for deriving a byte array using a key derivation
27
- * algorithm.
28
- *
29
- * The `deriveKeyBytes()` method to derives cryptographic bits from input data using the specified
30
- * key derivation algorithm. This interface is designed to support various key derivation
31
- * algorithms, accommodating different input and output types.
32
- */
33
- export interface KeyBytesDeriver<DeriveKeyBytesInput, DeriveKeyBytesOutput> {
34
- /**
35
- * Generates a specified number of cryptographic bits from given input parameters.
36
- *
37
- * @remarks
38
- * The `deriveKeyBytes()` method of the {@link KeyBytesDeriver | `KeyBytesDeriver`} interface is
39
- * used to create cryptographic material such as initialization vectors or keys from various
40
- * sources. The method takes in parameters specific to the chosen key derivation algorithm and
41
- * outputs a promise that resolves to a `Uint8Array` containing the derived bits.
42
- *
43
- * @param params - The parameters for the key derivation process, specific to the chosen
44
- * algorithm.
45
- *
46
- * @returns A Promise resolving to the derived bits in the specified format.
47
- */
48
- deriveKeyBytes(params: DeriveKeyBytesInput): Promise<DeriveKeyBytesOutput>;
49
- }
50
- //# sourceMappingURL=key-deriver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-deriver.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/key-deriver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CACzB,cAAc,EACd,eAAe;IAEf;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAC9B,mBAAmB,EACnB,oBAAoB;IAEpB;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC5E"}
@@ -1,49 +0,0 @@
1
- import type { Jwk } from '@enbox/crypto';
2
- /**
3
- * The `KeyExporter` interface provides a method for exporting cryptographic keys.
4
- */
5
- export interface KeyExporter<ExportKeyInput, ExportKeyOutput = Jwk> {
6
- /**
7
- * Exports a cryptographic key to an external JWK object.
8
- *
9
- * @remarks
10
- * The `exportKey()` method of the {@link KeyImporterExporter | `KeyImporterExporter`} interface
11
- * returns a cryptographic key in JWK format, facilitating interoperability and backup.
12
- *
13
- * @param params - The parameters for the key export operation.
14
- *
15
- * @returns A Promise resolving to the exported key in JWK format.
16
- */
17
- exportKey(params: ExportKeyInput): Promise<ExportKeyOutput>;
18
- }
19
- /**
20
- * The `KeyImporter` interface provides a method for importing cryptographic keys.
21
- */
22
- export interface KeyImporter<ImportKeyInput, ImportKeyOutput = void> {
23
- /**
24
- * Imports an external key in JWK format.
25
- *
26
- * @remarks
27
- * The `importKey()` method of the {@link KeyImporterExporter | `KeyImporterExporter`} interface
28
- * takes as input an external key in JWK format and typically returns a key identifier reference
29
- * for the imported key.
30
- *
31
- * @param params - The parameters for the key import operation.
32
- *
33
- * @returns A Promise resolving to the key identifier of the imported key.
34
- */
35
- importKey(params: ImportKeyInput): Promise<ImportKeyOutput>;
36
- }
37
- export interface KeyDeleter<DeleteKeyInput> {
38
- /**
39
- * Deletes a cryptographic key.
40
- *
41
- * @remarks
42
- * The `deleteKey()` method of the {@link KeyDeleter | `KeyDeleter`} interface deletes a cryptographic
43
- * key from the key store.
44
- *
45
- * @param params - The parameters for the key deletion operation.
46
- */
47
- deleteKey(params: DeleteKeyInput): Promise<void>;
48
- }
49
- //# sourceMappingURL=key-io.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-io.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/key-io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,cAAc,EAAE,eAAe,GAAG,GAAG;IAChE;;;;;;;;;;OAUG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,cAAc,EAAE,eAAe,GAAG,IAAI;IACjE;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,UAAU,CAAC,cAAc;IACxC;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD"}
@@ -1,69 +0,0 @@
1
- import type { KeyIdentifier, KmsDigestParams, KmsGenerateKeyParams, KmsGetKeyUriParams, KmsGetPublicKeyParams, KmsSignParams, KmsVerifyParams } from '@enbox/crypto';
2
- import type { DsaApi } from './crypto-api.js';
3
- import type { KmsCipherParams } from './params-kms.js';
4
- export interface KeyManagerParams {
5
- CipherInput?: unknown;
6
- GenerateKeyInput?: unknown;
7
- GenerateKeyOutput?: unknown;
8
- GetPublicKeyInput?: unknown;
9
- SignInput?: unknown;
10
- VerifyInput?: unknown;
11
- }
12
- export interface DefaultKeyManagerParams {
13
- CipherInput: KmsCipherParams;
14
- GenerateKeyInput: KmsGenerateKeyParams;
15
- GenerateKeyOutput: KeyIdentifier;
16
- GetPublicKeyInput: KmsGetPublicKeyParams;
17
- SignInput: KmsSignParams;
18
- VerifyInput: KmsVerifyParams;
19
- }
20
- /**
21
- * The `KeyManager` interface integrates key generation and signing capabilities.
22
- *
23
- * Concrete implementations of this interface are intended to be used as a Key Management System
24
- * (KMS), which is responsible for generating and storing cryptographic keys. The KMS is also
25
- * responsible for performing cryptographic operations using the keys it manages. The KMS can be
26
- * a local software based KMS, a cloud service, or a hardware device.
27
- *
28
- * Guidelines for implementing this interface:
29
- * - Must use JSON Web Keys ({@link Jwk | JWK}) as the key format.
30
- * - Must IANA registered JSON Object Signing and Encryption
31
- * {@ link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | (JOSE)}
32
- * names for algorithm, curves, etc. whenever possible.
33
- * - All I/O that interacts with private or secret keys must be done via reference using a
34
- * {@link KeyIdentifier | `KeyIdentifier`}. Implementations can use any string as the key
35
- * identifier (e.g. JWK thumbprint, UUID generated by hosted KMS, etc.).
36
- * - Must support key generation an signing operations.
37
- * - May be extended to support other cryptographic operations.
38
- * - Implementations of the `CryptoApi` interface can be passed as an argument to the public API
39
- * methods of Web5 libraries that involve key material (e.g., DID creation, VC signing, arbitrary
40
- * data signing/verification, etc.).
41
- *
42
- * @example
43
- * ```ts
44
- * // Example of using the KeyManager interface with default types
45
- * class DefaultKeyManager implements KeyManager {} // Uses default types
46
- *
47
- * // Example of using the KeyManager interface with custom types
48
- * class CustomKeyManager implements KeyManager<{
49
- * GenerateKeyInput: CustomGenerateKeyParams, // Custom type
50
- * KmsGetPublicKeyParams: CustomGetPublicKeyParams, // Custom type
51
- * KmsSignParams: CustomSignParams, // Custom type
52
- * // Omitting KmsVerifyParams to use the default
53
- * }> {
54
- * // Implementation here
55
- * }
56
- * ```
57
- *
58
- * @typeParam T - The type of the key manager parameters.
59
- */
60
- export interface KeyManager<T extends KeyManagerParams = DefaultKeyManagerParams> extends DsaApi<T['GenerateKeyInput'], T['GenerateKeyOutput'], T['GetPublicKeyInput'], KmsDigestParams, T['SignInput'], T['VerifyInput']> {
61
- /**
62
- *
63
- * @param params - The parameters for getting the key URI.
64
- * @param params.key - The key to get the URI for.
65
- * @returns The key URI.
66
- */
67
- getKeyUri(params: KmsGetKeyUriParams): Promise<KeyIdentifier>;
68
- }
69
- //# sourceMappingURL=key-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,eAAe,CAAC;IAC7B,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,iBAAiB,EAAE,aAAa,CAAC;IACjC,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,EAAE,eAAe,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,gBAAgB,GAAG,uBAAuB,CAC9E,SAAQ,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;IAExI;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/D"}
@@ -1,75 +0,0 @@
1
- import type { Jwk } from '@enbox/crypto';
2
- export interface BytesToPrivateKeyParams {
3
- algorithm: AlgorithmIdentifier;
4
- privateKeyBytes: Uint8Array;
5
- }
6
- export interface BytesToPublicKeyParams {
7
- algorithm: AlgorithmIdentifier;
8
- publicKeyBytes: Uint8Array;
9
- }
10
- /**
11
- * Parameters for encryption and decryption operations.
12
- *
13
- * Intended for use with a Key Management System.
14
- */
15
- export interface CipherParams {
16
- /** A {@link Jwk} containing the key to be used for encryption or decryption. */
17
- key: Jwk;
18
- /** Data to be encrypted or decrypted. */
19
- data: Uint8Array;
20
- /** Additional algorithm-specific parameters for encryption or decryption. */
21
- [key: string]: unknown;
22
- }
23
- /**
24
- * Parameters for derivation of cryptographic keys.
25
- */
26
- export interface DeriveKeyParams {
27
- /** The algorithm identifier. */
28
- algorithm: AlgorithmIdentifier;
29
- /** The base key to be used for derivation as a byte array. */
30
- baseKeyBytes: Uint8Array;
31
- /** The algorithm identifier for the derived key. */
32
- derivedKeyAlgorithm?: AlgorithmIdentifier;
33
- /** Additional algorithm-specific parameters for key derivation. */
34
- [key: string]: unknown;
35
- }
36
- /**
37
- * Parameters for derivation of cryptographic byte arrays.
38
- */
39
- export interface DeriveKeyBytesParams {
40
- /** The base key to be used for derivation as a byte array. */
41
- baseKeyBytes: Uint8Array;
42
- /** The desired length of the derived key in bits. */
43
- length: number;
44
- }
45
- export interface PrivateKeyToBytesParams {
46
- privateKey: Jwk;
47
- }
48
- export interface PublicKeyToBytesParams {
49
- publicKey: Jwk;
50
- }
51
- /**
52
- * Parameters for wrapping a key.
53
- */
54
- export interface WrapKeyParams {
55
- /** A {@link Jwk} containing the key used to encrypt the unwrapped key. */
56
- encryptionKey: Jwk;
57
- /** A {@link Jwk} containing the private key to be wrapped. */
58
- unwrappedKey: Jwk;
59
- /** An object defining the algorithm-specific parameters for encrypting the `unwrappedKey`. */
60
- encryptParams?: unknown;
61
- }
62
- /**
63
- * Parameters for unwrapping a key.
64
- */
65
- export interface UnwrapKeyParams {
66
- /** A {@link Jwk} containing the key used to decrypt the unwrapped key. */
67
- decryptionKey: Jwk;
68
- /** The wrapped private key as a byte array. */
69
- wrappedKeyBytes: Uint8Array;
70
- /** The algorithm identifier of the key encrypted in `wrappedKeyBytes`. */
71
- wrappedKeyAlgorithm: string;
72
- /** An object defining the algorithm-specific parameters for decrypting the `wrappedKeyBytes`. */
73
- decryptParams?: unknown;
74
- }
75
- //# sourceMappingURL=params-direct.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params-direct.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/types/params-direct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,cAAc,EAAE,UAAU,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,GAAG,EAAE,GAAG,CAAC;IAET,yCAAyC;IACzC,IAAI,EAAE,UAAU,CAAC;IAEjB,6EAA6E;IAC7E,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,SAAS,EAAE,mBAAmB,CAAC;IAE/B,8DAA8D;IAC9D,YAAY,EAAE,UAAU,CAAC;IAEzB,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAE1C,mEAAmE;IACnE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8DAA8D;IAC9D,YAAY,EAAE,UAAU,CAAC;IAEzB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,GAAG,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,GAAG,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,aAAa,EAAE,GAAG,CAAC;IAEnB,8DAA8D;IAC9D,YAAY,EAAE,GAAG,CAAC;IAElB,8FAA8F;IAC9F,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,aAAa,EAAE,GAAG,CAAC;IAEnB,+CAA+C;IAC/C,eAAe,EAAE,UAAU,CAAC;IAE5B,0EAA0E;IAC1E,mBAAmB,EAAE,MAAM,CAAC;IAE5B,iGAAiG;IACjG,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}