@dexterai/connect 0.31.3 → 0.34.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/dist/hosted.js CHANGED
@@ -1,22 +1,40 @@
1
1
  import {
2
2
  recoverWallet,
3
3
  runHostedMissingVaultRecoveryProof
4
- } from "./chunk-GIEQOIYI.js";
4
+ } from "./chunk-3SBEND6T.js";
5
5
  import {
6
6
  ConnectError,
7
7
  DEXTER_API_BASE,
8
8
  continueWithDexter,
9
9
  createWallet,
10
+ enrollAccountIdentity,
10
11
  passkeyLogin,
11
12
  resolveAgentDelegationMode,
12
- resolveWalletStoreMode
13
- } from "./chunk-IPEINLMT.js";
13
+ resolveWalletStoreMode,
14
+ signInAccountIdentity
15
+ } from "./chunk-Q7HTBUJF.js";
14
16
  import "./chunk-EMCGL64H.js";
15
17
 
16
18
  // src/hosted.ts
17
19
  var DEXTER_HOSTED_CEREMONY_ORIGIN = "https://dexter.cash";
18
20
  async function runHostedCeremony(request) {
19
21
  assertHostedCeremonyOrigin();
22
+ if (request.operation === "account-signin") {
23
+ return signInAccountIdentity({
24
+ apiBase: DEXTER_API_BASE,
25
+ transport: "inline",
26
+ ...request.targetUserHandle === void 0 ? {} : { targetUserHandle: request.targetUserHandle },
27
+ ...request.onPhase === void 0 ? {} : { onPhase: request.onPhase }
28
+ });
29
+ }
30
+ if (request.operation === "account-enroll") {
31
+ return enrollAccountIdentity({
32
+ apiBase: DEXTER_API_BASE,
33
+ transport: "inline",
34
+ ...request.name === void 0 ? {} : { name: request.name },
35
+ ...request.onPhase === void 0 ? {} : { onPhase: request.onPhase }
36
+ });
37
+ }
20
38
  const walletStore = resolveWalletStoreMode(request.walletStore);
21
39
  assertHostedDelegationChoice(request);
22
40
  const persistence = walletStore === "provisional" ? { walletStore } : {};
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as MissingVaultRecoveryConfig, c as MissingVaultRecoveryResult, d as ConnectVault, e as RecoverWalletConfig, R as RecoverOutcome, f as WalletIdentityProof, a as CeremonyPhase } from './enroll-Cqou8Pbi.js';
2
- export { A as AgentDelegationMode, g as CeremonyOperation, h as ConnectError, i as CreateWalletConfig, C as CreateWalletResult, D as DexterConnectConfig, H as HostedSignRequestPayload, j as HostedSignResult, k as HostedSignVaultIdentity, l as MissingVaultRecoveryAccount, m as MissingVaultRecoveryVault, P as PasskeyLoginTokens, n as RecoverVault, o as SESSION_TTL_30D, S as SignInResult, b as SpendPolicy, p as authoredPolicy, q as createWallet, u as usdToAtomic } from './enroll-Cqou8Pbi.js';
1
+ import { M as MissingVaultRecoveryConfig, c as MissingVaultRecoveryResult, d as ConnectVault, e as RecoverWalletConfig, R as RecoverOutcome, A as AccountIdentityResult, f as ConnectError, g as WalletIdentityProof, a as CeremonyPhase } from './accountIdentity-DQ_C-WAi.js';
2
+ export { h as ACCOUNT_IDENTITY_API_PATH, i as AccountAccessResult, j as AccountIdentityCredential, k as AccountIdentitySession, l as AccountRefusalRequest, m as AgentDelegationMode, n as CeremonyOperation, o as CreateWalletConfig, C as CreateWalletResult, D as DexterConnectConfig, E as EnrollAccountIdentityConfig, H as HostedSignRequestPayload, p as HostedSignResult, q as HostedSignVaultIdentity, r as MissingVaultRecoveryAccount, s as MissingVaultRecoveryVault, P as PasskeyLoginTokens, t as RecoverVault, u as SESSION_TTL_30D, v as SignInAccountIdentityConfig, S as SignInResult, b as SpendPolicy, w as authoredPolicy, x as createWallet, y as enrollAccountAccess, z as enrollAccountIdentity, B as signInAccountAccess, F as signInAccountIdentity, G as usdToAtomic } from './accountIdentity-DQ_C-WAi.js';
3
3
  import { PasskeySignerWithPublicKey } from '@dexterai/vault/signers';
