@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,49 +0,0 @@
1
- export type JsonRpcId = string | number | null;
2
- export type JsonRpcParams = any;
3
- export type JsonRpcVersion = '2.0';
4
- export interface JsonRpcRequest {
5
- jsonrpc: JsonRpcVersion;
6
- id?: JsonRpcId;
7
- /** JSON RPC Subscription Extension Parameters */
8
- subscription?: {
9
- id: JsonRpcId;
10
- };
11
- method: string;
12
- params?: any;
13
- }
14
- export interface JsonRpcError {
15
- code: JsonRpcErrorCodes;
16
- message: string;
17
- data?: any;
18
- }
19
- export declare enum JsonRpcErrorCodes {
20
- InvalidRequest = -32600,
21
- MethodNotFound = -32601,
22
- InvalidParams = -32602,
23
- InternalError = -32603,
24
- ParseError = -32700,
25
- TransportError = -32300,
26
- BadRequest = -50400,// equivalent to HTTP Status 400
27
- Unauthorized = -50401,// equivalent to HTTP Status 401
28
- Forbidden = -50403,// equivalent to HTTP Status 403,
29
- Conflict = -50409
30
- }
31
- export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
32
- export interface JsonRpcSuccessResponse {
33
- jsonrpc: JsonRpcVersion;
34
- id: JsonRpcId;
35
- result: any;
36
- error?: never;
37
- }
38
- export interface JsonRpcErrorResponse {
39
- jsonrpc: JsonRpcVersion;
40
- id: JsonRpcId;
41
- result?: never;
42
- error: JsonRpcError;
43
- }
44
- export declare const createJsonRpcErrorResponse: (id: JsonRpcId, code: JsonRpcErrorCodes, message: string, data?: any) => JsonRpcErrorResponse;
45
- export declare const createJsonRpcRequest: (id: JsonRpcId, method: string, params?: JsonRpcParams) => JsonRpcRequest;
46
- export declare const createJsonRpcSubscriptionRequest: (id: JsonRpcId, method: string, subscriptionId: JsonRpcId, params?: any) => JsonRpcRequest;
47
- export declare const createJsonRpcSuccessResponse: (id: JsonRpcId, result: any) => JsonRpcSuccessResponse;
48
- export declare function parseJson(text: string): object | null;
49
- //# sourceMappingURL=json-rpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/clients/json-rpc.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/C,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAChC,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC;AAEnC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,iDAAiD;IACjD,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,CAAA;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,oBAAY,iBAAiB;IAE3B,cAAc,SAAS;IACvB,cAAc,SAAS;IACvB,aAAa,SAAS;IACtB,aAAa,SAAS;IACtB,UAAU,SAAS;IACnB,cAAc,SAAS;IAGvB,UAAU,SAAS,CAAE,gCAAgC;IACrD,YAAY,SAAS,CAAE,gCAAgC;IACvD,SAAS,SAAS,CAAE,iCAAiC;IACrD,QAAQ,SAAS;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAE5E,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,cAAc,CAAC;IACxB,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,eAAO,MAAM,0BAA0B,OACjC,SAAS,QACP,iBAAiB,WACd,MAAM,SACR,GAAG,KACT,oBAOF,CAAC;AAEF,eAAO,MAAM,oBAAoB,OAC3B,SAAS,UACL,MAAM,WACL,aAAa,KACrB,cAOF,CAAC;AAEF,eAAO,MAAM,gCAAgC,OACvC,SAAS,UACL,MAAM,kBACE,SAAS,WAChB,GAAG,KACX,cAUF,CAAC;AAEF,eAAO,MAAM,4BAA4B,OACnC,SAAS,UACL,GAAG,KACV,sBAMF,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMrD"}
@@ -1,20 +0,0 @@
1
- import type { KeyValueStore } from '@enbox/common';
2
- export type ServerInfo = {
3
- /** the maximum file size the user can request to store */
4
- maxFileSize: number;
5
- /**
6
- * an array of strings representing the server's registration requirements.
7
- *
8
- * ie. ['proof-of-work-sha256-v0', 'terms-of-service']
9
- * */
10
- registrationRequirements: string[];
11
- /** whether web socket support is enabled on this server */
12
- webSocketSupport: boolean;
13
- };
14
- export interface DwnServerInfoCache extends KeyValueStore<string, ServerInfo | undefined> {
15
- }
16
- export interface DwnServerInfoRpc {
17
- /** retrieves the DWN Sever info, used to detect features such as WebSocket Subscriptions */
18
- getServerInfo(url: string): Promise<ServerInfo>;
19
- }
20
- //# sourceMappingURL=server-info-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-info-types.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/clients/server-info-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG;IACvB,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB;;;;SAIK;IACL,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,2DAA2D;IAC3D,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,aAAa,CAAC,MAAM,EAAE,UAAU,GAAE,SAAS,CAAC;CAAG;AAE3F,MAAM,WAAW,gBAAgB;IAC/B,4FAA4F;IAC5F,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjD"}
@@ -1,10 +0,0 @@
1
- import type { JsonRpcSocketOptions } from './json-rpc-socket.js';
2
- import type { DwnRpc, DwnRpcRequest, DwnRpcResponse } from './dwn-rpc-types.js';
3
- export declare class WebSocketDwnRpcClient implements DwnRpc {
4
- get transportProtocols(): string[];
5
- private static connections;
6
- sendDwnRequest(request: DwnRpcRequest, jsonRpcSocketOptions?: JsonRpcSocketOptions): Promise<DwnRpcResponse>;
7
- private static processMessage;
8
- private static subscriptionRequest;
9
- }
10
- //# sourceMappingURL=web-socket-clients.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-socket-clients.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/clients/web-socket-clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAA0B,MAAM,oBAAoB,CAAC;AAYxG,qBAAa,qBAAsB,YAAW,MAAM;IAClD,IAAW,kBAAkB,IAAI,MAAM,EAAE,CAA4B;IAErE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAuC;IAE3D,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;mBA8B7F,cAAc;mBAed,mBAAmB;CAuCzC"}
@@ -1,2 +0,0 @@
1
- export declare function hasDuplicateProperties(...objects: Array<Record<string, any> | undefined>): boolean;
2
- //# sourceMappingURL=object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/common/object.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAclG"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Infer the type of a type parameter.
3
- *
4
- * This is useful when you want to infer the type of a type parameter in a generic function.
5
- */
6
- export type InferType<T> = T extends infer U ? U : never;
7
- //# sourceMappingURL=type-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../../src/prototyping/common/type-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -1,151 +0,0 @@
1
- import type { AES_GCM_TAG_LENGTHS, Cipher, DecryptParams, EncryptParams, GenerateKeyParams, Jwk, KeyConverter, KeyGenerator } from '@enbox/crypto';
2
- import { CryptoAlgorithm } from '@enbox/crypto';
3
- import type { BytesToPrivateKeyParams, PrivateKeyToBytesParams } from '../types/params-direct.js';
4
- /**
5
- * The `AesGcmGenerateKeyParams` interface defines the algorithm-specific parameters that should be
6
- * passed into the `generateKey()` method when using the AES-GCM algorithm.
7
- */
8
- export interface AesGcmGenerateKeyParams extends GenerateKeyParams {
9
- /** Specifies the algorithm variant for key generation in AES-GCM mode.
10
- * The value determines the length of the key to be generated and must be one of the following:
11
- * - `"A128GCM"`: Generates a 128-bit key.
12
- * - `"A192GCM"`: Generates a 192-bit key.
13
- * - `"A256GCM"`: Generates a 256-bit key.
14
- */
15
- algorithm: 'A128GCM' | 'A192GCM' | 'A256GCM';
16
- }
17
- /**
18
- * The `AesGcmParams` interface defines the algorithm-specific parameters that should be passed
19
- * into the `encrypt()` and `decrypt()` methods when using the AES-GCM algorithm.
20
- */
21
- export interface AesGcmParams {
22
- /**
23
- * The `additionalData` property is used for authentication alongside encrypted data but isn't
24
- * encrypted itself. It must match in both encryption and decryption; a mismatch will cause
25
- * decryption to fail. This feature allows for the authentication of data without encrypting it.
26
- *
27
- * The `additionalData` property is optional and omitting it does not compromise encryption
28
- * security.
29
- */
30
- additionalData?: Uint8Array;
31
- /**
32
- * The initialization vector (IV) must be unique for every encryption operation carried out with a
33
- * given key. The IV need not be secret, but it must be unpredictable: that is, the IV must not be
34
- * reused with the same key. The IV must be 12 bytes (96 bits) in length in accordance with the
35
- * AES-GCM specification recommendedation to promote interoperability and efficiency.
36
- *
37
- * Note: It is OK to transmit the IV in the clear with the encrypted message.
38
- */
39
- iv: Uint8Array;
40
- /**
41
- * This property determines the size in bits of the authentication tag generated in the encryption
42
- * operation and used for authentication in the corresponding decryption. In accordance with the
43
- * AES-GCM specification, the tag length must be 96, 104, 112, 120 or 128.
44
- *
45
- * The `tagLength` property is optional and defaults to 128 bits if omitted.
46
- */
47
- tagLength?: typeof AES_GCM_TAG_LENGTHS[number];
48
- }
49
- /**
50
- * The `AesGcmAlgorithm` class provides a concrete implementation for cryptographic operations using
51
- * the AES algorithm in Galois/Counter Mode (GCM). This class implements both
52
- * {@link Cipher | `Cipher`} and { @link KeyGenerator | `KeyGenerator`} interfaces, providing
53
- * key generation, encryption, and decryption features.
54
- *
55
- * This class is typically accessed through implementations that extend the
56
- * {@link CryptoApi | `CryptoApi`} interface.
57
- */
58
- export declare class AesGcmAlgorithm extends CryptoAlgorithm implements Cipher<AesGcmParams, AesGcmParams>, KeyConverter, KeyGenerator<AesGcmGenerateKeyParams, Jwk> {
59
- bytesToPrivateKey({ privateKeyBytes }: BytesToPrivateKeyParams): Promise<Jwk>;
60
- /**
61
- * Decrypts the provided data using AES-GCM.
62
- *
63
- * @remarks
64
- * This method performs AES-GCM decryption on the given encrypted data using the specified key.
65
- * It requires an initialization vector (IV), the encrypted data along with the decryption key,
66
- * and optionally, additional authenticated data (AAD). The method returns the decrypted data as a
67
- * Uint8Array. The optional `tagLength` parameter specifies the size in bits of the authentication
68
- * tag used when encrypting the data. If not specified, the default tag length of 128 bits is
69
- * used.
70
- *
71
- * @example
72
- * ```ts
73
- * const aesGcm = new AesGcmAlgorithm();
74
- * const encryptedData = new Uint8Array([...]); // Encrypted data
75
- * const iv = new Uint8Array([...]); // Initialization vector used during encryption
76
- * const additionalData = new Uint8Array([...]); // Optional additional authenticated data
77
- * const key = { ... }; // A Jwk object representing the AES key
78
- * const decryptedData = await aesGcm.decrypt({
79
- * data: encryptedData,
80
- * iv,
81
- * additionalData,
82
- * key,
83
- * tagLength: 128 // Optional tag length in bits
84
- * });
85
- * ```
86
- *
87
- * @param params - The parameters for the decryption operation.
88
- *
89
- * @returns A Promise that resolves to the decrypted data as a Uint8Array.
90
- */
91
- decrypt(params: DecryptParams & AesGcmParams): Promise<Uint8Array>;
92
- /**
93
- * Encrypts the provided data using AES-GCM.
94
- *
95
- * @remarks
96
- * This method performs AES-GCM encryption on the given data using the specified key.
97
- * It requires an initialization vector (IV), the encrypted data along with the decryption key,
98
- * and optionally, additional authenticated data (AAD). The method returns the encrypted data as a
99
- * Uint8Array. The optional `tagLength` parameter specifies the size in bits of the authentication
100
- * tag generated in the encryption operation and used for authentication in the corresponding
101
- * decryption. If not specified, the default tag length of 128 bits is used.
102
- *
103
- * @example
104
- * ```ts
105
- * const aesGcm = new AesGcmAlgorithm();
106
- * const data = new TextEncoder().encode('Messsage');
107
- * const iv = new Uint8Array([...]); // Initialization vector
108
- * const additionalData = new Uint8Array([...]); // Optional additional authenticated data
109
- * const key = { ... }; // A Jwk object representing an AES key
110
- * const encryptedData = await aesGcm.encrypt({
111
- * data,
112
- * iv,
113
- * additionalData,
114
- * key,
115
- * tagLength: 128 // Optional tag length in bits
116
- * });
117
- * ```
118
- *
119
- * @param params - The parameters for the encryption operation.
120
- *
121
- * @returns A Promise that resolves to the encrypted data as a Uint8Array.
122
- */
123
- encrypt(params: EncryptParams & AesGcmParams): Promise<Uint8Array>;
124
- /**
125
- * Generates a symmetric key for AES in Galois/Counter Mode (GCM) in JSON Web Key (JWK) format.
126
- *
127
- * @remarks
128
- * This method generates a symmetric AES key for use in GCM mode, based on the specified
129
- * `algorithm` parameter which determines the key length. It uses cryptographically secure random
130
- * number generation to ensure the uniqueness and security of the key. The key is returned in JWK
131
- * format.
132
- *
133
- * The generated key includes the following components:
134
- * - `kty`: Key Type, set to 'oct' for Octet Sequence.
135
- * - `k`: The symmetric key component, base64url-encoded.
136
- * - `kid`: Key ID, generated based on the JWK thumbprint.
137
- *
138
- * @example
139
- * ```ts
140
- * const aesGcm = new AesGcmAlgorithm();
141
- * const privateKey = await aesGcm.generateKey({ algorithm: 'A256GCM' });
142
- * ```
143
- *
144
- * @param params - The parameters for the key generation.
145
- *
146
- * @returns A Promise that resolves to the generated symmetric key in JWK format.
147
- */
148
- generateKey({ algorithm }: AesGcmGenerateKeyParams): Promise<Jwk>;
149
- privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
150
- }
151
- //# sourceMappingURL=aes-gcm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aes-gcm.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/aes-gcm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,GAAG,EACH,YAAY,EACZ,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAU,eAAe,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE;;;;;OAKG;IACH,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;IAE5B;;;;;;;OAOG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,eACnC,YAAW,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,EAClC,YAAY,EACZ,YAAY,CAAC,uBAAuB,EAAE,GAAG,CAAC;IAExC,iBAAiB,CAAC,EAAE,eAAe,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC;IAU1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,OAAO,CAAC,MAAM,EACzB,aAAa,GAAG,YAAY,GAC3B,OAAO,CAAC,UAAU,CAAC;IAMtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,OAAO,CAAC,MAAM,EACzB,aAAa,GAAG,YAAY,GAC3B,OAAO,CAAC,UAAU,CAAC;IAMtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,WAAW,CAAC,EAAE,SAAS,EAAE,EACpC,uBAAuB,GACtB,OAAO,CAAC,GAAG,CAAC;IAaF,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;CAM7F"}
@@ -1,108 +0,0 @@
1
- import type { RequireOnly } from '@enbox/common';
2
- import type { BytesToPrivateKeyParams, GenerateKeyParams, Jwk, KeyConverter, KeyGenerator, KeyWrapper, PrivateKeyToBytesParams, UnwrapKeyParams, WrapKeyParams } from '@enbox/crypto';
3
- import { CryptoAlgorithm } from '@enbox/crypto';
4
- /**
5
- * The `AesKwGenerateKeyParams` interface defines the algorithm-specific parameters that should be
6
- * passed into the `generateKey()` method when using the AES-KW algorithm.
7
- */
8
- export interface AesKwGenerateKeyParams extends GenerateKeyParams {
9
- /** Specifies the algorithm variant for key generation in AES-KW mode.
10
- * The value determines the length of the key to be generated and must be one of the following:
11
- * - `"A128KW"`: AES Key Wrap using a 128-bit key.
12
- * - `"A192KW"`: AES Key Wrap using a 192-bit key.
13
- * - `"A256KW"`: AES Key Wrap using a 256-bit key.
14
- */
15
- algorithm: 'A128KW' | 'A192KW' | 'A256KW';
16
- }
17
- /**
18
- * The `AesKwAlgorithm` class provides a concrete implementation for cryptographic operations using
19
- * the AES algorithm for key wrapping. This class implements both
20
- * {@link KeyGenerator | `KeyGenerator`} and {@link KeyWrapper | `KeyWrapper`} interfaces, providing
21
- * key generation, key wrapping, and key unwrapping features.
22
- *
23
- * This class is typically accessed through implementations that extend the
24
- * {@link CryptoApi | `CryptoApi`} interface.
25
- */
26
- export declare class AesKwAlgorithm extends CryptoAlgorithm implements KeyConverter, KeyGenerator<AesKwGenerateKeyParams, Jwk>, KeyWrapper<WrapKeyParams, UnwrapKeyParams> {
27
- bytesToPrivateKey({ privateKeyBytes }: RequireOnly<BytesToPrivateKeyParams, 'privateKeyBytes'>): Promise<Jwk>;
28
- /**
29
- * Generates a symmetric key for AES for key wrapping in JSON Web Key (JWK) format.
30
- *
31
- * @remarks
32
- * This method generates a symmetric AES key for use in key wrapping mode, based on the specified
33
- * `algorithm` parameter which determines the key length. It uses cryptographically secure random
34
- * number generation to ensure the uniqueness and security of the key. The key is returned in JWK
35
- * format.
36
- *
37
- * The generated key includes the following components:
38
- * - `kty`: Key Type, set to 'oct' for Octet Sequence.
39
- * - `k`: The symmetric key component, base64url-encoded.
40
- * - `kid`: Key ID, generated based on the JWK thumbprint.
41
- * - `alg`: Algorithm, set to 'A128KW', 'A192KW', or 'A256KW' for AES Key Wrap with the
42
- * specified key length.
43
- *
44
- * @example
45
- * ```ts
46
- * const aesKw = new AesKwAlgorithm();
47
- * const privateKey = await aesKw.generateKey({ algorithm: 'A256KW' });
48
- * ```
49
- *
50
- * @param params - The parameters for the key generation.
51
- *
52
- * @returns A Promise that resolves to the generated symmetric key in JWK format.
53
- */
54
- generateKey({ algorithm }: AesKwGenerateKeyParams): Promise<Jwk>;
55
- privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
56
- /**
57
- * Decrypts a wrapped key using the AES Key Wrap algorithm.
58
- *
59
- * @remarks
60
- * This method unwraps a previously wrapped cryptographic key using the AES Key Wrap algorithm.
61
- * The wrapped key, provided as a byte array, is unwrapped using the decryption key specified in
62
- * the parameters.
63
- *
64
- * This operation is useful for securely receiving keys transmitted over untrusted mediums. The
65
- * method returns the unwrapped key as a JSON Web Key (JWK).
66
- *
67
- * @example
68
- * ```ts
69
- * const aesKw = new AesKwAlgorithm();
70
- * const wrappedKeyBytes = new Uint8Array([...]); // Byte array of a wrapped AES-256 GCM key
71
- * const decryptionKey = { ... }; // A Jwk object representing the AES unwrapping key
72
- * const unwrappedKey = await aesKw.unwrapKey({
73
- * wrappedKeyBytes,
74
- * wrappedKeyAlgorithm: 'A256GCM',
75
- * decryptionKey
76
- * });
77
- * ```
78
- *
79
- * @param params - The parameters for the key unwrapping operation.
80
- *
81
- * @returns A Promise that resolves to the unwrapped key in JWK format.
82
- */
83
- unwrapKey(params: UnwrapKeyParams): Promise<Jwk>;
84
- /**
85
- * Encrypts a given key using the AES Key Wrap algorithm.
86
- *
87
- * @remarks
88
- * This method wraps a given cryptographic key using the AES Key Wrap algorithm. The private key
89
- * to be wrapped is provided in the form of a JSON Web Key (JWK).
90
- *
91
- * This operation is useful for securely transmitting keys over untrusted mediums. The method
92
- * returns the wrapped key as a byte array.
93
- *
94
- * @example
95
- * ```ts
96
- * const aesKw = new AesKwAlgorithm();
97
- * const unwrappedKey = { ... }; // A Jwk object representing the key to be wrapped
98
- * const encryptionKey = { ... }; // A Jwk object representing the AES wrapping key
99
- * const wrappedKeyBytes = await aesKw.wrapKey({ unwrappedKey, encryptionKey });
100
- * ```
101
- *
102
- * @param params - The parameters for the key wrapping operation.
103
- *
104
- * @returns A Promise that resolves to the wrapped key as a Uint8Array.
105
- */
106
- wrapKey(params: WrapKeyParams): Promise<Uint8Array>;
107
- }
108
- //# sourceMappingURL=aes-kw.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aes-kw.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/aes-kw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtL,OAAO,EAAS,eAAe,EAAE,MAAM,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D;;;;;OAKG;IACH,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,eAClC,YAAW,YAAY,EACZ,YAAY,CAAC,sBAAsB,EAAE,GAAG,CAAC,EACzC,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC;IAExC,iBAAiB,CAAC,EAAE,eAAe,EAAE,EAChD,WAAW,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,GACtD,OAAO,CAAC,GAAG,CAAC;IAUf;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,WAAW,CAAC,EAAE,SAAS,EAAE,EACpC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAaF,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;IAOtB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACU,SAAS,CAAC,MAAM,EAC3B,eAAe,GACd,OAAO,CAAC,GAAG,CAAC;IAMf;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,OAAO,CAAC,MAAM,EACzB,aAAa,GACZ,OAAO,CAAC,UAAU,CAAC;CAKvB"}
@@ -1,160 +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 `EcdsaGenerateKeyParams` interface defines the algorithm-specific parameters that should be
6
- * passed into the `generateKey()` method when using the ECDSA algorithm.
7
- */
8
- export interface EcdsaGenerateKeyParams extends GenerateKeyParams {
9
- /**
10
- * A string defining the type of key to generate. The value must be one of the following:
11
- * - `"ES256"`: ECDSA using the secp256r1 (P-256) curve and SHA-256.
12
- * - `"ES256K"`: ECDSA using the secp256k1 curve and SHA-256.
13
- * - `"secp256k1"`: ECDSA using the secp256k1 curve and SHA-256.
14
- * - `"secp256r1"`: ECDSA using the secp256r1 (P-256) curve and SHA-256.
15
- */
16
- algorithm: 'ES256' | 'ES256K' | 'secp256k1' | 'secp256r1';
17
- }
18
- /**
19
- * The `EcdsaAlgorithm` class provides a concrete implementation for cryptographic operations using
20
- * the Elliptic Curve Digital Signature Algorithm (ECDSA). This class implements both
21
- * {@link Signer | `Signer`} and { @link AsymmetricKeyGenerator | `AsymmetricKeyGenerator`}
22
- * interfaces, providing private key generation, public key derivation, and creation/verification
23
- * of signatures.
24
- *
25
- * This class is typically accessed through implementations that extend the
26
- * {@link CryptoApi | `CryptoApi`} interface.
27
- */
28
- export declare class EcdsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EcdsaGenerateKeyParams, Jwk, GetPublicKeyParams>, KeyConverter, AsymmetricKeyConverter, Signer<SignParams, VerifyParams> {
29
- bytesToPrivateKey({ algorithm, privateKeyBytes }: BytesToPrivateKeyParams & {
30
- algorithm: 'ES256' | 'ES256K' | 'secp256k1' | 'secp256r1';
31
- }): Promise<Jwk>;
32
- bytesToPublicKey({ algorithm, publicKeyBytes }: BytesToPublicKeyParams & {
33
- algorithm: 'ES256' | 'ES256K' | 'secp256k1' | 'secp256r1';
34
- }): Promise<Jwk>;
35
- /**
36
- * Derives the public key in JWK format from a given private key.
37
- *
38
- * @remarks
39
- * This method takes a private key in JWK format and derives its corresponding public key,
40
- * also in JWK format. The process ensures that the derived public key correctly corresponds to
41
- * the given private key.
42
- *
43
- * @example
44
- * ```ts
45
- * const ecdsa = new EcdsaAlgorithm();
46
- * const privateKey = { ... }; // A Jwk object representing a private key
47
- * const publicKey = await ecdsa.computePublicKey({ key: privateKey });
48
- * ```
49
- *
50
- * @param params - The parameters for the public key derivation.
51
- * @param params.key - The private key in JWK format from which to derive the public key.
52
- *
53
- * @returns A Promise that resolves to the derived public key in JWK format.
54
- */
55
- computePublicKey({ key }: ComputePublicKeyParams): Promise<Jwk>;
56
- /**
57
- * Generates a new private key with the specified algorithm in JSON Web Key (JWK) format.
58
- *
59
- * @example
60
- * ```ts
61
- * const ecdsa = new EcdsaAlgorithm();
62
- * const privateKey = await ecdsa.generateKey({ algorithm: 'ES256K' });
63
- * ```
64
- *
65
- * @param params - The parameters for key generation.
66
- * @param params.algorithm - The algorithm to use for key generation.
67
- *
68
- * @returns A Promise that resolves to the generated private key in JWK format.
69
- */
70
- generateKey({ algorithm }: EcdsaGenerateKeyParams): Promise<Jwk>;
71
- /**
72
- * Retrieves the public key properties from a given private key in JWK format.
73
- *
74
- * @remarks
75
- * This method extracts the public key portion from an ECDSA private key in JWK format. It does
76
- * so by removing the private key property 'd' and making a shallow copy, effectively yielding the
77
- * public key.
78
- *
79
- * Note: This method offers a significant performance advantage, being about 200 times faster
80
- * than `computePublicKey()`. However, it does not mathematically validate the private key, nor
81
- * does it derive the public key from the private key. It simply extracts existing public key
82
- * properties from the private key object. This makes it suitable for scenarios where speed is
83
- * critical and the private key's integrity is already assured.
84
- *
85
- * @example
86
- * ```ts
87
- * const ecdsa = new EcdsaAlgorithm();
88
- * const privateKey = { ... }; // A Jwk object representing a private key
89
- * const publicKey = await ecdsa.getPublicKey({ key: privateKey });
90
- * ```
91
- *
92
- * @param params - The parameters for retrieving the public key properties.
93
- * @param params.key - The private key in JWK format.
94
- *
95
- * @returns A Promise that resolves to the public key in JWK format.
96
- */
97
- getPublicKey({ key }: GetPublicKeyParams): Promise<Jwk>;
98
- privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
99
- publicKeyToBytes({ publicKey }: PublicKeyToBytesParams): Promise<Uint8Array>;
100
- /**
101
- * Generates an ECDSA signature of given data using a private key.
102
- *
103
- * @remarks
104
- * This method uses the signature algorithm determined by the given `algorithm` to sign the
105
- * provided data.
106
- *
107
- * The signature can later be verified by parties with access to the corresponding
108
- * public key, ensuring that the data has not been tampered with and was indeed signed by the
109
- * holder of the private key.
110
- *
111
- * @example
112
- * ```ts
113
- * const ecdsa = new EcdsaAlgorithm();
114
- * const data = new TextEncoder().encode('Message');
115
- * const privateKey = { ... }; // A Jwk object representing a private key
116
- * const signature = await ecdsa.sign({
117
- * key: privateKey,
118
- * data
119
- * });
120
- * ```
121
- *
122
- * @param params - The parameters for the signing operation.
123
- * @param params.key - The private key to use for signing, represented in JWK format.
124
- * @param params.data - The data to sign.
125
- *
126
- * @returns A Promise resolving to the digital signature as a `Uint8Array`.
127
- */
128
- sign({ key, data }: SignParams): Promise<Uint8Array>;
129
- /**
130
- * Verifies an ECDSA signature associated with the provided data using the provided key.
131
- *
132
- * @remarks
133
- * This method uses the signature algorithm determined by the `crv` property of the provided key
134
- * to check the validity of a digital signature against the original data. It confirms whether the
135
- * signature was created by the holder of the corresponding private key and that the data has not
136
- * been tampered with.
137
- *s
138
- * @example
139
- * ```ts
140
- * const ecdsa = new EcdsaAlgorithm();
141
- * const publicKey = { ... }; // Public key in JWK format corresponding to the private key that signed the data
142
- * const signature = new Uint8Array([...]); // Signature to verify
143
- * const data = new TextEncoder().encode('Message');
144
- * const isValid = await ecdsa.verify({
145
- * key: publicKey,
146
- * signature,
147
- * data
148
- * });
149
- * ```
150
- *
151
- * @param params - The parameters for the verification operation.
152
- * @param params.key - The key to use for verification.
153
- * @param params.signature - The signature to verify.
154
- * @param params.data - The data to verify.
155
- *
156
- * @returns A Promise resolving to a boolean indicating whether the signature is valid.
157
- */
158
- verify({ key, signature, data }: VerifyParams): Promise<boolean>;
159
- }
160
- //# sourceMappingURL=ecdsa.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../../../src/prototyping/crypto/algorithms/ecdsa.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,EAAuD,MAAM,eAAe,CAAC;AAErG,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGlJ;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;CAC3D;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,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAA;KAAE,GACtF,OAAO,CAAC,GAAG,CAAC;IAuBF,gBAAgB,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,EACzD,sBAAsB,GAAG;QAAE,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAA;KAAE,GACrF,OAAO,CAAC,GAAG,CAAC;IAuBf;;;;;;;;;;;;;;;;;;;OAmBG;IACU,gBAAgB,CAAC,EAAE,GAAG,EAAE,EACnC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAuBf;;;;;;;;;;;;;OAaG;IACU,WAAW,CAAC,EAAE,SAAS,EAAE,EACpC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAmBf;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,EAAE,GAAG,EAAE,EAC/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAuBF,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;IAiBT,gBAAgB,CAAC,EAAE,SAAS,EAAE,EACzC,sBAAsB,GACrB,OAAO,CAAC,UAAU,CAAC;IAiBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACU,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAC7B,UAAU,GACT,OAAO,CAAC,UAAU,CAAC;IAmBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACU,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1C,YAAY,GACX,OAAO,CAAC,OAAO,CAAC;CAkBpB"}