@dynamic-labs-wallet/forward-mpc-shared 0.1.0-alpha.6

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 (163) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +52 -0
  3. package/dist/attestation/index.d.ts +1 -0
  4. package/dist/attestation/index.d.ts.map +1 -0
  5. package/dist/attestation/index.js +4 -0
  6. package/dist/attestation/index.js.map +1 -0
  7. package/dist/codecs/DomainCodec.d.ts +11 -0
  8. package/dist/codecs/DomainCodec.d.ts.map +1 -0
  9. package/dist/codecs/DomainCodec.js +25 -0
  10. package/dist/codecs/DomainCodec.js.map +1 -0
  11. package/dist/codecs/EncryptedKeyshareCodec.d.ts +11 -0
  12. package/dist/codecs/EncryptedKeyshareCodec.d.ts.map +1 -0
  13. package/dist/codecs/EncryptedKeyshareCodec.js +11 -0
  14. package/dist/codecs/EncryptedKeyshareCodec.js.map +1 -0
  15. package/dist/codecs/Uint32ArrayCodec.d.ts +3 -0
  16. package/dist/codecs/Uint32ArrayCodec.d.ts.map +1 -0
  17. package/dist/codecs/Uint32ArrayCodec.js +37 -0
  18. package/dist/codecs/Uint32ArrayCodec.js.map +1 -0
  19. package/dist/codecs/Uint8ArrayCodec.d.ts +3 -0
  20. package/dist/codecs/Uint8ArrayCodec.d.ts.map +1 -0
  21. package/dist/codecs/Uint8ArrayCodec.js +26 -0
  22. package/dist/codecs/Uint8ArrayCodec.js.map +1 -0
  23. package/dist/codecs/Uint8ArrayOrHexCodec.d.ts +3 -0
  24. package/dist/codecs/Uint8ArrayOrHexCodec.d.ts.map +1 -0
  25. package/dist/codecs/Uint8ArrayOrHexCodec.js +35 -0
  26. package/dist/codecs/Uint8ArrayOrHexCodec.js.map +1 -0
  27. package/dist/codecs/WebSocketErrorCodec.d.ts +15 -0
  28. package/dist/codecs/WebSocketErrorCodec.d.ts.map +1 -0
  29. package/dist/codecs/WebSocketErrorCodec.js +14 -0
  30. package/dist/codecs/WebSocketErrorCodec.js.map +1 -0
  31. package/dist/codecs/index.d.ts +4 -0
  32. package/dist/codecs/index.d.ts.map +1 -0
  33. package/dist/codecs/index.js +4 -0
  34. package/dist/codecs/index.js.map +1 -0
  35. package/dist/constants/algorithms.d.ts +56 -0
  36. package/dist/constants/algorithms.d.ts.map +1 -0
  37. package/dist/constants/algorithms.js +60 -0
  38. package/dist/constants/algorithms.js.map +1 -0
  39. package/dist/constants/index.d.ts +2 -0
  40. package/dist/constants/index.d.ts.map +1 -0
  41. package/dist/constants/index.js +2 -0
  42. package/dist/constants/index.js.map +1 -0
  43. package/dist/crypto/decapsulate.d.ts +2 -0
  44. package/dist/crypto/decapsulate.d.ts.map +1 -0
  45. package/dist/crypto/decapsulate.js +5 -0
  46. package/dist/crypto/decapsulate.js.map +1 -0
  47. package/dist/crypto/encapsulate.d.ts +5 -0
  48. package/dist/crypto/encapsulate.d.ts.map +1 -0
  49. package/dist/crypto/encapsulate.js +5 -0
  50. package/dist/crypto/encapsulate.js.map +1 -0
  51. package/dist/crypto/generateKeypair.d.ts +5 -0
  52. package/dist/crypto/generateKeypair.d.ts.map +1 -0
  53. package/dist/crypto/generateKeypair.js +17 -0
  54. package/dist/crypto/generateKeypair.js.map +1 -0
  55. package/dist/crypto/index.d.ts +6 -0
  56. package/dist/crypto/index.d.ts.map +1 -0
  57. package/dist/crypto/index.js +6 -0
  58. package/dist/crypto/index.js.map +1 -0
  59. package/dist/crypto/keyDerivation.d.ts +14 -0
  60. package/dist/crypto/keyDerivation.d.ts.map +1 -0
  61. package/dist/crypto/keyDerivation.js +21 -0
  62. package/dist/crypto/keyDerivation.js.map +1 -0
  63. package/dist/crypto/keyshareEncryption.d.ts +13 -0
  64. package/dist/crypto/keyshareEncryption.d.ts.map +1 -0
  65. package/dist/crypto/keyshareEncryption.js +39 -0
  66. package/dist/crypto/keyshareEncryption.js.map +1 -0
  67. package/dist/index.d.ts +9 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +18 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/messages/ConnectionAckV1Request.d.ts +43 -0
  72. package/dist/messages/ConnectionAckV1Request.d.ts.map +1 -0
  73. package/dist/messages/ConnectionAckV1Request.js +17 -0
  74. package/dist/messages/ConnectionAckV1Request.js.map +1 -0
  75. package/dist/messages/ConnectionAckV1Response.d.ts +45 -0
  76. package/dist/messages/ConnectionAckV1Response.d.ts.map +1 -0
  77. package/dist/messages/ConnectionAckV1Response.js +18 -0
  78. package/dist/messages/ConnectionAckV1Response.js.map +1 -0
  79. package/dist/messages/HandshakeV1Request.d.ts +45 -0
  80. package/dist/messages/HandshakeV1Request.d.ts.map +1 -0
  81. package/dist/messages/HandshakeV1Request.js +28 -0
  82. package/dist/messages/HandshakeV1Request.js.map +1 -0
  83. package/dist/messages/HandshakeV1Response.d.ts +47 -0
  84. package/dist/messages/HandshakeV1Response.d.ts.map +1 -0
  85. package/dist/messages/HandshakeV1Response.js +20 -0
  86. package/dist/messages/HandshakeV1Response.js.map +1 -0
  87. package/dist/messages/SignMessageV1Request.d.ts +63 -0
  88. package/dist/messages/SignMessageV1Request.d.ts.map +1 -0
  89. package/dist/messages/SignMessageV1Request.js +42 -0
  90. package/dist/messages/SignMessageV1Request.js.map +1 -0
  91. package/dist/messages/SignMessageV1Response.d.ts +47 -0
  92. package/dist/messages/SignMessageV1Response.d.ts.map +1 -0
  93. package/dist/messages/SignMessageV1Response.js +28 -0
  94. package/dist/messages/SignMessageV1Response.js.map +1 -0
  95. package/dist/messages/allMessages.d.ts +259 -0
  96. package/dist/messages/allMessages.d.ts.map +1 -0
  97. package/dist/messages/allMessages.js +57 -0
  98. package/dist/messages/allMessages.js.map +1 -0
  99. package/dist/messages/base.d.ts +27 -0
  100. package/dist/messages/base.d.ts.map +1 -0
  101. package/dist/messages/base.js +12 -0
  102. package/dist/messages/base.js.map +1 -0
  103. package/dist/messages/index.d.ts +11 -0
  104. package/dist/messages/index.d.ts.map +1 -0
  105. package/dist/messages/index.js +14 -0
  106. package/dist/messages/index.js.map +1 -0
  107. package/dist/messages/registry.d.ts +136 -0
  108. package/dist/messages/registry.d.ts.map +1 -0
  109. package/dist/messages/registry.js +67 -0
  110. package/dist/messages/registry.js.map +1 -0
  111. package/dist/messages/utils/StandardMessage.d.ts +97 -0
  112. package/dist/messages/utils/StandardMessage.d.ts.map +1 -0
  113. package/dist/messages/utils/StandardMessage.js +98 -0
  114. package/dist/messages/utils/StandardMessage.js.map +1 -0
  115. package/dist/messages/utils/encodingHelpers.d.ts +20 -0
  116. package/dist/messages/utils/encodingHelpers.d.ts.map +1 -0
  117. package/dist/messages/utils/encodingHelpers.js +50 -0
  118. package/dist/messages/utils/encodingHelpers.js.map +1 -0
  119. package/dist/messages/utils/index.d.ts +4 -0
  120. package/dist/messages/utils/index.d.ts.map +1 -0
  121. package/dist/messages/utils/index.js +5 -0
  122. package/dist/messages/utils/index.js.map +1 -0
  123. package/dist/messages/utils/schemaBuilder.d.ts +19 -0
  124. package/dist/messages/utils/schemaBuilder.d.ts.map +1 -0
  125. package/dist/messages/utils/schemaBuilder.js +31 -0
  126. package/dist/messages/utils/schemaBuilder.js.map +1 -0
  127. package/dist/signing/algorithms/BIP340SigningAlgorithm.d.ts +20 -0
  128. package/dist/signing/algorithms/BIP340SigningAlgorithm.d.ts.map +1 -0
  129. package/dist/signing/algorithms/BIP340SigningAlgorithm.js +35 -0
  130. package/dist/signing/algorithms/BIP340SigningAlgorithm.js.map +1 -0
  131. package/dist/signing/algorithms/EcdsaSigningAlgorithm.d.ts +20 -0
  132. package/dist/signing/algorithms/EcdsaSigningAlgorithm.d.ts.map +1 -0
  133. package/dist/signing/algorithms/EcdsaSigningAlgorithm.js +43 -0
  134. package/dist/signing/algorithms/EcdsaSigningAlgorithm.js.map +1 -0
  135. package/dist/signing/algorithms/Ed25519SigningAlgorithm.d.ts +18 -0
  136. package/dist/signing/algorithms/Ed25519SigningAlgorithm.d.ts.map +1 -0
  137. package/dist/signing/algorithms/Ed25519SigningAlgorithm.js +34 -0
  138. package/dist/signing/algorithms/Ed25519SigningAlgorithm.js.map +1 -0
  139. package/dist/signing/allAlgorithms.d.ts +50 -0
  140. package/dist/signing/allAlgorithms.d.ts.map +1 -0
  141. package/dist/signing/allAlgorithms.js +59 -0
  142. package/dist/signing/allAlgorithms.js.map +1 -0
  143. package/dist/signing/base.d.ts +42 -0
  144. package/dist/signing/base.d.ts.map +1 -0
  145. package/dist/signing/base.js +6 -0
  146. package/dist/signing/base.js.map +1 -0
  147. package/dist/signing/index.d.ts +7 -0
  148. package/dist/signing/index.d.ts.map +1 -0
  149. package/dist/signing/index.js +9 -0
  150. package/dist/signing/index.js.map +1 -0
  151. package/dist/signing/registry.d.ts +26 -0
  152. package/dist/signing/registry.d.ts.map +1 -0
  153. package/dist/signing/registry.js +36 -0
  154. package/dist/signing/registry.js.map +1 -0
  155. package/dist/types.d.ts +42 -0
  156. package/dist/types.d.ts.map +1 -0
  157. package/dist/types.js +12 -0
  158. package/dist/types.js.map +1 -0
  159. package/dist/utils/assertDefined.d.ts +16 -0
  160. package/dist/utils/assertDefined.d.ts.map +1 -0
  161. package/dist/utils/assertDefined.js +27 -0
  162. package/dist/utils/assertDefined.js.map +1 -0
  163. package/package.json +52 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @dynamic-labs-wallet/forward-mpc-shared