4
- import { A as ActiveWalletBindingIdentity, W as WalletBindingCandidate, a as WalletAccountRelationSnapshot, B as BindingFetch, b as WalletAccountBindingClient } from './connectionContract-BgecDiDk.js';
5
- export { c as AccountBindingCandidate, d as AccountSessionClearer, e as AccountSessionInstaller, f as BindingResolutionResult, C as ConnectDexterIdentityConfig, D as DexterConnectionCapability, g as DexterConnectionIntent, h as DexterConnectionPermissions, i as DexterControlModel, j as DexterControlPrimaryAction, k as DexterControlStage, l as DisconnectDexterIdentityConfig, R as RelationCandidates, m as RelationCheckReason, n as RelationRuntime, o as ResolveWalletAccountBindingInput, p as ResolvedWalletAccountRelation, S as ServerRelationVerificationRequest, q as ServerRelationVerificationResult, r as ServerRelationVerifier, s as WALLET_ACCOUNT_BINDING_PATH, t as WalletAccountBindingClientConfig, u as WalletAccountRelation, v as WalletAccountRelationController, w as WalletAccountRelationControllerOptions, x as WalletIdentityFetchInput, y as accountBindingCandidate, z as connectDexterIdentity, E as createDexterControlModel, F as createWalletAccountBindingClient, G as disconnectDexterIdentity, H as fetchWithWalletIdentity, I as walletBindingCandidate } from './connectionContract-BgecDiDk.js';
4
+ import { A as ActiveWalletBindingIdentity, W as WalletBindingCandidate, a as WalletAccountRelationSnapshot, B as BindingFetch, b as WalletAccountBindingClient } from './connectionContract-BA03zq2D.js';
5
+ export { c as AccountBindingCandidate, d as AccountSessionClearer, e as AccountSessionInstaller, f as BindingResolutionResult, C as ConnectDexterIdentityConfig, D as DexterConnectionCapability, g as DexterConnectionIntent, h as DexterConnectionPermissions, i as DexterControlModel, j as DexterControlPrimaryAction, k as DexterControlStage, l as DisconnectDexterIdentityConfig, R as RelationCandidates, m as RelationCheckReason, n as RelationRuntime, o as ResolveWalletAccountBindingInput, p as ResolvedWalletAccountRelation, S as ServerRelationVerificationRequest, q as ServerRelationVerificationResult, r as ServerRelationVerifier, s as WALLET_ACCOUNT_BINDING_PATH, t as WalletAccountBindingClientConfig, u as WalletAccountRelation, v as WalletAccountRelationController, w as WalletAccountRelationControllerOptions, x as WalletIdentityFetchInput, y as accountBindingCandidate, z as connectDexterIdentity, E as createDexterControlModel, F as createWalletAccountBindingClient, G as disconnectDexterIdentity, H as fetchWithWalletIdentity, I as walletBindingCandidate } from './connectionContract-BA03zq2D.js';
6
6
  import { PublicKeyCredentialRequestOptionsJSON, AuthenticationResponseJSON } from '@simplewebauthn/browser';
7
7
 
