@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 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW/B,CAAC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;;;;;;;;;;;;;;;EAQzB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAI5F;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAK1B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B,qCAAqC;;IAErC,+CAA+C;;IAE/C,iDAAiD;;;;;;;;;;;;;;;;;IAEjD,kDAAkD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAElD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,kDAAkD;;IAElD,gDAAgD;;;;;;;;EAEhD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAIlD;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAG,MAAe,CAAC"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
import { DerivationPathSchema, LedgerAccountSchema, LedgerIdSchema, NetworkIdSchema, } from './ledger.js';
|
|
29
|
+
/**
|
|
30
|
+
* @description Schema for dApp session request payload
|
|
31
|
+
*/
|
|
32
|
+
export const SessionRequestSchema = z.object({
|
|
33
|
+
appId: z.string().min(1),
|
|
34
|
+
appName: z.string().min(1),
|
|
35
|
+
appIcon: z.string().url().optional(),
|
|
36
|
+
ledgerId: LedgerIdSchema,
|
|
37
|
+
networkId: NetworkIdSchema,
|
|
38
|
+
purpose: z.array(z.string()).default([]),
|
|
39
|
+
permissions: z.array(z.string()).default([]),
|
|
40
|
+
nonce: z.string().uuid(),
|
|
41
|
+
timestamp: z.number().int().positive(),
|
|
42
|
+
metadata: z.record(z.unknown()).optional(),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* @description Schema for wallet's session approval/rejection response
|
|
46
|
+
*/
|
|
47
|
+
export const SessionApprovalSchema = SessionRequestSchema.extend({
|
|
48
|
+
approved: z.boolean(),
|
|
49
|
+
accounts: z.array(LedgerAccountSchema).default([]),
|
|
50
|
+
expiration: z.number().optional(),
|
|
51
|
+
signature: z.string().optional(),
|
|
52
|
+
metadata: z.record(z.unknown()).optional(),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* @description Schema for batch inner transaction
|
|
56
|
+
*/
|
|
57
|
+
export const BatchInnerTransactionSchema = z.object({
|
|
58
|
+
payload: z.union([z.string(), z.instanceof(Uint8Array)]),
|
|
59
|
+
description: z.string().optional(),
|
|
60
|
+
metadata: z.record(z.unknown()).optional(),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* @description Schema for signing request payload
|
|
64
|
+
* Can be either a single transaction or a batch of transactions
|
|
65
|
+
*/
|
|
66
|
+
export const SignPayloadSchema = z.object({
|
|
67
|
+
ledgerId: LedgerIdSchema,
|
|
68
|
+
networkId: NetworkIdSchema,
|
|
69
|
+
accountAddress: z.string().min(1),
|
|
70
|
+
payload: z.union([z.string(), z.instanceof(Uint8Array)]),
|
|
71
|
+
derivationPath: DerivationPathSchema.optional(),
|
|
72
|
+
context: z.record(z.unknown()).optional(),
|
|
73
|
+
nonce: z.string().uuid().optional(),
|
|
74
|
+
// Batch transaction support
|
|
75
|
+
isBatch: z.boolean().optional(),
|
|
76
|
+
batchKey: z.string().optional(), // Public key for batch transactions
|
|
77
|
+
innerTransactions: z.array(BatchInnerTransactionSchema).optional(),
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* @description Schema for signed inner transaction result
|
|
81
|
+
*/
|
|
82
|
+
export const SignedInnerTransactionSchema = z.object({
|
|
83
|
+
signedPayload: z.string(), // Base64 encoded signed transaction
|
|
84
|
+
transactionId: z.string().optional(),
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* @description Schema for signing operation result
|
|
88
|
+
* For single transactions: returns signature
|
|
89
|
+
* For batch transactions (sign mode): returns array of signed inner transactions
|
|
90
|
+
* For batch transactions (signAndExecute mode): returns transaction result
|
|
91
|
+
*/
|
|
92
|
+
export const SignResultSchema = z.object({
|
|
93
|
+
signature: z.string().optional(),
|
|
94
|
+
/** Full signed transaction bytes (hex-encoded), suitable for submission via submitTransaction */
|
|
95
|
+
signedPayload: z.string().optional(),
|
|
96
|
+
publicKey: z.string(),
|
|
97
|
+
payloadHash: z.string().optional(),
|
|
98
|
+
algorithm: z.string(),
|
|
99
|
+
// Batch transaction results (sign mode - returns signed inner txs)
|
|
100
|
+
signedInnerTransactions: z.array(SignedInnerTransactionSchema).optional(),
|
|
101
|
+
// Batch transaction results (signAndExecute mode - returns tx result)
|
|
102
|
+
transactionId: z.string().optional(),
|
|
103
|
+
transactionHash: z.string().optional(),
|
|
104
|
+
status: z.string().optional(),
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* @description Schema for message-signing result (§21.3).
|
|
108
|
+
*
|
|
109
|
+
* Separate from SignResultSchema because (a) message signing is semantically
|
|
110
|
+
* distinct from transaction signing — different security surface, different
|
|
111
|
+
* audit trail — and (b) it returns a narrower, always-required field set
|
|
112
|
+
* (signature, publicKey, algorithm) plus message-specific metadata
|
|
113
|
+
* (encoding, caipChainId, messageLength) that auditors and on-chain
|
|
114
|
+
* verifiers use to reconstruct the exact signed blob.
|
|
115
|
+
*
|
|
116
|
+
* The `algorithm` field is an enum (not free-form string) to make off-wallet
|
|
117
|
+
* verification deterministic. Consumers feed `signature`, `publicKey`,
|
|
118
|
+
* `algorithm`, `encoding`, `caipChainId`, and the original `message` back
|
|
119
|
+
* into `buildDomainSeparatedMessage` + the matching crypto primitive to
|
|
120
|
+
* verify the signature.
|
|
121
|
+
*/
|
|
122
|
+
export const MessageSignResultSchema = z.object({
|
|
123
|
+
/** Raw signature as hex (no 0x prefix). 128 chars for Ed25519, variable for ECDSA/secp256k1 DER. */
|
|
124
|
+
signature: z.string(),
|
|
125
|
+
/** Raw public key as hex (no 0x prefix). 64 chars for Ed25519, 66 chars for compressed secp256k1. */
|
|
126
|
+
publicKey: z.string(),
|
|
127
|
+
/** Signing algorithm — enum for deterministic verification. */
|
|
128
|
+
algorithm: z.enum(['ed25519', 'ecdsa_secp256k1', 'secp256k1']),
|
|
129
|
+
/** Encoding used to decode the original `message` into bytes. */
|
|
130
|
+
encoding: z.enum(['utf-8', 'base64']),
|
|
131
|
+
/**
|
|
132
|
+
* CAIP-2 chain identifier embedded in the signed blob. Mirrors the
|
|
133
|
+
* `caipChainId` from SignMessagePayload so verifiers can reconstruct
|
|
134
|
+
* the exact signed bytes without needing the original payload.
|
|
135
|
+
*/
|
|
136
|
+
caipChainId: z.string(),
|
|
137
|
+
/**
|
|
138
|
+
* Length of the decoded message in bytes (NOT the original string length).
|
|
139
|
+
* For UTF-8 messages this may exceed the character count (multi-byte
|
|
140
|
+
* codepoints). Used to prevent truncation attacks and for audit trail.
|
|
141
|
+
*/
|
|
142
|
+
messageLength: z.number().int().nonnegative(),
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* @description Schema for transaction submission payload
|
|
146
|
+
*/
|
|
147
|
+
export const TransactionSubmissionSchema = z.object({
|
|
148
|
+
ledgerId: LedgerIdSchema,
|
|
149
|
+
networkId: NetworkIdSchema,
|
|
150
|
+
transactionBlob: z.instanceof(Uint8Array),
|
|
151
|
+
context: z.record(z.unknown()).optional(),
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* @description Schema for message envelope wrapper
|
|
155
|
+
*/
|
|
156
|
+
export const MessageEnvelopeSchema = z.object({
|
|
157
|
+
id: z.string().uuid(),
|
|
158
|
+
topic: z.string(),
|
|
159
|
+
createdAt: z.number(),
|
|
160
|
+
payload: z.unknown(),
|
|
161
|
+
version: z.string().default('1.0.0'),
|
|
162
|
+
signature: z.string().optional(),
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* @description Schema for RPC method names
|
|
166
|
+
*/
|
|
167
|
+
export const RpcMethodSchema = z.enum([
|
|
168
|
+
'hsuite.session.request',
|
|
169
|
+
'hsuite.session.approve',
|
|
170
|
+
'hsuite.session.terminate',
|
|
171
|
+
'hsuite.ledger.sign',
|
|
172
|
+
'hsuite.ledger.submit',
|
|
173
|
+
'hsuite.wallet.accounts',
|
|
174
|
+
]);
|
|
175
|
+
/**
|
|
176
|
+
* @description Schema for RPC request
|
|
177
|
+
*/
|
|
178
|
+
export const RpcRequestSchema = z.object({
|
|
179
|
+
id: z.string().uuid(),
|
|
180
|
+
method: RpcMethodSchema,
|
|
181
|
+
params: z.unknown(),
|
|
182
|
+
origin: z.string().optional(),
|
|
183
|
+
timestamp: z.number(),
|
|
184
|
+
});
|
|
185
|
+
/**
|
|
186
|
+
* @description Schema for successful RPC response
|
|
187
|
+
*/
|
|
188
|
+
export const RpcSuccessSchema = z.object({
|
|
189
|
+
id: z.string().uuid(),
|
|
190
|
+
result: z.unknown(),
|
|
191
|
+
timestamp: z.number(),
|
|
192
|
+
});
|
|
193
|
+
/**
|
|
194
|
+
* @description Schema for failed RPC response
|
|
195
|
+
*/
|
|
196
|
+
export const RpcErrorSchema = z.object({
|
|
197
|
+
id: z.string().uuid(),
|
|
198
|
+
error: z.object({
|
|
199
|
+
code: z.number(),
|
|
200
|
+
message: z.string(),
|
|
201
|
+
data: z.unknown().optional(),
|
|
202
|
+
}),
|
|
203
|
+
timestamp: z.number(),
|
|
204
|
+
});
|
|
205
|
+
// ========== WebRTC P2P Types (Used for P2P upgrade signaling) ==========
|
|
206
|
+
/**
|
|
207
|
+
* @description Schema for ICE server configuration
|
|
208
|
+
* Used by SessionTransportMux for P2P WebRTC upgrade after Nostr signaling.
|
|
209
|
+
*/
|
|
210
|
+
export const IceServerSchema = z.object({
|
|
211
|
+
urls: z.union([z.string(), z.array(z.string())]),
|
|
212
|
+
username: z.string().optional(),
|
|
213
|
+
credential: z.string().optional(),
|
|
214
|
+
credentialType: z.enum(['password', 'oauth']).optional(),
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* @description Schema for WebRTC SDP offer
|
|
218
|
+
* Used internally by SessionTransportMux for P2P upgrade signaling.
|
|
219
|
+
*/
|
|
220
|
+
export const WebRtcOfferSchema = z.object({
|
|
221
|
+
/** Protocol version (currently 1) */
|
|
222
|
+
v: z.literal(1),
|
|
223
|
+
/** Compressed SDP offer (base64url encoded) */
|
|
224
|
+
sdp: z.string().min(1),
|
|
225
|
+
/** ICE server configuration for NAT traversal */
|
|
226
|
+
ice: z.array(IceServerSchema),
|
|
227
|
+
/** Optional session request payload for wallet */
|
|
228
|
+
session: SessionRequestSchema.optional(),
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* @description Schema for WebRTC SDP answer
|
|
232
|
+
*/
|
|
233
|
+
export const WebRtcAnswerSchema = z.object({
|
|
234
|
+
/** Protocol version (must match offer version) */
|
|
235
|
+
v: z.literal(1),
|
|
236
|
+
/** Compressed SDP answer (base64url encoded) */
|
|
237
|
+
sdp: z.string().min(1),
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* @description Current protocol version for WebRTC P2P upgrade
|
|
241
|
+
*/
|
|
242
|
+
export const WEBRTC_PROTOCOL_VERSION = 1;
|
|
243
|
+
// ========== HSuite Channel Protocol (hsc:) ==========
|
|
244
|
+
/**
|
|
245
|
+
* @description Protocol prefix for HSuite Channel invites
|
|
246
|
+
* Format: hsc:connect?i=<base64url-encoded-invite>
|
|
247
|
+
*
|
|
248
|
+
* This is the recommended protocol for all wallet connections.
|
|
249
|
+
* Uses Nostr for initial signaling with automatic P2P WebRTC upgrade.
|
|
250
|
+
*/
|
|
251
|
+
export const HSUITE_CHANNEL_PROTOCOL_PREFIX = 'hsc:';
|
|
252
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,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U,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC;AAOH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,qCAAqC;IACrC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACf,+CAA+C;IAC/C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,iDAAiD;IACjD,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC7B,kDAAkD;IAClD,OAAO,EAAE,oBAAoB,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,kDAAkD;IAClD,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACf,gDAAgD;IAChD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACvB,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAU,CAAC;AAElD,uDAAuD;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAe,CAAC"}
|
|
@@ -0,0 +1,419 @@
|
|
|
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
|
+
* @fileoverview Unified account management for singlesig and multisig accounts.
|
|
12
|
+
*
|
|
13
|
+
* This module provides a unified data model where both singlesig and multisig
|
|
14
|
+
* accounts are stored together in the KeyVault. This design enables:
|
|
15
|
+
*
|
|
16
|
+
* - **Single source of truth** - All accounts in one storage layer
|
|
17
|
+
* - **Seamless transformation** - Singlesig to multisig upgrade (especially XRPL)
|
|
18
|
+
* - **Unified history** - Transaction history across all account types
|
|
19
|
+
* - **Consistent UI** - Same treatment for all accounts
|
|
20
|
+
*
|
|
21
|
+
* Account Type Discrimination:
|
|
22
|
+
* - Check `metadata.accountType` for 'singlesig' or 'multisig'
|
|
23
|
+
* - Use {@link isMultisigAccount} for type-safe checking
|
|
24
|
+
* - Use {@link getMultisigInfo} to extract multisig configuration
|
|
25
|
+
*
|
|
26
|
+
* @module types/multisig-account
|
|
27
|
+
*
|
|
28
|
+
* Type definitions for unified account management (singlesig and multisig).
|
|
29
|
+
*
|
|
30
|
+
* This module provides a unified account model where both singlesig and multisig
|
|
31
|
+
* accounts are stored in the same storage layer (KeyVault). This enables:
|
|
32
|
+
* - Single source of truth for all account data
|
|
33
|
+
* - Seamless singlesig→multisig transformation (especially for XRPL)
|
|
34
|
+
* - Unified transaction history across all account types
|
|
35
|
+
* - Consistent UI treatment for all accounts
|
|
36
|
+
*/
|
|
37
|
+
import { z } from 'zod';
|
|
38
|
+
/**
|
|
39
|
+
* AccountType
|
|
40
|
+
*
|
|
41
|
+
* Discriminator for account types. Used to determine signing behavior
|
|
42
|
+
* and UI rendering for an account.
|
|
43
|
+
*
|
|
44
|
+
* - 'singlesig': Standard account with single private key control
|
|
45
|
+
* - 'multisig': Account requiring M-of-N signatures for transactions
|
|
46
|
+
*/
|
|
47
|
+
export type AccountType = 'singlesig' | 'multisig';
|
|
48
|
+
/**
|
|
49
|
+
* AccountTypeSchema
|
|
50
|
+
*
|
|
51
|
+
* Zod schema for AccountType validation.
|
|
52
|
+
*/
|
|
53
|
+
export declare const AccountTypeSchema: z.ZodEnum<["singlesig", "multisig"]>;
|
|
54
|
+
/**
|
|
55
|
+
* MultisigSigner
|
|
56
|
+
*
|
|
57
|
+
* Represents a single signer in a multisig account configuration.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* MultisigSignerSchema
|
|
61
|
+
*
|
|
62
|
+
* Zod schema for MultisigSigner validation.
|
|
63
|
+
*/
|
|
64
|
+
export declare const MultisigSignerSchema: z.ZodObject<{
|
|
65
|
+
/** Human-readable label for this signer */
|
|
66
|
+
label: z.ZodString;
|
|
67
|
+
/** Public key in hex or base64 format (ledger-specific) */
|
|
68
|
+
publicKey: z.ZodString;
|
|
69
|
+
/** On-chain account address for this signer (if applicable) */
|
|
70
|
+
accountAddress: z.ZodOptional<z.ZodString>;
|
|
71
|
+
/** Optional weight for weighted multisig (default: 1) */
|
|
72
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
74
|
+
isSelf: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
publicKey?: string;
|
|
77
|
+
label?: string;
|
|
78
|
+
accountAddress?: string;
|
|
79
|
+
weight?: number;
|
|
80
|
+
isSelf?: boolean;
|
|
81
|
+
}, {
|
|
82
|
+
publicKey?: string;
|
|
83
|
+
label?: string;
|
|
84
|
+
accountAddress?: string;
|
|
85
|
+
weight?: number;
|
|
86
|
+
isSelf?: boolean;
|
|
87
|
+
}>;
|
|
88
|
+
export interface MultisigSigner {
|
|
89
|
+
/** Human-readable label for this signer (e.g., "Alice", "Treasury Hot Wallet") */
|
|
90
|
+
label: string;
|
|
91
|
+
/** Public key in hex or base64 format (ledger-specific) */
|
|
92
|
+
publicKey: string;
|
|
93
|
+
/** On-chain account address for this signer (if applicable) */
|
|
94
|
+
accountAddress?: string;
|
|
95
|
+
/** Optional weight for weighted multisig (default: 1) */
|
|
96
|
+
weight?: number;
|
|
97
|
+
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
98
|
+
isSelf?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* MultisigAccountConfig
|
|
102
|
+
*
|
|
103
|
+
* Configuration for a multisig account. Stored locally and used to create parties.
|
|
104
|
+
*/
|
|
105
|
+
export interface MultisigAccountConfig {
|
|
106
|
+
/** Unique identifier for this multisig account configuration */
|
|
107
|
+
id: string;
|
|
108
|
+
/** Human-readable name (e.g., "Treasury 2-of-3", "DAO Operations") */
|
|
109
|
+
name: string;
|
|
110
|
+
/** Ledger this multisig operates on */
|
|
111
|
+
ledgerId: string;
|
|
112
|
+
/** Network ID (e.g., "hedera:mainnet", "xrpl:mainnet") */
|
|
113
|
+
networkId: string;
|
|
114
|
+
/** Number of signatures required to execute transactions */
|
|
115
|
+
threshold: number;
|
|
116
|
+
/** List of all signers (including self) */
|
|
117
|
+
signers: MultisigSigner[];
|
|
118
|
+
/** The on-chain multisig account address (if already created on ledger) */
|
|
119
|
+
accountAddress?: string;
|
|
120
|
+
/** Optional metadata (tags, notes, etc.) */
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
/** Creation timestamp */
|
|
123
|
+
createdAt: number;
|
|
124
|
+
/** Last updated timestamp */
|
|
125
|
+
updatedAt: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* MultisigAccountStatus
|
|
129
|
+
*
|
|
130
|
+
* Runtime status of a multisig account and its associated party.
|
|
131
|
+
*/
|
|
132
|
+
export interface MultisigAccountStatus {
|
|
133
|
+
/** The account configuration ID */
|
|
134
|
+
accountId: string;
|
|
135
|
+
/** Whether there's an active party for this account */
|
|
136
|
+
hasActiveParty: boolean;
|
|
137
|
+
/** Active party ID (if any) */
|
|
138
|
+
activePartyId?: string;
|
|
139
|
+
/** Number of signers currently online/connected */
|
|
140
|
+
connectedSigners?: number;
|
|
141
|
+
/** Last activity timestamp */
|
|
142
|
+
lastActivityAt?: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* MultisigInfoSchema
|
|
146
|
+
*
|
|
147
|
+
* Zod schema for multisig configuration stored in VaultKey.metadata.
|
|
148
|
+
* This allows singlesig accounts to be "upgraded" to multisig without
|
|
149
|
+
* moving them to a separate storage system.
|
|
150
|
+
*/
|
|
151
|
+
export declare const MultisigInfoSchema: z.ZodObject<{
|
|
152
|
+
/** Number of signatures required to execute transactions */
|
|
153
|
+
threshold: z.ZodNumber;
|
|
154
|
+
/** List of all signers (including self) */
|
|
155
|
+
signers: z.ZodArray<z.ZodObject<{
|
|
156
|
+
/** Human-readable label for this signer */
|
|
157
|
+
label: z.ZodString;
|
|
158
|
+
/** Public key in hex or base64 format (ledger-specific) */
|
|
159
|
+
publicKey: z.ZodString;
|
|
160
|
+
/** On-chain account address for this signer (if applicable) */
|
|
161
|
+
accountAddress: z.ZodOptional<z.ZodString>;
|
|
162
|
+
/** Optional weight for weighted multisig (default: 1) */
|
|
163
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
164
|
+
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
165
|
+
isSelf: z.ZodOptional<z.ZodBoolean>;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
publicKey?: string;
|
|
168
|
+
label?: string;
|
|
169
|
+
accountAddress?: string;
|
|
170
|
+
weight?: number;
|
|
171
|
+
isSelf?: boolean;
|
|
172
|
+
}, {
|
|
173
|
+
publicKey?: string;
|
|
174
|
+
label?: string;
|
|
175
|
+
accountAddress?: string;
|
|
176
|
+
weight?: number;
|
|
177
|
+
isSelf?: boolean;
|
|
178
|
+
}>, "many">;
|
|
179
|
+
/** The address of the local signer (this wallet's signing account) */
|
|
180
|
+
localSignerAddress: z.ZodOptional<z.ZodString>;
|
|
181
|
+
/** Name for this multisig configuration (e.g., "Treasury 2-of-3") */
|
|
182
|
+
name: z.ZodOptional<z.ZodString>;
|
|
183
|
+
/** ID of the original MultisigAccountConfig */
|
|
184
|
+
originalConfigId: z.ZodOptional<z.ZodString>;
|
|
185
|
+
/** When this account was converted to multisig */
|
|
186
|
+
convertedAt: z.ZodOptional<z.ZodNumber>;
|
|
187
|
+
/** The singlesig account address that was converted (for XRPL transformation) */
|
|
188
|
+
originalSinglesigAddress: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
name?: string;
|
|
191
|
+
threshold?: number;
|
|
192
|
+
signers?: {
|
|
193
|
+
publicKey?: string;
|
|
194
|
+
label?: string;
|
|
195
|
+
accountAddress?: string;
|
|
196
|
+
weight?: number;
|
|
197
|
+
isSelf?: boolean;
|
|
198
|
+
}[];
|
|
199
|
+
localSignerAddress?: string;
|
|
200
|
+
originalConfigId?: string;
|
|
201
|
+
convertedAt?: number;
|
|
202
|
+
originalSinglesigAddress?: string;
|
|
203
|
+
}, {
|
|
204
|
+
name?: string;
|
|
205
|
+
threshold?: number;
|
|
206
|
+
signers?: {
|
|
207
|
+
publicKey?: string;
|
|
208
|
+
label?: string;
|
|
209
|
+
accountAddress?: string;
|
|
210
|
+
weight?: number;
|
|
211
|
+
isSelf?: boolean;
|
|
212
|
+
}[];
|
|
213
|
+
localSignerAddress?: string;
|
|
214
|
+
originalConfigId?: string;
|
|
215
|
+
convertedAt?: number;
|
|
216
|
+
originalSinglesigAddress?: string;
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* MultisigInfo
|
|
220
|
+
*
|
|
221
|
+
* Multisig configuration that can be embedded in VaultKey.metadata.
|
|
222
|
+
* This unifies storage of singlesig and multisig accounts.
|
|
223
|
+
*/
|
|
224
|
+
export type MultisigInfo = z.infer<typeof MultisigInfoSchema>;
|
|
225
|
+
/**
|
|
226
|
+
* UnifiedAccountMetadataSchema
|
|
227
|
+
*
|
|
228
|
+
* Schema for account metadata that supports both singlesig and multisig accounts.
|
|
229
|
+
* Stored in VaultKey.metadata for unified account management.
|
|
230
|
+
*/
|
|
231
|
+
export declare const UnifiedAccountMetadataSchema: z.ZodObject<{
|
|
232
|
+
/** Account type discriminator */
|
|
233
|
+
accountType: z.ZodDefault<z.ZodEnum<["singlesig", "multisig"]>>;
|
|
234
|
+
/** Multisig configuration (only present for multisig accounts) */
|
|
235
|
+
multisig: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
/** Number of signatures required to execute transactions */
|
|
237
|
+
threshold: z.ZodNumber;
|
|
238
|
+
/** List of all signers (including self) */
|
|
239
|
+
signers: z.ZodArray<z.ZodObject<{
|
|
240
|
+
/** Human-readable label for this signer */
|
|
241
|
+
label: z.ZodString;
|
|
242
|
+
/** Public key in hex or base64 format (ledger-specific) */
|
|
243
|
+
publicKey: z.ZodString;
|
|
244
|
+
/** On-chain account address for this signer (if applicable) */
|
|
245
|
+
accountAddress: z.ZodOptional<z.ZodString>;
|
|
246
|
+
/** Optional weight for weighted multisig (default: 1) */
|
|
247
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
248
|
+
/** Whether this signer is "self" (controlled by this wallet instance) */
|
|
249
|
+
isSelf: z.ZodOptional<z.ZodBoolean>;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
publicKey?: string;
|
|
252
|
+
label?: string;
|
|
253
|
+
accountAddress?: string;
|
|
254
|
+
weight?: number;
|
|
255
|
+
isSelf?: boolean;
|
|
256
|
+
}, {
|
|
257
|
+
publicKey?: string;
|
|
258
|
+
label?: string;
|
|
259
|
+
accountAddress?: string;
|
|
260
|
+
weight?: number;
|
|
261
|
+
isSelf?: boolean;
|
|
262
|
+
}>, "many">;
|
|
263
|
+
/** The address of the local signer (this wallet's signing account) */
|
|
264
|
+
localSignerAddress: z.ZodOptional<z.ZodString>;
|
|
265
|
+
/** Name for this multisig configuration (e.g., "Treasury 2-of-3") */
|
|
266
|
+
name: z.ZodOptional<z.ZodString>;
|
|
267
|
+
/** ID of the original MultisigAccountConfig */
|
|
268
|
+
originalConfigId: z.ZodOptional<z.ZodString>;
|
|
269
|
+
/** When this account was converted to multisig */
|
|
270
|
+
convertedAt: z.ZodOptional<z.ZodNumber>;
|
|
271
|
+
/** The singlesig account address that was converted (for XRPL transformation) */
|
|
272
|
+
originalSinglesigAddress: z.ZodOptional<z.ZodString>;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
name?: string;
|
|
275
|
+
threshold?: number;
|
|
276
|
+
signers?: {
|
|
277
|
+
publicKey?: string;
|
|
278
|
+
label?: string;
|
|
279
|
+
accountAddress?: string;
|
|
280
|
+
weight?: number;
|
|
281
|
+
isSelf?: boolean;
|
|
282
|
+
}[];
|
|
283
|
+
localSignerAddress?: string;
|
|
284
|
+
originalConfigId?: string;
|
|
285
|
+
convertedAt?: number;
|
|
286
|
+
originalSinglesigAddress?: string;
|
|
287
|
+
}, {
|
|
288
|
+
name?: string;
|
|
289
|
+
threshold?: number;
|
|
290
|
+
signers?: {
|
|
291
|
+
publicKey?: string;
|
|
292
|
+
label?: string;
|
|
293
|
+
accountAddress?: string;
|
|
294
|
+
weight?: number;
|
|
295
|
+
isSelf?: boolean;
|
|
296
|
+
}[];
|
|
297
|
+
localSignerAddress?: string;
|
|
298
|
+
originalConfigId?: string;
|
|
299
|
+
convertedAt?: number;
|
|
300
|
+
originalSinglesigAddress?: string;
|
|
301
|
+
}>>;
|
|
302
|
+
/** User-defined label for the account */
|
|
303
|
+
label: z.ZodOptional<z.ZodString>;
|
|
304
|
+
/** Whether this is an imported account (not derived from seed) */
|
|
305
|
+
imported: z.ZodOptional<z.ZodBoolean>;
|
|
306
|
+
/** Whether the account has been activated on-chain (for Hedera) */
|
|
307
|
+
activated: z.ZodOptional<z.ZodBoolean>;
|
|
308
|
+
/** Whether this account is hidden from the UI */
|
|
309
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
310
|
+
/** Tags for organization */
|
|
311
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
312
|
+
/** Notes about this account */
|
|
313
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
314
|
+
/** When the account was created in this wallet */
|
|
315
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
316
|
+
/** Last time the account was used for signing */
|
|
317
|
+
lastUsedAt: z.ZodOptional<z.ZodNumber>;
|
|
318
|
+
}, "strip", z.ZodTypeAny, {
|
|
319
|
+
activated?: boolean;
|
|
320
|
+
label?: string;
|
|
321
|
+
notes?: string;
|
|
322
|
+
tags?: string[];
|
|
323
|
+
createdAt?: number;
|
|
324
|
+
multisig?: {
|
|
325
|
+
name?: string;
|
|
326
|
+
threshold?: number;
|
|
327
|
+
signers?: {
|
|
328
|
+
publicKey?: string;
|
|
329
|
+
label?: string;
|
|
330
|
+
accountAddress?: string;
|
|
331
|
+
weight?: number;
|
|
332
|
+
isSelf?: boolean;
|
|
333
|
+
}[];
|
|
334
|
+
localSignerAddress?: string;
|
|
335
|
+
originalConfigId?: string;
|
|
336
|
+
convertedAt?: number;
|
|
337
|
+
originalSinglesigAddress?: string;
|
|
338
|
+
};
|
|
339
|
+
accountType?: "singlesig" | "multisig";
|
|
340
|
+
imported?: boolean;
|
|
341
|
+
hidden?: boolean;
|
|
342
|
+
lastUsedAt?: number;
|
|
343
|
+
}, {
|
|
344
|
+
activated?: boolean;
|
|
345
|
+
label?: string;
|
|
346
|
+
notes?: string;
|
|
347
|
+
tags?: string[];
|
|
348
|
+
createdAt?: number;
|
|
349
|
+
multisig?: {
|
|
350
|
+
name?: string;
|
|
351
|
+
threshold?: number;
|
|
352
|
+
signers?: {
|
|
353
|
+
publicKey?: string;
|
|
354
|
+
label?: string;
|
|
355
|
+
accountAddress?: string;
|
|
356
|
+
weight?: number;
|
|
357
|
+
isSelf?: boolean;
|
|
358
|
+
}[];
|
|
359
|
+
localSignerAddress?: string;
|
|
360
|
+
originalConfigId?: string;
|
|
361
|
+
convertedAt?: number;
|
|
362
|
+
originalSinglesigAddress?: string;
|
|
363
|
+
};
|
|
364
|
+
accountType?: "singlesig" | "multisig";
|
|
365
|
+
imported?: boolean;
|
|
366
|
+
hidden?: boolean;
|
|
367
|
+
lastUsedAt?: number;
|
|
368
|
+
}>;
|
|
369
|
+
/**
|
|
370
|
+
* UnifiedAccountMetadata
|
|
371
|
+
*
|
|
372
|
+
* Metadata structure for unified account management.
|
|
373
|
+
*/
|
|
374
|
+
export type UnifiedAccountMetadata = z.infer<typeof UnifiedAccountMetadataSchema>;
|
|
375
|
+
/**
|
|
376
|
+
* isMultisigAccount
|
|
377
|
+
*
|
|
378
|
+
* Type guard to check if an account is a multisig account.
|
|
379
|
+
*
|
|
380
|
+
* @param metadata - Account metadata to check
|
|
381
|
+
* @returns true if the account is multisig
|
|
382
|
+
*/
|
|
383
|
+
export declare function isMultisigAccount(metadata?: Record<string, unknown>): boolean;
|
|
384
|
+
/**
|
|
385
|
+
* getMultisigInfo
|
|
386
|
+
*
|
|
387
|
+
* Extract MultisigInfo from account metadata.
|
|
388
|
+
*
|
|
389
|
+
* @param metadata - Account metadata
|
|
390
|
+
* @returns MultisigInfo if present, undefined otherwise
|
|
391
|
+
*/
|
|
392
|
+
export declare function getMultisigInfo(metadata?: Record<string, unknown>): MultisigInfo | undefined;
|
|
393
|
+
/**
|
|
394
|
+
* createMultisigMetadata
|
|
395
|
+
*
|
|
396
|
+
* Create unified account metadata for a multisig account.
|
|
397
|
+
*
|
|
398
|
+
* @param config - MultisigAccountConfig to convert
|
|
399
|
+
* @param localSignerAddress - Address of the local signer
|
|
400
|
+
* @returns UnifiedAccountMetadata for storage in VaultKey
|
|
401
|
+
*/
|
|
402
|
+
export declare function createMultisigMetadata(config: MultisigAccountConfig, localSignerAddress?: string): UnifiedAccountMetadata;
|
|
403
|
+
/**
|
|
404
|
+
* convertSinglesigToMultisig
|
|
405
|
+
*
|
|
406
|
+
* Update account metadata to convert a singlesig account to multisig.
|
|
407
|
+
* Used when an XRPL account is converted to multisig on-chain.
|
|
408
|
+
*
|
|
409
|
+
* @param existingMetadata - Current account metadata
|
|
410
|
+
* @param multisigConfig - Multisig configuration to apply
|
|
411
|
+
* @param localSignerAddress - Address of the local signer
|
|
412
|
+
* @returns Updated metadata with multisig configuration
|
|
413
|
+
*/
|
|
414
|
+
export declare function convertSinglesigToMultisig(existingMetadata: Record<string, unknown> | undefined, multisigConfig: {
|
|
415
|
+
threshold: number;
|
|
416
|
+
signers: MultisigSigner[];
|
|
417
|
+
name?: string;
|
|
418
|
+
}, localSignerAddress?: string): UnifiedAccountMetadata;
|
|
419
|
+
//# sourceMappingURL=multisig-account.d.ts.map
|