@txnlab/use-wallet 4.6.0 → 5.0.0-rc.1
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/adapter.d.ts +18 -0
- package/dist/adapter.js +3 -0
- package/dist/base-BKrq-rUH.d.ts +365 -0
- package/dist/custom-BXQKth41.d.ts +107 -0
- package/dist/index.d.ts +107 -1274
- package/dist/index.js +401 -9996
- package/dist/index.js.map +1 -1
- package/dist/store-CM2Y4xMP.js +335 -0
- package/dist/store-CM2Y4xMP.js.map +1 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.js +88 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-BduS9cZw.js +442 -0
- package/dist/types-BduS9cZw.js.map +1 -0
- package/package.json +30 -78
- package/dist/index.cjs +0 -10045
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1283
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { C as WalletKey, E as WalletTransaction, M as LogLevel, T as WalletState, _ as Siwa, a as setActiveAccount, b as WalletAdapterConfig, c as JsonRpcRequest, d as SignData, f as SignDataError, g as SignerTransaction, h as SignTxnsError, i as State, l as MultisigMetadata, m as SignMetadata, o as AdapterConstructorParams, p as SignDataResponse, s as AdapterStoreAccessor, t as BaseWallet, u as ScopeType, w as WalletMetadata, y as WalletAccount } from "./base-BKrq-rUH.js";
|
|
2
|
+
import { a as SecureKeyContainer, c as withSecureKeySync, i as custom, l as zeroMemory, n as CustomWallet, o as deriveAlgorandAccountFromEd25519, r as CustomWalletOptions, s as withSecureKey, t as CustomProvider, u as zeroString } from "./custom-BXQKth41.js";
|
|
3
|
+
import algosdk from "algosdk";
|
|
4
|
+
|
|
5
|
+
//#region src/utils.d.ts
|
|
6
|
+
declare function compareAccounts(accounts: WalletAccount[], compareTo: WalletAccount[]): boolean;
|
|
7
|
+
declare function base64ToByteArray(blob: string): Uint8Array;
|
|
8
|
+
declare function byteArrayToBase64(array: Uint8Array): string;
|
|
9
|
+
declare function stringToByteArray(str: string): Uint8Array;
|
|
10
|
+
declare function byteArrayToString(array: Uint8Array): string;
|
|
11
|
+
declare function isSignedTxn(txnObj: any): boolean;
|
|
12
|
+
declare function isTransaction(item: any): item is algosdk.Transaction;
|
|
13
|
+
declare function isTransactionArray(txnGroup: any): txnGroup is algosdk.Transaction[] | algosdk.Transaction[][];
|
|
14
|
+
declare function flattenTxnGroup<T>(txnGroup: T[]): T[];
|
|
15
|
+
declare function formatJsonRpcRequest<T = any>(method: string, params: T): JsonRpcRequest<T>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { type AdapterConstructorParams, type AdapterStoreAccessor, BaseWallet, type CustomProvider, CustomWallet, type CustomWalletOptions, type JsonRpcRequest, LogLevel, type MultisigMetadata, ScopeType, SecureKeyContainer, type SignData, SignDataError, type SignDataResponse, type SignMetadata, SignTxnsError, type SignerTransaction, type Siwa, type State, type WalletAccount, type WalletAdapterConfig, type WalletKey, type WalletMetadata, type WalletState, type WalletTransaction, base64ToByteArray, byteArrayToBase64, byteArrayToString, compareAccounts, custom, deriveAlgorandAccountFromEd25519, flattenTxnGroup, formatJsonRpcRequest, isSignedTxn, isTransaction, isTransactionArray, setActiveAccount, stringToByteArray, withSecureKey, withSecureKeySync, zeroMemory, zeroString };
|
|
18
|
+
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { h as LogLevel, s as setActiveAccount } from "./store-CM2Y4xMP.js";
|
|
2
|
+
import { S as zeroString, _ as SecureKeyContainer, a as custom, b as withSecureKeySync, c as byteArrayToString, d as formatJsonRpcRequest, f as isSignedTxn, g as BaseWallet, h as stringToByteArray, i as CustomWallet, l as compareAccounts, m as isTransactionArray, n as SignDataError, o as base64ToByteArray, p as isTransaction, r as SignTxnsError, s as byteArrayToBase64, t as ScopeType, u as flattenTxnGroup, v as deriveAlgorandAccountFromEd25519, x as zeroMemory, y as withSecureKey } from "./types-BduS9cZw.js";
|
|
3
|
+
export { BaseWallet, CustomWallet, LogLevel, ScopeType, SecureKeyContainer, SignDataError, SignTxnsError, base64ToByteArray, byteArrayToBase64, byteArrayToString, compareAccounts, custom, deriveAlgorandAccountFromEd25519, flattenTxnGroup, formatJsonRpcRequest, isSignedTxn, isTransaction, isTransactionArray, setActiveAccount, stringToByteArray, withSecureKey, withSecureKeySync, zeroMemory, zeroString };
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { Store } from "@tanstack/store";
|
|
2
|
+
import algosdk from "algosdk";
|
|
3
|
+
|
|
4
|
+
//#region src/logger.d.ts
|
|
5
|
+
declare enum LogLevel {
|
|
6
|
+
DEBUG = 0,
|
|
7
|
+
INFO = 1,
|
|
8
|
+
WARN = 2,
|
|
9
|
+
ERROR = 3
|
|
10
|
+
}
|
|
11
|
+
declare class Logger {
|
|
12
|
+
private static instance;
|
|
13
|
+
private level;
|
|
14
|
+
private isClient;
|
|
15
|
+
private constructor();
|
|
16
|
+
static getInstance(): Logger;
|
|
17
|
+
static setLevel(level: LogLevel): void;
|
|
18
|
+
private log;
|
|
19
|
+
createScopedLogger(scope: string): {
|
|
20
|
+
debug: (message: string, ...args: any[]) => void;
|
|
21
|
+
info: (message: string, ...args: any[]) => void;
|
|
22
|
+
warn: (message: string, ...args: any[]) => void;
|
|
23
|
+
error: (message: string, ...args: any[]) => void;
|
|
24
|
+
};
|
|
25
|
+
debug(message: string, ...args: any[]): void;
|
|
26
|
+
info(message: string, ...args: any[]): void;
|
|
27
|
+
warn(message: string, ...args: any[]): void;
|
|
28
|
+
error(message: string, ...args: any[]): void;
|
|
29
|
+
setIsClient(isClient: boolean): void;
|
|
30
|
+
}
|
|
31
|
+
declare const logger: Logger;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/network.d.ts
|
|
34
|
+
interface AlgodConfig {
|
|
35
|
+
token: string | algosdk.AlgodTokenHeader | algosdk.CustomTokenHeader | algosdk.BaseHTTPClient;
|
|
36
|
+
baseServer: string;
|
|
37
|
+
port?: string | number;
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
interface NetworkConfig {
|
|
41
|
+
algod: AlgodConfig;
|
|
42
|
+
genesisHash?: string;
|
|
43
|
+
genesisId?: string;
|
|
44
|
+
isTestnet?: boolean;
|
|
45
|
+
caipChainId?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const DEFAULT_NETWORK_CONFIG: Record<string, NetworkConfig>;
|
|
48
|
+
type DefaultNetworkConfig = Omit<Partial<NetworkConfig>, 'genesisHash' | 'genesisId' | 'caipChainId'>;
|
|
49
|
+
declare class NetworkConfigBuilder {
|
|
50
|
+
private networks;
|
|
51
|
+
constructor();
|
|
52
|
+
mainnet(config: DefaultNetworkConfig): this;
|
|
53
|
+
testnet(config: DefaultNetworkConfig): this;
|
|
54
|
+
betanet(config: DefaultNetworkConfig): this;
|
|
55
|
+
fnet(config: DefaultNetworkConfig): this;
|
|
56
|
+
localnet(config: Partial<NetworkConfig>): this;
|
|
57
|
+
addNetwork(id: string, config: NetworkConfig): this;
|
|
58
|
+
build(): {
|
|
59
|
+
[k: string]: NetworkConfig;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
declare enum NetworkId {
|
|
63
|
+
MAINNET = "mainnet",
|
|
64
|
+
TESTNET = "testnet",
|
|
65
|
+
BETANET = "betanet",
|
|
66
|
+
FNET = "fnet",
|
|
67
|
+
LOCALNET = "localnet"
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/wallets/types.d.ts
|
|
71
|
+
/**
|
|
72
|
+
* Wallet identifier. In v5 this is an open string type — each adapter
|
|
73
|
+
* package exports its own ID constant (e.g. `export const WALLET_ID = 'pera' as const`).
|
|
74
|
+
*/
|
|
75
|
+
type WalletId = string;
|
|
76
|
+
/**
|
|
77
|
+
* Unique key for a wallet instance in the store.
|
|
78
|
+
* Usually equals the wallet ID, but can be a composite key for
|
|
79
|
+
* skinned WalletConnect instances (e.g. 'walletconnect:biatec').
|
|
80
|
+
*/
|
|
81
|
+
type WalletKey = string;
|
|
82
|
+
type WalletMetadata = {
|
|
83
|
+
name: string;
|
|
84
|
+
icon: string;
|
|
85
|
+
};
|
|
86
|
+
type WalletAccount = {
|
|
87
|
+
name: string;
|
|
88
|
+
address: string;
|
|
89
|
+
metadata?: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Declares which networks a wallet adapter supports.
|
|
93
|
+
*
|
|
94
|
+
* Design: Option 5 — `supportedNetworks` + `excludedNetworks`.
|
|
95
|
+
*
|
|
96
|
+
* Most wallets list the networks they work with via `supportedNetworks`.
|
|
97
|
+
* Omitting both means "all networks". For wallets that work on all
|
|
98
|
+
* networks *except* specific ones (e.g. Mnemonic excludes MainNet for
|
|
99
|
+
* security), use `excludedNetworks`. Setting both is invalid.
|
|
100
|
+
*/
|
|
101
|
+
interface WalletCapabilities {
|
|
102
|
+
/** If set, the wallet is only available on these networks. */
|
|
103
|
+
supportedNetworks?: string[];
|
|
104
|
+
/** If set, the wallet is available on all networks EXCEPT these. */
|
|
105
|
+
excludedNetworks?: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Scoped store accessor provided to each adapter instance.
|
|
109
|
+
* All mutations are pre-bound to the adapter's wallet key —
|
|
110
|
+
* adapters cannot accidentally modify another wallet's state.
|
|
111
|
+
*/
|
|
112
|
+
interface AdapterStoreAccessor {
|
|
113
|
+
getWalletState(): WalletState | undefined;
|
|
114
|
+
getActiveWallet(): WalletKey | null;
|
|
115
|
+
getActiveNetwork(): string;
|
|
116
|
+
getState(): State;
|
|
117
|
+
addWallet(wallet: WalletState): void;
|
|
118
|
+
removeWallet(): void;
|
|
119
|
+
setAccounts(accounts: WalletAccount[]): void;
|
|
120
|
+
setActiveAccount(address: string): void;
|
|
121
|
+
setActive(): void;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Constructor parameters for adapter classes.
|
|
125
|
+
* Generic over the options type so adapters receive typed options
|
|
126
|
+
* without unsafe casts.
|
|
127
|
+
*/
|
|
128
|
+
interface AdapterConstructorParams<TOptions = Record<string, unknown>> {
|
|
129
|
+
id: string;
|
|
130
|
+
metadata: WalletMetadata;
|
|
131
|
+
store: AdapterStoreAccessor;
|
|
132
|
+
subscribe: (callback: (state: State) => void) => () => void;
|
|
133
|
+
getAlgodClient: () => algosdk.Algodv2;
|
|
134
|
+
options?: TOptions;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Return type of adapter factory functions.
|
|
138
|
+
* Uses `Record<string, unknown>` for options (type erasure) because
|
|
139
|
+
* the manager handles heterogeneous adapter configs in a single array.
|
|
140
|
+
* Type safety lives in the factory function signature, not here.
|
|
141
|
+
*/
|
|
142
|
+
interface WalletAdapterConfig {
|
|
143
|
+
/** Unique identifier for this wallet adapter */
|
|
144
|
+
id: string;
|
|
145
|
+
/** Display metadata (name, icon) */
|
|
146
|
+
metadata: WalletMetadata;
|
|
147
|
+
/** The adapter class constructor */
|
|
148
|
+
Adapter: new (params: AdapterConstructorParams) => BaseWallet;
|
|
149
|
+
/** Wallet-specific options, passed through to the adapter constructor */
|
|
150
|
+
options?: Record<string, unknown>;
|
|
151
|
+
/** Network capabilities — which networks this wallet supports */
|
|
152
|
+
capabilities?: WalletCapabilities;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The public-facing wallet shape returned by framework hooks
|
|
156
|
+
* (e.g. `useWallet()` in React). Defined in core so all framework
|
|
157
|
+
* adapters share a single type.
|
|
158
|
+
*/
|
|
159
|
+
interface Wallet {
|
|
160
|
+
id: string;
|
|
161
|
+
walletKey: string;
|
|
162
|
+
metadata: WalletMetadata;
|
|
163
|
+
accounts: WalletAccount[];
|
|
164
|
+
activeAccount: WalletAccount | null;
|
|
165
|
+
isConnected: boolean;
|
|
166
|
+
isActive: boolean;
|
|
167
|
+
canSignData: boolean;
|
|
168
|
+
canUsePrivateKey: boolean;
|
|
169
|
+
connect: (args?: Record<string, any>) => Promise<WalletAccount[]>;
|
|
170
|
+
disconnect: () => Promise<void>;
|
|
171
|
+
setActive: () => void;
|
|
172
|
+
setActiveAccount: (address: string) => void;
|
|
173
|
+
}
|
|
174
|
+
type WalletState = {
|
|
175
|
+
accounts: WalletAccount[];
|
|
176
|
+
activeAccount: WalletAccount | null;
|
|
177
|
+
};
|
|
178
|
+
/** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-multisigmetadata */
|
|
179
|
+
interface MultisigMetadata {
|
|
180
|
+
/**
|
|
181
|
+
* Multisig version.
|
|
182
|
+
*/
|
|
183
|
+
version: number;
|
|
184
|
+
/**
|
|
185
|
+
* Multisig threshold value. Authorization requires a subset of signatures,
|
|
186
|
+
* equal to or greater than the threshold value.
|
|
187
|
+
*/
|
|
188
|
+
threshold: number;
|
|
189
|
+
/**
|
|
190
|
+
* List of Algorand addresses of possible signers for this
|
|
191
|
+
* multisig. Order is important.
|
|
192
|
+
*/
|
|
193
|
+
addrs: string[];
|
|
194
|
+
}
|
|
195
|
+
/** @see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#interface-wallettransaction */
|
|
196
|
+
interface WalletTransaction {
|
|
197
|
+
/**
|
|
198
|
+
* Base64 encoding of the canonical msgpack encoding of a Transaction.
|
|
199
|
+
*/
|
|
200
|
+
txn: string;
|
|
201
|
+
/**
|
|
202
|
+
* Optional authorized address used to sign the transaction when the account
|
|
203
|
+
* is rekeyed. Also called the signor/sgnr.
|
|
204
|
+
*/
|
|
205
|
+
authAddr?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Multisig metadata used to sign the transaction
|
|
208
|
+
*/
|
|
209
|
+
msig?: MultisigMetadata;
|
|
210
|
+
/**
|
|
211
|
+
* Optional list of addresses that must sign the transactions
|
|
212
|
+
*/
|
|
213
|
+
signers?: string[];
|
|
214
|
+
/**
|
|
215
|
+
* Optional base64 encoding of the canonical msgpack encoding of a
|
|
216
|
+
* SignedTxn corresponding to txn, when signers=[]
|
|
217
|
+
*/
|
|
218
|
+
stxn?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Optional message explaining the reason of the transaction
|
|
221
|
+
*/
|
|
222
|
+
message?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Optional message explaining the reason of this group of transaction
|
|
225
|
+
* Field only allowed in the first transaction of a group
|
|
226
|
+
*/
|
|
227
|
+
groupMessage?: string;
|
|
228
|
+
}
|
|
229
|
+
/** @see https://github.com/perawallet/connect/blob/1.3.4/src/util/model/peraWalletModels.ts */
|
|
230
|
+
interface SignerTransaction {
|
|
231
|
+
txn: algosdk.Transaction;
|
|
232
|
+
/**
|
|
233
|
+
* Optional authorized address used to sign the transaction when
|
|
234
|
+
* the account is rekeyed. Also called the signor/sgnr.
|
|
235
|
+
*/
|
|
236
|
+
authAddr?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Optional list of addresses that must sign the transactions.
|
|
239
|
+
* Wallet skips to sign this txn if signers is empty array.
|
|
240
|
+
* If undefined, wallet tries to sign it.
|
|
241
|
+
*/
|
|
242
|
+
signers?: string[];
|
|
243
|
+
/**
|
|
244
|
+
* Optional message explaining the reason of the transaction
|
|
245
|
+
*/
|
|
246
|
+
message?: string;
|
|
247
|
+
}
|
|
248
|
+
interface JsonRpcRequest<T = any> {
|
|
249
|
+
id: number;
|
|
250
|
+
jsonrpc: string;
|
|
251
|
+
method: string;
|
|
252
|
+
params: T;
|
|
253
|
+
}
|
|
254
|
+
declare class SignTxnsError extends Error {
|
|
255
|
+
code: number;
|
|
256
|
+
data?: any;
|
|
257
|
+
constructor(message: string, code: number, data?: any);
|
|
258
|
+
}
|
|
259
|
+
interface Siwa {
|
|
260
|
+
domain: string;
|
|
261
|
+
account_address: string;
|
|
262
|
+
uri: string;
|
|
263
|
+
version: string;
|
|
264
|
+
statement?: string;
|
|
265
|
+
nonce?: string;
|
|
266
|
+
'issued-at'?: string;
|
|
267
|
+
'expiration-time'?: string;
|
|
268
|
+
'not-before'?: string;
|
|
269
|
+
'request-id'?: string;
|
|
270
|
+
chain_id: '283';
|
|
271
|
+
resources?: string[];
|
|
272
|
+
type: 'ed25519';
|
|
273
|
+
}
|
|
274
|
+
declare class SignDataError extends Error {
|
|
275
|
+
code: number;
|
|
276
|
+
data?: any;
|
|
277
|
+
constructor(message: string, code: number, data?: any);
|
|
278
|
+
}
|
|
279
|
+
interface SignData {
|
|
280
|
+
data: string;
|
|
281
|
+
signer: Uint8Array;
|
|
282
|
+
domain: string;
|
|
283
|
+
authenticatorData: Uint8Array;
|
|
284
|
+
requestId?: string;
|
|
285
|
+
hdPath?: string;
|
|
286
|
+
signature?: Uint8Array;
|
|
287
|
+
}
|
|
288
|
+
interface SignDataResponse extends SignData {
|
|
289
|
+
signature: Uint8Array;
|
|
290
|
+
}
|
|
291
|
+
declare enum ScopeType {
|
|
292
|
+
UNKNOWN = -1,
|
|
293
|
+
AUTH = 1
|
|
294
|
+
}
|
|
295
|
+
interface SignMetadata {
|
|
296
|
+
scope: ScopeType;
|
|
297
|
+
encoding: string;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/store.d.ts
|
|
301
|
+
type WalletStateMap = Partial<Record<WalletKey, WalletState>>;
|
|
302
|
+
type ManagerStatus = 'initializing' | 'ready';
|
|
303
|
+
interface State {
|
|
304
|
+
wallets: WalletStateMap;
|
|
305
|
+
activeWallet: WalletKey | null;
|
|
306
|
+
activeNetwork: string;
|
|
307
|
+
algodClient: algosdk.Algodv2;
|
|
308
|
+
managerStatus: ManagerStatus;
|
|
309
|
+
networkConfig: Record<string, NetworkConfig>;
|
|
310
|
+
customNetworkConfigs: Record<string, Partial<NetworkConfig>>;
|
|
311
|
+
}
|
|
312
|
+
declare const DEFAULT_STATE: State;
|
|
313
|
+
declare function setActiveAccount(store: Store<State>, {
|
|
314
|
+
walletId,
|
|
315
|
+
address
|
|
316
|
+
}: {
|
|
317
|
+
walletId: WalletKey;
|
|
318
|
+
address: string;
|
|
319
|
+
}): void;
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/wallets/base.d.ts
|
|
322
|
+
declare abstract class BaseWallet<TOptions = Record<string, unknown>> {
|
|
323
|
+
readonly id: string;
|
|
324
|
+
readonly walletKey: string;
|
|
325
|
+
metadata: WalletMetadata;
|
|
326
|
+
protected options: TOptions;
|
|
327
|
+
protected store: AdapterStoreAccessor;
|
|
328
|
+
protected getAlgodClient: () => algosdk.Algodv2;
|
|
329
|
+
subscribe: (callback: (state: State) => void) => () => void;
|
|
330
|
+
protected logger: ReturnType<typeof logger.createScopedLogger>;
|
|
331
|
+
protected constructor({
|
|
332
|
+
id,
|
|
333
|
+
metadata,
|
|
334
|
+
store,
|
|
335
|
+
subscribe,
|
|
336
|
+
getAlgodClient,
|
|
337
|
+
options
|
|
338
|
+
}: AdapterConstructorParams<TOptions>);
|
|
339
|
+
static defaultMetadata: WalletMetadata;
|
|
340
|
+
abstract connect(args?: Record<string, any>): Promise<WalletAccount[]>;
|
|
341
|
+
abstract disconnect(): Promise<void>;
|
|
342
|
+
abstract resumeSession(): Promise<void>;
|
|
343
|
+
setActive: () => void;
|
|
344
|
+
setActiveAccount: (account: string) => void;
|
|
345
|
+
abstract signTransactions<T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]): Promise<(Uint8Array | null)[]>;
|
|
346
|
+
transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
|
|
347
|
+
canSignData: boolean;
|
|
348
|
+
signData: (_data: string, _metadata: SignMetadata) => Promise<SignDataResponse>;
|
|
349
|
+
canUsePrivateKey: boolean;
|
|
350
|
+
withPrivateKey: <T>(_callback: (secretKey: Uint8Array) => Promise<T>) => Promise<T>;
|
|
351
|
+
get name(): string;
|
|
352
|
+
get accounts(): WalletAccount[];
|
|
353
|
+
get addresses(): string[];
|
|
354
|
+
get activeAccount(): WalletAccount | null;
|
|
355
|
+
get activeAddress(): string | null;
|
|
356
|
+
get activeNetwork(): string;
|
|
357
|
+
get isConnected(): boolean;
|
|
358
|
+
get isActive(): boolean;
|
|
359
|
+
get activeNetworkConfig(): NetworkConfig;
|
|
360
|
+
protected onDisconnect: () => void;
|
|
361
|
+
protected updateMetadata(updates: Partial<WalletMetadata>): void;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
export { NetworkConfigBuilder as A, WalletKey as C, AlgodConfig as D, WalletTransaction as E, LogLevel as M, DEFAULT_NETWORK_CONFIG as O, WalletId as S, WalletState as T, Siwa as _, setActiveAccount as a, WalletAdapterConfig as b, JsonRpcRequest as c, SignData as d, SignDataError as f, SignerTransaction as g, SignTxnsError as h, State as i, NetworkId as j, NetworkConfig as k, MultisigMetadata as l, SignMetadata as m, DEFAULT_STATE as n, AdapterConstructorParams as o, SignDataResponse as p, ManagerStatus as r, AdapterStoreAccessor as s, BaseWallet as t, ScopeType as u, Wallet as v, WalletMetadata as w, WalletCapabilities as x, WalletAccount as y };
|
|
365
|
+
//# sourceMappingURL=base-BKrq-rUH.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { b as WalletAdapterConfig, m as SignMetadata, o as AdapterConstructorParams, p as SignDataResponse, t as BaseWallet, w as WalletMetadata, y as WalletAccount } from "./base-BKrq-rUH.js";
|
|
2
|
+
import algosdk from "algosdk";
|
|
3
|
+
|
|
4
|
+
//#region src/secure-key.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Secure key handling utilities for managing sensitive cryptographic material.
|
|
7
|
+
*
|
|
8
|
+
* These utilities provide defense-in-depth for private key handling:
|
|
9
|
+
* 1. Memory zeroing - Overwrites key material before releasing references
|
|
10
|
+
* 2. Scoped key access - Keys are only available within controlled callbacks
|
|
11
|
+
* 3. Automatic cleanup - Keys are cleared after use via try/finally patterns
|
|
12
|
+
* 4. No persistence - Keys are never stored to disk/localStorage
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Securely zeros out a Uint8Array by overwriting all bytes with zeros.
|
|
16
|
+
* This helps prevent key material from lingering in memory.
|
|
17
|
+
*
|
|
18
|
+
* Note: JavaScript doesn't guarantee immediate memory clearing due to GC,
|
|
19
|
+
* but this provides defense-in-depth by:
|
|
20
|
+
* 1. Overwriting the buffer contents immediately
|
|
21
|
+
* 2. Reducing the window where key material is accessible
|
|
22
|
+
* 3. Preventing accidental key leakage through references
|
|
23
|
+
*/
|
|
24
|
+
declare function zeroMemory(buffer: Uint8Array): void;
|
|
25
|
+
/**
|
|
26
|
+
* Securely zeros out a string by creating a mutable copy and clearing it.
|
|
27
|
+
* Returns an empty string. The original string in memory may still exist
|
|
28
|
+
* due to string immutability in JS, but this clears any mutable references.
|
|
29
|
+
*/
|
|
30
|
+
declare function zeroString(str: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* A secure container for holding private key material.
|
|
33
|
+
* Provides controlled access and automatic cleanup.
|
|
34
|
+
*/
|
|
35
|
+
declare class SecureKeyContainer {
|
|
36
|
+
private _secretKey;
|
|
37
|
+
private _isCleared;
|
|
38
|
+
constructor(secretKey: Uint8Array);
|
|
39
|
+
/**
|
|
40
|
+
* Check if the key has been cleared
|
|
41
|
+
*/
|
|
42
|
+
get isCleared(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Execute a callback with access to the secret key.
|
|
45
|
+
* The key is automatically cleared if an error occurs.
|
|
46
|
+
*/
|
|
47
|
+
useKey<T>(callback: (secretKey: Uint8Array) => Promise<T>): Promise<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Execute a synchronous callback with access to the secret key.
|
|
50
|
+
*/
|
|
51
|
+
useKeySync<T>(callback: (secretKey: Uint8Array) => T): T;
|
|
52
|
+
/**
|
|
53
|
+
* Securely clear the key from memory.
|
|
54
|
+
* This should be called when the key is no longer needed.
|
|
55
|
+
*/
|
|
56
|
+
clear(): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Execute a function with a temporary secret key that is automatically
|
|
60
|
+
* cleared after the function completes (success or error).
|
|
61
|
+
*
|
|
62
|
+
* This is the preferred pattern for one-time key operations.
|
|
63
|
+
*/
|
|
64
|
+
declare function withSecureKey<T>(secretKey: Uint8Array, callback: (container: SecureKeyContainer) => Promise<T>): Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Synchronous version of withSecureKey for non-async operations.
|
|
67
|
+
*/
|
|
68
|
+
declare function withSecureKeySync<T>(secretKey: Uint8Array, callback: (container: SecureKeyContainer) => T): T;
|
|
69
|
+
/**
|
|
70
|
+
* Derive an Algorand account from an ed25519 private key seed.
|
|
71
|
+
* The input key should be 32 bytes (seed).
|
|
72
|
+
*
|
|
73
|
+
* SECURITY: The returned account contains a secret key reference.
|
|
74
|
+
* The caller is responsible for zeroing account.sk after use.
|
|
75
|
+
*/
|
|
76
|
+
declare function deriveAlgorandAccountFromEd25519(ed25519Seed: Uint8Array): Promise<{
|
|
77
|
+
addr: string;
|
|
78
|
+
sk: Uint8Array;
|
|
79
|
+
}>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/wallets/custom.d.ts
|
|
82
|
+
type CustomProvider = {
|
|
83
|
+
connect?(args?: Record<string, any>): Promise<WalletAccount[]>;
|
|
84
|
+
disconnect?(): Promise<void>;
|
|
85
|
+
resumeSession?(): Promise<WalletAccount[] | void>;
|
|
86
|
+
signTransactions?<T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]): Promise<(Uint8Array | null)[]>;
|
|
87
|
+
transactionSigner?(txnGroup: algosdk.Transaction[], indexesToSign: number[]): Promise<Uint8Array[]>;
|
|
88
|
+
signData?(data: string, metadata: SignMetadata): Promise<SignDataResponse>;
|
|
89
|
+
};
|
|
90
|
+
interface CustomWalletOptions {
|
|
91
|
+
provider: CustomProvider;
|
|
92
|
+
}
|
|
93
|
+
declare class CustomWallet extends BaseWallet<CustomWalletOptions> {
|
|
94
|
+
private provider;
|
|
95
|
+
constructor(params: AdapterConstructorParams<CustomWalletOptions>);
|
|
96
|
+
static defaultMetadata: WalletMetadata;
|
|
97
|
+
connect: (args?: Record<string, any>) => Promise<WalletAccount[]>;
|
|
98
|
+
disconnect: () => Promise<void>;
|
|
99
|
+
resumeSession: () => Promise<void>;
|
|
100
|
+
signTransactions: <T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]) => Promise<(Uint8Array | null)[]>;
|
|
101
|
+
transactionSigner: (txnGroup: algosdk.Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
|
|
102
|
+
signData: (data: string, metadata: SignMetadata) => Promise<SignDataResponse>;
|
|
103
|
+
}
|
|
104
|
+
declare function custom(options: CustomWalletOptions): WalletAdapterConfig;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { SecureKeyContainer as a, withSecureKeySync as c, custom as i, zeroMemory as l, CustomWallet as n, deriveAlgorandAccountFromEd25519 as o, CustomWalletOptions as r, withSecureKey as s, CustomProvider as t, zeroString as u };
|
|
107
|
+
//# sourceMappingURL=custom-BXQKth41.d.ts.map
|