8
8
  /**
@@ -82,6 +82,167 @@ declare function createPasskeySigner(vault: ConnectVault, apiBase?: string, opts
82
82
 
83
83
  declare function recoverWallet(config?: RecoverWalletConfig): Promise<RecoverOutcome>;
84
84
 
85
+ declare const ACCOUNT_API_PATH = "/api/account/v1";
86
+ interface DexterAccount {
87
+ readonly principal: string;
88
+ readonly wallet: string | null;
89
+ /**
90
+ * `held`: the Account's address is real and takes money now; it opens on the
91
+ * chain by itself on the first money or the first action. Show it as `ready`.
92
+ */
93
+ readonly status: 'ready' | 'held' | 'setting-up';
94
+ readonly nextStep: string | null;
95
+ }
96
+ /** The passkey the session is bound to, as its owner would recognise it. */
97
+ interface AccountPasskey {
98
+ /** The label given when the passkey was created, if one was stored. */
99
+ readonly name: string | null;
100
+ /** ISO time the passkey was created. */
101
+ readonly createdAt: string | null;
102
+ }
103
+ /** An operation whose last step was approved and whose outcome the API does not know yet. */
104
+ interface AccountUnsettled {
105
+ readonly operationId: string;
106
+ readonly flow: 'setup' | 'send';
107
+ readonly step: string;
108
+ }
109
+ interface AccountOverview {
110
+ readonly account: DexterAccount | null;
111
+ /**
112
+ * Set while an approved step may still land. Offer no new send until it is
113
+ * settled: read it with `getAccountOperation`.
114
+ */
115
+ readonly unsettled: AccountUnsettled | null;
116
+ /** Which chain the API is using. Anything but `mainnet` is a rehearsal and must be shown as one. */
117
+ readonly network: 'mainnet' | 'test' | null;
118
+ readonly passkey: AccountPasskey | null;
119
+ }
120
+ interface AccountTokenBalance {
121
+ readonly mint: string;
122
+ readonly symbol: string | null;
123
+ readonly decimals: number;
124
+ /** Smallest unit, as a decimal string. */
125
+ readonly amount: string;
126
+ }
127
+ interface AccountBalances {
128
+ readonly wallet: string;
129
+ readonly sol: {
130
+ readonly lamports: string;
131
+ };
132
+ readonly tokens: readonly AccountTokenBalance[];
133
+ readonly slot: number;
134
+ readonly commitment: string;
135
+ }
136
+ interface AccountSendRequest {
137
+ /** A mint address, or `SOL`. */
138
+ readonly mint: string;
139
+ /** Smallest unit, as a decimal string. */
140
+ readonly amount: string;
141
+ readonly to: string;
142
+ }
143
+ /**
144
+ * What the API actually prepared. Shown to the owner before the prompt.
145
+ * `approve-send` carries the amount and recipient; `prepare-token`, the
146
+ * one-time setup of a token for sending, carries the token only.
147
+ */
148
+ interface AccountOperationDetails {
149
+ readonly mint: string;
150
+ readonly symbol: string | null;
151
+ readonly decimals: number;
152
+ readonly amount: string | null;
153
+ readonly to: string | null;
154
+ }
155
+ type AccountStepPhase = 'preparing' | 'ready' | 'passkey' | 'sending' | 'confirmed';
156
+ /** One approval, as the page should show it. */
157
+ interface AccountStepView {
158
+ /** The API's name for the step. The page words the steps it knows. */
159
+ readonly step: string;
160
+ /** The API's wording, for a step the page does not know yet. */
161
+ readonly summary: string;
162
+ /** The kit's own text for what the passkey signs, when the API sends it. */
163
+ readonly statement: string | null;
164
+ readonly stepsRemaining: number | null;
165
+ readonly details: AccountOperationDetails | null;
166
+ readonly phase: AccountStepPhase;
167
+ /** Set once the step is confirmed. */
168
+ readonly signature: string | null;
169
+ }
170
+ interface AccountOperationConfig {
171
+ /** The Account session from `enrollAccountIdentity` or `signInAccountIdentity`. */
172
+ readonly identity: AccountIdentityResult;
173
+ readonly onStep?: (view: AccountStepView) => void;
174
+ /**
175
+ * Hold each prepared step until the owner taps. Resolve it inside the tap's
176
+ * own handler: browsers that require a user gesture for a passkey prompt
177
+ * then see the prompt as coming from that tap. Reject to cancel. Without
178
+ * it, the prompt follows the prepare directly.
179
+ */
180
+ readonly confirmStep?: (view: AccountStepView) => Promise<void>;
181
+ readonly signal?: AbortSignal;
182
+ }
183
+ interface AccountFlowResult {
184
+ /** Signatures of the transactions the flow sent, in order. A held setup step sends none. */
185
+ readonly signatures: readonly string[];
186
+ }
187
+ /**
188
+ * Where one operation stands, from the API's own record and the chain.
189
+ * `failed` means none of its transactions landed or can still land;
190
+ * `sending` means that is not known yet.
191
+ */
192
+ type AccountOperationStatus = 'prepared' | 'sending' | 'confirmed' | 'failed' | 'expired';
193
+ interface AccountOperationState {
194
+ readonly operationId: string;
195
+ readonly flow: 'setup' | 'send';
196
+ readonly step: string;
197
+ readonly status: AccountOperationStatus;
198
+ readonly signature: string | null;
199
+ readonly next: string | null;
200
+ }
201
+ /**
202
+ * An approved step whose outcome is not known: the reply was lost, slow, or
203
+ * the API could not say. Its transaction may still land, so the page must not
204
+ * say nothing was sent, and must not offer the same send again until
205
+ * `getAccountOperation` settles it.
206
+ */
207
+ declare class AccountOperationUnsettledError extends ConnectError {
208
+ readonly operationId: string;
209
+ readonly flow: 'setup' | 'send';
210
+ readonly step: string;
211
+ constructor(operationId: string, flow: 'setup' | 'send', step: string);
212
+ }
213
+ /** Read the signed-in owner's Account, or `null` when none is open yet. */
214
+ declare function getAccount(config: Pick<AccountOperationConfig, 'identity' | 'signal'>): Promise<DexterAccount | null>;
215
+ /**
216
+ * Read the Account together with what the owner should see around it: the
217
+ * chain in use and the passkey that owns, or is about to own, the Account.
218
+ * Fields the API does not send come back as `null`.
219
+ */
220
+ declare function getAccountOverview(config: Pick<AccountOperationConfig, 'identity' | 'signal'>): Promise<AccountOverview>;
221
+ /** Read where one operation stands. See `AccountOperationUnsettledError`. */
222
+ declare function getAccountOperation(config: Pick<AccountOperationConfig, 'identity' | 'signal'> & {
223
+ readonly operationId: string;
224
+ }): Promise<AccountOperationState>;
225
+ /** Read the Account wallet's balances. Amounts are smallest-unit strings. */
226
+ declare function getAccountBalances(config: Pick<AccountOperationConfig, 'identity' | 'signal'>): Promise<AccountBalances>;
227
+ /**
228
+ * Open the owner's Account, or finish opening it. Each step the API asks for
229
+ * is one passkey approval; the API decides how many there are. Resolves with
230
+ * the Account once it is ready. Safe to call again after an interruption.
231
+ */
232
+ declare function openAccount(config: AccountOperationConfig): Promise<DexterAccount>;
233
+ /**
234
+ * Send from the Account wallet. The owner approves one exact amount and
235
+ * recipient (`approve-send`). The first send of a token is preceded by its
236
+ * one-time setup (`prepare-token`), which is its own approval.
237
+ */
238
+ declare function sendFromAccount(config: AccountOperationConfig & {
239
+ readonly send: AccountSendRequest;
240
+ }): Promise<AccountFlowResult>;
241
+ /** Turn a smallest-unit amount into a plain decimal string, without rounding. */
242
+ declare function formatAccountAmount(amount: string, decimals: number): string;
243
+ /** Turn what a person typed ("2.5") into a smallest-unit string, or `null` if it is not an amount. */
244
+ declare function parseAccountAmount(input: string, decimals: number): string | null;
245
+
85
246
  /** One localStorage entry per Wallet keeps inactive Wallet proofs independent. */