2
+
3
+ Shared types, schemas, and utilities for Forward MPC Client operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @dynamic-labs-wallet/forward-mpc-shared
9
+ # or
10
+ pnpm add @dynamic-labs-wallet/forward-mpc-shared
11
+ # or
12
+ yarn add @dynamic-labs-wallet/forward-mpc-shared
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import {
19
+ // Core types and utilities
20
+ ForwardMpcMessage,
21
+ ForwardMpcError,
22
+
23
+ // Codecs for serialization
24
+ DomainCodec,
25
+ EncryptedKeyshareCodec,
26
+
27
+ // Crypto utilities
28
+ generateKeypair,
29
+ encapsulate,
30
+ decapsulate,
31
+
32
+ // Signing algorithms
33
+ SigningAlgorithm,
34
+ AllSigningAlgorithms,
35
+ } from '@dynamic-labs-wallet/forward-mpc-shared';
36
+ ```
37
+
38
+ ## Exports
39
+
40
+ ### Main Export
41
+
42
+ - Core types, utilities, and constants
43
+
44
+ ### Sub-exports
45
+
46
+ - `./codecs` - Serialization codecs for various data types
47
+ - `./crypto` - Cryptographic utilities and key operations
48
+ - `./utils/*` - Utility functions
49
+
50
+ ## License
51
+
52
+ MIT
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attestation/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Attestation types and constants have been moved to the client package
3
+ // since they are only used for client-side verification, not server-side generation
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/attestation/index.ts"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,oFAAoF","sourcesContent":["// Attestation types and constants have been moved to the client package\n// since they are only used for client-side verification, not server-side generation\n"]}
@@ -0,0 +1,11 @@
1
+ import { Type } from 'io-ts';
2
+ /**
3
+ * Codec for validating domain names without protocol or paths.
4
+ * Allows optional port numbers.
5
+ * Examples:
6
+ * - example.com
7
+ * - sub.example.com
8
+ * - example.com:8080
9
+ */
10
+ export declare const DomainCodec: Type<string, string, unknown>;
11
+ //# sourceMappingURL=DomainCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/DomainCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA8B,MAAM,OAAO,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,+BAuBvB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Type, failure, success, identity } from 'io-ts';
2
+ /**
3
+ * Codec for validating domain names without protocol or paths.
4
+ * Allows optional port numbers.
5
+ * Examples:
6
+ * - example.com
7
+ * - sub.example.com
8
+ * - example.com:8080
9
+ */
10
+ export const DomainCodec = new Type('DomainCodec', (u) => typeof u === 'string', (u, c) => {
11
+ if (typeof u !== 'string') {
12
+ return failure(u, c, 'Value must be a string');
13
+ }
14
+ // Domain regex pattern:
15
+ // - Starts with alphanumeric or hyphen
16
+ // - Can contain dots for subdomains
17
+ // - Optional port number at the end
18
+ // - No protocols or paths allowed
19
+ const domainPattern = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(?::\d{1,5})?$/;
20
+ if (!domainPattern.test(u)) {
21
+ return failure(u, c, 'Invalid domain format');
22
+ }
23
+ return success(u);
24
+ }, identity);
25
+ //# sourceMappingURL=DomainCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomainCodec.js","sourceRoot":"","sources":["../../src/codecs/DomainCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,IAAI,CACjC,aAAa,EACb,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,EACzC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACP,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,wBAAwB,CAAC,CAAC;IACjD,CAAC;IAED,wBAAwB;IACxB,uCAAuC;IACvC,oCAAoC;IACpC,oCAAoC;IACpC,kCAAkC;IAClC,MAAM,aAAa,GACjB,kHAAkH,CAAC;IAErH,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,uBAAuB,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,EACD,QAAQ,CACT,CAAC","sourcesContent":["import { Type, failure, success, identity } from 'io-ts';\n\n/**\n * Codec for validating domain names without protocol or paths.\n * Allows optional port numbers.\n * Examples:\n * - example.com\n * - sub.example.com\n * - example.com:8080\n */\nexport const DomainCodec = new Type<string>(\n 'DomainCodec',\n (u): u is string => typeof u === 'string',\n (u, c) => {\n if (typeof u !== 'string') {\n return failure(u, c, 'Value must be a string');\n }\n\n // Domain regex pattern:\n // - Starts with alphanumeric or hyphen\n // - Can contain dots for subdomains\n // - Optional port number at the end\n // - No protocols or paths allowed\n const domainPattern =\n /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(?::\\d{1,5})?$/;\n\n if (!domainPattern.test(u)) {\n return failure(u, c, 'Invalid domain format');\n }\n\n return success(u);\n },\n identity\n);\n"]}
@@ -0,0 +1,11 @@
1
+ import { TypeOf } from 'io-ts';
2
+ /**
3
+ * Encrypted keyshare structure for secure transmission
4
+ * Contains HKDF salt and AES-256-GCM encrypted payload
5
+ */
6
+ export declare const EncryptedKeyshareCodec: import("io-ts").TypeC<{
7
+ salt: import("io-ts").Type<Uint8Array<ArrayBufferLike>, string, unknown>;
8
+ encryptedPayload: import("io-ts").Type<Uint8Array<ArrayBufferLike>, string, unknown>;
9
+ }>;
10
+ export type EncryptedKeyshare = TypeOf<typeof EncryptedKeyshareCodec>;
11
+ //# sourceMappingURL=EncryptedKeyshareCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EncryptedKeyshareCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/EncryptedKeyshareCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,OAAO,CAAC;AAGrC;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;EAGjC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type } from 'io-ts';
2
+ import { Uint8ArrayCodec } from './Uint8ArrayCodec';
3
+ /**
4
+ * Encrypted keyshare structure for secure transmission
5
+ * Contains HKDF salt and AES-256-GCM encrypted payload
6
+ */
7
+ export const EncryptedKeyshareCodec = type({
8
+ salt: Uint8ArrayCodec,
9
+ encryptedPayload: Uint8ArrayCodec,
10
+ });
11
+ //# sourceMappingURL=EncryptedKeyshareCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EncryptedKeyshareCodec.js","sourceRoot":"","sources":["../../src/codecs/EncryptedKeyshareCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;IACzC,IAAI,EAAE,eAAe;IACrB,gBAAgB,EAAE,eAAe;CAClC,CAAC,CAAC","sourcesContent":["import { type, TypeOf } from 'io-ts';\nimport { Uint8ArrayCodec } from './Uint8ArrayCodec';\n\n/**\n * Encrypted keyshare structure for secure transmission\n * Contains HKDF salt and AES-256-GCM encrypted payload\n */\nexport const EncryptedKeyshareCodec = type({\n salt: Uint8ArrayCodec,\n encryptedPayload: Uint8ArrayCodec,\n});\n\nexport type EncryptedKeyshare = TypeOf<typeof EncryptedKeyshareCodec>;\n"]}
@@ -0,0 +1,3 @@
1
+ import { Type } from 'io-ts';
2
+ export declare const Uint32ArrayCodec: Type<Uint32Array<ArrayBufferLike>, string, unknown>;
3
+ //# sourceMappingURL=Uint32ArrayCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint32ArrayCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/Uint32ArrayCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,gBAAgB,qDA8C5B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { failure, success, Type } from 'io-ts';
2
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
3
+ export const Uint32ArrayCodec = new Type('Uint32Array', // The name of the codec
4
+ (u) => u instanceof Uint32Array, // A type guard
5
+ (u, c) => {
6
+ // The `validate` function for decoding
7
+ if (typeof u !== 'string') {
8
+ return failure(u, c, 'Expected a hex string for Uint32Array');
9
+ }
10
+ try {
11
+ // Remove any '0x' prefix if present
12
+ const cleanHex = u.startsWith('0x') ? u.slice(2) : u;
13
+ // Validate hex string (must be multiple of 8 characters for 32-bit values)
14
+ if (cleanHex.length === 0) {
15
+ return failure(u, c, 'Empty hex string not allowed for Uint32Array');
16
+ }
17
+ if (cleanHex.length % 8 !== 0) {
18
+ return failure(u, c, 'Invalid hex string format for Uint32Array (must be multiple of 8 hex characters)');
19
+ }
20
+ // Convert hex string to Uint8Array using noble-hashes
21
+ const uint8Array = hexToBytes(cleanHex);
22
+ // Convert Uint8Array to Uint32Array by interpreting the buffer
23
+ // Note: This assumes little-endian byte order
24
+ const uint32Array = new Uint32Array(uint8Array.buffer);
25
+ return success(uint32Array);
26
+ }
27
+ catch (e) {
28
+ return failure(u, c, `Invalid hex string: ${e}`);
29
+ }
30
+ },
31
+ // The `encode` function for converting back to the output type
32
+ (a) => {
33
+ // Convert Uint32Array to Uint8Array to use noble-hashes
34
+ const uint8Array = new Uint8Array(a.buffer);
35
+ return bytesToHex(uint8Array);
36
+ });
37
+ //# sourceMappingURL=Uint32ArrayCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint32ArrayCodec.js","sourceRoot":"","sources":["../../src/codecs/Uint32ArrayCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAKtC,aAAa,EAAE,wBAAwB;AACvC,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,YAAY,WAAW,EAAE,eAAe;AAClE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACP,uCAAuC;IACvC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,uCAAuC,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,CAAC;QACH,oCAAoC;QACpC,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAErD,2EAA2E;QAC3E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,8CAA8C,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,OAAO,CACZ,CAAC,EACD,CAAC,EACD,kFAAkF,CACnF,CAAC;QACJ,CAAC;QAED,sDAAsD;QACtD,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAExC,+DAA+D;QAC/D,8CAA8C;QAC9C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEvD,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AACD,+DAA+D;AAC/D,CAAC,CAAC,EAAE,EAAE;IACJ,wDAAwD;IACxD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC,CACF,CAAC","sourcesContent":["import { failure, success, Type } from 'io-ts';\nimport { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\nexport const Uint32ArrayCodec = new Type<\n Uint32Array, // A: The runtime type (the type you work with in your code)\n string, // O: The encoded output type (e.g., JSON representation)\n unknown // I: The input type (e.g., from JSON)\n>(\n 'Uint32Array', // The name of the codec\n (u): u is Uint32Array => u instanceof Uint32Array, // A type guard\n (u, c) => {\n // The `validate` function for decoding\n if (typeof u !== 'string') {\n return failure(u, c, 'Expected a hex string for Uint32Array');\n }\n try {\n // Remove any '0x' prefix if present\n const cleanHex = u.startsWith('0x') ? u.slice(2) : u;\n\n // Validate hex string (must be multiple of 8 characters for 32-bit values)\n if (cleanHex.length === 0) {\n return failure(u, c, 'Empty hex string not allowed for Uint32Array');\n }\n if (cleanHex.length % 8 !== 0) {\n return failure(\n u,\n c,\n 'Invalid hex string format for Uint32Array (must be multiple of 8 hex characters)'\n );\n }\n\n // Convert hex string to Uint8Array using noble-hashes\n const uint8Array = hexToBytes(cleanHex);\n\n // Convert Uint8Array to Uint32Array by interpreting the buffer\n // Note: This assumes little-endian byte order\n const uint32Array = new Uint32Array(uint8Array.buffer);\n\n return success(uint32Array);\n } catch (e) {\n return failure(u, c, `Invalid hex string: ${e}`);\n }\n },\n // The `encode` function for converting back to the output type\n (a) => {\n // Convert Uint32Array to Uint8Array to use noble-hashes\n const uint8Array = new Uint8Array(a.buffer);\n return bytesToHex(uint8Array);\n }\n);\n"]}
@@ -0,0 +1,3 @@
1
+ import { Type } from 'io-ts';
2
+ export declare const Uint8ArrayCodec: Type<Uint8Array<ArrayBufferLike>, string, unknown>;
3
+ //# sourceMappingURL=Uint8ArrayCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint8ArrayCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/Uint8ArrayCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,eAAe,oDA6B3B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { failure, success, Type } from 'io-ts';
2
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
3
+ export const Uint8ArrayCodec = new Type('Uint8Array', // The name of the codec
4
+ (u) => u instanceof Uint8Array, // A type guard
5
+ (u, c) => {
6
+ // The `validate` function for decoding
7
+ if (typeof u !== 'string') {
8
+ return failure(u, c, 'Expected a hex string for Uint8Array');
9
+ }
10
+ try {
11
+ // Remove any '0x' prefix if present
12
+ const cleanHex = u.startsWith('0x') ? u.slice(2) : u;
13
+ // Validate hex string (must be even length and contain only hex characters)
14
+ if (cleanHex.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(cleanHex)) {
15
+ return failure(u, c, 'Invalid hex string format');
16
+ }
17
+ const decoded = hexToBytes(cleanHex);
18
+ return success(decoded);
19
+ }
20
+ catch (e) {
21
+ return failure(u, c, `Invalid hex string: ${e}`);
22
+ }
23
+ },
24
+ // The `encode` function for converting back to the output type
25
+ (a) => bytesToHex(a));
26
+ //# sourceMappingURL=Uint8ArrayCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint8ArrayCodec.js","sourceRoot":"","sources":["../../src/codecs/Uint8ArrayCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,IAAI,CAKrC,YAAY,EAAE,wBAAwB;AACtC,CAAC,CAAC,EAAmB,EAAE,CAAC,CAAC,YAAY,UAAU,EAAE,eAAe;AAChE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACP,uCAAuC;IACvC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,sCAAsC,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC;QACH,oCAAoC;QACpC,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAErD,4EAA4E;QAC5E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AACD,+DAA+D;AAC/D,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CACrB,CAAC","sourcesContent":["import { failure, success, Type } from 'io-ts';\nimport { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\nexport const Uint8ArrayCodec = new Type<\n Uint8Array, // A: The runtime type (the type you work with in your code)\n string, // O: The encoded output type (e.g., JSON representation)\n unknown // I: The input type (e.g., from JSON)\n>(\n 'Uint8Array', // The name of the codec\n (u): u is Uint8Array => u instanceof Uint8Array, // A type guard\n (u, c) => {\n // The `validate` function for decoding\n if (typeof u !== 'string') {\n return failure(u, c, 'Expected a hex string for Uint8Array');\n }\n try {\n // Remove any '0x' prefix if present\n const cleanHex = u.startsWith('0x') ? u.slice(2) : u;\n\n // Validate hex string (must be even length and contain only hex characters)\n if (cleanHex.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(cleanHex)) {\n return failure(u, c, 'Invalid hex string format');\n }\n\n const decoded = hexToBytes(cleanHex);\n return success(decoded);\n } catch (e) {\n return failure(u, c, `Invalid hex string: ${e}`);\n }\n },\n // The `encode` function for converting back to the output type\n (a) => bytesToHex(a)\n);\n"]}
@@ -0,0 +1,3 @@
1
+ import { Type } from 'io-ts';
2
+ export declare const Uint8ArrayOrHexCodec: Type<string | Uint8Array<ArrayBufferLike>, string, unknown>;
3
+ //# sourceMappingURL=Uint8ArrayOrHexCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint8ArrayOrHexCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/Uint8ArrayOrHexCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,oBAAoB,6DAwChC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { failure, success, Type } from 'io-ts';
2
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
3
+ export const Uint8ArrayOrHexCodec = new Type('Uint8ArrayOrHex', // The name of the codec
4
+ (u) => u instanceof Uint8Array, // A type guard
5
+ (u, c) => {
6
+ // Handle Uint8Array input (already in correct format)
7
+ if (u instanceof Uint8Array) {
8
+ return success(u);
9
+ }
10
+ // Handle string input (hex string)
11
+ if (typeof u !== 'string') {
12
+ return failure(u, c, 'Expected a hex string or Uint8Array');
13
+ }
14
+ try {
15
+ // Remove any '0x' prefix if present
16
+ const cleanHex = u.startsWith('0x') ? u.slice(2) : u;
17
+ // Validate hex string (must be even length and contain only hex characters)
18
+ if (cleanHex.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(cleanHex)) {
19
+ return failure(u, c, 'Invalid hex string format');
20
+ }
21
+ const decoded = hexToBytes(cleanHex);
22
+ return success(decoded);
23
+ }
24
+ catch (e) {
25
+ return failure(u, c, `Invalid hex string: ${e}`);
26
+ }
27
+ },
28
+ // The `encode` function for converting back to the output type
29
+ (a) => {
30
+ if (typeof a === 'string') {
31
+ return a;
32
+ }
33
+ return bytesToHex(a);
34
+ });
35
+ //# sourceMappingURL=Uint8ArrayOrHexCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint8ArrayOrHexCodec.js","sourceRoot":"","sources":["../../src/codecs/Uint8ArrayOrHexCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,IAAI,CAK1C,iBAAiB,EAAE,wBAAwB;AAC3C,CAAC,CAAC,EAAmB,EAAE,CAAC,CAAC,YAAY,UAAU,EAAE,eAAe;AAChE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACP,sDAAsD;IACtD,IAAK,CAAS,YAAY,UAAU,EAAE,CAAC;QACrC,OAAO,OAAO,CAAC,CAA0B,CAAC,CAAC;IAC7C,CAAC;IAED,mCAAmC;IACnC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,qCAAqC,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,CAAC;QACH,oCAAoC;QACpC,MAAM,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAErD,4EAA4E;QAC5E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AACD,+DAA+D;AAC/D,CAAC,CAAC,EAAE,EAAE;IACJ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC,CACF,CAAC","sourcesContent":["import { failure, success, Type } from 'io-ts';\nimport { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\nexport const Uint8ArrayOrHexCodec = new Type<\n Uint8Array | string, // A: The runtime type (the type you work with in your code)\n string, // O: The encoded output type (e.g., JSON representation)\n string | unknown // I: The input type (e.g., from JSON)\n>(\n 'Uint8ArrayOrHex', // The name of the codec\n (u): u is Uint8Array => u instanceof Uint8Array, // A type guard\n (u, c) => {\n // Handle Uint8Array input (already in correct format)\n if ((u as any) instanceof Uint8Array) {\n return success(u as unknown as Uint8Array);\n }\n\n // Handle string input (hex string)\n if (typeof u !== 'string') {\n return failure(u, c, 'Expected a hex string or Uint8Array');\n }\n\n try {\n // Remove any '0x' prefix if present\n const cleanHex = u.startsWith('0x') ? u.slice(2) : u;\n\n // Validate hex string (must be even length and contain only hex characters)\n if (cleanHex.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(cleanHex)) {\n return failure(u, c, 'Invalid hex string format');\n }\n\n const decoded = hexToBytes(cleanHex);\n return success(decoded);\n } catch (e) {\n return failure(u, c, `Invalid hex string: ${e}`);\n }\n },\n // The `encode` function for converting back to the output type\n (a) => {\n if (typeof a === 'string') {\n return a;\n }\n return bytesToHex(a);\n }\n);\n"]}
@@ -0,0 +1,15 @@
1
+ import { TypeOf } from 'io-ts';
2
+ /**
3
+ * WebSocket Error Type Codec
4
+ */
5
+ export declare const WebSocketErrorTypeCodec: import("io-ts").StringC;
6
+ /**
7
+ * WebSocket Error Codec
8
+ */
9
+ export declare const WebSocketErrorCodec: import("io-ts").TypeC<{
10
+ type: import("io-ts").StringC;
11
+ message: import("io-ts").StringC;
12
+ details: import("io-ts").UnionC<[import("io-ts").UnknownC, import("io-ts").UndefinedC]>;
13
+ }>;
14
+ export type WebSocketErrorValidated = TypeOf<typeof WebSocketErrorCodec>;
15
+ //# sourceMappingURL=WebSocketErrorCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketErrorCodec.d.ts","sourceRoot":"","sources":["../../src/codecs/WebSocketErrorCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,MAAM,EACP,MAAM,OAAO,CAAC;AAEf;;GAEG;AACH,eAAO,MAAM,uBAAuB,yBAAS,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;EAI9B,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type, string, union, undefined as undefinedType, unknown, } from 'io-ts';
2
+ /**
3
+ * WebSocket Error Type Codec
4
+ */
5
+ export const WebSocketErrorTypeCodec = string; // Just use string directly
6
+ /**
7
+ * WebSocket Error Codec
8
+ */
9
+ export const WebSocketErrorCodec = type({
10
+ type: WebSocketErrorTypeCodec,
11
+ message: string,
12
+ details: union([unknown, undefinedType]), // Optional details field
13
+ });
14
+ //# sourceMappingURL=WebSocketErrorCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketErrorCodec.js","sourceRoot":"","sources":["../../src/codecs/WebSocketErrorCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,SAAS,IAAI,aAAa,EAC1B,OAAO,GAER,MAAM,OAAO,CAAC;AAEf;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,CAAC,2BAA2B;AAE1E;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,yBAAyB;CACpE,CAAC,CAAC","sourcesContent":["import {\n type,\n string,\n union,\n undefined as undefinedType,\n unknown,\n TypeOf,\n} from 'io-ts';\n\n/**\n * WebSocket Error Type Codec\n */\nexport const WebSocketErrorTypeCodec = string; // Just use string directly\n\n/**\n * WebSocket Error Codec\n */\nexport const WebSocketErrorCodec = type({\n type: WebSocketErrorTypeCodec,\n message: string,\n details: union([unknown, undefinedType]), // Optional details field\n});\n\nexport type WebSocketErrorValidated = TypeOf<typeof WebSocketErrorCodec>;\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './Uint8ArrayCodec';
2
+ export * from './Uint32ArrayCodec';
3
+ export * from './EncryptedKeyshareCodec';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codecs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './Uint8ArrayCodec';
2
+ export * from './Uint32ArrayCodec';
3
+ export * from './EncryptedKeyshareCodec';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codecs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './Uint8ArrayCodec';\nexport * from './Uint32ArrayCodec';\nexport * from './EncryptedKeyshareCodec';\n"]}
@@ -0,0 +1,56 @@
1
+ import { type AllSigningAlgorithmSchemas, type SigningAlgorithmName } from '../signing/allAlgorithms';
2
+ import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
3
+ /**
4
+ * Algorithm configurations for complex properties
5
+ * Maps Dynamic SDK enum values to our internal algorithm names
6
+ */
7
+ export declare const ALGORITHMS: {
8
+ readonly ECDSA: {
9
+ readonly name: "ecdsa";
10
+ readonly dynamicEnum: SigningAlgorithm.ECDSA;
11
+ readonly className: "Ecdsa";
12
+ readonly requiresHashAlgo: true;
13
+ readonly supportsDerivationPath: true;
14
+ readonly supportsTweak: false;
15
+ readonly supportedHashAlgos: readonly ["sha256", "sha256d", "keccak256"];
16
+ };
17
+ readonly ED25519: {
18
+ readonly name: "ed25519";
19
+ readonly dynamicEnum: SigningAlgorithm.ED25519;
20
+ readonly className: "Ed25519";
21
+ readonly requiresHashAlgo: false;
22
+ readonly supportsDerivationPath: true;
23
+ readonly supportsTweak: false;
24
+ readonly supportedHashAlgos: readonly [];
25
+ };
26
+ readonly BIP340: {
27
+ readonly name: "bip340";
28
+ readonly dynamicEnum: SigningAlgorithm.BIP340;
29
+ readonly className: "BIP340";
30
+ readonly requiresHashAlgo: false;
31
+ readonly supportsDerivationPath: true;
32
+ readonly supportsTweak: true;
33
+ readonly supportedHashAlgos: readonly [];
34
+ };
35
+ };
36
+ /**
37
+ * Type definitions - use Dynamic SDK's SigningAlgorithm enum
38
+ */
39
+ export type HashAlgorithm = 'sha256' | 'sha256d' | 'keccak256';
40
+ /**
41
+ * Helper function to convert our internal algorithm names to Dynamic SDK enum values
42
+ */
43
+ export declare function toDynamicSigningAlgorithm(algorithmName: SigningAlgorithmName): SigningAlgorithm;
44
+ /**
45
+ * Helper function to convert Dynamic SDK enum values to our internal algorithm names
46
+ */
47
+ export declare function fromDynamicSigningAlgorithm(dynamicAlgorithm: SigningAlgorithm): SigningAlgorithmName;
48
+ /**
49
+ * Union schema derived from algorithm instances (no more manual schema generation!)
50
+ */
51
+ export declare const SignatureAlgoSchema: import("io-ts").Type<AllSigningAlgorithmSchemas, AllSigningAlgorithmSchemas, unknown>;
52
+ /**
53
+ * Export the union type for external use
54
+ */
55
+ export type { AllSigningAlgorithmSchemas as SigningAlgorithmSchemas };
56
+ //# sourceMappingURL=algorithms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorithms.d.ts","sourceRoot":"","sources":["../../src/constants/algorithms.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAE/D;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,oBAAoB,GAClC,gBAAgB,CAQlB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,gBAAgB,GACjC,oBAAoB,CAMtB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,uFAA+B,CAAC;AAEhE;;GAEG;AACH,YAAY,EAAE,0BAA0B,IAAI,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { ALL_SIGNING_ALGORITHM_SCHEMA, } from '../signing/allAlgorithms';
2
+ import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
3
+ /**
4
+ * Algorithm configurations for complex properties
5
+ * Maps Dynamic SDK enum values to our internal algorithm names
6
+ */
7
+ export const ALGORITHMS = {
8
+ [SigningAlgorithm.ECDSA]: {
9
+ name: 'ecdsa',
10
+ dynamicEnum: SigningAlgorithm.ECDSA,
11
+ className: 'Ecdsa',
12
+ requiresHashAlgo: true,
13
+ supportsDerivationPath: true,
14
+ supportsTweak: false,
15
+ supportedHashAlgos: ['sha256', 'sha256d', 'keccak256'],
16
+ },
17
+ [SigningAlgorithm.ED25519]: {
18
+ name: 'ed25519',
19
+ dynamicEnum: SigningAlgorithm.ED25519,
20
+ className: 'Ed25519',
21
+ requiresHashAlgo: false,
22
+ supportsDerivationPath: true,
23
+ supportsTweak: false,
24
+ supportedHashAlgos: [],
25
+ },
26
+ [SigningAlgorithm.BIP340]: {
27
+ name: 'bip340',
28
+ dynamicEnum: SigningAlgorithm.BIP340,
29
+ className: 'BIP340',
30
+ requiresHashAlgo: false,
31
+ supportsDerivationPath: true,
32
+ supportsTweak: true,
33
+ supportedHashAlgos: [],
34
+ },
35
+ };
36
+ /**
37
+ * Helper function to convert our internal algorithm names to Dynamic SDK enum values
38
+ */
39
+ export function toDynamicSigningAlgorithm(algorithmName) {
40
+ const algorithmConfig = Object.values(ALGORITHMS).find((config) => config.name === algorithmName);
41
+ if (!algorithmConfig) {
42
+ throw new Error(`Unknown algorithm: ${algorithmName}`);
43
+ }
44
+ return algorithmConfig.dynamicEnum;
45
+ }
46
+ /**
47
+ * Helper function to convert Dynamic SDK enum values to our internal algorithm names
48
+ */
49
+ export function fromDynamicSigningAlgorithm(dynamicAlgorithm) {
50
+ const algorithmConfig = ALGORITHMS[dynamicAlgorithm];
51
+ if (!algorithmConfig) {
52
+ throw new Error(`Unknown Dynamic SDK algorithm: ${dynamicAlgorithm}`);
53
+ }
54
+ return algorithmConfig.name;
55
+ }
56
+ /**
57
+ * Union schema derived from algorithm instances (no more manual schema generation!)
58
+ */
59
+ export const SignatureAlgoSchema = ALL_SIGNING_ALGORITHM_SCHEMA;
60
+ //# sourceMappingURL=algorithms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorithms.js","sourceRoot":"","sources":["../../src/constants/algorithms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,GAG7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE;QACxB,IAAI,EAAE,OAAgB;QACtB,WAAW,EAAE,gBAAgB,CAAC,KAAK;QACnC,SAAS,EAAE,OAAgB;QAC3B,gBAAgB,EAAE,IAAI;QACtB,sBAAsB,EAAE,IAAI;QAC5B,aAAa,EAAE,KAAK;QACpB,kBAAkB,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAU;KAChE;IACD,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC1B,IAAI,EAAE,SAAkB;QACxB,WAAW,EAAE,gBAAgB,CAAC,OAAO;QACrC,SAAS,EAAE,SAAkB;QAC7B,gBAAgB,EAAE,KAAK;QACvB,sBAAsB,EAAE,IAAI;QAC5B,aAAa,EAAE,KAAK;QACpB,kBAAkB,EAAE,EAAW;KAChC;IACD,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;QACzB,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,gBAAgB,CAAC,MAAM;QACpC,SAAS,EAAE,QAAiB;QAC5B,gBAAgB,EAAE,KAAK;QACvB,sBAAsB,EAAE,IAAI;QAC5B,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,EAAW;KAChC;CACO,CAAC;AAOX;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,aAAmC;IAEnC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CACpD,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,CAC1C,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,aAAa,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC,WAAW,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,gBAAkC;IAElC,MAAM,eAAe,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,gBAAgB,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,eAAe,CAAC,IAAI,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,4BAA4B,CAAC","sourcesContent":["import {\n ALL_SIGNING_ALGORITHM_SCHEMA,\n type AllSigningAlgorithmSchemas,\n type SigningAlgorithmName,\n} from '../signing/allAlgorithms';\nimport { SigningAlgorithm } from '@dynamic-labs-wallet/core';\n\n/**\n * Algorithm configurations for complex properties\n * Maps Dynamic SDK enum values to our internal algorithm names\n */\nexport const ALGORITHMS = {\n [SigningAlgorithm.ECDSA]: {\n name: 'ecdsa' as const,\n dynamicEnum: SigningAlgorithm.ECDSA,\n className: 'Ecdsa' as const,\n requiresHashAlgo: true,\n supportsDerivationPath: true,\n supportsTweak: false,\n supportedHashAlgos: ['sha256', 'sha256d', 'keccak256'] as const,\n },\n [SigningAlgorithm.ED25519]: {\n name: 'ed25519' as const,\n dynamicEnum: SigningAlgorithm.ED25519,\n className: 'Ed25519' as const,\n requiresHashAlgo: false,\n supportsDerivationPath: true,\n supportsTweak: false,\n supportedHashAlgos: [] as const,\n },\n [SigningAlgorithm.BIP340]: {\n name: 'bip340' as const,\n dynamicEnum: SigningAlgorithm.BIP340,\n className: 'BIP340' as const,\n requiresHashAlgo: false,\n supportsDerivationPath: true,\n supportsTweak: true,\n supportedHashAlgos: [] as const,\n },\n} as const;\n\n/**\n * Type definitions - use Dynamic SDK's SigningAlgorithm enum\n */\nexport type HashAlgorithm = 'sha256' | 'sha256d' | 'keccak256';\n\n/**\n * Helper function to convert our internal algorithm names to Dynamic SDK enum values\n */\nexport function toDynamicSigningAlgorithm(\n algorithmName: SigningAlgorithmName\n): SigningAlgorithm {\n const algorithmConfig = Object.values(ALGORITHMS).find(\n (config) => config.name === algorithmName\n );\n if (!algorithmConfig) {\n throw new Error(`Unknown algorithm: ${algorithmName}`);\n }\n return algorithmConfig.dynamicEnum;\n}\n\n/**\n * Helper function to convert Dynamic SDK enum values to our internal algorithm names\n */\nexport function fromDynamicSigningAlgorithm(\n dynamicAlgorithm: SigningAlgorithm\n): SigningAlgorithmName {\n const algorithmConfig = ALGORITHMS[dynamicAlgorithm];\n if (!algorithmConfig) {\n throw new Error(`Unknown Dynamic SDK algorithm: ${dynamicAlgorithm}`);\n }\n return algorithmConfig.name;\n}\n\n/**\n * Union schema derived from algorithm instances (no more manual schema generation!)\n */\nexport const SignatureAlgoSchema = ALL_SIGNING_ALGORITHM_SCHEMA;\n\n/**\n * Export the union type for external use\n */\nexport type { AllSigningAlgorithmSchemas as SigningAlgorithmSchemas };\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './algorithms';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './algorithms';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './algorithms';\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const decapsulateMlKem768: (decapsulationKey: Uint8Array, cipherText: Uint8Array) => Uint8Array;
2
+ //# sourceMappingURL=decapsulate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decapsulate.d.ts","sourceRoot":"","sources":["../../src/crypto/decapsulate.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,GAC9B,kBAAkB,UAAU,EAC5B,YAAY,UAAU,KACrB,UAEF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
2
+ export const decapsulateMlKem768 = (decapsulationKey, cipherText) => {
3
+ return ml_kem768.decapsulate(cipherText, decapsulationKey);
4
+ };
5
+ //# sourceMappingURL=decapsulate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decapsulate.js","sourceRoot":"","sources":["../../src/crypto/decapsulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,gBAA4B,EAC5B,UAAsB,EACV,EAAE;IACd,OAAO,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AAC7D,CAAC,CAAC","sourcesContent":["import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';\n\nexport const decapsulateMlKem768 = (\n decapsulationKey: Uint8Array,\n cipherText: Uint8Array\n): Uint8Array => {\n return ml_kem768.decapsulate(cipherText, decapsulationKey);\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const encapsulateMlKem768: (encapsulationKey: Uint8Array) => {
2
+ cipherText: Uint8Array;
3
+ sharedSecret: Uint8Array;
4
+ };
5
+ //# sourceMappingURL=encapsulate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encapsulate.d.ts","sourceRoot":"","sources":["../../src/crypto/encapsulate.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,GAC9B,kBAAkB,UAAU,KAC3B;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,UAAU,CAAA;CAEpD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
2
+ export const encapsulateMlKem768 = (encapsulationKey) => {
3
+ return ml_kem768.encapsulate(encapsulationKey);
4
+ };
5
+ //# sourceMappingURL=encapsulate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encapsulate.js","sourceRoot":"","sources":["../../src/crypto/encapsulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,gBAA4B,EAC0B,EAAE;IACxD,OAAO,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';\n\nexport const encapsulateMlKem768 = (\n encapsulationKey: Uint8Array\n): { cipherText: Uint8Array; sharedSecret: Uint8Array } => {\n return ml_kem768.encapsulate(encapsulationKey);\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const generateMlKem768Keypair: () => {
2
+ encapsulationKey: Uint8Array;
3
+ decapsulationKey: Uint8Array;
4
+ };
5
+ //# sourceMappingURL=generateKeypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateKeypair.d.ts","sourceRoot":"","sources":["../../src/crypto/generateKeypair.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,QAAO;IACzC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,gBAAgB,EAAE,UAAU,CAAC;CAe9B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
2
+ import { assertNotNull } from '../utils/assertDefined';
3
+ export const generateMlKem768Keypair = () => {
4
+ try {
5
+ const keys = ml_kem768.keygen();
6
+ assertNotNull(keys.publicKey, 'Encapsulation key must be defined');
7
+ assertNotNull(keys.secretKey, 'Decapsulation key must be defined');
8
+ return {
9
+ encapsulationKey: keys.publicKey,
10
+ decapsulationKey: keys.secretKey,
11
+ };
12
+ }
13
+ catch (error) {
14
+ throw new Error(`Failed to generate ML-KEM-768 keypair: ${error instanceof Error ? error.message : String(error)}`);
15
+ }
16
+ };
17
+ //# sourceMappingURL=generateKeypair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateKeypair.js","sourceRoot":"","sources":["../../src/crypto/generateKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAGrC,EAAE;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAChC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,mCAAmC,CAAC,CAAC;QACnE,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,mCAAmC,CAAC,CAAC;QACnE,OAAO;YACL,gBAAgB,EAAE,IAAI,CAAC,SAAS;YAChC,gBAAgB,EAAE,IAAI,CAAC,SAAS;SACjC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0CAA0C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACnG,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';\nimport { assertNotNull } from '../utils/assertDefined';\n\nexport const generateMlKem768Keypair = (): {\n encapsulationKey: Uint8Array;\n decapsulationKey: Uint8Array;\n} => {\n try {\n const keys = ml_kem768.keygen();\n assertNotNull(keys.publicKey, 'Encapsulation key must be defined');\n assertNotNull(keys.secretKey, 'Decapsulation key must be defined');\n return {\n encapsulationKey: keys.publicKey,\n decapsulationKey: keys.secretKey,\n };\n } catch (error) {\n throw new Error(\n `Failed to generate ML-KEM-768 keypair: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n};\n"]}