@dexterai/connect 0.29.0 → 0.31.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 +134 -0
- package/dist/{chunk-XKOVUW5P.js → chunk-4FTJB7FT.js} +591 -636
- package/dist/chunk-WHGR5FUY.js +316 -0
- package/dist/chunk-Z6YHGWG3.js +618 -0
- package/dist/connectionContract-BzV_pjOI.d.ts +239 -0
- package/dist/enroll-BmD1y8KH.d.ts +276 -0
- package/dist/hosted.d.ts +79 -0
- package/dist/hosted.js +101 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.js +20 -182
- package/dist/react.d.ts +76 -4
- package/dist/react.js +596 -50
- package/package.json +7 -2
- package/dist/connectionContract-QGRidIHM.d.ts +0 -470
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { P as PasskeyLoginTokens, r as PasskeyLoginConfig, a as CeremonyPhase, S as SignInResult } from './enroll-BmD1y8KH.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Framework-neutral Wallet/account relationship controller.
|
|
5
|
+
*
|
|
6
|
+
* Browser presence is insufficient to establish a bound identity. The injected
|
|
7
|
+
* verifier is the only path to `bound` or `conflict`; every local identity
|
|
8
|
+
* change immediately falls back to a provisional relation while verification
|
|
9
|
+
* runs. Candidate objects should be immutable for the duration of a check.
|
|
10
|
+
*/
|
|
11
|
+
type WalletAccountRelation = 'none' | 'wallet_only' | 'account_only' | 'bound' | 'conflict';
|
|
12
|
+
type RelationCheckReason = 'restore' | 'wallet_change' | 'account_change' | 'retry';
|
|
13
|
+
type RelationRuntime = {
|
|
14
|
+
readonly phase: 'hydrating';
|
|
15
|
+
} | {
|
|
16
|
+
readonly phase: 'checking';
|
|
17
|
+
readonly reason: RelationCheckReason;
|
|
18
|
+
} | {
|
|
19
|
+
readonly phase: 'ready';
|
|
20
|
+
} | {
|
|
21
|
+
readonly phase: 'offline';
|
|
22
|
+
} | {
|
|
23
|
+
readonly phase: 'expired';
|
|
24
|
+
readonly subject: 'wallet' | 'account' | 'both';
|
|
25
|
+
} | {
|
|
26
|
+
readonly phase: 'error';
|
|
27
|
+
readonly code: string;
|
|
28
|
+
};
|
|
29
|
+
interface WalletAccountRelationSnapshot {
|
|
30
|
+
readonly relation: WalletAccountRelation;
|
|
31
|
+
readonly runtime: RelationRuntime;
|
|
32
|
+
readonly walletPresent: boolean;
|
|
33
|
+
readonly accountPresent: boolean;
|
|
34
|
+
/** Account-scoped data and actions stay locked unless the server verified the pair. */
|
|
35
|
+
readonly privateAccountAccess: boolean;
|
|
36
|
+
/** A verified mismatch. Consumers should expose only their repair path. */
|
|
37
|
+
readonly quarantined: boolean;
|
|
38
|
+
readonly verifiedAt: number | null;
|
|
39
|
+
readonly revision: number;
|
|
40
|
+
}
|
|
41
|
+
type ServerRelationVerificationResult = {
|
|
42
|
+
readonly ok: true;
|
|
43
|
+
readonly relation: 'bound' | 'conflict';
|
|
44
|
+
readonly verifiedAt?: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly ok: false;
|
|
47
|
+
readonly reason: 'offline';
|
|
48
|
+
} | {
|
|
49
|
+
readonly ok: false;
|
|
50
|
+
readonly reason: 'expired';
|
|
51
|
+
readonly subject: 'wallet' | 'account' | 'both';
|
|
52
|
+
} | {
|
|
53
|
+
readonly ok: false;
|
|
54
|
+
readonly reason: 'error';
|
|
55
|
+
readonly code: string;
|
|
56
|
+
};
|
|
57
|
+
interface ServerRelationVerificationRequest<TWallet, TAccount> {
|
|
58
|
+
readonly wallet: TWallet;
|
|
59
|
+
readonly account: TAccount;
|
|
60
|
+
readonly reason: RelationCheckReason;
|
|
61
|
+
readonly signal: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
type ServerRelationVerifier<TWallet, TAccount> = (request: ServerRelationVerificationRequest<TWallet, TAccount>) => Promise<ServerRelationVerificationResult>;
|
|
64
|
+
interface WalletAccountRelationControllerOptions<TWallet, TAccount> {
|
|
65
|
+
/**
|
|
66
|
+
* Call the Dexter API with proof for both candidates. Local equality checks
|
|
67
|
+
* are not verification and must not be substituted here.
|
|
68
|
+
*/
|
|
69
|
+
readonly verify: ServerRelationVerifier<TWallet, TAccount>;
|
|
70
|
+
readonly now?: () => number;
|
|
71
|
+
}
|
|
72
|
+
interface RelationCandidates<TWallet, TAccount> {
|
|
73
|
+
readonly wallet: TWallet | null;
|
|
74
|
+
readonly account: TAccount | null;
|
|
75
|
+
}
|
|
76
|
+
type Listener = (snapshot: WalletAccountRelationSnapshot) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Owns relationship state without owning storage, HTTP, React, or credentials.
|
|
79
|
+
* Consumers feed it Wallet/account candidates and provide the API verifier.
|
|
80
|
+
*/
|
|
81
|
+
declare class WalletAccountRelationController<TWallet, TAccount> {
|
|
82
|
+
private wallet;
|
|
83
|
+
private account;
|
|
84
|
+
private revision;
|
|
85
|
+
private activeCheck;
|
|
86
|
+
private readonly listeners;
|
|
87
|
+
private readonly verify;
|
|
88
|
+
private readonly now;
|
|
89
|
+
private snapshot;
|
|
90
|
+
constructor(options: WalletAccountRelationControllerOptions<TWallet, TAccount>);
|
|
91
|
+
getSnapshot(): WalletAccountRelationSnapshot;
|
|
92
|
+
subscribe(listener: Listener): () => void;
|
|
93
|
+
/** Restore cached candidates, then verify the exact pair before unlocking account access. */
|
|
94
|
+
restore(candidates: RelationCandidates<TWallet, TAccount>): Promise<WalletAccountRelationSnapshot>;
|
|
95
|
+
/** Lock account-owned data while the host restores its account session. */
|
|
96
|
+
beginRestore(): void;
|
|
97
|
+
/** An explicit Wallet event always invalidates prior binding, even for the same object. */
|
|
98
|
+
setWallet(wallet: TWallet | null): Promise<WalletAccountRelationSnapshot>;
|
|
99
|
+
/** An explicit account event always invalidates prior binding, even for the same object. */
|
|
100
|
+
setAccount(account: TAccount | null): Promise<WalletAccountRelationSnapshot>;
|
|
101
|
+
retry(): Promise<WalletAccountRelationSnapshot>;
|
|
102
|
+
dispose(): void;
|
|
103
|
+
private runtimeAfterChange;
|
|
104
|
+
private replaceCandidates;
|
|
105
|
+
private invalidate;
|
|
106
|
+
private settle;
|
|
107
|
+
private runCheck;
|
|
108
|
+
private isCurrentCheck;
|
|
109
|
+
private publish;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare const WALLET_ACCOUNT_BINDING_PATH = "/api/passkey-anon/binding/resolve";
|
|
113
|
+
type ResolvedWalletAccountRelation = 'wallet_only' | 'account_only' | 'bound' | 'conflict';
|
|
114
|
+
declare const walletBindingCandidateBrand: unique symbol;
|
|
115
|
+
declare const accountBindingCandidateBrand: unique symbol;
|
|
116
|
+
/** Opaque bearer for a server-issued Dexter Wallet identity proof. */
|
|
117
|
+
interface WalletBindingCandidate {
|
|
118
|
+
readonly kind: 'dexter_wallet_identity_proof';
|
|
119
|
+
readonly [walletBindingCandidateBrand]: true;
|
|
120
|
+
}
|
|
121
|
+
/** The exact active Wallet selected by the consumer for this relation check. */
|
|
122
|
+
interface ActiveWalletBindingIdentity {
|
|
123
|
+
readonly userHandle: string;
|
|
124
|
+
readonly vaultPda: string;
|
|
125
|
+
}
|
|
126
|
+
/** Opaque bearer for an authenticated Dexter account session. */
|
|
127
|
+
interface AccountBindingCandidate {
|
|
128
|
+
readonly kind: 'dexter_account_session';
|
|
129
|
+
readonly [accountBindingCandidateBrand]: true;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Wrap a Wallet proof before giving it to the relationship controller. The
|
|
133
|
+
* proof stays outside enumerable object properties, JSON, and snapshots.
|
|
134
|
+
*/
|
|
135
|
+
declare function walletBindingCandidate(identityProof: string, activeWallet: ActiveWalletBindingIdentity): WalletBindingCandidate;
|
|
136
|
+
/**
|
|
137
|
+
* Wrap an account access token before giving it to the relationship controller.
|
|
138
|
+
* The token stays outside enumerable object properties, JSON, and snapshots.
|
|
139
|
+
*/
|
|
140
|
+
declare function accountBindingCandidate(accessToken: string): AccountBindingCandidate;
|
|
141
|
+
type BindingResolutionResult = {
|
|
142
|
+
readonly ok: true;
|
|
143
|
+
readonly relation: ResolvedWalletAccountRelation;
|
|
144
|
+
} | {
|
|
145
|
+
readonly ok: false;
|
|
146
|
+
readonly reason: 'offline';
|
|
147
|
+
} | {
|
|
148
|
+
readonly ok: false;
|
|
149
|
+
readonly reason: 'expired';
|
|
150
|
+
readonly subject: 'wallet' | 'account' | 'both';
|
|
151
|
+
} | {
|
|
152
|
+
readonly ok: false;
|
|
153
|
+
readonly reason: 'error';
|
|
154
|
+
readonly code: string;
|
|
155
|
+
};
|
|
156
|
+
interface ResolveWalletAccountBindingInput {
|
|
157
|
+
readonly wallet?: WalletBindingCandidate | null;
|
|
158
|
+
readonly account?: AccountBindingCandidate | null;
|
|
159
|
+
readonly signal?: AbortSignal;
|
|
160
|
+
}
|
|
161
|
+
type BindingFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
162
|
+
interface WalletIdentityFetchInput {
|
|
163
|
+
readonly wallet: WalletBindingCandidate;
|
|
164
|
+
readonly activeWallet: ActiveWalletBindingIdentity;
|
|
165
|
+
readonly url: string | URL;
|
|
166
|
+
readonly init?: RequestInit;
|
|
167
|
+
readonly fetch?: BindingFetch;
|
|
168
|
+
}
|
|
169
|
+
/** Send the retained identity proof to Dexter without exposing its token.
|
|
170
|
+
* Identity permits wallet reads; each financial action still requires its
|
|
171
|
+
* own authorization. Redirects cannot forward the proof to another origin. */
|
|
172
|
+
declare function fetchWithWalletIdentity(input: WalletIdentityFetchInput): Promise<Response>;
|
|
173
|
+
interface WalletAccountBindingClientConfig {
|
|
174
|
+
/** Compatibility option; only the canonical Dexter API origin is accepted. */
|
|
175
|
+
readonly apiBase?: string;
|
|
176
|
+
/** Injectable for tests, edge runtimes, and hosts with a custom fetch adapter. */
|
|
177
|
+
readonly fetch?: BindingFetch;
|
|
178
|
+
}
|
|
179
|
+
interface WalletAccountBindingClient {
|
|
180
|
+
resolve(input: ResolveWalletAccountBindingInput): Promise<BindingResolutionResult>;
|
|
181
|
+
readonly verify: ServerRelationVerifier<WalletBindingCandidate, AccountBindingCandidate>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Create the API adapter that resolves Wallet/account relation from two
|
|
185
|
+
* independently issued proofs. It never compares browser identifiers.
|
|
186
|
+
*/
|
|
187
|
+
declare function createWalletAccountBindingClient(config?: WalletAccountBindingClientConfig): WalletAccountBindingClient;
|
|
188
|
+
|
|
189
|
+
type AccountSessionInstaller = (session: PasskeyLoginTokens) => void | Promise<void>;
|
|
190
|
+
type AccountSessionClearer = () => void | Promise<void>;
|
|
191
|
+
interface ConnectDexterIdentityConfig extends Omit<PasskeyLoginConfig, 'walletStore'> {
|
|
192
|
+
/**
|
|
193
|
+
* Install the account session returned by the same passkey ceremony. Reject
|
|
194
|
+
* without publishing a replacement session if installation fails.
|
|
195
|
+
*/
|
|
196
|
+
readonly installAccountSession: AccountSessionInstaller;
|
|
197
|
+
/** Injectable binding fetch for tests and non-browser hosts. */
|
|
198
|
+
readonly bindingFetch?: BindingFetch;
|
|
199
|
+
}
|
|
200
|
+
interface DisconnectDexterIdentityConfig {
|
|
201
|
+
/** Clear the host account session after Connect drops the active Wallet. */
|
|
202
|
+
readonly clearAccountSession: AccountSessionClearer;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Complete a full Dexter identity transition from one passkey result.
|
|
206
|
+
*
|
|
207
|
+
* The candidate Wallet and account are verified as an exact pair before local
|
|
208
|
+
* state changes. Connect then publishes the Wallet and asks the host to install
|
|
209
|
+
* the matching account session. A rejected install restores the prior Wallet.
|
|
210
|
+
*/
|
|
211
|
+
declare function connectDexterIdentity(config: ConnectDexterIdentityConfig, onPhase?: (phase: CeremonyPhase) => void): Promise<SignInResult>;
|
|
212
|
+
/** Clear the complete browser identity while retaining its device passkey. */
|
|
213
|
+
declare function disconnectDexterIdentity(config: DisconnectDexterIdentityConfig): Promise<boolean>;
|
|
214
|
+
|
|
215
|
+
type DexterConnectionIntent = 'identity' | 'wallet' | 'agent';
|
|
216
|
+
type DexterConnectionCapability = 'identity' | 'wallet.read' | 'wallet.use' | 'agent.authority';
|
|
217
|
+
type DexterControlStage = 'connect' | 'checking' | 'ready' | 'repair' | 'offline' | 'error';
|
|
218
|
+
type DexterControlPrimaryAction = 'connect' | 'use_another_wallet' | 'retry' | 'repair';
|
|
219
|
+
interface DexterConnectionPermissions {
|
|
220
|
+
readonly capabilities: readonly DexterConnectionCapability[];
|
|
221
|
+
readonly walletIdentityVisible: boolean;
|
|
222
|
+
readonly walletDataVisible: boolean;
|
|
223
|
+
readonly ownerWalletUseEnabled: boolean;
|
|
224
|
+
readonly accountContentVisible: boolean;
|
|
225
|
+
readonly agentAuthorityVisible: boolean;
|
|
226
|
+
}
|
|
227
|
+
interface DexterControlModel {
|
|
228
|
+
readonly intent: DexterConnectionIntent;
|
|
229
|
+
readonly stage: DexterControlStage;
|
|
230
|
+
readonly primaryAction: DexterControlPrimaryAction;
|
|
231
|
+
readonly permissions: DexterConnectionPermissions;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Produce the display and permission contract for the canonical Dexter control.
|
|
235
|
+
* Account-owned content is available only after the API verifies `bound`.
|
|
236
|
+
*/
|
|
237
|
+
declare function createDexterControlModel(intent: DexterConnectionIntent, relation: WalletAccountRelationSnapshot): DexterControlModel;
|
|
238
|
+
|
|
239
|
+
export { type ActiveWalletBindingIdentity as A, type BindingFetch as B, type ConnectDexterIdentityConfig as C, type DexterConnectionCapability as D, createDexterControlModel as E, createWalletAccountBindingClient as F, disconnectDexterIdentity as G, fetchWithWalletIdentity as H, walletBindingCandidate as I, type RelationCandidates as R, type ServerRelationVerificationRequest as S, type WalletBindingCandidate as W, type WalletAccountRelationSnapshot as a, type WalletAccountBindingClient as b, type AccountBindingCandidate as c, type AccountSessionClearer as d, type AccountSessionInstaller as e, type BindingResolutionResult as f, type DexterConnectionIntent as g, type DexterConnectionPermissions as h, type DexterControlModel as i, type DexterControlPrimaryAction as j, type DexterControlStage as k, type DisconnectDexterIdentityConfig as l, type RelationCheckReason as m, type RelationRuntime as n, type ResolveWalletAccountBindingInput as o, type ResolvedWalletAccountRelation as p, type ServerRelationVerificationResult as q, type ServerRelationVerifier as r, WALLET_ACCOUNT_BINDING_PATH as s, type WalletAccountBindingClientConfig as t, type WalletAccountRelation as u, WalletAccountRelationController as v, type WalletAccountRelationControllerOptions as w, type WalletIdentityFetchInput as x, accountBindingCandidate as y, connectDexterIdentity as z };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/** Supabase session tokens returned by dexter-api's passkey-login (camelCase). */
|
|
2
|
+
interface PasskeyLoginTokens {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
refreshToken: string;
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
expiresIn: number;
|
|
7
|
+
tokenType: string;
|
|
8
|
+
}
|
|
9
|
+
/** Dexter-signed Wallet identity proof returned by a completed passkey ceremony. */
|
|
10
|
+
interface WalletIdentityProof {
|
|
11
|
+
token: string;
|
|
12
|
+
tokenType: 'Bearer';
|
|
13
|
+
/** Epoch seconds. */
|
|
14
|
+
expiresAt: number;
|
|
15
|
+
/** Lifetime in seconds. */
|
|
16
|
+
expiresIn: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Wallet identity returned alongside the account session by passkey login.
|
|
20
|
+
* `vaultPda` and `publicKey` are required by the passkey signer.
|
|
21
|
+
*/
|
|
22
|
+
interface ConnectVault {
|
|
23
|
+
vaultPda: string;
|
|
24
|
+
/** Swig state address, base58 — the user-facing Dexter Wallet address. */
|
|
25
|
+
swigAddress: string;
|
|
26
|
+
/** v2 swig wallet PDA (deposit address); null until the swig is deployed. */
|
|
27
|
+
receiveAddress: string | null;
|
|
28
|
+
/** Swig wallet's USDC ATA, base58 (for the connected-chip balance read);
|
|
29
|
+
* null until the swig is deployed. Server-resolved (off-curve-safe). */
|
|
30
|
+
usdcAta: string | null;
|
|
31
|
+
/** base64 33-byte SEC1 compressed P-256 authority pubkey (for the signer). */
|
|
32
|
+
publicKey: string;
|
|
33
|
+
userHandle: string;
|
|
34
|
+
credentialId: string;
|
|
35
|
+
/** The wallet's cross-device display name (user-authored via rename), or
|
|
36
|
+
* null when never named. Identity is first-class: every sign-in carries
|
|
37
|
+
* the human name so no consumer ever falls back to a synthetic email.
|
|
38
|
+
* Optional for wire-compat with servers/popup pages predating 0.23. */
|
|
39
|
+
walletLabel?: string | null;
|
|
40
|
+
}
|
|
41
|
+
/** Result of a completed "Sign in with Dexter" ceremony. */
|
|
42
|
+
interface SignInResult {
|
|
43
|
+
session: PasskeyLoginTokens;
|
|
44
|
+
vault: ConnectVault;
|
|
45
|
+
walletIdentityProof: WalletIdentityProof;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Coarse ceremony phase, emitted as a sign-in/create ceremony progresses so the
|
|
49
|
+
* UI can show live "connecting steps" instead of one flat spinner:
|
|
50
|
+
* challenge → passkey (the OS prompt) → verifying → finalizing (create only).
|
|
51
|
+
*/
|
|
52
|
+
type CeremonyPhase = 'challenge' | 'passkey' | 'verifying' | 'finalizing';
|
|
53
|
+
/**
|
|
54
|
+
* Controls whether a successful sign-in/recovery immediately changes the
|
|
55
|
+
* browser's active-wallet store.
|
|
56
|
+
*
|
|
57
|
+
* `commit` preserves the historical SDK behavior. `provisional` returns the
|
|
58
|
+
* verified session and Wallet without changing the browser's active Wallet.
|
|
59
|
+
* The canonical identity transition uses it until the exact Wallet/account
|
|
60
|
+
* pair has been verified.
|
|
61
|
+
*/
|
|
62
|
+
type WalletStoreMode = 'commit' | 'provisional';
|
|
63
|
+
/**
|
|
64
|
+
* Controls whether wallet creation also asks the owner to configure an agent
|
|
65
|
+
* spending allowance.
|
|
66
|
+
*
|
|
67
|
+
* `deferred` creates the wallet for its owner. `configure-now` is the explicit
|
|
68
|
+
* compatibility path for a caller that has already collected an agent
|
|
69
|
+
* spending allowance.
|
|
70
|
+
*/
|
|
71
|
+
type AgentDelegationMode = 'configure-now' | 'deferred';
|
|
72
|
+
/** Exact action the hosted Dexter consent window is being asked to perform. */
|
|
73
|
+
type CeremonyOperation = 'signin' | 'create' | 'continue' | 'recover' | 'sign' | 'recover-missing-vault';
|
|
74
|
+
/** Minimal vault identity transferred to Dexter's hosted signing window. */
|
|
75
|
+
interface HostedSignVaultIdentity {
|
|
76
|
+
vaultPda: string;
|
|
77
|
+
publicKey: string;
|
|
78
|
+
userHandle: string;
|
|
79
|
+
credentialId: string;
|
|
80
|
+
walletLabel?: string | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Sensitive signing input. This is structured-cloned to the pinned Dexter
|
|
84
|
+
* popup only after the browser-stamped hello/ack; it is never serialized into
|
|
85
|
+
* the popup URL.
|
|
86
|
+
*/
|
|
87
|
+
interface HostedSignRequestPayload {
|
|
88
|
+
operationMessage: Uint8Array;
|
|
89
|
+
vault: HostedSignVaultIdentity;
|
|
90
|
+
}
|
|
91
|
+
/** On-chain-ready assertion bytes returned by the hosted Dexter popup. */
|
|
92
|
+
interface HostedSignResult {
|
|
93
|
+
signature: Uint8Array;
|
|
94
|
+
clientDataJSON: Uint8Array;
|
|
95
|
+
authenticatorData: Uint8Array;
|
|
96
|
+
}
|
|
97
|
+
/** Durable account identity selected by the authenticated recovery API. */
|
|
98
|
+
interface MissingVaultRecoveryAccount {
|
|
99
|
+
provider: 'x';
|
|
100
|
+
/** Canonical X handle, including the leading @. */
|
|
101
|
+
handle: string;
|
|
102
|
+
}
|
|
103
|
+
/** Vault row attached to the already-authenticated account after recovery. */
|
|
104
|
+
interface MissingVaultRecoveryVault {
|
|
105
|
+
vaultPda: string;
|
|
106
|
+
swigAddress: string;
|
|
107
|
+
receiveAddress: string;
|
|
108
|
+
userHandle: string;
|
|
109
|
+
credentialId: string;
|
|
110
|
+
state: 'initialized';
|
|
111
|
+
}
|
|
112
|
+
/** Result of explicitly repairing an account whose passkey exists without its Vault row. */
|
|
113
|
+
interface MissingVaultRecoveryResult {
|
|
114
|
+
recovered: true;
|
|
115
|
+
alreadyRecovered: boolean;
|
|
116
|
+
relation: 'bound';
|
|
117
|
+
account: MissingVaultRecoveryAccount;
|
|
118
|
+
vault: MissingVaultRecoveryVault;
|
|
119
|
+
}
|
|
120
|
+
interface MissingVaultRecoveryConfig {
|
|
121
|
+
/** Supabase access token for the existing account being repaired. */
|
|
122
|
+
accountAccessToken: string;
|
|
123
|
+
/** Compatibility-only API base; omitted or exactly https://api.dexter.cash. */
|
|
124
|
+
apiBase?: string;
|
|
125
|
+
/** Compatibility-only hosted page; omitted or exactly https://dexter.cash/connect. */
|
|
126
|
+
connectHost?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Vault identity on the wallet-only recover leg, as reported by
|
|
130
|
+
* /api/passkey-vault-anon/status. Narrower than ConnectVault on purpose —
|
|
131
|
+
* the status endpoint carries no publicKey/usdcAta, so a recover cannot
|
|
132
|
+
* construct a passkey signer; it only restores the browser Wallet candidate.
|
|
133
|
+
*/
|
|
134
|
+
interface RecoverVault {
|
|
135
|
+
vaultPda: string;
|
|
136
|
+
/** Swig state address, base58 — the user-facing Dexter Wallet address. */
|
|
137
|
+
swigAddress: string;
|
|
138
|
+
/** Deposit address; null until the swig is deployed. */
|
|
139
|
+
receiveAddress: string | null;
|
|
140
|
+
isActivated: boolean;
|
|
141
|
+
walletLabel: string | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Result of a wallet-only recover ceremony. A discriminated RESULT, not a
|
|
145
|
+
* throw: user-cancel is a normal outcome in WebAuthn, and consumers branch on
|
|
146
|
+
* `reason` (no_credential → offer create; cancelled → stay silent; error →
|
|
147
|
+
* retry copy). `no_credential` covers both the immediate-mode instant
|
|
148
|
+
* rejection (no passkey on this device) and a verify 404 (a passkey the
|
|
149
|
+
* server has no row for).
|
|
150
|
+
*/
|
|
151
|
+
type RecoverOutcome = {
|
|
152
|
+
ok: true;
|
|
153
|
+
userHandle: string;
|
|
154
|
+
credentialId: string;
|
|
155
|
+
vault: RecoverVault;
|
|
156
|
+
walletIdentityProof: WalletIdentityProof;
|
|
157
|
+
} | {
|
|
158
|
+
ok: false;
|
|
159
|
+
reason: 'no_credential' | 'cancelled' | 'error';
|
|
160
|
+
error?: ConnectError;
|
|
161
|
+
};
|
|
162
|
+
interface RecoverWalletConfig extends DexterConnectConfig {
|
|
163
|
+
/** Chrome-149+ immediate UI mode: instant fast-fail when this device has no
|
|
164
|
+
* discoverable passkey (no empty account-picker sheet). Falls back to the
|
|
165
|
+
* normal modal wherever unsupported. */
|
|
166
|
+
preferImmediate?: boolean;
|
|
167
|
+
/** See `PasskeyLoginConfig.walletStore`. */
|
|
168
|
+
walletStore?: WalletStoreMode;
|
|
169
|
+
onPhase?: (phase: CeremonyPhase) => void;
|
|
170
|
+
}
|
|
171
|
+
/** Configuration for `passkeyLogin`. */
|
|
172
|
+
interface PasskeyLoginConfig extends DexterConnectConfig {
|
|
173
|
+
/**
|
|
174
|
+
* Wallet-store behavior after a successful passkey ceremony. Defaults to
|
|
175
|
+
* `commit` for backward compatibility. Use `provisional` when the returned
|
|
176
|
+
* wallet must pass a separate approval before becoming active.
|
|
177
|
+
*/
|
|
178
|
+
walletStore?: WalletStoreMode;
|
|
179
|
+
}
|
|
180
|
+
interface DexterConnectConfig {
|
|
181
|
+
/**
|
|
182
|
+
* Compatibility-only Dexter API base. Omit it or pass exactly
|
|
183
|
+
* https://api.dexter.cash. Noncanonical values fail before WebAuthn and this
|
|
184
|
+
* value is never propagated into the hosted popup.
|
|
185
|
+
*/
|
|
186
|
+
apiBase?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Where the WebAuthn ceremony runs:
|
|
189
|
+
* - 'auto' (default): inline on the canonical Dexter origin (dexter.cash),
|
|
190
|
+
* popup on ANY other origin — so a third-party site works without the
|
|
191
|
+
* WebAuthn rpId-origin problem (in-page only works on dexter.cash).
|
|
192
|
+
* - 'popup': always via the hosted popup (works on any website).
|
|
193
|
+
* - 'inline': always in-page — only valid on a Dexter origin; this is what
|
|
194
|
+
* the hosted ceremony page itself uses.
|
|
195
|
+
*/
|
|
196
|
+
transport?: 'auto' | 'popup' | 'inline';
|
|
197
|
+
/** Hosted ceremony page (popup transport). Default https://dexter.cash/connect. */
|
|
198
|
+
connectHost?: string;
|
|
199
|
+
}
|
|
200
|
+
/** Typed error whose `code` is the server's snake_case error string. */
|
|
201
|
+
declare class ConnectError extends Error {
|
|
202
|
+
readonly code: string;
|
|
203
|
+
constructor(code: string, message?: string);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Consent-at-birth allowance (Branch rulings 2026-07-02/03).
|
|
207
|
+
* The user authors the number; zero is not consent; TTL is fixed 30d and
|
|
208
|
+
* never user-editable; no caller may invent a default. */
|
|
209
|
+
declare const SESSION_TTL_30D = "2592000";
|
|
210
|
+
interface SpendPolicy {
|
|
211
|
+
/** Role-2 allowance, atomic USDC (6dp), decimal string. User-authored. */
|
|
212
|
+
spendLimitAtomic: string;
|
|
213
|
+
/** Fixed 30d. Present for wire compatibility; always SESSION_TTL_30D. */
|
|
214
|
+
sessionTtlSeconds: string;
|
|
215
|
+
}
|
|
216
|
+
/** Parse user-entered USD ("5", "$20", "1,000", "20.5") to atomic USDC.
|
|
217
|
+
* Null on anything invalid — callers must not invent a fallback. */
|
|
218
|
+
declare function usdToAtomic(input: string): bigint | null;
|
|
219
|
+
/** Null when invalid or zero (zero is not consent). */
|
|
220
|
+
declare function authoredPolicy(usdInput: string): SpendPolicy | null;
|
|
221
|
+
|
|
222
|
+
interface CreateWalletConfig extends DexterConnectConfig {
|
|
223
|
+
/**
|
|
224
|
+
* Wallet-store behavior after successful creation. Defaults to `commit` for
|
|
225
|
+
* backward compatibility. Use `provisional` when the created wallet must
|
|
226
|
+
* pass a separate approval before becoming active.
|
|
227
|
+
*/
|
|
228
|
+
walletStore?: WalletStoreMode;
|
|
229
|
+
/** Label for the passkey in the OS keychain AND the wallet roster. Set at
|
|
230
|
+
* creation — the only moment naming is guaranteed to stick. Default "Dexter Wallet". */
|
|
231
|
+
name?: string;
|
|
232
|
+
/** RP id for the new credential. Default "dexter.cash". */
|
|
233
|
+
rpId?: string;
|
|
234
|
+
/** Consent-at-birth allowance the user authored at creation (chips $5/$20/$50
|
|
235
|
+
* or Custom; zero is not consent; build it with authoredPolicy()). When
|
|
236
|
+
* present it rides the /initialize body so the number becomes the server-side
|
|
237
|
+
* write-once consent record. The TTL is ruled fixed 30d — whatever the object
|
|
238
|
+
* carries, the wire always sends SESSION_TTL_30D. Absent → no policy authored
|
|
239
|
+
* (the vault initializes without one; nothing invents a default). */
|
|
240
|
+
spendPolicy?: SpendPolicy;
|
|
241
|
+
/**
|
|
242
|
+
* When agent authority is configured. The default, `deferred`, creates the
|
|
243
|
+
* wallet without an agent allowance. `configure-now` is an explicit
|
|
244
|
+
* compatibility path for callers that have already collected a
|
|
245
|
+
* `spendPolicy`. A deferred creation must not also carry a `spendPolicy`.
|
|
246
|
+
*/
|
|
247
|
+
agentDelegation?: AgentDelegationMode;
|
|
248
|
+
/** Called as the ceremony progresses, for live "connecting steps" UI:
|
|
249
|
+
* challenge → passkey → verifying → finalizing. */
|
|
250
|
+
onPhase?: (phase: CeremonyPhase) => void;
|
|
251
|
+
}
|
|
252
|
+
interface CreateWalletResult {
|
|
253
|
+
/** Server-minted 16-byte user handle, base64url — the vault identity. */
|
|
254
|
+
handle: string;
|
|
255
|
+
/** base64url credential id of the new passkey. */
|
|
256
|
+
credentialId: string;
|
|
257
|
+
/** The freshly initialized vault (swig not yet deployed; deploys lazily). */
|
|
258
|
+
vault: ConnectVault;
|
|
259
|
+
/** Wallet name recorded at birth (server-confirmed via /initialize). Rides
|
|
260
|
+
* the result so a popup-typed name reaches the OPENER's wallet store —
|
|
261
|
+
* before 0.23.2 it lived only on the popup origin. null = unnamed. */
|
|
262
|
+
label: string | null;
|
|
263
|
+
/** Dexter-signed proof used to restore this Wallet's account relationship. */
|
|
264
|
+
walletIdentityProof: WalletIdentityProof;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Mint a brand-new Dexter wallet (passkey + vault). Commit mode (the default)
|
|
268
|
+
* makes it active immediately; provisional mode returns it without changing
|
|
269
|
+
* the active-wallet store.
|
|
270
|
+
*
|
|
271
|
+
* One passkey approval. Throws ConnectError on any failed leg (the `code` is the
|
|
272
|
+
* server's error string, or webauthn_failed / no_credential for the ceremony).
|
|
273
|
+
*/
|
|
274
|
+
declare function createWallet(config?: CreateWalletConfig): Promise<CreateWalletResult>;
|
|
275
|
+
|
|
276
|
+
export { type AgentDelegationMode as A, type CreateWalletResult as C, type DexterConnectConfig as D, type HostedSignRequestPayload as H, type MissingVaultRecoveryConfig as M, type PasskeyLoginTokens as P, type RecoverOutcome as R, type SignInResult as S, type WalletStoreMode as W, type CeremonyPhase as a, type SpendPolicy as b, type MissingVaultRecoveryResult as c, type ConnectVault as d, type RecoverWalletConfig as e, type WalletIdentityProof as f, type CeremonyOperation as g, ConnectError as h, type CreateWalletConfig as i, type HostedSignResult as j, type HostedSignVaultIdentity as k, type MissingVaultRecoveryAccount as l, type MissingVaultRecoveryVault as m, type RecoverVault as n, SESSION_TTL_30D as o, authoredPolicy as p, createWallet as q, type PasskeyLoginConfig as r, usdToAtomic as u };
|
package/dist/hosted.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { S as SignInResult, C as CreateWalletResult, W as WalletStoreMode, a as CeremonyPhase, b as SpendPolicy, R as RecoverOutcome } from './enroll-BmD1y8KH.js';
|
|
2
|
+
import { AuthenticationResponseJSON } from '@simplewebauthn/browser';
|
|
3
|
+
|
|
4
|
+
type ContinueResult = ({
|
|
5
|
+
kind: 'signin';
|
|
6
|
+
} & SignInResult) | ({
|
|
7
|
+
kind: 'create';
|
|
8
|
+
} & CreateWalletResult)
|
|
9
|
+
/** This device has no passkey (proven by an immediate fast-fail) but the
|
|
10
|
+
* caller supplied neither an authored spendPolicy nor explicit deferred
|
|
11
|
+
* agent setup — collect name + allowance, then call createWallet. */
|
|
12
|
+
| {
|
|
13
|
+
kind: 'needs_create';
|
|
14
|
+
}
|
|
15
|
+
/** Cannot silently probe (no immediate support, no local handle): render an
|
|
16
|
+
* explicit "Sign in" / "I'm new" choice. Never guess. */
|
|
17
|
+
| {
|
|
18
|
+
kind: 'needs_choice';
|
|
19
|
+
}
|
|
20
|
+
/** The user dismissed the passkey sheet. Not an error — stay quiet. */
|
|
21
|
+
| {
|
|
22
|
+
kind: 'cancelled';
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The only production browser origin allowed to run an inline Dexter ceremony. */
|
|
26
|
+
declare const DEXTER_HOSTED_CEREMONY_ORIGIN = "https://dexter.cash";
|
|
27
|
+
type HostedCeremonyOperation = 'signin' | 'continue' | 'create' | 'recover';
|
|
28
|
+
type HostedContinueResult = ContinueResult;
|
|
29
|
+
interface HostedCeremonyBase {
|
|
30
|
+
/** Commit to Dexter's host-side Wallet store, or return the Wallet provisionally. */
|
|
31
|
+
walletStore?: WalletStoreMode;
|
|
32
|
+
onPhase?: (phase: CeremonyPhase) => void;
|
|
33
|
+
}
|
|
34
|
+
interface HostedSignInCeremony extends HostedCeremonyBase {
|
|
35
|
+
operation: 'signin';
|
|
36
|
+
}
|
|
37
|
+
type HostedDelegationChoice = {
|
|
38
|
+
agentDelegation: 'configure-now';
|
|
39
|
+
spendPolicy: SpendPolicy;
|
|
40
|
+
} | {
|
|
41
|
+
agentDelegation: 'deferred';
|
|
42
|
+
spendPolicy?: never;
|
|
43
|
+
} | {
|
|
44
|
+
agentDelegation?: undefined;
|
|
45
|
+
spendPolicy?: SpendPolicy;
|
|
46
|
+
};
|
|
47
|
+
type HostedContinueCeremony = HostedCeremonyBase & HostedDelegationChoice & {
|
|
48
|
+
operation: 'continue';
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
51
|
+
type HostedCreateCeremony = HostedCeremonyBase & HostedDelegationChoice & {
|
|
52
|
+
operation: 'create';
|
|
53
|
+
name?: string;
|
|
54
|
+
};
|
|
55
|
+
interface HostedRecoverCeremony extends HostedCeremonyBase {
|
|
56
|
+
operation: 'recover';
|
|
57
|
+
preferImmediate?: boolean;
|
|
58
|
+
}
|
|
59
|
+
type HostedCeremonyRequest = HostedSignInCeremony | HostedContinueCeremony | HostedCreateCeremony | HostedRecoverCeremony;
|
|
60
|
+
type HostedCeremonyResult<O extends HostedCeremonyOperation> = O extends 'signin' ? SignInResult : O extends 'continue' ? HostedContinueResult : O extends 'create' ? CreateWalletResult : RecoverOutcome;
|
|
61
|
+
/**
|
|
62
|
+
* Run one first-party hosted Wallet ceremony.
|
|
63
|
+
*
|
|
64
|
+
* The caller chooses only the operation and host-side persistence behavior.
|
|
65
|
+
* API origin and transport are fixed here so a hosted route cannot drift into
|
|
66
|
+
* a second implementation or accept an opener-controlled credential server.
|
|
67
|
+
*/
|
|
68
|
+
declare function runHostedCeremony(request: HostedSignInCeremony): Promise<SignInResult>;
|
|
69
|
+
declare function runHostedCeremony(request: HostedContinueCeremony): Promise<HostedContinueResult>;
|
|
70
|
+
declare function runHostedCeremony(request: HostedCreateCeremony): Promise<CreateWalletResult>;
|
|
71
|
+
declare function runHostedCeremony(request: HostedRecoverCeremony): Promise<RecoverOutcome>;
|
|
72
|
+
/**
|
|
73
|
+
* Run only the account-bound missing-Vault proof supplied by an opener after
|
|
74
|
+
* the exact popup handshake. API/session binding and completion stay in the
|
|
75
|
+
* opener; this page receives no account token.
|
|
76
|
+
*/
|
|
77
|
+
declare function runHostedMissingVaultRecoveryProof(options: unknown): Promise<AuthenticationResponseJSON>;
|
|
78
|
+
|
|
79
|
+
export { DEXTER_HOSTED_CEREMONY_ORIGIN, type HostedCeremonyOperation, type HostedCeremonyRequest, type HostedCeremonyResult, type HostedContinueCeremony, type HostedContinueResult, type HostedCreateCeremony, type HostedRecoverCeremony, type HostedSignInCeremony, runHostedCeremony, runHostedMissingVaultRecoveryProof };
|