86
247
  declare const WALLET_PROOF_SESSION_STORAGE_PREFIX: "dexter:wallet-identity-proof-session:";
87
248
  declare const walletProofSessionBrand: unique symbol;
@@ -651,4 +812,4 @@ declare function readAgentAuthority(input: {
651
812
  fetchImpl?: typeof fetch;
652
813
  }): Promise<AgentAuthorityStatus>;
653
814
 
654
- export { AGENT_AUTHORITY_NAMESPACE, AGENT_AUTHORITY_STATUS_NAMESPACE, type AgentAuthorityActiveRole, type AgentAuthorityApprovalMode, type AgentAuthorityAuthorization, type AgentAuthorityBootstrapRequest, type AgentAuthorityCapacity, AgentAuthorityError, type AgentAuthorityRule, type AgentAuthorityRuleBase, type AgentAuthorityStagedReceipt, type AgentAuthorityStatus, type AgentAuthorityTarget, AgentSpendError, type AgentSpendIdentity, type AgentSpendStatus, type AgentSpendTab, type AnonChallengeResult, type AnonServerPolicy, type AutomaticAgentSpend, BindingFetch, AgentAuthorityError as BoundedX402AuthorityError, type BoundedX402Authorization, type BoundedX402BootstrapRequest, type BoundedX402Draft, type BoundedX402Limits, type BoundedX402Rule, type BoundedX402StagedReceipt, type BoundedX402Validation, CeremonyPhase, ConnectVault, type CreatePasskeySignerOptions, type DexterIdentityCoordinator, type DexterIdentityCoordinatorOptions, type EnableAgentSpendResult, MAX_AUTHORITY_AMOUNT_ATOMIC, MissingVaultRecoveryConfig, MissingVaultRecoveryResult, type PasskeySignalSupport, type RawAgentSpendSession, type RawAgentSpendStatus, RecoverOutcome, RecoverWalletConfig, type RevokeAgentSpendResult, type StagedAgentAuthorityRule, type TradeAuthorityRule, WALLET_PROOF_SESSION_STORAGE_PREFIX, WalletAccountBindingClient, WalletAccountRelationSnapshot, WalletBindingCandidate, WalletIdentityProof, type WalletProofLifecycleEvent, type WalletProofSession, type WalletProofSessionEvent, type WalletProofSessionOperation, type WalletProofSessionStorage, type WalletProofSessionStore, type WalletProofSessionStoreOptions, type WalletProofStorageEvent, type WalletProofStorageEventSource, type X402LimitDraft, type X402LimitValidation, type X402Limits, type X402PaymentAuthorityRule, X402_ALLOWED_SCHEMES, X402_ASSET, X402_COUNTERPARTY_SCOPE, X402_PROTOCOL_ID, X402_PROTOCOL_VERSION, assembleAgentSpendStatus, beginAgentAuthority, beginBoundedX402Authority, buildAgentAuthorityRequest, buildBoundedX402BootstrapRequest, buildX402PaymentRule, ceremonyPhaseLabel, createAnonServerPolicy, createDexterIdentityCoordinator, createPasskeySigner, createWalletProofSessionStore, describeAgentSpendError, enableAgentSpend, exactAgentAuthorityApprovalRedirect, exactBoundedX402ApprovalRedirect, noCustomX402Limits, passkeySignalSupport, prunePasskey, readAgentAuthority, recoverMissingVaultForAccount, recoverWallet, renamePasskey, revokeAgentSpend, stageAgentAuthority, stageBoundedX402Authority, syncAcceptedPasskeys, validateBoundedX402Draft, walletProofSessionStore };
815
+ export { ACCOUNT_API_PATH, AGENT_AUTHORITY_NAMESPACE, AGENT_AUTHORITY_STATUS_NAMESPACE, type AccountBalances, type AccountFlowResult, AccountIdentityResult, type AccountOperationConfig, type AccountOperationDetails, type AccountOperationState, type AccountOperationStatus, AccountOperationUnsettledError, type AccountOverview, type AccountPasskey, type AccountSendRequest, type AccountStepPhase, type AccountStepView, type AccountTokenBalance, type AccountUnsettled, type AgentAuthorityActiveRole, type AgentAuthorityApprovalMode, type AgentAuthorityAuthorization, type AgentAuthorityBootstrapRequest, type AgentAuthorityCapacity, AgentAuthorityError, type AgentAuthorityRule, type AgentAuthorityRuleBase, type AgentAuthorityStagedReceipt, type AgentAuthorityStatus, type AgentAuthorityTarget, AgentSpendError, type AgentSpendIdentity, type AgentSpendStatus, type AgentSpendTab, type AnonChallengeResult, type AnonServerPolicy, type AutomaticAgentSpend, BindingFetch, AgentAuthorityError as BoundedX402AuthorityError, type BoundedX402Authorization, type BoundedX402BootstrapRequest, type BoundedX402Draft, type BoundedX402Limits, type BoundedX402Rule, type BoundedX402StagedReceipt, type BoundedX402Validation, CeremonyPhase, ConnectError, ConnectVault, type CreatePasskeySignerOptions, type DexterAccount, type DexterIdentityCoordinator, type DexterIdentityCoordinatorOptions, type EnableAgentSpendResult, MAX_AUTHORITY_AMOUNT_ATOMIC, MissingVaultRecoveryConfig, MissingVaultRecoveryResult, type PasskeySignalSupport, type RawAgentSpendSession, type RawAgentSpendStatus, RecoverOutcome, RecoverWalletConfig, type RevokeAgentSpendResult, type StagedAgentAuthorityRule, type TradeAuthorityRule, WALLET_PROOF_SESSION_STORAGE_PREFIX, WalletAccountBindingClient, WalletAccountRelationSnapshot, WalletBindingCandidate, WalletIdentityProof, type WalletProofLifecycleEvent, type WalletProofSession, type WalletProofSessionEvent, type WalletProofSessionOperation, type WalletProofSessionStorage, type WalletProofSessionStore, type WalletProofSessionStoreOptions, type WalletProofStorageEvent, type WalletProofStorageEventSource, type X402LimitDraft, type X402LimitValidation, type X402Limits, type X402PaymentAuthorityRule, X402_ALLOWED_SCHEMES, X402_ASSET, X402_COUNTERPARTY_SCOPE, X402_PROTOCOL_ID, X402_PROTOCOL_VERSION, assembleAgentSpendStatus, beginAgentAuthority, beginBoundedX402Authority, buildAgentAuthorityRequest, buildBoundedX402BootstrapRequest, buildX402PaymentRule, ceremonyPhaseLabel, createAnonServerPolicy, createDexterIdentityCoordinator, createPasskeySigner, createWalletProofSessionStore, describeAgentSpendError, enableAgentSpend, exactAgentAuthorityApprovalRedirect, exactBoundedX402ApprovalRedirect, formatAccountAmount, getAccount, getAccountBalances, getAccountOperation, getAccountOverview, noCustomX402Limits, openAccount, parseAccountAmount, passkeySignalSupport, prunePasskey, readAgentAuthority, recoverMissingVaultForAccount, recoverWallet, renamePasskey, revokeAgentSpend, sendFromAccount, stageAgentAuthority, stageBoundedX402Authority, syncAcceptedPasskeys, validateBoundedX402Draft, walletProofSessionStore };