@hsuite/native-connect-types 1.0.0
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/README.md +50 -0
- package/dist/address-avatar.d.ts +67 -0
- package/dist/address-avatar.d.ts.map +1 -0
- package/dist/address-avatar.js +130 -0
- package/dist/address-avatar.js.map +1 -0
- package/dist/addressbook.d.ts +289 -0
- package/dist/addressbook.d.ts.map +1 -0
- package/dist/addressbook.js +82 -0
- package/dist/addressbook.js.map +1 -0
- package/dist/enrichment.d.ts +88 -0
- package/dist/enrichment.d.ts.map +1 -0
- package/dist/enrichment.js +47 -0
- package/dist/enrichment.js.map +1 -0
- package/dist/hedera-system-accounts.d.ts +49 -0
- package/dist/hedera-system-accounts.d.ts.map +1 -0
- package/dist/hedera-system-accounts.js +56 -0
- package/dist/hedera-system-accounts.js.map +1 -0
- package/dist/identity.d.ts +94 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +190 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +848 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +152 -0
- package/dist/ledger.js.map +1 -0
- package/dist/messages.d.ts +726 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +252 -0
- package/dist/messages.js.map +1 -0
- package/dist/multisig-account.d.ts +419 -0
- package/dist/multisig-account.d.ts.map +1 -0
- package/dist/multisig-account.js +201 -0
- package/dist/multisig-account.js.map +1 -0
- package/dist/private-key-export.d.ts +112 -0
- package/dist/private-key-export.d.ts.map +1 -0
- package/dist/private-key-export.js +11 -0
- package/dist/private-key-export.js.map +1 -0
- package/dist/rpc.d.ts +872 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +143 -0
- package/dist/rpc.js.map +1 -0
- package/dist/transaction-approval.d.ts +895 -0
- package/dist/transaction-approval.d.ts.map +1 -0
- package/dist/transaction-approval.js +11 -0
- package/dist/transaction-approval.js.map +1 -0
- package/dist/transaction-parser.d.ts +93 -0
- package/dist/transaction-parser.d.ts.map +1 -0
- package/dist/transaction-parser.js +11 -0
- package/dist/transaction-parser.js.map +1 -0
- package/dist/vault.d.ts +673 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +188 -0
- package/dist/vault.js.map +1 -0
- package/dist/widget.types.d.ts +323 -0
- package/dist/widget.types.d.ts.map +1 -0
- package/dist/widget.types.js +140 -0
- package/dist/widget.types.js.map +1 -0
- package/package.json +43 -0
- package/src/address-avatar.ts +181 -0
- package/src/addressbook.spec.ts +220 -0
- package/src/addressbook.ts +115 -0
- package/src/enrichment.ts +97 -0
- package/src/hedera-system-accounts.ts +60 -0
- package/src/identity.spec.ts +243 -0
- package/src/identity.ts +244 -0
- package/src/index.ts +197 -0
- package/src/ledger.spec.ts +366 -0
- package/src/ledger.ts +567 -0
- package/src/messages.ts +381 -0
- package/src/multisig-account.spec.ts +362 -0
- package/src/multisig-account.ts +310 -0
- package/src/private-key-export.ts +117 -0
- package/src/rpc.spec.ts +396 -0
- package/src/rpc.ts +257 -0
- package/src/transaction-approval.ts +1033 -0
- package/src/transaction-parser.ts +98 -0
- package/src/vault.spec.ts +268 -0
- package/src/vault.ts +256 -0
- package/src/widget.types.spec.ts +337 -0
- package/src/widget.types.ts +501 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +36 -0
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @file Protocol message types for dApp-wallet communication.
|
|
12
|
+
*
|
|
13
|
+
* This module defines the core message schemas and types used in the HSuite
|
|
14
|
+
* Channel Protocol (hsc:) for secure communication between dApps and wallets.
|
|
15
|
+
*
|
|
16
|
+
* Message Flow:
|
|
17
|
+
* 1. dApp sends {@link SessionRequest} to initiate connection
|
|
18
|
+
* 2. Wallet responds with {@link SessionApproval} (approve/reject)
|
|
19
|
+
* 3. dApp sends {@link SignPayload} for transaction signing
|
|
20
|
+
* 4. Wallet returns {@link SignResult} with signature
|
|
21
|
+
*
|
|
22
|
+
* All messages are wrapped in {@link MessageEnvelope} for transport with
|
|
23
|
+
* versioning, timestamps, and optional signatures.
|
|
24
|
+
*
|
|
25
|
+
* @module types/messages
|
|
26
|
+
*/
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
/**
|
|
29
|
+
* @description Schema for dApp session request payload
|
|
30
|
+
*/
|
|
31
|
+
export declare const SessionRequestSchema: z.ZodObject<{
|
|
32
|
+
appId: z.ZodString;
|
|
33
|
+
appName: z.ZodString;
|
|
34
|
+
appIcon: z.ZodOptional<z.ZodString>;
|
|
35
|
+
ledgerId: z.ZodString;
|
|
36
|
+
networkId: z.ZodString;
|
|
37
|
+
purpose: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
38
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
39
|
+
nonce: z.ZodString;
|
|
40
|
+
timestamp: z.ZodNumber;
|
|
41
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
ledgerId?: string;
|
|
44
|
+
networkId?: string;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
purpose?: string[];
|
|
47
|
+
timestamp?: number;
|
|
48
|
+
appId?: string;
|
|
49
|
+
appName?: string;
|
|
50
|
+
appIcon?: string;
|
|
51
|
+
permissions?: string[];
|
|
52
|
+
nonce?: string;
|
|
53
|
+
}, {
|
|
54
|
+
ledgerId?: string;
|
|
55
|
+
networkId?: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
purpose?: string[];
|
|
58
|
+
timestamp?: number;
|
|
59
|
+
appId?: string;
|
|
60
|
+
appName?: string;
|
|
61
|
+
appIcon?: string;
|
|
62
|
+
permissions?: string[];
|
|
63
|
+
nonce?: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* @description Type representing session request payload from dApp
|
|
67
|
+
*/
|
|
68
|
+
export type SessionRequest = z.infer<typeof SessionRequestSchema>;
|
|
69
|
+
/**
|
|
70
|
+
* @description Schema for wallet's session approval/rejection response
|
|
71
|
+
*/
|
|
72
|
+
export declare const SessionApprovalSchema: z.ZodObject<{
|
|
73
|
+
appId: z.ZodString;
|
|
74
|
+
appName: z.ZodString;
|
|
75
|
+
appIcon: z.ZodOptional<z.ZodString>;
|
|
76
|
+
ledgerId: z.ZodString;
|
|
77
|
+
networkId: z.ZodString;
|
|
78
|
+
purpose: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
79
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
80
|
+
nonce: z.ZodString;
|
|
81
|
+
timestamp: z.ZodNumber;
|
|
82
|
+
} & {
|
|
83
|
+
approved: z.ZodBoolean;
|
|
84
|
+
accounts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
85
|
+
ledgerId: z.ZodString;
|
|
86
|
+
networkId: z.ZodString;
|
|
87
|
+
address: z.ZodString;
|
|
88
|
+
publicKey: z.ZodString;
|
|
89
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
ledgerId?: string;
|
|
92
|
+
networkId?: string;
|
|
93
|
+
address?: string;
|
|
94
|
+
publicKey?: string;
|
|
95
|
+
metadata?: Record<string, unknown>;
|
|
96
|
+
}, {
|
|
97
|
+
ledgerId?: string;
|
|
98
|
+
networkId?: string;
|
|
99
|
+
address?: string;
|
|
100
|
+
publicKey?: string;
|
|
101
|
+
metadata?: Record<string, unknown>;
|
|
102
|
+
}>, "many">>;
|
|
103
|
+
expiration: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
105
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
ledgerId?: string;
|
|
108
|
+
networkId?: string;
|
|
109
|
+
metadata?: Record<string, unknown>;
|
|
110
|
+
purpose?: string[];
|
|
111
|
+
timestamp?: number;
|
|
112
|
+
appId?: string;
|
|
113
|
+
appName?: string;
|
|
114
|
+
appIcon?: string;
|
|
115
|
+
permissions?: string[];
|
|
116
|
+
nonce?: string;
|
|
117
|
+
approved?: boolean;
|
|
118
|
+
accounts?: {
|
|
119
|
+
ledgerId?: string;
|
|
120
|
+
networkId?: string;
|
|
121
|
+
address?: string;
|
|
122
|
+
publicKey?: string;
|
|
123
|
+
metadata?: Record<string, unknown>;
|
|
124
|
+
}[];
|
|
125
|
+
expiration?: number;
|
|
126
|
+
signature?: string;
|
|
127
|
+
}, {
|
|
128
|
+
ledgerId?: string;
|
|
129
|
+
networkId?: string;
|
|
130
|
+
metadata?: Record<string, unknown>;
|
|
131
|
+
purpose?: string[];
|
|
132
|
+
timestamp?: number;
|
|
133
|
+
appId?: string;
|
|
134
|
+
appName?: string;
|
|
135
|
+
appIcon?: string;
|
|
136
|
+
permissions?: string[];
|
|
137
|
+
nonce?: string;
|
|
138
|
+
approved?: boolean;
|
|
139
|
+
accounts?: {
|
|
140
|
+
ledgerId?: string;
|
|
141
|
+
networkId?: string;
|
|
142
|
+
address?: string;
|
|
143
|
+
publicKey?: string;
|
|
144
|
+
metadata?: Record<string, unknown>;
|
|
145
|
+
}[];
|
|
146
|
+
expiration?: number;
|
|
147
|
+
signature?: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* @description Type representing session approval response
|
|
151
|
+
*/
|
|
152
|
+
export type SessionApproval = z.infer<typeof SessionApprovalSchema>;
|
|
153
|
+
/**
|
|
154
|
+
* @description Schema for batch inner transaction
|
|
155
|
+
*/
|
|
156
|
+
export declare const BatchInnerTransactionSchema: z.ZodObject<{
|
|
157
|
+
payload: z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>]>;
|
|
158
|
+
description: z.ZodOptional<z.ZodString>;
|
|
159
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
metadata?: Record<string, unknown>;
|
|
162
|
+
description?: string;
|
|
163
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
164
|
+
}, {
|
|
165
|
+
metadata?: Record<string, unknown>;
|
|
166
|
+
description?: string;
|
|
167
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* @description Type representing batch inner transaction
|
|
171
|
+
*/
|
|
172
|
+
export type BatchInnerTransaction = z.infer<typeof BatchInnerTransactionSchema>;
|
|
173
|
+
/**
|
|
174
|
+
* @description Schema for signing request payload
|
|
175
|
+
* Can be either a single transaction or a batch of transactions
|
|
176
|
+
*/
|
|
177
|
+
export declare const SignPayloadSchema: z.ZodObject<{
|
|
178
|
+
ledgerId: z.ZodString;
|
|
179
|
+
networkId: z.ZodString;
|
|
180
|
+
accountAddress: z.ZodString;
|
|
181
|
+
payload: z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>]>;
|
|
182
|
+
derivationPath: z.ZodOptional<z.ZodObject<{
|
|
183
|
+
purpose: z.ZodNumber;
|
|
184
|
+
coinType: z.ZodNumber;
|
|
185
|
+
account: z.ZodDefault<z.ZodNumber>;
|
|
186
|
+
change: z.ZodDefault<z.ZodNumber>;
|
|
187
|
+
addressIndex: z.ZodDefault<z.ZodNumber>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
purpose?: number;
|
|
190
|
+
coinType?: number;
|
|
191
|
+
account?: number;
|
|
192
|
+
change?: number;
|
|
193
|
+
addressIndex?: number;
|
|
194
|
+
}, {
|
|
195
|
+
purpose?: number;
|
|
196
|
+
coinType?: number;
|
|
197
|
+
account?: number;
|
|
198
|
+
change?: number;
|
|
199
|
+
addressIndex?: number;
|
|
200
|
+
}>>;
|
|
201
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
202
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
203
|
+
isBatch: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
batchKey: z.ZodOptional<z.ZodString>;
|
|
205
|
+
innerTransactions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
206
|
+
payload: z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>]>;
|
|
207
|
+
description: z.ZodOptional<z.ZodString>;
|
|
208
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
metadata?: Record<string, unknown>;
|
|
211
|
+
description?: string;
|
|
212
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
213
|
+
}, {
|
|
214
|
+
metadata?: Record<string, unknown>;
|
|
215
|
+
description?: string;
|
|
216
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
217
|
+
}>, "many">>;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
ledgerId?: string;
|
|
220
|
+
networkId?: string;
|
|
221
|
+
nonce?: string;
|
|
222
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
223
|
+
accountAddress?: string;
|
|
224
|
+
derivationPath?: {
|
|
225
|
+
purpose?: number;
|
|
226
|
+
coinType?: number;
|
|
227
|
+
account?: number;
|
|
228
|
+
change?: number;
|
|
229
|
+
addressIndex?: number;
|
|
230
|
+
};
|
|
231
|
+
context?: Record<string, unknown>;
|
|
232
|
+
isBatch?: boolean;
|
|
233
|
+
batchKey?: string;
|
|
234
|
+
innerTransactions?: {
|
|
235
|
+
metadata?: Record<string, unknown>;
|
|
236
|
+
description?: string;
|
|
237
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
238
|
+
}[];
|
|
239
|
+
}, {
|
|
240
|
+
ledgerId?: string;
|
|
241
|
+
networkId?: string;
|
|
242
|
+
nonce?: string;
|
|
243
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
244
|
+
accountAddress?: string;
|
|
245
|
+
derivationPath?: {
|
|
246
|
+
purpose?: number;
|
|
247
|
+
coinType?: number;
|
|
248
|
+
account?: number;
|
|
249
|
+
change?: number;
|
|
250
|
+
addressIndex?: number;
|
|
251
|
+
};
|
|
252
|
+
context?: Record<string, unknown>;
|
|
253
|
+
isBatch?: boolean;
|
|
254
|
+
batchKey?: string;
|
|
255
|
+
innerTransactions?: {
|
|
256
|
+
metadata?: Record<string, unknown>;
|
|
257
|
+
description?: string;
|
|
258
|
+
payload?: string | Uint8Array<ArrayBuffer>;
|
|
259
|
+
}[];
|
|
260
|
+
}>;
|
|
261
|
+
/**
|
|
262
|
+
* @description Type representing signing request
|
|
263
|
+
*/
|
|
264
|
+
export type SignPayload = z.infer<typeof SignPayloadSchema>;
|
|
265
|
+
/**
|
|
266
|
+
* @description Schema for signed inner transaction result
|
|
267
|
+
*/
|
|
268
|
+
export declare const SignedInnerTransactionSchema: z.ZodObject<{
|
|
269
|
+
signedPayload: z.ZodString;
|
|
270
|
+
transactionId: z.ZodOptional<z.ZodString>;
|
|
271
|
+
}, "strip", z.ZodTypeAny, {
|
|
272
|
+
signedPayload?: string;
|
|
273
|
+
transactionId?: string;
|
|
274
|
+
}, {
|
|
275
|
+
signedPayload?: string;
|
|
276
|
+
transactionId?: string;
|
|
277
|
+
}>;
|
|
278
|
+
/**
|
|
279
|
+
* @description Type representing signed inner transaction
|
|
280
|
+
*/
|
|
281
|
+
export type SignedInnerTransaction = z.infer<typeof SignedInnerTransactionSchema>;
|
|
282
|
+
/**
|
|
283
|
+
* @description Schema for signing operation result
|
|
284
|
+
* For single transactions: returns signature
|
|
285
|
+
* For batch transactions (sign mode): returns array of signed inner transactions
|
|
286
|
+
* For batch transactions (signAndExecute mode): returns transaction result
|
|
287
|
+
*/
|
|
288
|
+
export declare const SignResultSchema: z.ZodObject<{
|
|
289
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
290
|
+
/** Full signed transaction bytes (hex-encoded), suitable for submission via submitTransaction */
|
|
291
|
+
signedPayload: z.ZodOptional<z.ZodString>;
|
|
292
|
+
publicKey: z.ZodString;
|
|
293
|
+
payloadHash: z.ZodOptional<z.ZodString>;
|
|
294
|
+
algorithm: z.ZodString;
|
|
295
|
+
signedInnerTransactions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
296
|
+
signedPayload: z.ZodString;
|
|
297
|
+
transactionId: z.ZodOptional<z.ZodString>;
|
|
298
|
+
}, "strip", z.ZodTypeAny, {
|
|
299
|
+
signedPayload?: string;
|
|
300
|
+
transactionId?: string;
|
|
301
|
+
}, {
|
|
302
|
+
signedPayload?: string;
|
|
303
|
+
transactionId?: string;
|
|
304
|
+
}>, "many">>;
|
|
305
|
+
transactionId: z.ZodOptional<z.ZodString>;
|
|
306
|
+
transactionHash: z.ZodOptional<z.ZodString>;
|
|
307
|
+
status: z.ZodOptional<z.ZodString>;
|
|
308
|
+
}, "strip", z.ZodTypeAny, {
|
|
309
|
+
status?: string;
|
|
310
|
+
publicKey?: string;
|
|
311
|
+
signature?: string;
|
|
312
|
+
signedPayload?: string;
|
|
313
|
+
transactionId?: string;
|
|
314
|
+
payloadHash?: string;
|
|
315
|
+
algorithm?: string;
|
|
316
|
+
signedInnerTransactions?: {
|
|
317
|
+
signedPayload?: string;
|
|
318
|
+
transactionId?: string;
|
|
319
|
+
}[];
|
|
320
|
+
transactionHash?: string;
|
|
321
|
+
}, {
|
|
322
|
+
status?: string;
|
|
323
|
+
publicKey?: string;
|
|
324
|
+
signature?: string;
|
|
325
|
+
signedPayload?: string;
|
|
326
|
+
transactionId?: string;
|
|
327
|
+
payloadHash?: string;
|
|
328
|
+
algorithm?: string;
|
|
329
|
+
signedInnerTransactions?: {
|
|
330
|
+
signedPayload?: string;
|
|
331
|
+
transactionId?: string;
|
|
332
|
+
}[];
|
|
333
|
+
transactionHash?: string;
|
|
334
|
+
}>;
|
|
335
|
+
/**
|
|
336
|
+
* @description Type representing signature result
|
|
337
|
+
*/
|
|
338
|
+
export type SignResult = z.infer<typeof SignResultSchema>;
|
|
339
|
+
/**
|
|
340
|
+
* @description Payload for arbitrary message signing (ledger/signMessage RPC).
|
|
341
|
+
*
|
|
342
|
+
* Distinct from SignPayload (which carries transaction protobuf). Used by the
|
|
343
|
+
* §21.3 message-signing flow end-to-end: dApp → ChannelClient → wallet →
|
|
344
|
+
* adapter.signMessage() → domain-separated Ed25519/secp256k1 signing.
|
|
345
|
+
*/
|
|
346
|
+
export interface SignMessagePayload {
|
|
347
|
+
/** The message to sign — UTF-8 string or base64-encoded bytes depending on `encoding`. */
|
|
348
|
+
message: string;
|
|
349
|
+
/** How to decode `message` into bytes before domain separation + signing. */
|
|
350
|
+
encoding: 'utf-8' | 'base64';
|
|
351
|
+
/** Account address that will sign (selects the correct private key from the vault). */
|
|
352
|
+
accountAddress: string;
|
|
353
|
+
/**
|
|
354
|
+
* CAIP-2 chain identifier embedded verbatim in the signed blob.
|
|
355
|
+
* Example: "hedera:testnet", "xrpl:mainnet". Prevents cross-network replay:
|
|
356
|
+
* a signature over "hedera:testnet" + msg cannot be verified against
|
|
357
|
+
* "hedera:mainnet" + msg because the signed bytes differ.
|
|
358
|
+
*
|
|
359
|
+
* Must match `/^[a-z0-9]+:[a-z0-9]+$/` (CAIP-2 lower-kebab-case shape).
|
|
360
|
+
*/
|
|
361
|
+
caipChainId: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* @description Schema for message-signing result (§21.3).
|
|
365
|
+
*
|
|
366
|
+
* Separate from SignResultSchema because (a) message signing is semantically
|
|
367
|
+
* distinct from transaction signing — different security surface, different
|
|
368
|
+
* audit trail — and (b) it returns a narrower, always-required field set
|
|
369
|
+
* (signature, publicKey, algorithm) plus message-specific metadata
|
|
370
|
+
* (encoding, caipChainId, messageLength) that auditors and on-chain
|
|
371
|
+
* verifiers use to reconstruct the exact signed blob.
|
|
372
|
+
*
|
|
373
|
+
* The `algorithm` field is an enum (not free-form string) to make off-wallet
|
|
374
|
+
* verification deterministic. Consumers feed `signature`, `publicKey`,
|
|
375
|
+
* `algorithm`, `encoding`, `caipChainId`, and the original `message` back
|
|
376
|
+
* into `buildDomainSeparatedMessage` + the matching crypto primitive to
|
|
377
|
+
* verify the signature.
|
|
378
|
+
*/
|
|
379
|
+
export declare const MessageSignResultSchema: z.ZodObject<{
|
|
380
|
+
/** Raw signature as hex (no 0x prefix). 128 chars for Ed25519, variable for ECDSA/secp256k1 DER. */
|
|
381
|
+
signature: z.ZodString;
|
|
382
|
+
/** Raw public key as hex (no 0x prefix). 64 chars for Ed25519, 66 chars for compressed secp256k1. */
|
|
383
|
+
publicKey: z.ZodString;
|
|
384
|
+
/** Signing algorithm — enum for deterministic verification. */
|
|
385
|
+
algorithm: z.ZodEnum<["ed25519", "ecdsa_secp256k1", "secp256k1"]>;
|
|
386
|
+
/** Encoding used to decode the original `message` into bytes. */
|
|
387
|
+
encoding: z.ZodEnum<["utf-8", "base64"]>;
|
|
388
|
+
/**
|
|
389
|
+
* CAIP-2 chain identifier embedded in the signed blob. Mirrors the
|
|
390
|
+
* `caipChainId` from SignMessagePayload so verifiers can reconstruct
|
|
391
|
+
* the exact signed bytes without needing the original payload.
|
|
392
|
+
*/
|
|
393
|
+
caipChainId: z.ZodString;
|
|
394
|
+
/**
|
|
395
|
+
* Length of the decoded message in bytes (NOT the original string length).
|
|
396
|
+
* For UTF-8 messages this may exceed the character count (multi-byte
|
|
397
|
+
* codepoints). Used to prevent truncation attacks and for audit trail.
|
|
398
|
+
*/
|
|
399
|
+
messageLength: z.ZodNumber;
|
|
400
|
+
}, "strip", z.ZodTypeAny, {
|
|
401
|
+
publicKey?: string;
|
|
402
|
+
signature?: string;
|
|
403
|
+
algorithm?: "ed25519" | "ecdsa_secp256k1" | "secp256k1";
|
|
404
|
+
encoding?: "utf-8" | "base64";
|
|
405
|
+
caipChainId?: string;
|
|
406
|
+
messageLength?: number;
|
|
407
|
+
}, {
|
|
408
|
+
publicKey?: string;
|
|
409
|
+
signature?: string;
|
|
410
|
+
algorithm?: "ed25519" | "ecdsa_secp256k1" | "secp256k1";
|
|
411
|
+
encoding?: "utf-8" | "base64";
|
|
412
|
+
caipChainId?: string;
|
|
413
|
+
messageLength?: number;
|
|
414
|
+
}>;
|
|
415
|
+
/**
|
|
416
|
+
* @description Type representing message signature result
|
|
417
|
+
*/
|
|
418
|
+
export type MessageSignResult = z.infer<typeof MessageSignResultSchema>;
|
|
419
|
+
/**
|
|
420
|
+
* @description Schema for transaction submission payload
|
|
421
|
+
*/
|
|
422
|
+
export declare const TransactionSubmissionSchema: z.ZodObject<{
|
|
423
|
+
ledgerId: z.ZodString;
|
|
424
|
+
networkId: z.ZodString;
|
|
425
|
+
transactionBlob: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
|
|
426
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
427
|
+
}, "strip", z.ZodTypeAny, {
|
|
428
|
+
ledgerId?: string;
|
|
429
|
+
networkId?: string;
|
|
430
|
+
context?: Record<string, unknown>;
|
|
431
|
+
transactionBlob?: Uint8Array<ArrayBuffer>;
|
|
432
|
+
}, {
|
|
433
|
+
ledgerId?: string;
|
|
434
|
+
networkId?: string;
|
|
435
|
+
context?: Record<string, unknown>;
|
|
436
|
+
transactionBlob?: Uint8Array<ArrayBuffer>;
|
|
437
|
+
}>;
|
|
438
|
+
/**
|
|
439
|
+
* @description Type representing transaction submission request
|
|
440
|
+
*/
|
|
441
|
+
export type TransactionSubmission = z.infer<typeof TransactionSubmissionSchema>;
|
|
442
|
+
/**
|
|
443
|
+
* @description Schema for message envelope wrapper
|
|
444
|
+
*/
|
|
445
|
+
export declare const MessageEnvelopeSchema: z.ZodObject<{
|
|
446
|
+
id: z.ZodString;
|
|
447
|
+
topic: z.ZodString;
|
|
448
|
+
createdAt: z.ZodNumber;
|
|
449
|
+
payload: z.ZodUnknown;
|
|
450
|
+
version: z.ZodDefault<z.ZodString>;
|
|
451
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
452
|
+
}, "strip", z.ZodTypeAny, {
|
|
453
|
+
id?: string;
|
|
454
|
+
createdAt?: number;
|
|
455
|
+
version?: string;
|
|
456
|
+
signature?: string;
|
|
457
|
+
payload?: unknown;
|
|
458
|
+
topic?: string;
|
|
459
|
+
}, {
|
|
460
|
+
id?: string;
|
|
461
|
+
createdAt?: number;
|
|
462
|
+
version?: string;
|
|
463
|
+
signature?: string;
|
|
464
|
+
payload?: unknown;
|
|
465
|
+
topic?: string;
|
|
466
|
+
}>;
|
|
467
|
+
/**
|
|
468
|
+
* @description Type representing message envelope with generic payload
|
|
469
|
+
*/
|
|
470
|
+
export type MessageEnvelope<TPayload = unknown> = z.infer<typeof MessageEnvelopeSchema> & {
|
|
471
|
+
payload: TPayload;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* @description Schema for RPC method names
|
|
475
|
+
*/
|
|
476
|
+
export declare const RpcMethodSchema: z.ZodEnum<["hsuite.session.request", "hsuite.session.approve", "hsuite.session.terminate", "hsuite.ledger.sign", "hsuite.ledger.submit", "hsuite.wallet.accounts"]>;
|
|
477
|
+
/**
|
|
478
|
+
* @description Type representing RPC method
|
|
479
|
+
*/
|
|
480
|
+
export type RpcMethod = z.infer<typeof RpcMethodSchema>;
|
|
481
|
+
/**
|
|
482
|
+
* @description Schema for RPC request
|
|
483
|
+
*/
|
|
484
|
+
export declare const RpcRequestSchema: z.ZodObject<{
|
|
485
|
+
id: z.ZodString;
|
|
486
|
+
method: z.ZodEnum<["hsuite.session.request", "hsuite.session.approve", "hsuite.session.terminate", "hsuite.ledger.sign", "hsuite.ledger.submit", "hsuite.wallet.accounts"]>;
|
|
487
|
+
params: z.ZodUnknown;
|
|
488
|
+
origin: z.ZodOptional<z.ZodString>;
|
|
489
|
+
timestamp: z.ZodNumber;
|
|
490
|
+
}, "strip", z.ZodTypeAny, {
|
|
491
|
+
params?: unknown;
|
|
492
|
+
id?: string;
|
|
493
|
+
timestamp?: number;
|
|
494
|
+
method?: "hsuite.session.request" | "hsuite.session.approve" | "hsuite.session.terminate" | "hsuite.ledger.sign" | "hsuite.ledger.submit" | "hsuite.wallet.accounts";
|
|
495
|
+
origin?: string;
|
|
496
|
+
}, {
|
|
497
|
+
params?: unknown;
|
|
498
|
+
id?: string;
|
|
499
|
+
timestamp?: number;
|
|
500
|
+
method?: "hsuite.session.request" | "hsuite.session.approve" | "hsuite.session.terminate" | "hsuite.ledger.sign" | "hsuite.ledger.submit" | "hsuite.wallet.accounts";
|
|
501
|
+
origin?: string;
|
|
502
|
+
}>;
|
|
503
|
+
/**
|
|
504
|
+
* @description Type representing RPC request
|
|
505
|
+
*/
|
|
506
|
+
export type RpcRequest = z.infer<typeof RpcRequestSchema>;
|
|
507
|
+
/**
|
|
508
|
+
* @description Schema for successful RPC response
|
|
509
|
+
*/
|
|
510
|
+
export declare const RpcSuccessSchema: z.ZodObject<{
|
|
511
|
+
id: z.ZodString;
|
|
512
|
+
result: z.ZodUnknown;
|
|
513
|
+
timestamp: z.ZodNumber;
|
|
514
|
+
}, "strip", z.ZodTypeAny, {
|
|
515
|
+
id?: string;
|
|
516
|
+
timestamp?: number;
|
|
517
|
+
result?: unknown;
|
|
518
|
+
}, {
|
|
519
|
+
id?: string;
|
|
520
|
+
timestamp?: number;
|
|
521
|
+
result?: unknown;
|
|
522
|
+
}>;
|
|
523
|
+
/**
|
|
524
|
+
* @description Schema for failed RPC response
|
|
525
|
+
*/
|
|
526
|
+
export declare const RpcErrorSchema: z.ZodObject<{
|
|
527
|
+
id: z.ZodString;
|
|
528
|
+
error: z.ZodObject<{
|
|
529
|
+
code: z.ZodNumber;
|
|
530
|
+
message: z.ZodString;
|
|
531
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
532
|
+
}, "strip", z.ZodTypeAny, {
|
|
533
|
+
code?: number;
|
|
534
|
+
message?: string;
|
|
535
|
+
data?: unknown;
|
|
536
|
+
}, {
|
|
537
|
+
code?: number;
|
|
538
|
+
message?: string;
|
|
539
|
+
data?: unknown;
|
|
540
|
+
}>;
|
|
541
|
+
timestamp: z.ZodNumber;
|
|
542
|
+
}, "strip", z.ZodTypeAny, {
|
|
543
|
+
id?: string;
|
|
544
|
+
timestamp?: number;
|
|
545
|
+
error?: {
|
|
546
|
+
code?: number;
|
|
547
|
+
message?: string;
|
|
548
|
+
data?: unknown;
|
|
549
|
+
};
|
|
550
|
+
}, {
|
|
551
|
+
id?: string;
|
|
552
|
+
timestamp?: number;
|
|
553
|
+
error?: {
|
|
554
|
+
code?: number;
|
|
555
|
+
message?: string;
|
|
556
|
+
data?: unknown;
|
|
557
|
+
};
|
|
558
|
+
}>;
|
|
559
|
+
/**
|
|
560
|
+
* @description Type representing RPC response (success or error)
|
|
561
|
+
*/
|
|
562
|
+
export type RpcResponse = z.infer<typeof RpcSuccessSchema> | z.infer<typeof RpcErrorSchema>;
|
|
563
|
+
/**
|
|
564
|
+
* @description Schema for ICE server configuration
|
|
565
|
+
* Used by SessionTransportMux for P2P WebRTC upgrade after Nostr signaling.
|
|
566
|
+
*/
|
|
567
|
+
export declare const IceServerSchema: z.ZodObject<{
|
|
568
|
+
urls: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
569
|
+
username: z.ZodOptional<z.ZodString>;
|
|
570
|
+
credential: z.ZodOptional<z.ZodString>;
|
|
571
|
+
credentialType: z.ZodOptional<z.ZodEnum<["password", "oauth"]>>;
|
|
572
|
+
}, "strip", z.ZodTypeAny, {
|
|
573
|
+
urls?: string | string[];
|
|
574
|
+
username?: string;
|
|
575
|
+
credential?: string;
|
|
576
|
+
credentialType?: "password" | "oauth";
|
|
577
|
+
}, {
|
|
578
|
+
urls?: string | string[];
|
|
579
|
+
username?: string;
|
|
580
|
+
credential?: string;
|
|
581
|
+
credentialType?: "password" | "oauth";
|
|
582
|
+
}>;
|
|
583
|
+
/**
|
|
584
|
+
* @description Type representing ICE server configuration
|
|
585
|
+
*/
|
|
586
|
+
export type IceServer = z.infer<typeof IceServerSchema>;
|
|
587
|
+
/**
|
|
588
|
+
* @description Schema for WebRTC SDP offer
|
|
589
|
+
* Used internally by SessionTransportMux for P2P upgrade signaling.
|
|
590
|
+
*/
|
|
591
|
+
export declare const WebRtcOfferSchema: z.ZodObject<{
|
|
592
|
+
/** Protocol version (currently 1) */
|
|
593
|
+
v: z.ZodLiteral<1>;
|
|
594
|
+
/** Compressed SDP offer (base64url encoded) */
|
|
595
|
+
sdp: z.ZodString;
|
|
596
|
+
/** ICE server configuration for NAT traversal */
|
|
597
|
+
ice: z.ZodArray<z.ZodObject<{
|
|
598
|
+
urls: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
599
|
+
username: z.ZodOptional<z.ZodString>;
|
|
600
|
+
credential: z.ZodOptional<z.ZodString>;
|
|
601
|
+
credentialType: z.ZodOptional<z.ZodEnum<["password", "oauth"]>>;
|
|
602
|
+
}, "strip", z.ZodTypeAny, {
|
|
603
|
+
urls?: string | string[];
|
|
604
|
+
username?: string;
|
|
605
|
+
credential?: string;
|
|
606
|
+
credentialType?: "password" | "oauth";
|
|
607
|
+
}, {
|
|
608
|
+
urls?: string | string[];
|
|
609
|
+
username?: string;
|
|
610
|
+
credential?: string;
|
|
611
|
+
credentialType?: "password" | "oauth";
|
|
612
|
+
}>, "many">;
|
|
613
|
+
/** Optional session request payload for wallet */
|
|
614
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
615
|
+
appId: z.ZodString;
|
|
616
|
+
appName: z.ZodString;
|
|
617
|
+
appIcon: z.ZodOptional<z.ZodString>;
|
|
618
|
+
ledgerId: z.ZodString;
|
|
619
|
+
networkId: z.ZodString;
|
|
620
|
+
purpose: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
621
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
622
|
+
nonce: z.ZodString;
|
|
623
|
+
timestamp: z.ZodNumber;
|
|
624
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
625
|
+
}, "strip", z.ZodTypeAny, {
|
|
626
|
+
ledgerId?: string;
|
|
627
|
+
networkId?: string;
|
|
628
|
+
metadata?: Record<string, unknown>;
|
|
629
|
+
purpose?: string[];
|
|
630
|
+
timestamp?: number;
|
|
631
|
+
appId?: string;
|
|
632
|
+
appName?: string;
|
|
633
|
+
appIcon?: string;
|
|
634
|
+
permissions?: string[];
|
|
635
|
+
nonce?: string;
|
|
636
|
+
}, {
|
|
637
|
+
ledgerId?: string;
|
|
638
|
+
networkId?: string;
|
|
639
|
+
metadata?: Record<string, unknown>;
|
|
640
|
+
purpose?: string[];
|
|
641
|
+
timestamp?: number;
|
|
642
|
+
appId?: string;
|
|
643
|
+
appName?: string;
|
|
644
|
+
appIcon?: string;
|
|
645
|
+
permissions?: string[];
|
|
646
|
+
nonce?: string;
|
|
647
|
+
}>>;
|
|
648
|
+
}, "strip", z.ZodTypeAny, {
|
|
649
|
+
v?: 1;
|
|
650
|
+
sdp?: string;
|
|
651
|
+
ice?: {
|
|
652
|
+
urls?: string | string[];
|
|
653
|
+
username?: string;
|
|
654
|
+
credential?: string;
|
|
655
|
+
credentialType?: "password" | "oauth";
|
|
656
|
+
}[];
|
|
657
|
+
session?: {
|
|
658
|
+
ledgerId?: string;
|
|
659
|
+
networkId?: string;
|
|
660
|
+
metadata?: Record<string, unknown>;
|
|
661
|
+
purpose?: string[];
|
|
662
|
+
timestamp?: number;
|
|
663
|
+
appId?: string;
|
|
664
|
+
appName?: string;
|
|
665
|
+
appIcon?: string;
|
|
666
|
+
permissions?: string[];
|
|
667
|
+
nonce?: string;
|
|
668
|
+
};
|
|
669
|
+
}, {
|
|
670
|
+
v?: 1;
|
|
671
|
+
sdp?: string;
|
|
672
|
+
ice?: {
|
|
673
|
+
urls?: string | string[];
|
|
674
|
+
username?: string;
|
|
675
|
+
credential?: string;
|
|
676
|
+
credentialType?: "password" | "oauth";
|
|
677
|
+
}[];
|
|
678
|
+
session?: {
|
|
679
|
+
ledgerId?: string;
|
|
680
|
+
networkId?: string;
|
|
681
|
+
metadata?: Record<string, unknown>;
|
|
682
|
+
purpose?: string[];
|
|
683
|
+
timestamp?: number;
|
|
684
|
+
appId?: string;
|
|
685
|
+
appName?: string;
|
|
686
|
+
appIcon?: string;
|
|
687
|
+
permissions?: string[];
|
|
688
|
+
nonce?: string;
|
|
689
|
+
};
|
|
690
|
+
}>;
|
|
691
|
+
/**
|
|
692
|
+
* @description Type representing WebRTC SDP offer
|
|
693
|
+
*/
|
|
694
|
+
export type WebRtcOffer = z.infer<typeof WebRtcOfferSchema>;
|
|
695
|
+
/**
|
|
696
|
+
* @description Schema for WebRTC SDP answer
|
|
697
|
+
*/
|
|
698
|
+
export declare const WebRtcAnswerSchema: z.ZodObject<{
|
|
699
|
+
/** Protocol version (must match offer version) */
|
|
700
|
+
v: z.ZodLiteral<1>;
|
|
701
|
+
/** Compressed SDP answer (base64url encoded) */
|
|
702
|
+
sdp: z.ZodString;
|
|
703
|
+
}, "strip", z.ZodTypeAny, {
|
|
704
|
+
v?: 1;
|
|
705
|
+
sdp?: string;
|
|
706
|
+
}, {
|
|
707
|
+
v?: 1;
|
|
708
|
+
sdp?: string;
|
|
709
|
+
}>;
|
|
710
|
+
/**
|
|
711
|
+
* @description Type representing WebRTC SDP answer
|
|
712
|
+
*/
|
|
713
|
+
export type WebRtcAnswer = z.infer<typeof WebRtcAnswerSchema>;
|
|
714
|
+
/**
|
|
715
|
+
* @description Current protocol version for WebRTC P2P upgrade
|
|
716
|
+
*/
|
|
717
|
+
export declare const WEBRTC_PROTOCOL_VERSION: 1;
|
|
718
|
+
/**
|
|
719
|
+
* @description Protocol prefix for HSuite Channel invites
|
|
720
|
+
* Format: hsc:connect?i=<base64url-encoded-invite>
|
|
721
|
+
*
|
|
722
|
+
* This is the recommended protocol for all wallet connections.
|
|
723
|
+
* Uses Nostr for initial signaling with automatic P2P WebRTC upgrade.
|
|
724
|
+
*/
|
|
725
|
+
export declare const HSUITE_CHANNEL_PROTOCOL_PREFIX: "hsc:";
|
|
726
|
+
//# sourceMappingURL=messages.d.ts.map
|