@dynamic-labs-wallet/forward-mpc-shared 0.1.0-alpha.6 → 0.1.0-alpha.7
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.
- package/dist/index.cjs +823 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1030 -0
- package/dist/index.d.ts +1030 -9
- package/dist/index.js +768 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
- package/dist/attestation/index.d.ts +0 -1
- package/dist/attestation/index.d.ts.map +0 -1
- package/dist/attestation/index.js +0 -4
- package/dist/attestation/index.js.map +0 -1
- package/dist/codecs/DomainCodec.d.ts +0 -11
- package/dist/codecs/DomainCodec.d.ts.map +0 -1
- package/dist/codecs/DomainCodec.js +0 -25
- package/dist/codecs/DomainCodec.js.map +0 -1
- package/dist/codecs/EncryptedKeyshareCodec.d.ts +0 -11
- package/dist/codecs/EncryptedKeyshareCodec.d.ts.map +0 -1
- package/dist/codecs/EncryptedKeyshareCodec.js +0 -11
- package/dist/codecs/EncryptedKeyshareCodec.js.map +0 -1
- package/dist/codecs/Uint32ArrayCodec.d.ts +0 -3
- package/dist/codecs/Uint32ArrayCodec.d.ts.map +0 -1
- package/dist/codecs/Uint32ArrayCodec.js +0 -37
- package/dist/codecs/Uint32ArrayCodec.js.map +0 -1
- package/dist/codecs/Uint8ArrayCodec.d.ts +0 -3
- package/dist/codecs/Uint8ArrayCodec.d.ts.map +0 -1
- package/dist/codecs/Uint8ArrayCodec.js +0 -26
- package/dist/codecs/Uint8ArrayCodec.js.map +0 -1
- package/dist/codecs/Uint8ArrayOrHexCodec.d.ts +0 -3
- package/dist/codecs/Uint8ArrayOrHexCodec.d.ts.map +0 -1
- package/dist/codecs/Uint8ArrayOrHexCodec.js +0 -35
- package/dist/codecs/Uint8ArrayOrHexCodec.js.map +0 -1
- package/dist/codecs/WebSocketErrorCodec.d.ts +0 -15
- package/dist/codecs/WebSocketErrorCodec.d.ts.map +0 -1
- package/dist/codecs/WebSocketErrorCodec.js +0 -14
- package/dist/codecs/WebSocketErrorCodec.js.map +0 -1
- package/dist/codecs/index.d.ts +0 -4
- package/dist/codecs/index.d.ts.map +0 -1
- package/dist/codecs/index.js +0 -4
- package/dist/codecs/index.js.map +0 -1
- package/dist/constants/algorithms.d.ts +0 -56
- package/dist/constants/algorithms.d.ts.map +0 -1
- package/dist/constants/algorithms.js +0 -60
- package/dist/constants/algorithms.js.map +0 -1
- package/dist/constants/index.d.ts +0 -2
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -2
- package/dist/constants/index.js.map +0 -1
- package/dist/crypto/decapsulate.d.ts +0 -2
- package/dist/crypto/decapsulate.d.ts.map +0 -1
- package/dist/crypto/decapsulate.js +0 -5
- package/dist/crypto/decapsulate.js.map +0 -1
- package/dist/crypto/encapsulate.d.ts +0 -5
- package/dist/crypto/encapsulate.d.ts.map +0 -1
- package/dist/crypto/encapsulate.js +0 -5
- package/dist/crypto/encapsulate.js.map +0 -1
- package/dist/crypto/generateKeypair.d.ts +0 -5
- package/dist/crypto/generateKeypair.d.ts.map +0 -1
- package/dist/crypto/generateKeypair.js +0 -17
- package/dist/crypto/generateKeypair.js.map +0 -1
- package/dist/crypto/index.d.ts +0 -6
- package/dist/crypto/index.d.ts.map +0 -1
- package/dist/crypto/index.js +0 -6
- package/dist/crypto/index.js.map +0 -1
- package/dist/crypto/keyDerivation.d.ts +0 -14
- package/dist/crypto/keyDerivation.d.ts.map +0 -1
- package/dist/crypto/keyDerivation.js +0 -21
- package/dist/crypto/keyDerivation.js.map +0 -1
- package/dist/crypto/keyshareEncryption.d.ts +0 -13
- package/dist/crypto/keyshareEncryption.d.ts.map +0 -1
- package/dist/crypto/keyshareEncryption.js +0 -39
- package/dist/crypto/keyshareEncryption.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/messages/ConnectionAckV1Request.d.ts +0 -43
- package/dist/messages/ConnectionAckV1Request.d.ts.map +0 -1
- package/dist/messages/ConnectionAckV1Request.js +0 -17
- package/dist/messages/ConnectionAckV1Request.js.map +0 -1
- package/dist/messages/ConnectionAckV1Response.d.ts +0 -45
- package/dist/messages/ConnectionAckV1Response.d.ts.map +0 -1
- package/dist/messages/ConnectionAckV1Response.js +0 -18
- package/dist/messages/ConnectionAckV1Response.js.map +0 -1
- package/dist/messages/HandshakeV1Request.d.ts +0 -45
- package/dist/messages/HandshakeV1Request.d.ts.map +0 -1
- package/dist/messages/HandshakeV1Request.js +0 -28
- package/dist/messages/HandshakeV1Request.js.map +0 -1
- package/dist/messages/HandshakeV1Response.d.ts +0 -47
- package/dist/messages/HandshakeV1Response.d.ts.map +0 -1
- package/dist/messages/HandshakeV1Response.js +0 -20
- package/dist/messages/HandshakeV1Response.js.map +0 -1
- package/dist/messages/SignMessageV1Request.d.ts +0 -63
- package/dist/messages/SignMessageV1Request.d.ts.map +0 -1
- package/dist/messages/SignMessageV1Request.js +0 -42
- package/dist/messages/SignMessageV1Request.js.map +0 -1
- package/dist/messages/SignMessageV1Response.d.ts +0 -47
- package/dist/messages/SignMessageV1Response.d.ts.map +0 -1
- package/dist/messages/SignMessageV1Response.js +0 -28
- package/dist/messages/SignMessageV1Response.js.map +0 -1
- package/dist/messages/allMessages.d.ts +0 -259
- package/dist/messages/allMessages.d.ts.map +0 -1
- package/dist/messages/allMessages.js +0 -57
- package/dist/messages/allMessages.js.map +0 -1
- package/dist/messages/base.d.ts +0 -27
- package/dist/messages/base.d.ts.map +0 -1
- package/dist/messages/base.js +0 -12
- package/dist/messages/base.js.map +0 -1
- package/dist/messages/index.d.ts +0 -11
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -14
- package/dist/messages/index.js.map +0 -1
- package/dist/messages/registry.d.ts +0 -136
- package/dist/messages/registry.d.ts.map +0 -1
- package/dist/messages/registry.js +0 -67
- package/dist/messages/registry.js.map +0 -1
- package/dist/messages/utils/StandardMessage.d.ts +0 -97
- package/dist/messages/utils/StandardMessage.d.ts.map +0 -1
- package/dist/messages/utils/StandardMessage.js +0 -98
- package/dist/messages/utils/StandardMessage.js.map +0 -1
- package/dist/messages/utils/encodingHelpers.d.ts +0 -20
- package/dist/messages/utils/encodingHelpers.d.ts.map +0 -1
- package/dist/messages/utils/encodingHelpers.js +0 -50
- package/dist/messages/utils/encodingHelpers.js.map +0 -1
- package/dist/messages/utils/index.d.ts +0 -4
- package/dist/messages/utils/index.d.ts.map +0 -1
- package/dist/messages/utils/index.js +0 -5
- package/dist/messages/utils/index.js.map +0 -1
- package/dist/messages/utils/schemaBuilder.d.ts +0 -19
- package/dist/messages/utils/schemaBuilder.d.ts.map +0 -1
- package/dist/messages/utils/schemaBuilder.js +0 -31
- package/dist/messages/utils/schemaBuilder.js.map +0 -1
- package/dist/signing/algorithms/BIP340SigningAlgorithm.d.ts +0 -20
- package/dist/signing/algorithms/BIP340SigningAlgorithm.d.ts.map +0 -1
- package/dist/signing/algorithms/BIP340SigningAlgorithm.js +0 -35
- package/dist/signing/algorithms/BIP340SigningAlgorithm.js.map +0 -1
- package/dist/signing/algorithms/EcdsaSigningAlgorithm.d.ts +0 -20
- package/dist/signing/algorithms/EcdsaSigningAlgorithm.d.ts.map +0 -1
- package/dist/signing/algorithms/EcdsaSigningAlgorithm.js +0 -43
- package/dist/signing/algorithms/EcdsaSigningAlgorithm.js.map +0 -1
- package/dist/signing/algorithms/Ed25519SigningAlgorithm.d.ts +0 -18
- package/dist/signing/algorithms/Ed25519SigningAlgorithm.d.ts.map +0 -1
- package/dist/signing/algorithms/Ed25519SigningAlgorithm.js +0 -34
- package/dist/signing/algorithms/Ed25519SigningAlgorithm.js.map +0 -1
- package/dist/signing/allAlgorithms.d.ts +0 -50
- package/dist/signing/allAlgorithms.d.ts.map +0 -1
- package/dist/signing/allAlgorithms.js +0 -59
- package/dist/signing/allAlgorithms.js.map +0 -1
- package/dist/signing/base.d.ts +0 -42
- package/dist/signing/base.d.ts.map +0 -1
- package/dist/signing/base.js +0 -6
- package/dist/signing/base.js.map +0 -1
- package/dist/signing/index.d.ts +0 -7
- package/dist/signing/index.d.ts.map +0 -1
- package/dist/signing/index.js +0 -9
- package/dist/signing/index.js.map +0 -1
- package/dist/signing/registry.d.ts +0 -26
- package/dist/signing/registry.d.ts.map +0 -1
- package/dist/signing/registry.js +0 -36
- package/dist/signing/registry.js.map +0 -1
- package/dist/types.d.ts +0 -42
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
- package/dist/utils/assertDefined.d.ts +0 -16
- package/dist/utils/assertDefined.d.ts.map +0 -1
- package/dist/utils/assertDefined.js +0 -27
- package/dist/utils/assertDefined.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
import * as fp_ts_lib_Either from 'fp-ts/lib/Either';
|
|
2
|
+
import * as io_ts from 'io-ts';
|
|
3
|
+
import { TypeOf, Type } from 'io-ts';
|
|
4
|
+
import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
|
|
5
|
+
import { either } from 'fp-ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base structure for all WebSocket messages
|
|
9
|
+
*/
|
|
10
|
+
interface BaseWebSocketMessage {
|
|
11
|
+
type: string;
|
|
12
|
+
version: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* WebSocket error types
|
|
16
|
+
*/
|
|
17
|
+
declare enum WebSocketErrorType {
|
|
18
|
+
INVALID_MESSAGE = "INVALID_MESSAGE",
|
|
19
|
+
HANDLER_NOT_FOUND = "HANDLER_NOT_FOUND",
|
|
20
|
+
HANDLER_ERROR = "HANDLER_ERROR",
|
|
21
|
+
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
22
|
+
VALIDATION_ERROR = "VALIDATION_ERROR"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Structured WebSocket error
|
|
26
|
+
*/
|
|
27
|
+
interface WebSocketError {
|
|
28
|
+
type: WebSocketErrorType;
|
|
29
|
+
message: string;
|
|
30
|
+
details?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Standard error response format
|
|
34
|
+
*/
|
|
35
|
+
interface ErrorResponse extends BaseWebSocketMessage {
|
|
36
|
+
type: 'error';
|
|
37
|
+
error: WebSocketError;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* WebSocket connection context (client-side version without ws instance)
|
|
41
|
+
*/
|
|
42
|
+
interface WebSocketConnectionInfo {
|
|
43
|
+
id: string;
|
|
44
|
+
connectedAt: Date;
|
|
45
|
+
lastActivity: Date;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Base interface for all messages
|
|
51
|
+
*/
|
|
52
|
+
interface IMessage<TRuntime = any, TWire = any> {
|
|
53
|
+
readonly type: string;
|
|
54
|
+
readonly version: number;
|
|
55
|
+
/**
|
|
56
|
+
* Encode this message to wire format for transmission
|
|
57
|
+
*/
|
|
58
|
+
encode(): TWire;
|
|
59
|
+
/**
|
|
60
|
+
* Get the runtime data of this message
|
|
61
|
+
*/
|
|
62
|
+
getData(): TRuntime;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Abstract base class for all messages
|
|
66
|
+
*/
|
|
67
|
+
declare abstract class BaseMessage<TRuntime = any, TWire = any> implements IMessage<TRuntime, TWire> {
|
|
68
|
+
readonly data: TRuntime;
|
|
69
|
+
abstract readonly type: string;
|
|
70
|
+
abstract readonly version: number;
|
|
71
|
+
protected constructor(data: TRuntime);
|
|
72
|
+
abstract encode(): TWire;
|
|
73
|
+
getData(): TRuntime;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Connection Acknowledgment Response Runtime Data
|
|
78
|
+
*/
|
|
79
|
+
interface ConnectionAckResponseData {
|
|
80
|
+
status: 'acknowledged';
|
|
81
|
+
timestamp: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Connection Acknowledgment Response Wire Format
|
|
85
|
+
*/
|
|
86
|
+
interface ConnectionAckResponseWire {
|
|
87
|
+
type: 'connection_ack_response';
|
|
88
|
+
version: 1;
|
|
89
|
+
status: 'acknowledged';
|
|
90
|
+
timestamp: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Connection Acknowledgment Response Schema (built using Ultra-DRY utilities)
|
|
94
|
+
*/
|
|
95
|
+
declare const ConnectionAckResponseSchema: io_ts.Type<any, any, unknown>;
|
|
96
|
+
type ConnectionAckResponse = TypeOf<typeof ConnectionAckResponseSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* Connection Acknowledgment V1 Response Message Class (Ultra-DRY implementation)
|
|
99
|
+
*/
|
|
100
|
+
declare const ConnectionAckV1ResponseMessage: {
|
|
101
|
+
new (data: ConnectionAckResponseData): {
|
|
102
|
+
readonly type: "connection_ack_response";
|
|
103
|
+
readonly version: 1;
|
|
104
|
+
encode(): any;
|
|
105
|
+
readonly data: ConnectionAckResponseData;
|
|
106
|
+
getData(): ConnectionAckResponseData;
|
|
107
|
+
};
|
|
108
|
+
readonly MESSAGE_TYPE: "connection_ack_response";
|
|
109
|
+
readonly MESSAGE_VERSION: 1;
|
|
110
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
111
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
112
|
+
readonly type: "connection_ack_response";
|
|
113
|
+
readonly version: 1;
|
|
114
|
+
encode(): any;
|
|
115
|
+
readonly data: ConnectionAckResponseData;
|
|
116
|
+
getData(): ConnectionAckResponseData;
|
|
117
|
+
}>;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Connection Acknowledgment Request Runtime Data
|
|
122
|
+
*/
|
|
123
|
+
interface ConnectionAckRequestData {
|
|
124
|
+
connectionId?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Connection Acknowledgment Request Wire Format
|
|
128
|
+
*/
|
|
129
|
+
interface ConnectionAckRequestWire {
|
|
130
|
+
type: 'connection_ack';
|
|
131
|
+
version: 1;
|
|
132
|
+
connectionId?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Connection Acknowledgment Request Schema (built using Ultra-DRY utilities)
|
|
136
|
+
*/
|
|
137
|
+
declare const ConnectionAckRequestSchema: io_ts.Type<any, any, unknown>;
|
|
138
|
+
type ConnectionAckRequest = TypeOf<typeof ConnectionAckRequestSchema>;
|
|
139
|
+
/**
|
|
140
|
+
* Connection Acknowledgment V1 Request Message Class (Ultra-DRY implementation)
|
|
141
|
+
*/
|
|
142
|
+
declare const ConnectionAckV1RequestMessage: {
|
|
143
|
+
new (data: ConnectionAckRequestData): {
|
|
144
|
+
readonly type: "connection_ack";
|
|
145
|
+
readonly version: 1;
|
|
146
|
+
encode(): any;
|
|
147
|
+
readonly data: ConnectionAckRequestData;
|
|
148
|
+
getData(): ConnectionAckRequestData;
|
|
149
|
+
};
|
|
150
|
+
readonly MESSAGE_TYPE: "connection_ack";
|
|
151
|
+
readonly MESSAGE_VERSION: 1;
|
|
152
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
153
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
154
|
+
readonly type: "connection_ack";
|
|
155
|
+
readonly version: 1;
|
|
156
|
+
encode(): any;
|
|
157
|
+
readonly data: ConnectionAckRequestData;
|
|
158
|
+
getData(): ConnectionAckRequestData;
|
|
159
|
+
}>;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sign Message Response Runtime Data
|
|
164
|
+
*/
|
|
165
|
+
interface SignMessageResponseData {
|
|
166
|
+
signature?: Uint8Array;
|
|
167
|
+
error?: WebSocketError;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Sign Message Response Wire Format
|
|
171
|
+
*/
|
|
172
|
+
interface SignMessageResponseWire {
|
|
173
|
+
type: 'signMessage_response';
|
|
174
|
+
version: 1;
|
|
175
|
+
signature?: string;
|
|
176
|
+
error?: WebSocketError;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Sign Message Response Schema (built using Ultra-DRY utilities)
|
|
180
|
+
* Schema expects wire format types (string for signature)
|
|
181
|
+
*/
|
|
182
|
+
declare const SignMessageResponseSchema: io_ts.Type<any, any, unknown>;
|
|
183
|
+
type SignMessageResponse = TypeOf<typeof SignMessageResponseSchema>;
|
|
184
|
+
/**
|
|
185
|
+
* Sign Message V1 Response Message Class (Ultra-DRY implementation)
|
|
186
|
+
*/
|
|
187
|
+
declare const SignMessageV1ResponseMessage: {
|
|
188
|
+
new (data: SignMessageResponseData): {
|
|
189
|
+
readonly type: "signMessage_response";
|
|
190
|
+
readonly version: 1;
|
|
191
|
+
encode(): SignMessageResponseWire;
|
|
192
|
+
readonly data: SignMessageResponseData;
|
|
193
|
+
getData(): SignMessageResponseData;
|
|
194
|
+
};
|
|
195
|
+
readonly MESSAGE_TYPE: "signMessage_response";
|
|
196
|
+
readonly MESSAGE_VERSION: 1;
|
|
197
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
198
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
199
|
+
readonly type: "signMessage_response";
|
|
200
|
+
readonly version: 1;
|
|
201
|
+
encode(): SignMessageResponseWire;
|
|
202
|
+
readonly data: SignMessageResponseData;
|
|
203
|
+
getData(): SignMessageResponseData;
|
|
204
|
+
}>;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Base secret share data (what gets encrypted)
|
|
209
|
+
*/
|
|
210
|
+
interface SecretShareData {
|
|
211
|
+
secretShare: string;
|
|
212
|
+
signingAlgorithm: string;
|
|
213
|
+
timestamp: number;
|
|
214
|
+
nonce: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Decrypted secret share with reconstructed keygen result
|
|
218
|
+
*/
|
|
219
|
+
interface DecryptedSecretShare {
|
|
220
|
+
keygenResult: any;
|
|
221
|
+
signingAlgorithm: string;
|
|
222
|
+
timestamp: number;
|
|
223
|
+
nonce: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Base interface for signing algorithm implementations
|
|
227
|
+
*/
|
|
228
|
+
interface ISigningAlgorithm {
|
|
229
|
+
readonly algorithmName: string;
|
|
230
|
+
readonly version: number;
|
|
231
|
+
readonly schema: Type<any>;
|
|
232
|
+
createKeygenResultFromSecretShare(secretShare: string): any;
|
|
233
|
+
createSignRequest(keygenResult: any, params: any): any;
|
|
234
|
+
processSignResult(result: any): Uint8Array;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Base signing algorithm class
|
|
238
|
+
*/
|
|
239
|
+
declare abstract class BaseSigningAlgorithm implements ISigningAlgorithm {
|
|
240
|
+
abstract readonly algorithmName: string;
|
|
241
|
+
abstract readonly version: number;
|
|
242
|
+
abstract readonly schema: Type<any>;
|
|
243
|
+
abstract createKeygenResultFromSecretShare(secretShare: string): any;
|
|
244
|
+
abstract createSignRequest(keygenResult: any, params: any): any;
|
|
245
|
+
abstract processSignResult(result: any): Uint8Array;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface Ed25519SignMessageSchema {
|
|
249
|
+
signingAlgo: 'ed25519';
|
|
250
|
+
derivationPath?: Uint32Array;
|
|
251
|
+
}
|
|
252
|
+
declare class Ed25519SigningAlgorithm extends BaseSigningAlgorithm {
|
|
253
|
+
readonly algorithmName: "ed25519";
|
|
254
|
+
readonly version = 1;
|
|
255
|
+
readonly schema: io_ts.IntersectionC<[io_ts.TypeC<{
|
|
256
|
+
signingAlgo: io_ts.LiteralC<"ed25519">;
|
|
257
|
+
}>, io_ts.PartialC<{
|
|
258
|
+
derivationPath: io_ts.Type<Uint32Array<ArrayBufferLike>, string, unknown>;
|
|
259
|
+
}>]>;
|
|
260
|
+
createKeygenResultFromSecretShare(secretShare: string): any;
|
|
261
|
+
createSignRequest(keygenResult: any, params: any): any;
|
|
262
|
+
processSignResult(_result: any): Uint8Array;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface BIP340SignMessageSchema {
|
|
266
|
+
signingAlgo: 'bip340';
|
|
267
|
+
derivationPath?: Uint32Array;
|
|
268
|
+
tweak?: Uint8Array;
|
|
269
|
+
}
|
|
270
|
+
declare class BIP340SigningAlgorithm extends BaseSigningAlgorithm {
|
|
271
|
+
readonly algorithmName: "bip340";
|
|
272
|
+
readonly version = 1;
|
|
273
|
+
readonly schema: io_ts.IntersectionC<[io_ts.TypeC<{
|
|
274
|
+
signingAlgo: io_ts.LiteralC<"bip340">;
|
|
275
|
+
}>, io_ts.PartialC<{
|
|
276
|
+
derivationPath: io_ts.Type<Uint32Array<ArrayBufferLike>, string, unknown>;
|
|
277
|
+
tweak: io_ts.Type<Uint8Array<ArrayBufferLike>, string, unknown>;
|
|
278
|
+
}>]>;
|
|
279
|
+
createKeygenResultFromSecretShare(secretShare: string): any;
|
|
280
|
+
createSignRequest(keygenResult: any, params: any): any;
|
|
281
|
+
processSignResult(_result: any): Uint8Array;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
interface EcdsaSignMessageSchema {
|
|
285
|
+
signingAlgo: 'ecdsa';
|
|
286
|
+
hashAlgo: 'sha256' | 'sha256d' | 'keccak256';
|
|
287
|
+
derivationPath?: Uint32Array;
|
|
288
|
+
}
|
|
289
|
+
declare class EcdsaSigningAlgorithm extends BaseSigningAlgorithm {
|
|
290
|
+
readonly algorithmName: "ecdsa";
|
|
291
|
+
readonly version = 1;
|
|
292
|
+
readonly schema: io_ts.IntersectionC<[io_ts.TypeC<{
|
|
293
|
+
signingAlgo: io_ts.LiteralC<"ecdsa">;
|
|
294
|
+
}>, io_ts.PartialC<{
|
|
295
|
+
hashAlgo: io_ts.UnionC<[io_ts.LiteralC<"sha256">, io_ts.LiteralC<"sha256d">, io_ts.LiteralC<"keccak256">]>;
|
|
296
|
+
derivationPath: io_ts.Type<Uint32Array<ArrayBufferLike>, string, unknown>;
|
|
297
|
+
}>]>;
|
|
298
|
+
createKeygenResultFromSecretShare(secretShare: string): any;
|
|
299
|
+
createSignRequest(keygenResult: any, params: any): any;
|
|
300
|
+
processSignResult(_result: any): Uint8Array;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 🎯 SINGLE SOURCE OF TRUTH - Add new algorithms here and everything else is automatic!
|
|
305
|
+
* This is the ONLY place you need to add new signing algorithms
|
|
306
|
+
*/
|
|
307
|
+
declare const SIGNING_ALGORITHM_CLASSES: {
|
|
308
|
+
readonly ed25519: typeof Ed25519SigningAlgorithm;
|
|
309
|
+
readonly bip340: typeof BIP340SigningAlgorithm;
|
|
310
|
+
readonly ecdsa: typeof EcdsaSigningAlgorithm;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* 📝 Explicit union type of all signing algorithm schemas
|
|
314
|
+
* (Only other place you need to add new algorithms)
|
|
315
|
+
*/
|
|
316
|
+
type AllSigningAlgorithmSchemas = Ed25519SignMessageSchema | BIP340SignMessageSchema | EcdsaSignMessageSchema;
|
|
317
|
+
/**
|
|
318
|
+
* Derive signing algorithm name type from classes
|
|
319
|
+
*/
|
|
320
|
+
type SigningAlgorithmName = keyof typeof SIGNING_ALGORITHM_CLASSES;
|
|
321
|
+
/**
|
|
322
|
+
* Derive runtime array of algorithm names from classes
|
|
323
|
+
*/
|
|
324
|
+
declare const ALL_SIGNING_ALGORITHM_NAMES: SigningAlgorithmName[];
|
|
325
|
+
/**
|
|
326
|
+
* Create algorithm instances (derived from classes)
|
|
327
|
+
*/
|
|
328
|
+
declare const SIGNING_ALGORITHM_INSTANCES: Record<SigningAlgorithmName, ISigningAlgorithm>;
|
|
329
|
+
/**
|
|
330
|
+
* Create union schema (derived from instances)
|
|
331
|
+
*/
|
|
332
|
+
declare const ALL_SIGNING_ALGORITHM_SCHEMA: Type<AllSigningAlgorithmSchemas>;
|
|
333
|
+
/**
|
|
334
|
+
* Helper type to extract algorithm-specific schema
|
|
335
|
+
*/
|
|
336
|
+
type SigningAlgorithmSchemaFor<T extends AllSigningAlgorithmSchemas['signingAlgo']> = Extract<AllSigningAlgorithmSchemas, {
|
|
337
|
+
signingAlgo: T;
|
|
338
|
+
}>;
|
|
339
|
+
/**
|
|
340
|
+
* Utility to check if a string is a valid signing algorithm name
|
|
341
|
+
*/
|
|
342
|
+
declare function isValidSigningAlgorithm(name: string): name is SigningAlgorithmName;
|
|
343
|
+
/**
|
|
344
|
+
* Create keygen result from secret share using algorithm-specific logic
|
|
345
|
+
*/
|
|
346
|
+
declare function createKeygenResultFromSecretShare(algorithmName: SigningAlgorithmName, secretShare: string): any;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Algorithm configurations for complex properties
|
|
350
|
+
* Maps Dynamic SDK enum values to our internal algorithm names
|
|
351
|
+
*/
|
|
352
|
+
declare const ALGORITHMS: {
|
|
353
|
+
readonly ECDSA: {
|
|
354
|
+
readonly name: "ecdsa";
|
|
355
|
+
readonly dynamicEnum: SigningAlgorithm.ECDSA;
|
|
356
|
+
readonly className: "Ecdsa";
|
|
357
|
+
readonly requiresHashAlgo: true;
|
|
358
|
+
readonly supportsDerivationPath: true;
|
|
359
|
+
readonly supportsTweak: false;
|
|
360
|
+
readonly supportedHashAlgos: readonly ["sha256", "sha256d", "keccak256"];
|
|
361
|
+
};
|
|
362
|
+
readonly ED25519: {
|
|
363
|
+
readonly name: "ed25519";
|
|
364
|
+
readonly dynamicEnum: SigningAlgorithm.ED25519;
|
|
365
|
+
readonly className: "Ed25519";
|
|
366
|
+
readonly requiresHashAlgo: false;
|
|
367
|
+
readonly supportsDerivationPath: true;
|
|
368
|
+
readonly supportsTweak: false;
|
|
369
|
+
readonly supportedHashAlgos: readonly [];
|
|
370
|
+
};
|
|
371
|
+
readonly BIP340: {
|
|
372
|
+
readonly name: "bip340";
|
|
373
|
+
readonly dynamicEnum: SigningAlgorithm.BIP340;
|
|
374
|
+
readonly className: "BIP340";
|
|
375
|
+
readonly requiresHashAlgo: false;
|
|
376
|
+
readonly supportsDerivationPath: true;
|
|
377
|
+
readonly supportsTweak: true;
|
|
378
|
+
readonly supportedHashAlgos: readonly [];
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Type definitions - use Dynamic SDK's SigningAlgorithm enum
|
|
383
|
+
*/
|
|
384
|
+
type HashAlgorithm = 'sha256' | 'sha256d' | 'keccak256';
|
|
385
|
+
/**
|
|
386
|
+
* Helper function to convert our internal algorithm names to Dynamic SDK enum values
|
|
387
|
+
*/
|
|
388
|
+
declare function toDynamicSigningAlgorithm(algorithmName: SigningAlgorithmName): SigningAlgorithm;
|
|
389
|
+
/**
|
|
390
|
+
* Helper function to convert Dynamic SDK enum values to our internal algorithm names
|
|
391
|
+
*/
|
|
392
|
+
declare function fromDynamicSigningAlgorithm(dynamicAlgorithm: SigningAlgorithm): SigningAlgorithmName;
|
|
393
|
+
/**
|
|
394
|
+
* Union schema derived from algorithm instances (no more manual schema generation!)
|
|
395
|
+
*/
|
|
396
|
+
declare const SignatureAlgoSchema: io_ts.Type<AllSigningAlgorithmSchemas, AllSigningAlgorithmSchemas, unknown>;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Encrypted keyshare structure for secure transmission
|
|
400
|
+
* Contains HKDF salt and AES-256-GCM encrypted payload
|
|
401
|
+
*/
|
|
402
|
+
declare const EncryptedKeyshareCodec: io_ts.TypeC<{
|
|
403
|
+
salt: io_ts.Type<Uint8Array<ArrayBufferLike>, string, unknown>;
|
|
404
|
+
encryptedPayload: io_ts.Type<Uint8Array<ArrayBufferLike>, string, unknown>;
|
|
405
|
+
}>;
|
|
406
|
+
type EncryptedKeyshare = TypeOf<typeof EncryptedKeyshareCodec>;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Sign Message Request Runtime Data
|
|
410
|
+
*/
|
|
411
|
+
interface SignMessageRequestData {
|
|
412
|
+
relayDomain: string;
|
|
413
|
+
signingAlgo: SigningAlgorithm;
|
|
414
|
+
hashAlgo?: HashAlgorithm;
|
|
415
|
+
derivationPath?: Uint32Array;
|
|
416
|
+
tweak?: Uint8Array;
|
|
417
|
+
keyshare: EncryptedKeyshare;
|
|
418
|
+
message: Uint8Array | string;
|
|
419
|
+
roomUuid: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Sign Message Request Wire Format
|
|
423
|
+
*/
|
|
424
|
+
interface SignMessageRequestWire {
|
|
425
|
+
type: 'signMessage';
|
|
426
|
+
version: 1;
|
|
427
|
+
relayDomain: string;
|
|
428
|
+
signingAlgo: SigningAlgorithm;
|
|
429
|
+
hashAlgo?: HashAlgorithm;
|
|
430
|
+
derivationPath?: string;
|
|
431
|
+
tweak?: string;
|
|
432
|
+
keyshare: {
|
|
433
|
+
salt: string;
|
|
434
|
+
encryptedPayload: string;
|
|
435
|
+
};
|
|
436
|
+
message: string;
|
|
437
|
+
roomUuid: string;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Sign Message Request Schema - uses codecs that handle both formats automatically
|
|
441
|
+
*/
|
|
442
|
+
declare const SignMessageRequestSchema: io_ts.Type<any, any, unknown>;
|
|
443
|
+
type SignMessageRequest = TypeOf<typeof SignMessageRequestSchema>;
|
|
444
|
+
/**
|
|
445
|
+
* Sign Message V1 Request Message Class - Clean implementation using createComplexEncoder
|
|
446
|
+
*/
|
|
447
|
+
declare const SignMessageV1RequestMessage: {
|
|
448
|
+
new (data: SignMessageRequestData): {
|
|
449
|
+
readonly type: "signMessage";
|
|
450
|
+
readonly version: 1;
|
|
451
|
+
encode(): unknown;
|
|
452
|
+
readonly data: SignMessageRequestData;
|
|
453
|
+
getData(): SignMessageRequestData;
|
|
454
|
+
};
|
|
455
|
+
readonly MESSAGE_TYPE: "signMessage";
|
|
456
|
+
readonly MESSAGE_VERSION: 1;
|
|
457
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
458
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
459
|
+
readonly type: "signMessage";
|
|
460
|
+
readonly version: 1;
|
|
461
|
+
encode(): unknown;
|
|
462
|
+
readonly data: SignMessageRequestData;
|
|
463
|
+
getData(): SignMessageRequestData;
|
|
464
|
+
}>;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Handshake Response Runtime Data
|
|
469
|
+
*/
|
|
470
|
+
interface HandshakeResponseData {
|
|
471
|
+
encapsulatedSharedSecret: string;
|
|
472
|
+
attestationDoc: string;
|
|
473
|
+
connectionId: string;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Handshake Response Wire Format
|
|
477
|
+
*/
|
|
478
|
+
interface HandshakeResponseWire {
|
|
479
|
+
type: 'handshake_response';
|
|
480
|
+
version: 1;
|
|
481
|
+
encapsulatedSharedSecret: string;
|
|
482
|
+
attestationDoc: string;
|
|
483
|
+
connectionId: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Handshake Response Schema (built using Ultra-DRY utilities)
|
|
487
|
+
*/
|
|
488
|
+
declare const HandshakeResponseSchema: io_ts.Type<any, any, unknown>;
|
|
489
|
+
type HandshakeResponse = TypeOf<typeof HandshakeResponseSchema>;
|
|
490
|
+
/**
|
|
491
|
+
* Handshake V1 Response Message Class (Ultra-DRY implementation)
|
|
492
|
+
*/
|
|
493
|
+
declare const HandshakeV1ResponseMessage: {
|
|
494
|
+
new (data: HandshakeResponseData): {
|
|
495
|
+
readonly type: "handshake_response";
|
|
496
|
+
readonly version: 1;
|
|
497
|
+
encode(): any;
|
|
498
|
+
readonly data: HandshakeResponseData;
|
|
499
|
+
getData(): HandshakeResponseData;
|
|
500
|
+
};
|
|
501
|
+
readonly MESSAGE_TYPE: "handshake_response";
|
|
502
|
+
readonly MESSAGE_VERSION: 1;
|
|
503
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
504
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
505
|
+
readonly type: "handshake_response";
|
|
506
|
+
readonly version: 1;
|
|
507
|
+
encode(): any;
|
|
508
|
+
readonly data: HandshakeResponseData;
|
|
509
|
+
getData(): HandshakeResponseData;
|
|
510
|
+
}>;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Handshake Request Runtime Data
|
|
515
|
+
*/
|
|
516
|
+
interface HandshakeRequestData {
|
|
517
|
+
challenge: Uint8Array;
|
|
518
|
+
nonce: Uint8Array;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Handshake Request Wire Format
|
|
522
|
+
*/
|
|
523
|
+
interface HandshakeRequestWire {
|
|
524
|
+
type: 'handshake';
|
|
525
|
+
version: 1;
|
|
526
|
+
challenge: string;
|
|
527
|
+
nonce: string;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Handshake Request Schema (built using Ultra-DRY utilities)
|
|
531
|
+
*/
|
|
532
|
+
declare const HandshakeRequestSchema: io_ts.Type<any, any, unknown>;
|
|
533
|
+
type HandshakeRequest = TypeOf<typeof HandshakeRequestSchema>;
|
|
534
|
+
/**
|
|
535
|
+
* Handshake V1 Request Message Class (Ultra-DRY implementation)
|
|
536
|
+
*/
|
|
537
|
+
declare const HandshakeV1RequestMessage: {
|
|
538
|
+
new (data: HandshakeRequestData): {
|
|
539
|
+
readonly type: "handshake";
|
|
540
|
+
readonly version: 1;
|
|
541
|
+
encode(): HandshakeRequestWire;
|
|
542
|
+
readonly data: HandshakeRequestData;
|
|
543
|
+
getData(): HandshakeRequestData;
|
|
544
|
+
};
|
|
545
|
+
readonly MESSAGE_TYPE: "handshake";
|
|
546
|
+
readonly MESSAGE_VERSION: 1;
|
|
547
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
548
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
549
|
+
readonly type: "handshake";
|
|
550
|
+
readonly version: 1;
|
|
551
|
+
encode(): HandshakeRequestWire;
|
|
552
|
+
readonly data: HandshakeRequestData;
|
|
553
|
+
getData(): HandshakeRequestData;
|
|
554
|
+
}>;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Ultra-DRY Message Registry - everything is derived, no registration needed
|
|
559
|
+
*/
|
|
560
|
+
declare class MessageRegistry {
|
|
561
|
+
private static instance;
|
|
562
|
+
private constructor();
|
|
563
|
+
static getInstance(): MessageRegistry;
|
|
564
|
+
/**
|
|
565
|
+
* Get a message class by type and version (derived from single source)
|
|
566
|
+
*/
|
|
567
|
+
getMessageClass(type: string, version: number): {
|
|
568
|
+
new (data: HandshakeRequestData): {
|
|
569
|
+
readonly type: "handshake";
|
|
570
|
+
readonly version: 1;
|
|
571
|
+
encode(): HandshakeRequestWire;
|
|
572
|
+
readonly data: HandshakeRequestData;
|
|
573
|
+
getData(): HandshakeRequestData;
|
|
574
|
+
};
|
|
575
|
+
readonly MESSAGE_TYPE: "handshake";
|
|
576
|
+
readonly MESSAGE_VERSION: 1;
|
|
577
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
578
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
579
|
+
readonly type: "handshake";
|
|
580
|
+
readonly version: 1;
|
|
581
|
+
encode(): HandshakeRequestWire;
|
|
582
|
+
readonly data: HandshakeRequestData;
|
|
583
|
+
getData(): HandshakeRequestData;
|
|
584
|
+
}>;
|
|
585
|
+
} | {
|
|
586
|
+
new (data: HandshakeResponseData): {
|
|
587
|
+
readonly type: "handshake_response";
|
|
588
|
+
readonly version: 1;
|
|
589
|
+
encode(): any;
|
|
590
|
+
readonly data: HandshakeResponseData;
|
|
591
|
+
getData(): HandshakeResponseData;
|
|
592
|
+
};
|
|
593
|
+
readonly MESSAGE_TYPE: "handshake_response";
|
|
594
|
+
readonly MESSAGE_VERSION: 1;
|
|
595
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
596
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
597
|
+
readonly type: "handshake_response";
|
|
598
|
+
readonly version: 1;
|
|
599
|
+
encode(): any;
|
|
600
|
+
readonly data: HandshakeResponseData;
|
|
601
|
+
getData(): HandshakeResponseData;
|
|
602
|
+
}>;
|
|
603
|
+
} | {
|
|
604
|
+
new (data: SignMessageRequestData): {
|
|
605
|
+
readonly type: "signMessage";
|
|
606
|
+
readonly version: 1;
|
|
607
|
+
encode(): unknown;
|
|
608
|
+
readonly data: SignMessageRequestData;
|
|
609
|
+
getData(): SignMessageRequestData;
|
|
610
|
+
};
|
|
611
|
+
readonly MESSAGE_TYPE: "signMessage";
|
|
612
|
+
readonly MESSAGE_VERSION: 1;
|
|
613
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
614
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
615
|
+
readonly type: "signMessage";
|
|
616
|
+
readonly version: 1;
|
|
617
|
+
encode(): unknown;
|
|
618
|
+
readonly data: SignMessageRequestData;
|
|
619
|
+
getData(): SignMessageRequestData;
|
|
620
|
+
}>;
|
|
621
|
+
} | {
|
|
622
|
+
new (data: SignMessageResponseData): {
|
|
623
|
+
readonly type: "signMessage_response";
|
|
624
|
+
readonly version: 1;
|
|
625
|
+
encode(): SignMessageResponseWire;
|
|
626
|
+
readonly data: SignMessageResponseData;
|
|
627
|
+
getData(): SignMessageResponseData;
|
|
628
|
+
};
|
|
629
|
+
readonly MESSAGE_TYPE: "signMessage_response";
|
|
630
|
+
readonly MESSAGE_VERSION: 1;
|
|
631
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
632
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
633
|
+
readonly type: "signMessage_response";
|
|
634
|
+
readonly version: 1;
|
|
635
|
+
encode(): SignMessageResponseWire;
|
|
636
|
+
readonly data: SignMessageResponseData;
|
|
637
|
+
getData(): SignMessageResponseData;
|
|
638
|
+
}>;
|
|
639
|
+
} | {
|
|
640
|
+
new (data: ConnectionAckRequestData): {
|
|
641
|
+
readonly type: "connection_ack";
|
|
642
|
+
readonly version: 1;
|
|
643
|
+
encode(): any;
|
|
644
|
+
readonly data: ConnectionAckRequestData;
|
|
645
|
+
getData(): ConnectionAckRequestData;
|
|
646
|
+
};
|
|
647
|
+
readonly MESSAGE_TYPE: "connection_ack";
|
|
648
|
+
readonly MESSAGE_VERSION: 1;
|
|
649
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
650
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
651
|
+
readonly type: "connection_ack";
|
|
652
|
+
readonly version: 1;
|
|
653
|
+
encode(): any;
|
|
654
|
+
readonly data: ConnectionAckRequestData;
|
|
655
|
+
getData(): ConnectionAckRequestData;
|
|
656
|
+
}>;
|
|
657
|
+
} | {
|
|
658
|
+
new (data: ConnectionAckResponseData): {
|
|
659
|
+
readonly type: "connection_ack_response";
|
|
660
|
+
readonly version: 1;
|
|
661
|
+
encode(): any;
|
|
662
|
+
readonly data: ConnectionAckResponseData;
|
|
663
|
+
getData(): ConnectionAckResponseData;
|
|
664
|
+
};
|
|
665
|
+
readonly MESSAGE_TYPE: "connection_ack_response";
|
|
666
|
+
readonly MESSAGE_VERSION: 1;
|
|
667
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
668
|
+
decode(wireData: unknown): either.Either<io_ts.Errors, {
|
|
669
|
+
readonly type: "connection_ack_response";
|
|
670
|
+
readonly version: 1;
|
|
671
|
+
encode(): any;
|
|
672
|
+
readonly data: ConnectionAckResponseData;
|
|
673
|
+
getData(): ConnectionAckResponseData;
|
|
674
|
+
}>;
|
|
675
|
+
} | undefined;
|
|
676
|
+
/**
|
|
677
|
+
* Create a message instance from wire data (using derived message classes)
|
|
678
|
+
*/
|
|
679
|
+
decode(wireData: any): either.Either<string, IMessage>;
|
|
680
|
+
/**
|
|
681
|
+
* Encode a message to wire format
|
|
682
|
+
*/
|
|
683
|
+
encode(message: IMessage): any;
|
|
684
|
+
/**
|
|
685
|
+
* Get all registered message types (derived from single source)
|
|
686
|
+
*/
|
|
687
|
+
getRegisteredTypes(): string[];
|
|
688
|
+
}
|
|
689
|
+
declare const messageRegistry: MessageRegistry;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* 🎯 SINGLE SOURCE OF TRUTH - Add new messages here and everything else is automatic!
|
|
693
|
+
* This is the ONLY place you need to add new message types
|
|
694
|
+
*/
|
|
695
|
+
declare const ALL_MESSAGE_CLASSES: {
|
|
696
|
+
readonly 'handshake@1': {
|
|
697
|
+
new (data: HandshakeRequestData): {
|
|
698
|
+
readonly type: "handshake";
|
|
699
|
+
readonly version: 1;
|
|
700
|
+
encode(): HandshakeRequestWire;
|
|
701
|
+
readonly data: HandshakeRequestData;
|
|
702
|
+
getData(): HandshakeRequestData;
|
|
703
|
+
};
|
|
704
|
+
readonly MESSAGE_TYPE: "handshake";
|
|
705
|
+
readonly MESSAGE_VERSION: 1;
|
|
706
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
707
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
708
|
+
readonly type: "handshake";
|
|
709
|
+
readonly version: 1;
|
|
710
|
+
encode(): HandshakeRequestWire;
|
|
711
|
+
readonly data: HandshakeRequestData;
|
|
712
|
+
getData(): HandshakeRequestData;
|
|
713
|
+
}>;
|
|
714
|
+
};
|
|
715
|
+
readonly 'handshake_response@1': {
|
|
716
|
+
new (data: HandshakeResponseData): {
|
|
717
|
+
readonly type: "handshake_response";
|
|
718
|
+
readonly version: 1;
|
|
719
|
+
encode(): any;
|
|
720
|
+
readonly data: HandshakeResponseData;
|
|
721
|
+
getData(): HandshakeResponseData;
|
|
722
|
+
};
|
|
723
|
+
readonly MESSAGE_TYPE: "handshake_response";
|
|
724
|
+
readonly MESSAGE_VERSION: 1;
|
|
725
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
726
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
727
|
+
readonly type: "handshake_response";
|
|
728
|
+
readonly version: 1;
|
|
729
|
+
encode(): any;
|
|
730
|
+
readonly data: HandshakeResponseData;
|
|
731
|
+
getData(): HandshakeResponseData;
|
|
732
|
+
}>;
|
|
733
|
+
};
|
|
734
|
+
readonly 'signMessage@1': {
|
|
735
|
+
new (data: SignMessageRequestData): {
|
|
736
|
+
readonly type: "signMessage";
|
|
737
|
+
readonly version: 1;
|
|
738
|
+
encode(): unknown;
|
|
739
|
+
readonly data: SignMessageRequestData;
|
|
740
|
+
getData(): SignMessageRequestData;
|
|
741
|
+
};
|
|
742
|
+
readonly MESSAGE_TYPE: "signMessage";
|
|
743
|
+
readonly MESSAGE_VERSION: 1;
|
|
744
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
745
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
746
|
+
readonly type: "signMessage";
|
|
747
|
+
readonly version: 1;
|
|
748
|
+
encode(): unknown;
|
|
749
|
+
readonly data: SignMessageRequestData;
|
|
750
|
+
getData(): SignMessageRequestData;
|
|
751
|
+
}>;
|
|
752
|
+
};
|
|
753
|
+
readonly 'signMessage_response@1': {
|
|
754
|
+
new (data: SignMessageResponseData): {
|
|
755
|
+
readonly type: "signMessage_response";
|
|
756
|
+
readonly version: 1;
|
|
757
|
+
encode(): SignMessageResponseWire;
|
|
758
|
+
readonly data: SignMessageResponseData;
|
|
759
|
+
getData(): SignMessageResponseData;
|
|
760
|
+
};
|
|
761
|
+
readonly MESSAGE_TYPE: "signMessage_response";
|
|
762
|
+
readonly MESSAGE_VERSION: 1;
|
|
763
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
764
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
765
|
+
readonly type: "signMessage_response";
|
|
766
|
+
readonly version: 1;
|
|
767
|
+
encode(): SignMessageResponseWire;
|
|
768
|
+
readonly data: SignMessageResponseData;
|
|
769
|
+
getData(): SignMessageResponseData;
|
|
770
|
+
}>;
|
|
771
|
+
};
|
|
772
|
+
readonly 'connection_ack@1': {
|
|
773
|
+
new (data: ConnectionAckRequestData): {
|
|
774
|
+
readonly type: "connection_ack";
|
|
775
|
+
readonly version: 1;
|
|
776
|
+
encode(): any;
|
|
777
|
+
readonly data: ConnectionAckRequestData;
|
|
778
|
+
getData(): ConnectionAckRequestData;
|
|
779
|
+
};
|
|
780
|
+
readonly MESSAGE_TYPE: "connection_ack";
|
|
781
|
+
readonly MESSAGE_VERSION: 1;
|
|
782
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
783
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
784
|
+
readonly type: "connection_ack";
|
|
785
|
+
readonly version: 1;
|
|
786
|
+
encode(): any;
|
|
787
|
+
readonly data: ConnectionAckRequestData;
|
|
788
|
+
getData(): ConnectionAckRequestData;
|
|
789
|
+
}>;
|
|
790
|
+
};
|
|
791
|
+
readonly 'connection_ack_response@1': {
|
|
792
|
+
new (data: ConnectionAckResponseData): {
|
|
793
|
+
readonly type: "connection_ack_response";
|
|
794
|
+
readonly version: 1;
|
|
795
|
+
encode(): any;
|
|
796
|
+
readonly data: ConnectionAckResponseData;
|
|
797
|
+
getData(): ConnectionAckResponseData;
|
|
798
|
+
};
|
|
799
|
+
readonly MESSAGE_TYPE: "connection_ack_response";
|
|
800
|
+
readonly MESSAGE_VERSION: 1;
|
|
801
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
802
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
803
|
+
readonly type: "connection_ack_response";
|
|
804
|
+
readonly version: 1;
|
|
805
|
+
encode(): any;
|
|
806
|
+
readonly data: ConnectionAckResponseData;
|
|
807
|
+
getData(): ConnectionAckResponseData;
|
|
808
|
+
}>;
|
|
809
|
+
};
|
|
810
|
+
};
|
|
811
|
+
/**
|
|
812
|
+
* Derive message type union from classes
|
|
813
|
+
*/
|
|
814
|
+
type AllMessageTypes = keyof typeof ALL_MESSAGE_CLASSES;
|
|
815
|
+
/**
|
|
816
|
+
* Derive runtime array of message keys from classes
|
|
817
|
+
*/
|
|
818
|
+
declare const ALL_MESSAGE_KEYS: AllMessageTypes[];
|
|
819
|
+
/**
|
|
820
|
+
* Get message class by type and version (derived from single source)
|
|
821
|
+
*/
|
|
822
|
+
declare function getMessageClass(type: string, version: number): {
|
|
823
|
+
new (data: HandshakeRequestData): {
|
|
824
|
+
readonly type: "handshake";
|
|
825
|
+
readonly version: 1;
|
|
826
|
+
encode(): HandshakeRequestWire;
|
|
827
|
+
readonly data: HandshakeRequestData;
|
|
828
|
+
getData(): HandshakeRequestData;
|
|
829
|
+
};
|
|
830
|
+
readonly MESSAGE_TYPE: "handshake";
|
|
831
|
+
readonly MESSAGE_VERSION: 1;
|
|
832
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
833
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
834
|
+
readonly type: "handshake";
|
|
835
|
+
readonly version: 1;
|
|
836
|
+
encode(): HandshakeRequestWire;
|
|
837
|
+
readonly data: HandshakeRequestData;
|
|
838
|
+
getData(): HandshakeRequestData;
|
|
839
|
+
}>;
|
|
840
|
+
} | {
|
|
841
|
+
new (data: HandshakeResponseData): {
|
|
842
|
+
readonly type: "handshake_response";
|
|
843
|
+
readonly version: 1;
|
|
844
|
+
encode(): any;
|
|
845
|
+
readonly data: HandshakeResponseData;
|
|
846
|
+
getData(): HandshakeResponseData;
|
|
847
|
+
};
|
|
848
|
+
readonly MESSAGE_TYPE: "handshake_response";
|
|
849
|
+
readonly MESSAGE_VERSION: 1;
|
|
850
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
851
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
852
|
+
readonly type: "handshake_response";
|
|
853
|
+
readonly version: 1;
|
|
854
|
+
encode(): any;
|
|
855
|
+
readonly data: HandshakeResponseData;
|
|
856
|
+
getData(): HandshakeResponseData;
|
|
857
|
+
}>;
|
|
858
|
+
} | {
|
|
859
|
+
new (data: SignMessageRequestData): {
|
|
860
|
+
readonly type: "signMessage";
|
|
861
|
+
readonly version: 1;
|
|
862
|
+
encode(): unknown;
|
|
863
|
+
readonly data: SignMessageRequestData;
|
|
864
|
+
getData(): SignMessageRequestData;
|
|
865
|
+
};
|
|
866
|
+
readonly MESSAGE_TYPE: "signMessage";
|
|
867
|
+
readonly MESSAGE_VERSION: 1;
|
|
868
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
869
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
870
|
+
readonly type: "signMessage";
|
|
871
|
+
readonly version: 1;
|
|
872
|
+
encode(): unknown;
|
|
873
|
+
readonly data: SignMessageRequestData;
|
|
874
|
+
getData(): SignMessageRequestData;
|
|
875
|
+
}>;
|
|
876
|
+
} | {
|
|
877
|
+
new (data: SignMessageResponseData): {
|
|
878
|
+
readonly type: "signMessage_response";
|
|
879
|
+
readonly version: 1;
|
|
880
|
+
encode(): SignMessageResponseWire;
|
|
881
|
+
readonly data: SignMessageResponseData;
|
|
882
|
+
getData(): SignMessageResponseData;
|
|
883
|
+
};
|
|
884
|
+
readonly MESSAGE_TYPE: "signMessage_response";
|
|
885
|
+
readonly MESSAGE_VERSION: 1;
|
|
886
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
887
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
888
|
+
readonly type: "signMessage_response";
|
|
889
|
+
readonly version: 1;
|
|
890
|
+
encode(): SignMessageResponseWire;
|
|
891
|
+
readonly data: SignMessageResponseData;
|
|
892
|
+
getData(): SignMessageResponseData;
|
|
893
|
+
}>;
|
|
894
|
+
} | {
|
|
895
|
+
new (data: ConnectionAckRequestData): {
|
|
896
|
+
readonly type: "connection_ack";
|
|
897
|
+
readonly version: 1;
|
|
898
|
+
encode(): any;
|
|
899
|
+
readonly data: ConnectionAckRequestData;
|
|
900
|
+
getData(): ConnectionAckRequestData;
|
|
901
|
+
};
|
|
902
|
+
readonly MESSAGE_TYPE: "connection_ack";
|
|
903
|
+
readonly MESSAGE_VERSION: 1;
|
|
904
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
905
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
906
|
+
readonly type: "connection_ack";
|
|
907
|
+
readonly version: 1;
|
|
908
|
+
encode(): any;
|
|
909
|
+
readonly data: ConnectionAckRequestData;
|
|
910
|
+
getData(): ConnectionAckRequestData;
|
|
911
|
+
}>;
|
|
912
|
+
} | {
|
|
913
|
+
new (data: ConnectionAckResponseData): {
|
|
914
|
+
readonly type: "connection_ack_response";
|
|
915
|
+
readonly version: 1;
|
|
916
|
+
encode(): any;
|
|
917
|
+
readonly data: ConnectionAckResponseData;
|
|
918
|
+
getData(): ConnectionAckResponseData;
|
|
919
|
+
};
|
|
920
|
+
readonly MESSAGE_TYPE: "connection_ack_response";
|
|
921
|
+
readonly MESSAGE_VERSION: 1;
|
|
922
|
+
readonly schema: io_ts.Type<any, any, unknown>;
|
|
923
|
+
decode(wireData: unknown): fp_ts_lib_Either.Either<io_ts.Errors, {
|
|
924
|
+
readonly type: "connection_ack_response";
|
|
925
|
+
readonly version: 1;
|
|
926
|
+
encode(): any;
|
|
927
|
+
readonly data: ConnectionAckResponseData;
|
|
928
|
+
getData(): ConnectionAckResponseData;
|
|
929
|
+
}>;
|
|
930
|
+
};
|
|
931
|
+
/**
|
|
932
|
+
* Type-safe check if message type exists
|
|
933
|
+
*/
|
|
934
|
+
declare function isValidMessageType(type: string, version: number): boolean;
|
|
935
|
+
/**
|
|
936
|
+
* Get all supported message types and versions
|
|
937
|
+
*/
|
|
938
|
+
declare function getAllSupportedMessages(): Array<{
|
|
939
|
+
type: string;
|
|
940
|
+
version: number;
|
|
941
|
+
}>;
|
|
942
|
+
/**
|
|
943
|
+
* Helper to extract message type and version from key
|
|
944
|
+
*/
|
|
945
|
+
declare function parseMessageKey(key: AllMessageTypes): {
|
|
946
|
+
type: string;
|
|
947
|
+
version: number;
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
declare const Uint8ArrayCodec: Type<Uint8Array<ArrayBufferLike>, string, unknown>;
|
|
951
|
+
|
|
952
|
+
declare const Uint32ArrayCodec: Type<Uint32Array<ArrayBufferLike>, string, unknown>;
|
|
953
|
+
|
|
954
|
+
declare const generateMlKem768Keypair: () => {
|
|
955
|
+
encapsulationKey: Uint8Array;
|
|
956
|
+
decapsulationKey: Uint8Array;
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
declare const encapsulateMlKem768: (encapsulationKey: Uint8Array) => {
|
|
960
|
+
cipherText: Uint8Array;
|
|
961
|
+
sharedSecret: Uint8Array;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
declare const decapsulateMlKem768: (decapsulationKey: Uint8Array, cipherText: Uint8Array) => Uint8Array;
|
|
965
|
+
|
|
966
|
+
declare const AES_256_GCM_KEY_SIZE = 32;
|
|
967
|
+
declare const AES_256_GCM_NONCE_SIZE = 12;
|
|
968
|
+
declare const AES_256_GCM_TAG_SIZE = 16;
|
|
969
|
+
declare const HKDF_SALT_SIZE = 32;
|
|
970
|
+
/**
|
|
971
|
+
* Derive AES-256 key from ML-KEM shared secret using HKDF
|
|
972
|
+
* Following NIST SP 800-56C recommendations
|
|
973
|
+
*/
|
|
974
|
+
declare function deriveAESKey(sharedSecret: Uint8Array, salt: Uint8Array, info: string): Uint8Array;
|
|
975
|
+
/**
|
|
976
|
+
* Create standardized context info for HKDF
|
|
977
|
+
*/
|
|
978
|
+
declare function createKeyDerivationInfo(purpose: 'keyshare' | 'hmac', connectionId: string, version?: number): string;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Encrypt keyshare using AES-256-GCM with ML-KEM derived key
|
|
982
|
+
*
|
|
983
|
+
* @param keyshare - The keyshare object from Dynamic Wallet SDK
|
|
984
|
+
* @param sharedSecret - ML-KEM shared secret from handshake
|
|
985
|
+
* @param connectionId - Unique connection identifier
|
|
986
|
+
* @param signingAlgorithm - Algorithm name for context
|
|
987
|
+
* @returns Encrypted keyshare with salt and encrypted payload
|
|
988
|
+
*/
|
|
989
|
+
declare function encryptKeyshare(keyshare: any, sharedSecret: Uint8Array, connectionId: string, signingAlgorithm: SigningAlgorithmName): Promise<EncryptedKeyshare>;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Asserts that a value is defined (not null or undefined)
|
|
993
|
+
* @throws Error if value is null or undefined
|
|
994
|
+
*/
|
|
995
|
+
declare function assertDefined<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
996
|
+
/**
|
|
997
|
+
* Asserts that a value is not null
|
|
998
|
+
* @throws Error if value is null
|
|
999
|
+
*/
|
|
1000
|
+
declare function assertNotNull<T>(value: T | null, message?: string): asserts value is T;
|
|
1001
|
+
/**
|
|
1002
|
+
* Returns a value if it is defined, otherwise throws an error
|
|
1003
|
+
* @throws Error if value is null or undefined
|
|
1004
|
+
*/
|
|
1005
|
+
declare function getDefined<T>(value: T | null | undefined, message?: string): T;
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Ultra-simple registry - everything is derived, no registration needed
|
|
1009
|
+
*/
|
|
1010
|
+
declare class SigningAlgorithmRegistry {
|
|
1011
|
+
/**
|
|
1012
|
+
* Get algorithm instance (derived from single source of truth)
|
|
1013
|
+
*/
|
|
1014
|
+
get(name: SigningAlgorithmName): ISigningAlgorithm;
|
|
1015
|
+
/**
|
|
1016
|
+
* Type-safe check if algorithm exists
|
|
1017
|
+
*/
|
|
1018
|
+
has(name: string): name is SigningAlgorithmName;
|
|
1019
|
+
/**
|
|
1020
|
+
* Get all algorithm names (derived from classes)
|
|
1021
|
+
*/
|
|
1022
|
+
getAllNames(): SigningAlgorithmName[];
|
|
1023
|
+
/**
|
|
1024
|
+
* Get all algorithm instances (derived from classes)
|
|
1025
|
+
*/
|
|
1026
|
+
getAllInstances(): Record<SigningAlgorithmName, ISigningAlgorithm>;
|
|
1027
|
+
}
|
|
1028
|
+
declare const signingAlgorithmRegistry: SigningAlgorithmRegistry;
|
|
1029
|
+
|
|
1030
|
+
export { AES_256_GCM_KEY_SIZE, AES_256_GCM_NONCE_SIZE, AES_256_GCM_TAG_SIZE, ALGORITHMS, ALL_MESSAGE_CLASSES, ALL_MESSAGE_KEYS, ALL_SIGNING_ALGORITHM_NAMES, ALL_SIGNING_ALGORITHM_SCHEMA, type AllMessageTypes, type AllSigningAlgorithmSchemas, BIP340SigningAlgorithm, BaseMessage, BaseSigningAlgorithm, type BaseWebSocketMessage, type ConnectionAckRequest, type ConnectionAckRequestData, ConnectionAckRequestSchema, type ConnectionAckRequestWire, type ConnectionAckResponse, type ConnectionAckResponseData, ConnectionAckResponseSchema, type ConnectionAckResponseWire, ConnectionAckV1RequestMessage, ConnectionAckV1ResponseMessage, type DecryptedSecretShare, EcdsaSigningAlgorithm, Ed25519SigningAlgorithm, type EncryptedKeyshare, EncryptedKeyshareCodec, type ErrorResponse, HKDF_SALT_SIZE, type HandshakeRequest, type HandshakeRequestData, HandshakeRequestSchema, type HandshakeRequestWire, type HandshakeResponse, type HandshakeResponseData, HandshakeResponseSchema, type HandshakeResponseWire, HandshakeV1RequestMessage, HandshakeV1ResponseMessage, type HashAlgorithm, type IMessage, type ISigningAlgorithm, MessageRegistry, SIGNING_ALGORITHM_CLASSES, SIGNING_ALGORITHM_INSTANCES, type SecretShareData, type SignMessageRequest, type SignMessageRequestData, SignMessageRequestSchema, type SignMessageRequestWire, type SignMessageResponse, type SignMessageResponseData, SignMessageResponseSchema, type SignMessageResponseWire, SignMessageV1RequestMessage, SignMessageV1ResponseMessage, SignatureAlgoSchema, type SigningAlgorithmName, type SigningAlgorithmSchemaFor, type AllSigningAlgorithmSchemas as SigningAlgorithmSchemas, Uint32ArrayCodec, Uint8ArrayCodec, type WebSocketConnectionInfo, type WebSocketError, WebSocketErrorType, assertDefined, assertNotNull, createKeyDerivationInfo, createKeygenResultFromSecretShare, decapsulateMlKem768, deriveAESKey, encapsulateMlKem768, encryptKeyshare, fromDynamicSigningAlgorithm, generateMlKem768Keypair, getAllSupportedMessages, getDefined, getMessageClass, isValidMessageType, isValidSigningAlgorithm, messageRegistry, parseMessageKey, signingAlgorithmRegistry, toDynamicSigningAlgorithm };
|