@ab-org/sdk-core 0.0.1 → 0.1.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/index.d.ts +536 -16
- package/dist/index.js +1776 -16
- package/package.json +5 -3
- package/dist/core/capabilities.d.ts +0 -32
- package/dist/core/capabilities.js +0 -88
- package/dist/core/chains.d.ts +0 -23
- package/dist/core/chains.js +0 -83
- package/dist/core/errors.d.ts +0 -9
- package/dist/core/errors.js +0 -51
- package/dist/core/sessionStore.d.ts +0 -26
- package/dist/core/sessionStore.js +0 -129
- package/dist/core/types.d.ts +0 -75
- package/dist/core/types.js +0 -1
- package/dist/core/walletConnector.d.ts +0 -29
- package/dist/core/walletConnector.js +0 -153
- package/dist/core/walletExecution.d.ts +0 -22
- package/dist/core/walletExecution.js +0 -89
- package/dist/hooks/useAccount.d.ts +0 -11
- package/dist/hooks/useAccount.js +0 -32
- package/dist/hooks/useWalletConnect.d.ts +0 -16
- package/dist/hooks/useWalletConnect.js +0 -24
- package/dist/providers/base.d.ts +0 -15
- package/dist/providers/base.js +0 -30
- package/dist/providers/plugin/injectedEvmProvider.d.ts +0 -112
- package/dist/providers/plugin/injectedEvmProvider.js +0 -326
- package/dist/providers/plugin/injectedWalletRegistry.d.ts +0 -9
- package/dist/providers/plugin/injectedWalletRegistry.js +0 -34
- package/dist/providers/plugin/metamaskProvider.d.ts +0 -1
- package/dist/providers/plugin/metamaskProvider.js +0 -1
- package/dist/providers/social/baseSocialProvider.d.ts +0 -21
- package/dist/providers/social/baseSocialProvider.js +0 -11
- package/dist/providers/social/cubeSignerAuth.d.ts +0 -89
- package/dist/providers/social/cubeSignerAuth.js +0 -128
- package/dist/providers/social/cubistEvmWalletProvider.d.ts +0 -9
- package/dist/providers/social/cubistEvmWalletProvider.js +0 -175
- package/dist/providers/social/cubistProvider.d.ts +0 -52
- package/dist/providers/social/cubistProvider.js +0 -160
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,536 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { Environment, EnvInterface, CubeSignerClient, SessionData } from '@cubist-labs/cubesigner-sdk';
|
|
3
|
+
|
|
4
|
+
type WalletCapability = "eth_accounts" | "eth_requestAccounts" | "eth_chainId" | "eth_signTransaction" | "eth_sendTransaction" | "personal_sign" | "eth_signTypedData_v4" | "wallet_disconnect" | "wallet_rehydrate" | string;
|
|
5
|
+
interface SessionCapabilityPolicy {
|
|
6
|
+
id: string;
|
|
7
|
+
appId?: string;
|
|
8
|
+
origin?: string;
|
|
9
|
+
expiresAt?: number;
|
|
10
|
+
methods?: WalletCapability[];
|
|
11
|
+
chains?: SupportedChain[];
|
|
12
|
+
tokens?: SupportedToken[];
|
|
13
|
+
maxAmount?: string;
|
|
14
|
+
revocable?: boolean;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
interface SessionCapabilityCheck {
|
|
18
|
+
capability: WalletCapability;
|
|
19
|
+
chain?: SupportedChain;
|
|
20
|
+
token?: SupportedToken;
|
|
21
|
+
amount?: string | number | bigint;
|
|
22
|
+
appId?: string;
|
|
23
|
+
origin?: string;
|
|
24
|
+
now?: number;
|
|
25
|
+
}
|
|
26
|
+
declare class SessionCapabilityError extends Error {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
declare const createSessionCapabilityPolicy: (input?: Partial<SessionCapabilityPolicy>) => SessionCapabilityPolicy;
|
|
30
|
+
declare const isSessionExpired: (session: Pick<WalletSession, "expiresAt"> | null | undefined, now?: number) => boolean;
|
|
31
|
+
declare const isCapabilityPolicyExpired: (policy: SessionCapabilityPolicy | null | undefined, now?: number) => boolean;
|
|
32
|
+
declare const sessionSupportsCapability: (session: Pick<WalletSession, "capabilities"> | null | undefined, capability: WalletCapability) => boolean;
|
|
33
|
+
declare const describeSessionCapabilityPolicy: (policy: SessionCapabilityPolicy | null | undefined) => string[];
|
|
34
|
+
declare const assertSessionCapability: (session: WalletSession, check: SessionCapabilityCheck) => void;
|
|
35
|
+
|
|
36
|
+
type ChainNamespace = "evm" | "solana" | "ab-core";
|
|
37
|
+
type ChainRpcFamily = "evm" | "solana" | "custom";
|
|
38
|
+
interface ChainDescriptor {
|
|
39
|
+
chain: SupportedChain;
|
|
40
|
+
namespace: ChainNamespace;
|
|
41
|
+
reference: string;
|
|
42
|
+
label: string;
|
|
43
|
+
rpcFamily: ChainRpcFamily;
|
|
44
|
+
evmChainId?: number;
|
|
45
|
+
supportsSmartSessions: boolean;
|
|
46
|
+
supportsAccountAbstraction: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface ChainContext {
|
|
49
|
+
walletChain: SupportedChain;
|
|
50
|
+
walletChainDescriptor: ChainDescriptor;
|
|
51
|
+
settlementChain: SupportedChain;
|
|
52
|
+
settlementChainDescriptor: ChainDescriptor;
|
|
53
|
+
}
|
|
54
|
+
declare const getChainDescriptor: (chain: SupportedChain) => ChainDescriptor;
|
|
55
|
+
declare const getAllChainDescriptors: () => ChainDescriptor[];
|
|
56
|
+
declare const getSupportedChainFromEvmChainId: (value: string | number | bigint) => SupportedChain;
|
|
57
|
+
declare const createChainContext: (walletChain: SupportedChain, settlementChain?: SupportedChain) => ChainContext;
|
|
58
|
+
|
|
59
|
+
type SupportedChain = "AB_CORE" | "ETH" | "BSC" | "SOL" | "ETH_TENDERLY" | "BSC_TENDERLY";
|
|
60
|
+
type SupportedToken = "USD1" | "USDC" | "USDT" | "ETH" | "AB";
|
|
61
|
+
type ProviderCategory = "plugin" | "social";
|
|
62
|
+
type WalletType = "injected" | "social" | "smart";
|
|
63
|
+
type WalletAuthSource = "google" | "twitter" | "wallet" | "session";
|
|
64
|
+
type EvmQuantity = string | number | bigint;
|
|
65
|
+
interface EvmAccessListItem {
|
|
66
|
+
address: string;
|
|
67
|
+
storageKeys?: string[];
|
|
68
|
+
}
|
|
69
|
+
interface EvmTransactionRequest {
|
|
70
|
+
from?: string;
|
|
71
|
+
to?: string;
|
|
72
|
+
data?: string;
|
|
73
|
+
gas?: EvmQuantity;
|
|
74
|
+
gasPrice?: EvmQuantity;
|
|
75
|
+
maxFeePerGas?: EvmQuantity;
|
|
76
|
+
maxPriorityFeePerGas?: EvmQuantity;
|
|
77
|
+
nonce?: EvmQuantity;
|
|
78
|
+
value?: EvmQuantity;
|
|
79
|
+
type?: EvmQuantity;
|
|
80
|
+
chainId?: EvmQuantity;
|
|
81
|
+
accessList?: EvmAccessListItem[];
|
|
82
|
+
}
|
|
83
|
+
interface WalletProviderRequest {
|
|
84
|
+
method: string;
|
|
85
|
+
params?: unknown[];
|
|
86
|
+
}
|
|
87
|
+
interface WalletProvider {
|
|
88
|
+
request<T = unknown>(payload: WalletProviderRequest): Promise<T>;
|
|
89
|
+
disconnect(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
interface WalletConnectArgs {
|
|
92
|
+
options?: unknown;
|
|
93
|
+
payload?: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface WalletAdapter {
|
|
96
|
+
id: string;
|
|
97
|
+
title: string;
|
|
98
|
+
icon?: string;
|
|
99
|
+
category?: ProviderCategory;
|
|
100
|
+
connect(args?: WalletConnectArgs): Promise<WalletSession>;
|
|
101
|
+
disconnect(): Promise<void>;
|
|
102
|
+
getProvider(): WalletProvider | null;
|
|
103
|
+
/**
|
|
104
|
+
* Silently restore a wallet session from persisted data without user interaction.
|
|
105
|
+
* Returns a fresh session if the wallet can be reconnected, or null otherwise.
|
|
106
|
+
*/
|
|
107
|
+
reconnect?(persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
108
|
+
}
|
|
109
|
+
interface WalletSession {
|
|
110
|
+
address: string;
|
|
111
|
+
chain: SupportedChain;
|
|
112
|
+
provider: WalletProvider;
|
|
113
|
+
walletType?: WalletType;
|
|
114
|
+
authSource?: WalletAuthSource;
|
|
115
|
+
sessionId?: string;
|
|
116
|
+
expiresAt?: number;
|
|
117
|
+
capabilities?: WalletCapability[];
|
|
118
|
+
sessionData?: unknown;
|
|
119
|
+
chainContext?: ChainContext;
|
|
120
|
+
capabilityPolicy?: SessionCapabilityPolicy;
|
|
121
|
+
}
|
|
122
|
+
interface BalanceInfo {
|
|
123
|
+
formatted: string;
|
|
124
|
+
symbol: SupportedToken;
|
|
125
|
+
wei: bigint;
|
|
126
|
+
}
|
|
127
|
+
interface WalletState {
|
|
128
|
+
session: WalletSession | null;
|
|
129
|
+
balance: BalanceInfo | null;
|
|
130
|
+
isConnecting: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare const EVM_TRANSACTION_SIGNING_UNSUPPORTED = "EVM_TRANSACTION_SIGNING_UNSUPPORTED";
|
|
134
|
+
declare class EvmTransactionSigningUnsupportedError extends Error {
|
|
135
|
+
readonly providerName: string;
|
|
136
|
+
readonly cause?: unknown | undefined;
|
|
137
|
+
readonly code = "EVM_TRANSACTION_SIGNING_UNSUPPORTED";
|
|
138
|
+
constructor(providerName: string, cause?: unknown | undefined);
|
|
139
|
+
}
|
|
140
|
+
declare const isUnsupportedEvmTransactionSigningError: (error: unknown) => boolean;
|
|
141
|
+
declare const normalizeEvmTransactionSigningError: (providerName: string, error: unknown) => Error;
|
|
142
|
+
|
|
143
|
+
type WalletEvents = {
|
|
144
|
+
"session:changed": [WalletSession | null];
|
|
145
|
+
"session:rehydrated": [WalletSession];
|
|
146
|
+
"session:expired": [WalletSession];
|
|
147
|
+
"session:revoked": [WalletSession];
|
|
148
|
+
"balance:changed": [BalanceInfo | null];
|
|
149
|
+
"connecting:changed": [boolean];
|
|
150
|
+
};
|
|
151
|
+
declare class SessionStore {
|
|
152
|
+
private state;
|
|
153
|
+
private emitter;
|
|
154
|
+
constructor();
|
|
155
|
+
getState(): WalletState;
|
|
156
|
+
setConnecting(flag: boolean): void;
|
|
157
|
+
setSession(session: WalletSession | null): void;
|
|
158
|
+
rehydrateSession(session: WalletSession): void;
|
|
159
|
+
clearSession(): void;
|
|
160
|
+
expireSession(): void;
|
|
161
|
+
revokeSession(): void;
|
|
162
|
+
setBalance(balance: BalanceInfo | null): void;
|
|
163
|
+
on<T extends keyof WalletEvents>(event: T, listener: (...args: WalletEvents[T]) => void): () => EventEmitter<WalletEvents, any>;
|
|
164
|
+
private tryRehydrate;
|
|
165
|
+
}
|
|
166
|
+
declare const sessionStore: SessionStore;
|
|
167
|
+
|
|
168
|
+
declare class WalletConnector {
|
|
169
|
+
private adapters;
|
|
170
|
+
private currentAdapterId;
|
|
171
|
+
constructor(adapters: WalletAdapter[]);
|
|
172
|
+
private getAdapterById;
|
|
173
|
+
private getCurrentAdapter;
|
|
174
|
+
private clearActiveSession;
|
|
175
|
+
private requireActiveSession;
|
|
176
|
+
connect(adapterId: string, args?: WalletConnectArgs): Promise<WalletSession>;
|
|
177
|
+
disconnect(): Promise<void>;
|
|
178
|
+
rehydrateSession(adapterId: string, session: WalletSession): WalletSession;
|
|
179
|
+
/**
|
|
180
|
+
* Attempt to silently reconnect a wallet whose session was rehydrated
|
|
181
|
+
* from localStorage. Uses the adapter's `reconnect()` if available,
|
|
182
|
+
* falling back to `connect()` for backward compatibility.
|
|
183
|
+
*
|
|
184
|
+
* Returns the restored session on success, or `null` if reconnection
|
|
185
|
+
* is not possible (e.g. wallet extension removed, social session expired).
|
|
186
|
+
*/
|
|
187
|
+
tryAutoReconnect(): Promise<WalletSession | null>;
|
|
188
|
+
supportsCapability(capability: WalletCapability): boolean;
|
|
189
|
+
requestCurrentProvider<T = unknown>(payload: WalletProviderRequest): Promise<T>;
|
|
190
|
+
sendEvmTransaction(transaction: EvmTransactionRequest): Promise<string>;
|
|
191
|
+
signEvmTransaction(transaction: EvmTransactionRequest): Promise<string>;
|
|
192
|
+
signMessage(message: string): Promise<string>;
|
|
193
|
+
signTypedData(typedData: Record<string, unknown>): Promise<string>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface WalletExecutionClient {
|
|
197
|
+
readonly session: WalletSession;
|
|
198
|
+
readonly capabilities: WalletCapability[];
|
|
199
|
+
supports(capability: WalletCapability): boolean;
|
|
200
|
+
sendTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
201
|
+
signTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
202
|
+
signMessage(message: string, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
203
|
+
signTypedData(typedData: Record<string, unknown>, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
204
|
+
}
|
|
205
|
+
declare const getWalletExecutionCapabilities: (session?: WalletSession | null) => WalletCapability[];
|
|
206
|
+
declare const createWalletExecutionClient: (session?: WalletSession | null) => WalletExecutionClient;
|
|
207
|
+
declare const createWalletExecutionController: () => {
|
|
208
|
+
readonly session: WalletSession | null;
|
|
209
|
+
readonly capabilities: string[];
|
|
210
|
+
supports(capability: WalletCapability): boolean;
|
|
211
|
+
sendTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
212
|
+
signTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
213
|
+
signMessage(message: string, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
214
|
+
signTypedData(typedData: Record<string, unknown>, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
interface WalletConnectControllerOptions {
|
|
218
|
+
connector: WalletConnector;
|
|
219
|
+
defaultAdapterId?: string;
|
|
220
|
+
}
|
|
221
|
+
declare const createWalletConnectController: ({ connector, defaultAdapterId, }: WalletConnectControllerOptions) => {
|
|
222
|
+
readonly openModal: (adapterId?: string | undefined, args?: WalletConnectArgs) => Promise<void>;
|
|
223
|
+
readonly disconnect: () => Promise<void>;
|
|
224
|
+
readonly rehydrate: (adapterId: string, session: WalletSession) => WalletSession;
|
|
225
|
+
readonly tryAutoReconnect: () => Promise<WalletSession | null>;
|
|
226
|
+
readonly supports: (capability: WalletCapability) => boolean;
|
|
227
|
+
readonly isConnected: boolean;
|
|
228
|
+
readonly isConnecting: boolean;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
declare const createAccountController: () => {
|
|
232
|
+
readonly session: WalletSession | null;
|
|
233
|
+
readonly address: string | null;
|
|
234
|
+
readonly chain: SupportedChain | null;
|
|
235
|
+
readonly balance: BalanceInfo | null;
|
|
236
|
+
readonly isConnected: boolean;
|
|
237
|
+
readonly currentProvider: WalletProvider | null;
|
|
238
|
+
readonly chainContext: ChainContext | null;
|
|
239
|
+
readonly capabilities: string[];
|
|
240
|
+
readonly capabilityPolicy: SessionCapabilityPolicy | null;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
declare abstract class AbstractProvider implements WalletAdapter {
|
|
244
|
+
abstract readonly id: string;
|
|
245
|
+
abstract readonly title: string;
|
|
246
|
+
abstract readonly category: ProviderCategory;
|
|
247
|
+
protected currentSession: WalletSession | null;
|
|
248
|
+
abstract connect(args?: WalletConnectArgs): Promise<WalletSession>;
|
|
249
|
+
disconnect(): Promise<void>;
|
|
250
|
+
protected setSession(session: WalletSession): WalletSession;
|
|
251
|
+
protected clearSession(): void;
|
|
252
|
+
protected get session(): WalletSession | null;
|
|
253
|
+
protected requireSession(message?: string): WalletSession;
|
|
254
|
+
getProvider(): WalletProvider | null;
|
|
255
|
+
reconnect(_persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface InjectedEthereumProvider extends WalletProvider {
|
|
259
|
+
request<T = unknown>(args: {
|
|
260
|
+
method: string;
|
|
261
|
+
params?: unknown[];
|
|
262
|
+
}): Promise<T>;
|
|
263
|
+
providers?: InjectedEthereumProvider[];
|
|
264
|
+
isMetaMask?: boolean;
|
|
265
|
+
isCoinbaseWallet?: boolean;
|
|
266
|
+
isTrust?: boolean;
|
|
267
|
+
isTrustWallet?: boolean;
|
|
268
|
+
isPhantom?: boolean;
|
|
269
|
+
isRabby?: boolean;
|
|
270
|
+
isOkxWallet?: boolean;
|
|
271
|
+
isBitKeep?: boolean;
|
|
272
|
+
isRainbow?: boolean;
|
|
273
|
+
isZerion?: boolean;
|
|
274
|
+
isBraveWallet?: boolean;
|
|
275
|
+
isBitget?: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface EIP6963ProviderInfo {
|
|
278
|
+
uuid: string;
|
|
279
|
+
name: string;
|
|
280
|
+
icon: string;
|
|
281
|
+
rdns: string;
|
|
282
|
+
}
|
|
283
|
+
interface EIP6963ProviderDetail {
|
|
284
|
+
info: EIP6963ProviderInfo;
|
|
285
|
+
provider: InjectedEthereumProvider;
|
|
286
|
+
}
|
|
287
|
+
declare global {
|
|
288
|
+
interface Window {
|
|
289
|
+
ethereum?: InjectedEthereumProvider;
|
|
290
|
+
okxwallet?: InjectedEthereumProvider | {
|
|
291
|
+
ethereum?: InjectedEthereumProvider;
|
|
292
|
+
};
|
|
293
|
+
coinbaseWalletExtension?: InjectedEthereumProvider;
|
|
294
|
+
trustwallet?: InjectedEthereumProvider | {
|
|
295
|
+
ethereum?: InjectedEthereumProvider;
|
|
296
|
+
};
|
|
297
|
+
phantom?: {
|
|
298
|
+
ethereum?: InjectedEthereumProvider;
|
|
299
|
+
};
|
|
300
|
+
rabby?: InjectedEthereumProvider;
|
|
301
|
+
bitkeep?: InjectedEthereumProvider | {
|
|
302
|
+
ethereum?: InjectedEthereumProvider;
|
|
303
|
+
};
|
|
304
|
+
rainbow?: {
|
|
305
|
+
ethereum?: InjectedEthereumProvider;
|
|
306
|
+
};
|
|
307
|
+
zerionWallet?: InjectedEthereumProvider;
|
|
308
|
+
bitget?: InjectedEthereumProvider | {
|
|
309
|
+
ethereum?: InjectedEthereumProvider;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
declare function discoverEIP6963Providers(): EIP6963ProviderDetail[];
|
|
314
|
+
declare function findInjectedProvider(predicate: (provider: InjectedEthereumProvider) => boolean): InjectedEthereumProvider | undefined;
|
|
315
|
+
declare function findEIP6963Provider(predicate: (detail: EIP6963ProviderDetail) => boolean): InjectedEthereumProvider | undefined;
|
|
316
|
+
interface InjectedWalletConfig {
|
|
317
|
+
id: string;
|
|
318
|
+
title: string;
|
|
319
|
+
resolveProvider: () => InjectedEthereumProvider | undefined;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Force wallet to the default funding chain (e.g. 3131). If the chain is missing (4902), add it then switch.
|
|
323
|
+
* Call after external wallet connect so subsequent business runs on the configured funding network.
|
|
324
|
+
*/
|
|
325
|
+
declare function switchToFallbackFundingChain(provider: InjectedEthereumProvider): Promise<void>;
|
|
326
|
+
declare class InjectedEvmProvider extends AbstractProvider {
|
|
327
|
+
private config;
|
|
328
|
+
private injected?;
|
|
329
|
+
readonly id: string;
|
|
330
|
+
readonly title: string;
|
|
331
|
+
readonly category: "plugin";
|
|
332
|
+
constructor(config: InjectedWalletConfig, injected?: InjectedEthereumProvider | undefined);
|
|
333
|
+
isAvailable(): boolean;
|
|
334
|
+
protected get client(): InjectedEthereumProvider;
|
|
335
|
+
connect(_args?: WalletConnectArgs): Promise<WalletSession>;
|
|
336
|
+
reconnect(_persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
337
|
+
}
|
|
338
|
+
declare class MetaMaskProvider extends InjectedEvmProvider {
|
|
339
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
340
|
+
}
|
|
341
|
+
declare class OKXProvider extends InjectedEvmProvider {
|
|
342
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
343
|
+
}
|
|
344
|
+
declare class CoinbaseWalletProvider extends InjectedEvmProvider {
|
|
345
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
346
|
+
}
|
|
347
|
+
declare class TrustWalletProvider extends InjectedEvmProvider {
|
|
348
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
349
|
+
}
|
|
350
|
+
declare class PhantomProvider extends InjectedEvmProvider {
|
|
351
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
352
|
+
}
|
|
353
|
+
declare class RabbyProvider extends InjectedEvmProvider {
|
|
354
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
355
|
+
}
|
|
356
|
+
declare class RainbowProvider extends InjectedEvmProvider {
|
|
357
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
358
|
+
}
|
|
359
|
+
declare class ZerionProvider extends InjectedEvmProvider {
|
|
360
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
361
|
+
}
|
|
362
|
+
declare class BraveWalletProvider extends InjectedEvmProvider {
|
|
363
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
364
|
+
}
|
|
365
|
+
declare class BitgetProvider extends InjectedEvmProvider {
|
|
366
|
+
constructor(injected?: InjectedEthereumProvider);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
interface InjectedWalletRegistryItem {
|
|
370
|
+
id: string;
|
|
371
|
+
title: string;
|
|
372
|
+
installUrl?: string;
|
|
373
|
+
provider: InjectedEvmProvider;
|
|
374
|
+
installed: boolean;
|
|
375
|
+
}
|
|
376
|
+
declare function createDefaultInjectedWalletRegistry(): InjectedWalletRegistryItem[];
|
|
377
|
+
|
|
378
|
+
interface SocialLoginOptions {
|
|
379
|
+
hint?: string;
|
|
380
|
+
redirectUri?: string;
|
|
381
|
+
}
|
|
382
|
+
interface SocialConnectArgs extends WalletConnectArgs {
|
|
383
|
+
options?: SocialLoginOptions;
|
|
384
|
+
}
|
|
385
|
+
declare abstract class AbstractSocialProvider extends AbstractProvider {
|
|
386
|
+
readonly category: "social";
|
|
387
|
+
/**
|
|
388
|
+
* Authenticate and cache a social-wallet session.
|
|
389
|
+
*
|
|
390
|
+
* Some providers only need `options`, while others may require an
|
|
391
|
+
* additional credential payload (for example an OIDC token or OAuth result).
|
|
392
|
+
*/
|
|
393
|
+
abstract signIn(options?: SocialLoginOptions, payload?: unknown): Promise<void>;
|
|
394
|
+
abstract signOut(): Promise<void>;
|
|
395
|
+
connect(args?: WalletConnectArgs): Promise<WalletSession>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Hook for OIDC login when user does not yet exist in CubeSigner.
|
|
400
|
+
* Before creating a session, we call CubeSigner SDK's proof (proveOidcIdentity) to check
|
|
401
|
+
* if the user exists. If proof fails (e.g. user not registered), this is invoked so the
|
|
402
|
+
* caller can register the user on their backend; then login proceeds.
|
|
403
|
+
*/
|
|
404
|
+
interface OidcLoginHooks {
|
|
405
|
+
/**
|
|
406
|
+
* Register the user on your backend when CubeSigner proof indicates the user does not exist.
|
|
407
|
+
* Called with the same OIDC token; after this resolves, OIDC session creation continues.
|
|
408
|
+
*/
|
|
409
|
+
registerUser(oidcToken: string): Promise<void>;
|
|
410
|
+
}
|
|
411
|
+
interface CubeSignerConfig {
|
|
412
|
+
/** CubeSigner environment name or custom env object. */
|
|
413
|
+
env: Environment | EnvInterface;
|
|
414
|
+
/** Organization ID. */
|
|
415
|
+
orgId: string;
|
|
416
|
+
/** Session scopes (default: `["sign:*", "manage:*"]`). */
|
|
417
|
+
scopes?: string[];
|
|
418
|
+
/** Optional capability policy applied to smart-wallet sessions created from this auth flow. */
|
|
419
|
+
defaultSessionPolicy?: Partial<SessionCapabilityPolicy>;
|
|
420
|
+
/**
|
|
421
|
+
* Optional OIDC login hook. When provided, OIDC login will call CubeSigner SDK's
|
|
422
|
+
* proveOidcIdentity first; if the user does not exist (proof fails), registerUser is
|
|
423
|
+
* called, then login proceeds. If omitted, login uses the OIDC token directly.
|
|
424
|
+
*/
|
|
425
|
+
oidcLoginHooks?: OidcLoginHooks;
|
|
426
|
+
}
|
|
427
|
+
interface CubeSignerSession {
|
|
428
|
+
/** Authenticated CubeSigner client — use it for signing, key management, etc. */
|
|
429
|
+
client: CubeSignerClient;
|
|
430
|
+
/** Raw session data (can be persisted / refreshed). */
|
|
431
|
+
sessionData: SessionData;
|
|
432
|
+
}
|
|
433
|
+
interface TwitterCodeExchangeParams {
|
|
434
|
+
/** Authorization code from Twitter OAuth 2.0 PKCE flow. */
|
|
435
|
+
code: string;
|
|
436
|
+
/** PKCE code_verifier that was generated for the auth request. */
|
|
437
|
+
codeVerifier: string;
|
|
438
|
+
/** redirect_uri that was used in the authorization request. */
|
|
439
|
+
redirectUri: string;
|
|
440
|
+
}
|
|
441
|
+
declare class CubeSignerAuth {
|
|
442
|
+
private readonly env;
|
|
443
|
+
private readonly orgId;
|
|
444
|
+
private readonly scopes;
|
|
445
|
+
readonly defaultSessionPolicy?: Partial<SessionCapabilityPolicy>;
|
|
446
|
+
private readonly oidcLoginHooks?;
|
|
447
|
+
private _client;
|
|
448
|
+
private _sessionData;
|
|
449
|
+
constructor(config: CubeSignerConfig);
|
|
450
|
+
/** Currently authenticated client (null if not logged in). */
|
|
451
|
+
get client(): CubeSignerClient | null;
|
|
452
|
+
get currentSession(): CubeSignerSession | null;
|
|
453
|
+
/**
|
|
454
|
+
* Login with a Google ID token (JWT).
|
|
455
|
+
* The token is used directly as the OIDC credential.
|
|
456
|
+
*/
|
|
457
|
+
loginWithGoogle(idToken: string): Promise<CubeSignerSession>;
|
|
458
|
+
/**
|
|
459
|
+
* Login with a Twitter OAuth 2.0 authorization code.
|
|
460
|
+
*
|
|
461
|
+
* 1. Exchange the code for an OIDC `id_token` via CubeSigner's
|
|
462
|
+
* `/v0/org/{org_id}/oauth2/twitter` endpoint.
|
|
463
|
+
* 2. Create a CubeSigner session with that token.
|
|
464
|
+
*/
|
|
465
|
+
loginWithTwitter(params: TwitterCodeExchangeParams): Promise<CubeSignerSession>;
|
|
466
|
+
signOut(): Promise<void>;
|
|
467
|
+
/**
|
|
468
|
+
* Restore a CubeSigner session from previously persisted SessionData.
|
|
469
|
+
* Useful for reconnecting after page reload without re-authentication.
|
|
470
|
+
*/
|
|
471
|
+
restoreSession(sessionData: SessionData): Promise<CubeSignerSession>;
|
|
472
|
+
private authenticateWithOidcToken;
|
|
473
|
+
/**
|
|
474
|
+
* Exchange a Twitter authorization code for an OIDC id_token
|
|
475
|
+
* via CubeSigner's dedicated endpoint.
|
|
476
|
+
*
|
|
477
|
+
* `POST {SignerApiRoot}/v0/org/{org_id}/oauth2/twitter`
|
|
478
|
+
*/
|
|
479
|
+
private exchangeTwitterCode;
|
|
480
|
+
/**
|
|
481
|
+
* Create a CubeSigner OIDC session from a generic OIDC id_token.
|
|
482
|
+
*/
|
|
483
|
+
private createOidcSession;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
type CubistLoginMethod = {
|
|
487
|
+
type: "google";
|
|
488
|
+
idToken: string;
|
|
489
|
+
} | {
|
|
490
|
+
type: "twitter";
|
|
491
|
+
params: TwitterCodeExchangeParams;
|
|
492
|
+
};
|
|
493
|
+
interface CubistSessionAdapter {
|
|
494
|
+
/**
|
|
495
|
+
* Convert a raw CubeSigner session into a WalletSession
|
|
496
|
+
* (resolve the first key's address, chain, build a provider, etc.).
|
|
497
|
+
*/
|
|
498
|
+
resolve(session: CubeSignerSession): Promise<WalletSession>;
|
|
499
|
+
}
|
|
500
|
+
declare class CubistSocialProvider extends AbstractSocialProvider {
|
|
501
|
+
readonly id = "cubist";
|
|
502
|
+
readonly title = "Cubist Social Wallet";
|
|
503
|
+
private auth;
|
|
504
|
+
private adapter;
|
|
505
|
+
private lastCubeSignerSession;
|
|
506
|
+
/** Stash the login method so `connect()` can auto-retry. */
|
|
507
|
+
private lastLogin;
|
|
508
|
+
constructor(config: CubeSignerConfig, adapter?: CubistSessionAdapter);
|
|
509
|
+
private createWalletSession;
|
|
510
|
+
private authenticate;
|
|
511
|
+
private getResolvedLoginMethod;
|
|
512
|
+
/**
|
|
513
|
+
* Preferred explicit sign-in entrypoint.
|
|
514
|
+
*/
|
|
515
|
+
signInWith(method: CubistLoginMethod, _options?: SocialLoginOptions): Promise<void>;
|
|
516
|
+
/**
|
|
517
|
+
* Backward-compatible abstract implementation.
|
|
518
|
+
*
|
|
519
|
+
* - If `payload` is provided, it is treated as the login method.
|
|
520
|
+
* - Otherwise reuses the previously cached login method if available.
|
|
521
|
+
*/
|
|
522
|
+
signIn(_options?: SocialLoginOptions, payload?: unknown): Promise<void>;
|
|
523
|
+
/**
|
|
524
|
+
* Explicit connect flow that both authenticates and returns the wallet session.
|
|
525
|
+
*/
|
|
526
|
+
connectWith(method: CubistLoginMethod, options?: SocialLoginOptions): Promise<WalletSession>;
|
|
527
|
+
connect(args?: WalletConnectArgs): Promise<WalletSession>;
|
|
528
|
+
reconnect(persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
529
|
+
signOut(): Promise<void>;
|
|
530
|
+
disconnect(): Promise<void>;
|
|
531
|
+
/** Direct access to the underlying CubeSignerAuth for advanced use-cases. */
|
|
532
|
+
get cubeSignerAuth(): CubeSignerAuth;
|
|
533
|
+
get cubeSignerSession(): CubeSignerSession | null;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export { AbstractProvider, AbstractSocialProvider, type BalanceInfo, BitgetProvider, BraveWalletProvider, type ChainContext, type ChainDescriptor, type ChainNamespace, type ChainRpcFamily, CoinbaseWalletProvider, CubeSignerAuth, type CubeSignerConfig, type CubeSignerSession, type CubistLoginMethod, type CubistSessionAdapter, CubistSocialProvider, type EIP6963ProviderDetail, type EIP6963ProviderInfo, EVM_TRANSACTION_SIGNING_UNSUPPORTED, type EvmAccessListItem, type EvmQuantity, type EvmTransactionRequest, EvmTransactionSigningUnsupportedError, type InjectedEthereumProvider, InjectedEvmProvider, type InjectedWalletConfig, type InjectedWalletRegistryItem, MetaMaskProvider, OKXProvider, type OidcLoginHooks, PhantomProvider, type ProviderCategory, RabbyProvider, RainbowProvider, type SessionCapabilityCheck, SessionCapabilityError, type SessionCapabilityPolicy, SessionStore, type SocialConnectArgs, type SocialLoginOptions, type SupportedChain, type SupportedToken, TrustWalletProvider, type TwitterCodeExchangeParams, type WalletAdapter, type WalletAuthSource, type WalletCapability, type WalletConnectArgs, type WalletConnectControllerOptions, WalletConnector, type WalletEvents, type WalletExecutionClient, type WalletProvider, type WalletProviderRequest, type WalletSession, type WalletState, type WalletType, ZerionProvider, assertSessionCapability, createAccountController, createChainContext, createDefaultInjectedWalletRegistry, createSessionCapabilityPolicy, createWalletConnectController, createWalletExecutionClient, createWalletExecutionController, describeSessionCapabilityPolicy, discoverEIP6963Providers, findEIP6963Provider, findInjectedProvider, getAllChainDescriptors, getChainDescriptor, getSupportedChainFromEvmChainId, getWalletExecutionCapabilities, isCapabilityPolicyExpired, isSessionExpired, isUnsupportedEvmTransactionSigningError, normalizeEvmTransactionSigningError, sessionStore, sessionSupportsCapability, switchToFallbackFundingChain };
|