@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
package/dist/hosted.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
recoverWallet,
|
|
3
|
+
runHostedMissingVaultRecoveryProof
|
|
4
|
+
} from "./chunk-WHGR5FUY.js";
|
|
5
|
+
import {
|
|
6
|
+
ConnectError,
|
|
7
|
+
DEXTER_API_BASE,
|
|
8
|
+
continueWithDexter,
|
|
9
|
+
createWallet,
|
|
10
|
+
passkeyLogin,
|
|
11
|
+
resolveAgentDelegationMode,
|
|
12
|
+
resolveWalletStoreMode
|
|
13
|
+
} from "./chunk-4FTJB7FT.js";
|
|
14
|
+
import "./chunk-EMCGL64H.js";
|
|
15
|
+
|
|
16
|
+
// src/hosted.ts
|
|
17
|
+
var DEXTER_HOSTED_CEREMONY_ORIGIN = "https://dexter.cash";
|
|
18
|
+
async function runHostedCeremony(request) {
|
|
19
|
+
assertHostedCeremonyOrigin();
|
|
20
|
+
const walletStore = resolveWalletStoreMode(request.walletStore);
|
|
21
|
+
assertHostedDelegationChoice(request);
|
|
22
|
+
const persistence = walletStore === "provisional" ? { walletStore } : {};
|
|
23
|
+
switch (request.operation) {
|
|
24
|
+
case "signin":
|
|
25
|
+
return await passkeyLogin(
|
|
26
|
+
{
|
|
27
|
+
apiBase: DEXTER_API_BASE,
|
|
28
|
+
transport: "inline",
|
|
29
|
+
...persistence
|
|
30
|
+
},
|
|
31
|
+
request.onPhase
|
|
32
|
+
);
|
|
33
|
+
case "continue":
|
|
34
|
+
return await continueWithDexter(
|
|
35
|
+
{
|
|
36
|
+
apiBase: DEXTER_API_BASE,
|
|
37
|
+
transport: "inline",
|
|
38
|
+
...persistence,
|
|
39
|
+
...request.name !== void 0 ? { name: request.name } : {},
|
|
40
|
+
...request.spendPolicy !== void 0 ? { spendPolicy: request.spendPolicy } : {},
|
|
41
|
+
...request.agentDelegation !== void 0 ? { agentDelegation: request.agentDelegation } : {}
|
|
42
|
+
},
|
|
43
|
+
request.onPhase
|
|
44
|
+
);
|
|
45
|
+
case "create":
|
|
46
|
+
return await createWallet({
|
|
47
|
+
apiBase: DEXTER_API_BASE,
|
|
48
|
+
transport: "inline",
|
|
49
|
+
...persistence,
|
|
50
|
+
...request.name !== void 0 ? { name: request.name } : {},
|
|
51
|
+
...request.spendPolicy !== void 0 ? { spendPolicy: request.spendPolicy } : {},
|
|
52
|
+
...request.agentDelegation !== void 0 ? { agentDelegation: request.agentDelegation } : {},
|
|
53
|
+
...request.onPhase !== void 0 ? { onPhase: request.onPhase } : {}
|
|
54
|
+
});
|
|
55
|
+
case "recover":
|
|
56
|
+
return await recoverWallet({
|
|
57
|
+
apiBase: DEXTER_API_BASE,
|
|
58
|
+
transport: "inline",
|
|
59
|
+
...persistence,
|
|
60
|
+
...request.preferImmediate !== void 0 ? { preferImmediate: request.preferImmediate } : {},
|
|
61
|
+
...request.onPhase !== void 0 ? { onPhase: request.onPhase } : {}
|
|
62
|
+
});
|
|
63
|
+
default:
|
|
64
|
+
throw new ConnectError("unsupported_hosted_ceremony");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function runHostedMissingVaultRecoveryProof2(options) {
|
|
68
|
+
assertHostedCeremonyOrigin();
|
|
69
|
+
return runHostedMissingVaultRecoveryProof(options);
|
|
70
|
+
}
|
|
71
|
+
function assertHostedDelegationChoice(request) {
|
|
72
|
+
if (request.operation !== "continue" && request.operation !== "create") return;
|
|
73
|
+
const agentDelegation = resolveAgentDelegationMode(
|
|
74
|
+
request.agentDelegation ?? (request.spendPolicy ? "configure-now" : void 0)
|
|
75
|
+
);
|
|
76
|
+
if (agentDelegation === "configure-now" && !request.spendPolicy) {
|
|
77
|
+
throw new ConnectError(
|
|
78
|
+
"missing_spend_policy",
|
|
79
|
+
"agentDelegation configure-now requires a spendPolicy"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (agentDelegation === "deferred" && request.spendPolicy) {
|
|
83
|
+
throw new ConnectError(
|
|
84
|
+
"conflicting_agent_delegation",
|
|
85
|
+
"agentDelegation deferred cannot include a spendPolicy"
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function assertHostedCeremonyOrigin() {
|
|
90
|
+
if (typeof window === "undefined" || window.location.origin !== DEXTER_HOSTED_CEREMONY_ORIGIN) {
|
|
91
|
+
throw new ConnectError(
|
|
92
|
+
"hosted_ceremony_origin_required",
|
|
93
|
+
`Hosted Wallet ceremonies run only on ${DEXTER_HOSTED_CEREMONY_ORIGIN}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
DEXTER_HOSTED_CEREMONY_ORIGIN,
|
|
99
|
+
runHostedCeremony,
|
|
100
|
+
runHostedMissingVaultRecoveryProof2 as runHostedMissingVaultRecoveryProof
|
|
101
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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-BmD1y8KH.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-BmD1y8KH.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-BzV_pjOI.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-BzV_pjOI.js';
|
|
4
6
|
import { PublicKeyCredentialRequestOptionsJSON, AuthenticationResponseJSON } from '@simplewebauthn/browser';
|
|
5
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Repair one confirmed split state: a Dexter passkey exists, but its Vault row
|
|
10
|
+
* is missing from the already-authenticated account. This never signs in,
|
|
11
|
+
* creates an account, or changes the browser's active Wallet.
|
|
12
|
+
*
|
|
13
|
+
* Call directly from a user click. The trusted popup opens synchronously; the
|
|
14
|
+
* account-authenticated challenge fetch begins only after it exists.
|
|
15
|
+
*/
|
|
16
|
+
declare function recoverMissingVaultForAccount(config: MissingVaultRecoveryConfig): Promise<MissingVaultRecoveryResult>;
|
|
17
|
+
|
|
6
18
|
/** What `issueChallenge` returns to the SDK signer. */
|
|
7
19
|
interface AnonChallengeResult {
|
|
8
20
|
/** Server-issued canonical 200-byte passkey-authorization envelope. */
|
|
@@ -639,4 +651,4 @@ declare function readAgentAuthority(input: {
|
|
|
639
651
|
fetchImpl?: typeof fetch;
|
|
640
652
|
}): Promise<AgentAuthorityStatus>;
|
|
641
653
|
|
|
642
|
-
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, 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, recoverWallet, renamePasskey, revokeAgentSpend, stageAgentAuthority, stageBoundedX402Authority, syncAcceptedPasskeys, validateBoundedX402Draft, walletProofSessionStore };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WalletAccountRelationController,
|
|
3
|
+
ceremonyPhaseLabel,
|
|
4
|
+
connectDexterIdentity,
|
|
5
|
+
createDexterControlModel,
|
|
6
|
+
createDexterIdentityCoordinator,
|
|
7
|
+
disconnectDexterIdentity,
|
|
8
|
+
passkeySignalSupport,
|
|
9
|
+
prunePasskey,
|
|
10
|
+
renamePasskey,
|
|
11
|
+
syncAcceptedPasskeys
|
|
12
|
+
} from "./chunk-Z6YHGWG3.js";
|
|
13
|
+
import {
|
|
14
|
+
recoverMissingVaultForAccount,
|
|
15
|
+
recoverWallet
|
|
16
|
+
} from "./chunk-WHGR5FUY.js";
|
|
1
17
|
import {
|
|
2
18
|
ConnectError,
|
|
3
19
|
SESSION_TTL_30D,
|
|
4
20
|
WALLET_ACCOUNT_BINDING_PATH,
|
|
5
21
|
WALLET_PROOF_SESSION_STORAGE_PREFIX,
|
|
6
|
-
WalletAccountRelationController,
|
|
7
22
|
accountBindingCandidate,
|
|
8
|
-
activateRecoveredVault,
|
|
9
23
|
authoredPolicy,
|
|
10
24
|
bytesEqual,
|
|
11
|
-
ceremonyPhaseLabel,
|
|
12
|
-
classifyWebAuthnRejection,
|
|
13
|
-
connectDexterIdentity,
|
|
14
|
-
createDexterControlModel,
|
|
15
|
-
createDexterIdentityCoordinator,
|
|
16
25
|
createWallet,
|
|
17
26
|
createWalletAccountBindingClient,
|
|
18
27
|
createWalletProofSessionStore,
|
|
19
|
-
|
|
20
|
-
immediateAuthentication,
|
|
21
|
-
immediateGetSupported,
|
|
28
|
+
fetchWithWalletIdentity,
|
|
22
29
|
openCeremonyPopup,
|
|
23
|
-
parseWalletIdentityProof,
|
|
24
|
-
passkeySignalSupport,
|
|
25
|
-
primeImmediateSupport,
|
|
26
|
-
prunePasskey,
|
|
27
30
|
readErrorCode,
|
|
28
|
-
renamePasskey,
|
|
29
31
|
resolveDexterApiBase,
|
|
30
32
|
resolveDexterRpId,
|
|
31
|
-
resolveWalletStoreMode,
|
|
32
33
|
shouldUsePopup,
|
|
33
|
-
syncAcceptedPasskeys,
|
|
34
34
|
usdToAtomic,
|
|
35
35
|
walletBindingCandidate,
|
|
36
36
|
walletProofSessionStore
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-4FTJB7FT.js";
|
|
38
38
|
import {
|
|
39
39
|
base64ToBytes,
|
|
40
40
|
base64urlToBytes,
|
|
@@ -209,170 +209,6 @@ async function validateHostedSignResult(result, operationMessage, expectedVault)
|
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
// src/recover.ts
|
|
213
|
-
import { startAuthentication, browserSupportsWebAuthn } from "@simplewebauthn/browser";
|
|
214
|
-
var ANON_SIGN_BASE2 = "/api/passkey-anon/sign";
|
|
215
|
-
primeImmediateSupport();
|
|
216
|
-
async function recoverWallet(config = {}) {
|
|
217
|
-
let apiBase;
|
|
218
|
-
let walletStore;
|
|
219
|
-
try {
|
|
220
|
-
apiBase = resolveDexterApiBase(config.apiBase);
|
|
221
|
-
} catch (err) {
|
|
222
|
-
return netError("untrusted_api_base", err);
|
|
223
|
-
}
|
|
224
|
-
try {
|
|
225
|
-
walletStore = resolveWalletStoreMode(config.walletStore);
|
|
226
|
-
} catch (err) {
|
|
227
|
-
return {
|
|
228
|
-
ok: false,
|
|
229
|
-
reason: "error",
|
|
230
|
-
error: err instanceof ConnectError ? err : new ConnectError("invalid_wallet_store_mode")
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
if (shouldUsePopup(config.transport)) {
|
|
234
|
-
let outcome;
|
|
235
|
-
try {
|
|
236
|
-
outcome = await openCeremonyPopup("recover", {
|
|
237
|
-
connectHost: config.connectHost,
|
|
238
|
-
preferImmediate: config.preferImmediate,
|
|
239
|
-
...walletStore === "provisional" ? { walletStore } : {}
|
|
240
|
-
});
|
|
241
|
-
} catch (err) {
|
|
242
|
-
const ce = err instanceof ConnectError ? err : new ConnectError("popup_failed", err instanceof Error ? err.message : String(err));
|
|
243
|
-
if (ce.code === "popup_closed") return { ok: false, reason: "cancelled" };
|
|
244
|
-
return { ok: false, reason: "error", error: ce };
|
|
245
|
-
}
|
|
246
|
-
if (outcome.ok) {
|
|
247
|
-
try {
|
|
248
|
-
outcome = {
|
|
249
|
-
...outcome,
|
|
250
|
-
walletIdentityProof: parseWalletIdentityProof(
|
|
251
|
-
outcome.walletIdentityProof
|
|
252
|
-
)
|
|
253
|
-
};
|
|
254
|
-
} catch (err) {
|
|
255
|
-
return netError("wallet_identity_proof_malformed", err);
|
|
256
|
-
}
|
|
257
|
-
if (walletStore === "commit") {
|
|
258
|
-
activateRecoveredVault(
|
|
259
|
-
outcome.userHandle,
|
|
260
|
-
outcome.credentialId,
|
|
261
|
-
outcome.vault,
|
|
262
|
-
outcome.walletIdentityProof
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return outcome;
|
|
267
|
-
}
|
|
268
|
-
if (typeof navigator === "undefined" || !browserSupportsWebAuthn()) {
|
|
269
|
-
return {
|
|
270
|
-
ok: false,
|
|
271
|
-
reason: "error",
|
|
272
|
-
error: new ConnectError("webauthn_unsupported", "WebAuthn unavailable in this environment")
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
const onPhase = config.onPhase;
|
|
276
|
-
onPhase?.("challenge");
|
|
277
|
-
let options;
|
|
278
|
-
try {
|
|
279
|
-
const res = await fetch(`${apiBase}${ANON_SIGN_BASE2}/recover-challenge`, {
|
|
280
|
-
method: "POST",
|
|
281
|
-
headers: { "content-type": "application/json" },
|
|
282
|
-
body: "{}"
|
|
283
|
-
});
|
|
284
|
-
if (!res.ok) return { ok: false, reason: "error", error: new ConnectError(await readErrorCode(res)) };
|
|
285
|
-
const serverOptions = (await res.json()).options;
|
|
286
|
-
if (!serverOptions?.challenge) {
|
|
287
|
-
return {
|
|
288
|
-
ok: false,
|
|
289
|
-
reason: "error",
|
|
290
|
-
error: new ConnectError("recover_challenge_malformed", "no challenge in response")
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
options = { ...serverOptions, rpId: resolveDexterRpId(serverOptions.rpId) };
|
|
294
|
-
} catch (err) {
|
|
295
|
-
if (err instanceof ConnectError && err.code === "untrusted_rp_id") {
|
|
296
|
-
return { ok: false, reason: "error", error: err };
|
|
297
|
-
}
|
|
298
|
-
return netError("recover_challenge_failed", err);
|
|
299
|
-
}
|
|
300
|
-
onPhase?.("passkey");
|
|
301
|
-
const useImmediate = Boolean(config.preferImmediate) && await immediateGetSupported();
|
|
302
|
-
let credential;
|
|
303
|
-
try {
|
|
304
|
-
credential = useImmediate ? await immediateAuthentication(options) : await startAuthentication({ optionsJSON: options });
|
|
305
|
-
} catch (err) {
|
|
306
|
-
if (classifyWebAuthnRejection(err)) {
|
|
307
|
-
return { ok: false, reason: useImmediate ? "no_credential" : "cancelled" };
|
|
308
|
-
}
|
|
309
|
-
return {
|
|
310
|
-
ok: false,
|
|
311
|
-
reason: "error",
|
|
312
|
-
error: new ConnectError("webauthn_failed", err instanceof Error ? err.message : String(err))
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
onPhase?.("verifying");
|
|
316
|
-
let userHandle;
|
|
317
|
-
let credentialId;
|
|
318
|
-
let walletIdentityProof;
|
|
319
|
-
try {
|
|
320
|
-
const res = await fetch(`${apiBase}${ANON_SIGN_BASE2}/recover-verify`, {
|
|
321
|
-
method: "POST",
|
|
322
|
-
headers: { "content-type": "application/json" },
|
|
323
|
-
body: JSON.stringify({ credential })
|
|
324
|
-
});
|
|
325
|
-
if (res.status === 404) return { ok: false, reason: "no_credential" };
|
|
326
|
-
if (!res.ok) return { ok: false, reason: "error", error: new ConnectError(await readErrorCode(res)) };
|
|
327
|
-
const data = await res.json();
|
|
328
|
-
userHandle = data.userHandle;
|
|
329
|
-
credentialId = data.credentialId;
|
|
330
|
-
walletIdentityProof = parseWalletIdentityProof(data.walletIdentityProof);
|
|
331
|
-
} catch (err) {
|
|
332
|
-
return netError("recover_verify_failed", err);
|
|
333
|
-
}
|
|
334
|
-
let vault;
|
|
335
|
-
try {
|
|
336
|
-
const res = await fetch(
|
|
337
|
-
`${apiBase}/api/passkey-vault-anon/status?user_handle=${encodeURIComponent(userHandle)}`
|
|
338
|
-
);
|
|
339
|
-
if (!res.ok) return { ok: false, reason: "error", error: new ConnectError(await readErrorCode(res)) };
|
|
340
|
-
const data = await res.json();
|
|
341
|
-
if (!data.hasVault || !data.vault) {
|
|
342
|
-
return {
|
|
343
|
-
ok: false,
|
|
344
|
-
reason: "error",
|
|
345
|
-
error: new ConnectError("vault_not_found", "this sign-in key has no wallet attached")
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
vault = {
|
|
349
|
-
vaultPda: data.vault.vaultPda,
|
|
350
|
-
swigAddress: data.vault.swigAddress,
|
|
351
|
-
receiveAddress: data.vault.receiveAddress ?? null,
|
|
352
|
-
isActivated: Boolean(data.vault.isActivated),
|
|
353
|
-
walletLabel: data.vault.walletLabel ?? null
|
|
354
|
-
};
|
|
355
|
-
} catch (err) {
|
|
356
|
-
return netError("vault_status_failed", err);
|
|
357
|
-
}
|
|
358
|
-
if (walletStore === "commit") {
|
|
359
|
-
activateRecoveredVault(
|
|
360
|
-
userHandle,
|
|
361
|
-
credentialId,
|
|
362
|
-
vault,
|
|
363
|
-
walletIdentityProof
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
return { ok: true, userHandle, credentialId, vault, walletIdentityProof };
|
|
367
|
-
}
|
|
368
|
-
function netError(code, err) {
|
|
369
|
-
return {
|
|
370
|
-
ok: false,
|
|
371
|
-
reason: "error",
|
|
372
|
-
error: new ConnectError(code, err instanceof Error ? err.message : String(err))
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
212
|
// src/agentSpend.ts
|
|
377
213
|
import { PublicKey as PublicKey2 } from "@solana/web3.js";
|
|
378
214
|
import { WebAuthnAssertion } from "@dexterai/vault/signers/browser";
|
|
@@ -1128,10 +964,12 @@ export {
|
|
|
1128
964
|
enableAgentSpend,
|
|
1129
965
|
exactAgentAuthorityApprovalRedirect,
|
|
1130
966
|
exactBoundedX402ApprovalRedirect,
|
|
967
|
+
fetchWithWalletIdentity,
|
|
1131
968
|
noCustomX402Limits,
|
|
1132
969
|
passkeySignalSupport,
|
|
1133
970
|
prunePasskey,
|
|
1134
971
|
readAgentAuthority,
|
|
972
|
+
recoverMissingVaultForAccount,
|
|
1135
973
|
recoverWallet,
|
|
1136
974
|
renamePasskey,
|
|
1137
975
|
revokeAgentSpend,
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { h as ConnectError, S as SignInResult, r as PasskeyLoginConfig, C as CreateWalletResult, A as AgentDelegationMode } from './enroll-BmD1y8KH.js';
|
|
2
|
+
export { d as ConnectVault, R as RecoverOutcome, n as RecoverVault, f as WalletIdentityProof } from './enroll-BmD1y8KH.js';
|
|
3
|
+
import { i as DexterControlModel, a as WalletAccountRelationSnapshot, g as DexterConnectionIntent, e as AccountSessionInstaller, d as AccountSessionClearer, B as BindingFetch } from './connectionContract-BzV_pjOI.js';
|
|
4
|
+
export { D as DexterConnectionCapability, h as DexterConnectionPermissions, j as DexterControlPrimaryAction, k as DexterControlStage } from './connectionContract-BzV_pjOI.js';
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import { ButtonHTMLAttributes, ReactNode, ReactElement, ComponentType, AnchorHTMLAttributes } from 'react';
|
|
4
7
|
|
|
5
8
|
/** The Dexter passkey mark carried on the branded button. */
|
|
6
9
|
declare function DexterMark(): ReactElement;
|
|
@@ -127,10 +130,79 @@ interface CreateWalletPanelProps {
|
|
|
127
130
|
agentDelegation?: AgentDelegationMode;
|
|
128
131
|
/** Extra className composed after the brand classes. */
|
|
129
132
|
className?: string;
|
|
133
|
+
/** Account wording for the shared account control; wallet remains compatible. */
|
|
134
|
+
terminology?: 'wallet' | 'account';
|
|
135
|
+
/** Hide when the containing panel already carries Dexter's mark. */
|
|
136
|
+
withMark?: boolean;
|
|
130
137
|
}
|
|
131
138
|
/** The turnkey consent-at-birth create panel. */
|
|
132
139
|
declare function CreateWalletPanel(props: CreateWalletPanelProps): ReactElement;
|
|
133
140
|
|
|
141
|
+
type AccountLinkComponent = ComponentType<AnchorHTMLAttributes<HTMLAnchorElement>>;
|
|
142
|
+
interface AccountDestination {
|
|
143
|
+
href: string;
|
|
144
|
+
label?: string;
|
|
145
|
+
}
|
|
146
|
+
interface AccountNavigation {
|
|
147
|
+
money: AccountDestination | false;
|
|
148
|
+
send: AccountDestination | false;
|
|
149
|
+
receive: AccountDestination | false;
|
|
150
|
+
activity: AccountDestination | false;
|
|
151
|
+
agents: AccountDestination | false;
|
|
152
|
+
profile: AccountDestination | false;
|
|
153
|
+
support: AccountDestination | false;
|
|
154
|
+
settings: AccountDestination | false;
|
|
155
|
+
}
|
|
156
|
+
/** Local app destinations can replace any hosted destination; false hides it. */
|
|
157
|
+
declare const DEFAULT_ACCOUNT_NAVIGATION: Readonly<AccountNavigation>;
|
|
158
|
+
interface AccountMenuItem {
|
|
159
|
+
id: string;
|
|
160
|
+
label: string;
|
|
161
|
+
href: string;
|
|
162
|
+
icon?: ReactNode;
|
|
163
|
+
hint?: string;
|
|
164
|
+
/** The host remains responsible for authorizing its destination. */
|
|
165
|
+
requires: 'account' | 'wallet';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface DexterAccountControlProps {
|
|
169
|
+
/** Reuse the app's canonical useDexterConnection instance. */
|
|
170
|
+
connection: UseDexterConnection;
|
|
171
|
+
open?: boolean;
|
|
172
|
+
onOpenChange?: (open: boolean) => void;
|
|
173
|
+
/** Shown only after the connection verifies account access. */
|
|
174
|
+
profile?: {
|
|
175
|
+
name?: string;
|
|
176
|
+
email?: string;
|
|
177
|
+
};
|
|
178
|
+
navigation?: Partial<AccountNavigation>;
|
|
179
|
+
/** Host-specific links. The connection also gates the required access. */
|
|
180
|
+
items?: readonly AccountMenuItem[];
|
|
181
|
+
LinkComponent?: AccountLinkComponent;
|
|
182
|
+
/** Optional adapter for an existing portfolio reader; presentation stays shared. */
|
|
183
|
+
renderSummary?: (onNavigate: () => void) => ReactNode;
|
|
184
|
+
formatError?: (code?: string) => string;
|
|
185
|
+
className?: string;
|
|
186
|
+
triggerClassName?: string;
|
|
187
|
+
styleNonce?: string;
|
|
188
|
+
}
|
|
189
|
+
/** Branded account entry with canonical connection, balance and settings. */
|
|
190
|
+
declare function DexterAccountControl({ connection: dexter, open: controlledOpen, onOpenChange, profile, navigation, items, LinkComponent, renderSummary, formatError, className, triggerClassName, styleNonce, }: DexterAccountControlProps): react.JSX.Element;
|
|
191
|
+
|
|
192
|
+
interface DexterAccountSummaryProps {
|
|
193
|
+
/** Formatted value from a read bound to the currently selected account. */
|
|
194
|
+
amount: string | null;
|
|
195
|
+
loading: boolean;
|
|
196
|
+
partial?: boolean;
|
|
197
|
+
refresh: () => Promise<void>;
|
|
198
|
+
navigation?: Partial<AccountNavigation>;
|
|
199
|
+
LinkComponent?: AccountLinkComponent;
|
|
200
|
+
onNavigate?: () => void;
|
|
201
|
+
styleNonce?: string;
|
|
202
|
+
}
|
|
203
|
+
/** The same balance and money actions used by DexterAccountControl. */
|
|
204
|
+
declare function DexterAccountSummary({ amount, loading, partial, refresh, navigation, LinkComponent, onNavigate, styleNonce }: DexterAccountSummaryProps): react.JSX.Element;
|
|
205
|
+
|
|
134
206
|
type InstallApp = 'claude' | 'chatgpt' | 'cursor' | 'vscode' | 'hermes' | 'claude-code';
|
|
135
207
|
interface AppInstallButtonsProps {
|
|
136
208
|
/** MCP endpoint to install. Default: OpenDexter. */
|
|
@@ -156,4 +228,4 @@ declare function hermesOpenUrl(name: string): string;
|
|
|
156
228
|
declare function claudeCodeInstallCommand(name: string, mcpUrl: string): string;
|
|
157
229
|
declare function AppInstallButtons(props: AppInstallButtonsProps): ReactElement;
|
|
158
230
|
|
|
159
|
-
export { AllowanceChips, type AllowanceChipsProps, AppInstallButtons, type AppInstallButtonsProps, CreateWalletPanel, type CreateWalletPanelProps, CreateWalletResult, type DexterAccountSession, DexterButton, type DexterButtonProps, DexterConnectionIntent, type DexterConnectionOperation, DexterControlModel, type DexterIdentityView, DexterMark, type DexterWalletView, type InstallApp, REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION, type RemoveDexterFromDeviceConfirmation, type RemoveDexterFromDeviceResult, SignInResult, type UseDexterConnection, type UseDexterConnectionConfig, WalletAccountRelationSnapshot, chatgptPluginsUrl, claudeCodeInstallCommand, claudeWebConnectorUrl, cursorInstallUrl, hermesInstallCommand, hermesOpenUrl, useDexterConnection, vscodeInstallUrl };
|
|
231
|
+
export { type AccountDestination, type AccountLinkComponent, type AccountMenuItem, type AccountNavigation, AllowanceChips, type AllowanceChipsProps, AppInstallButtons, type AppInstallButtonsProps, CreateWalletPanel, type CreateWalletPanelProps, CreateWalletResult, DEFAULT_ACCOUNT_NAVIGATION, DexterAccountControl, type DexterAccountControlProps, type DexterAccountSession, DexterAccountSummary, type DexterAccountSummaryProps, DexterButton, type DexterButtonProps, DexterConnectionIntent, type DexterConnectionOperation, DexterControlModel, type DexterIdentityView, DexterMark, type DexterWalletView, type InstallApp, REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION, type RemoveDexterFromDeviceConfirmation, type RemoveDexterFromDeviceResult, SignInResult, type UseDexterConnection, type UseDexterConnectionConfig, WalletAccountRelationSnapshot, chatgptPluginsUrl, claudeCodeInstallCommand, claudeWebConnectorUrl, cursorInstallUrl, hermesInstallCommand, hermesOpenUrl, useDexterConnection, vscodeInstallUrl };
|