@dexterai/connect 0.26.2 → 0.26.3
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
CHANGED
|
@@ -95,6 +95,34 @@ import { passkeyLogin } from '@dexterai/connect';
|
|
|
95
95
|
const { session, vault } = await passkeyLogin({ transport: 'auto' });
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
By default, a successful sign-in immediately makes its wallet active in the
|
|
99
|
+
browser wallet store, preserving existing behavior. A flow that must finish a
|
|
100
|
+
separate account-level approval can instead keep the result provisional:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { passkeyLogin, setActiveHandle } from '@dexterai/connect';
|
|
104
|
+
|
|
105
|
+
const result = await passkeyLogin({
|
|
106
|
+
transport: 'auto',
|
|
107
|
+
walletStore: 'provisional',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Only after your approval has bound this exact wallet to the account:
|
|
111
|
+
if (result.vault) {
|
|
112
|
+
setActiveHandle(
|
|
113
|
+
result.vault.userHandle,
|
|
114
|
+
result.vault.walletLabel ?? undefined,
|
|
115
|
+
result.vault.credentialId,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`provisional` suppresses both active-handle and wallet-roster writes on the
|
|
121
|
+
hosted Dexter origin and the calling origin. It does not weaken passkey
|
|
122
|
+
verification or persist a second identity. `recoverWallet` accepts the same
|
|
123
|
+
option. The only supported modes are exact `commit` and `provisional`; omitted
|
|
124
|
+
means `commit`.
|
|
125
|
+
|
|
98
126
|
## Verify the session on your server
|
|
99
127
|
|
|
100
128
|
```ts
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
+
function resolveWalletStoreMode(mode) {
|
|
3
|
+
if (mode === void 0 || mode === "commit") return "commit";
|
|
4
|
+
if (mode === "provisional") return "provisional";
|
|
5
|
+
throw new ConnectError(
|
|
6
|
+
"invalid_wallet_store_mode",
|
|
7
|
+
"walletStore must be exactly commit or provisional"
|
|
8
|
+
);
|
|
9
|
+
}
|
|
2
10
|
var ConnectError = class extends Error {
|
|
3
11
|
code;
|
|
4
12
|
constructor(code, message) {
|
|
@@ -196,9 +204,11 @@ function openCeremonyPopup(op, config = {}) {
|
|
|
196
204
|
const openerOrigin = window.location.origin;
|
|
197
205
|
const requestId = makeNonce();
|
|
198
206
|
const signRequest = snapshotSignRequest(op, config.signRequest);
|
|
207
|
+
const walletStore = resolveWalletStoreMode(config.walletStore);
|
|
199
208
|
const params = new URLSearchParams({ v: "1", op, requestId, origin: openerOrigin });
|
|
200
209
|
if (config.name) params.set("name", config.name);
|
|
201
210
|
if (config.preferImmediate) params.set("preferImmediate", "1");
|
|
211
|
+
if (walletStore === "provisional") params.set("walletStore", "provisional");
|
|
202
212
|
const url = `${host}?${params.toString()}`;
|
|
203
213
|
return new Promise((resolve, reject) => {
|
|
204
214
|
const popup = window.open(url, "dexter-connect", popupFeatures());
|
|
@@ -570,11 +580,13 @@ var ANON_SIGN_BASE = "/api/passkey-anon/sign";
|
|
|
570
580
|
primeImmediateSupport();
|
|
571
581
|
async function passkeyLogin(config = {}, onPhase) {
|
|
572
582
|
const apiBase = resolveDexterApiBase(config.apiBase);
|
|
583
|
+
const walletStore = resolveWalletStoreMode(config.walletStore);
|
|
573
584
|
if (shouldUsePopup(config.transport)) {
|
|
574
585
|
const result2 = await openCeremonyPopup("signin", {
|
|
575
|
-
connectHost: config.connectHost
|
|
586
|
+
connectHost: config.connectHost,
|
|
587
|
+
...walletStore === "provisional" ? { walletStore } : {}
|
|
576
588
|
});
|
|
577
|
-
if (result2.vault) {
|
|
589
|
+
if (walletStore === "commit" && result2.vault) {
|
|
578
590
|
setActiveHandle(result2.vault.userHandle, result2.vault.walletLabel ?? void 0, result2.vault.credentialId);
|
|
579
591
|
}
|
|
580
592
|
return result2;
|
|
@@ -593,7 +605,7 @@ async function passkeyLogin(config = {}, onPhase) {
|
|
|
593
605
|
}
|
|
594
606
|
onPhase?.("verifying");
|
|
595
607
|
const result = await submitLogin(apiBase, response);
|
|
596
|
-
if (result.vault) {
|
|
608
|
+
if (walletStore === "commit" && result.vault) {
|
|
597
609
|
setActiveHandle(result.vault.userHandle, result.vault.walletLabel ?? void 0, result.vault.credentialId);
|
|
598
610
|
}
|
|
599
611
|
return result;
|
|
@@ -873,24 +885,35 @@ var ANON_SIGN_BASE3 = "/api/passkey-anon/sign";
|
|
|
873
885
|
primeImmediateSupport();
|
|
874
886
|
async function recoverWallet(config = {}) {
|
|
875
887
|
let apiBase;
|
|
888
|
+
let walletStore;
|
|
876
889
|
try {
|
|
877
890
|
apiBase = resolveDexterApiBase(config.apiBase);
|
|
878
891
|
} catch (err) {
|
|
879
892
|
return netError("untrusted_api_base", err);
|
|
880
893
|
}
|
|
894
|
+
try {
|
|
895
|
+
walletStore = resolveWalletStoreMode(config.walletStore);
|
|
896
|
+
} catch (err) {
|
|
897
|
+
return {
|
|
898
|
+
ok: false,
|
|
899
|
+
reason: "error",
|
|
900
|
+
error: err instanceof ConnectError ? err : new ConnectError("invalid_wallet_store_mode")
|
|
901
|
+
};
|
|
902
|
+
}
|
|
881
903
|
if (shouldUsePopup(config.transport)) {
|
|
882
904
|
let outcome;
|
|
883
905
|
try {
|
|
884
906
|
outcome = await openCeremonyPopup("recover", {
|
|
885
907
|
connectHost: config.connectHost,
|
|
886
|
-
preferImmediate: config.preferImmediate
|
|
908
|
+
preferImmediate: config.preferImmediate,
|
|
909
|
+
...walletStore === "provisional" ? { walletStore } : {}
|
|
887
910
|
});
|
|
888
911
|
} catch (err) {
|
|
889
912
|
const ce = err instanceof ConnectError ? err : new ConnectError("popup_failed", err instanceof Error ? err.message : String(err));
|
|
890
913
|
if (ce.code === "popup_closed") return { ok: false, reason: "cancelled" };
|
|
891
914
|
return { ok: false, reason: "error", error: ce };
|
|
892
915
|
}
|
|
893
|
-
if (outcome.ok) {
|
|
916
|
+
if (walletStore === "commit" && outcome.ok) {
|
|
894
917
|
setActiveHandle(outcome.userHandle, outcome.vault.walletLabel ?? void 0, outcome.credentialId);
|
|
895
918
|
}
|
|
896
919
|
return outcome;
|
|
@@ -983,7 +1006,9 @@ async function recoverWallet(config = {}) {
|
|
|
983
1006
|
} catch (err) {
|
|
984
1007
|
return netError("vault_status_failed", err);
|
|
985
1008
|
}
|
|
986
|
-
|
|
1009
|
+
if (walletStore === "commit") {
|
|
1010
|
+
setActiveHandle(userHandle, vault.walletLabel ?? void 0, credentialId);
|
|
1011
|
+
}
|
|
987
1012
|
return { ok: true, userHandle, credentialId, vault };
|
|
988
1013
|
}
|
|
989
1014
|
function netError(code, err) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ConnectVault, R as RecoverWalletConfig, a as RecoverOutcome, b as CeremonyPhase, I as IdentityKind } from './signals-
|
|
2
|
-
export { A as ACTIVE_WALLET_STORAGE_KEY, c as CeremonyOperation, d as ConnectError, e as ContinueResult, f as CreateWalletConfig, g as CreateWalletResult, D as DexterConnectConfig, H as HostedSignRequestPayload, h as HostedSignResult, i as HostedSignVaultIdentity, j as IdentityInput, P as
|
|
1
|
+
import { C as ConnectVault, R as RecoverWalletConfig, a as RecoverOutcome, b as CeremonyPhase, I as IdentityKind } from './signals-Dx090EYY.js';
|
|
2
|
+
export { A as ACTIVE_WALLET_STORAGE_KEY, c as CeremonyOperation, d as ConnectError, e as ContinueResult, f as CreateWalletConfig, g as CreateWalletResult, D as DexterConnectConfig, H as HostedSignRequestPayload, h as HostedSignResult, i as HostedSignVaultIdentity, j as IdentityInput, P as PasskeyLoginConfig, k as PasskeyLoginTokens, l as PasskeySignalSupport, m as RecoverVault, n as ResolvedIdentity, S as SESSION_TTL_30D, o as SignInResult, p as SpendPolicy, q as StoredWallet, W as WalletStoreMode, r as authoredPolicy, s as continueWithDexter, t as createWallet, u as ejectActiveWallet, v as forgetWallet, w as getActiveHandle, x as getCredentialId, y as listWallets, z as passkeyLogin, B as passkeySignalSupport, E as prunePasskey, F as renamePasskey, G as resolveIdentity, J as setActiveHandle, K as subscribeWallet, L as switchWallet, M as syncAcceptedPasskeys, N as usdToAtomic } from './signals-Dx090EYY.js';
|
|
3
3
|
import { PasskeySignerWithPublicKey } from '@dexterai/vault/signers';
|
|
4
4
|
|
|
5
5
|
/** What `issueChallenge` returns to the SDK signer. */
|
package/dist/index.js
CHANGED
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PasskeySignerWithPublicKey } from '@dexterai/vault/signers';
|
|
2
|
-
import { b as CeremonyPhase,
|
|
3
|
-
export {
|
|
2
|
+
import { b as CeremonyPhase, o as SignInResult, a as RecoverOutcome, e as ContinueResult, k as PasskeyLoginTokens, C as ConnectVault, d as ConnectError, q as StoredWallet, l as PasskeySignalSupport, n as ResolvedIdentity, g as CreateWalletResult } from './signals-Dx090EYY.js';
|
|
3
|
+
export { m as RecoverVault } from './signals-Dx090EYY.js';
|
|
4
4
|
import { ReactElement, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
type ConnectStatus = 'idle' | 'pending' | 'done' | 'error';
|
package/dist/react.js
CHANGED
|
@@ -43,6 +43,16 @@ interface SignInResult {
|
|
|
43
43
|
* challenge → passkey (the OS prompt) → verifying → finalizing (create only).
|
|
44
44
|
*/
|
|
45
45
|
type CeremonyPhase = 'challenge' | 'passkey' | 'verifying' | 'finalizing';
|
|
46
|
+
/**
|
|
47
|
+
* Controls whether a successful sign-in/recovery immediately changes the
|
|
48
|
+
* browser's active-wallet store.
|
|
49
|
+
*
|
|
50
|
+
* `commit` preserves the historical SDK behavior. `provisional` returns the
|
|
51
|
+
* verified session/vault without writing either the active handle or wallet
|
|
52
|
+
* roster, so a caller can finish an account-level approval first and then
|
|
53
|
+
* explicitly commit the approved wallet with `setActiveHandle`.
|
|
54
|
+
*/
|
|
55
|
+
type WalletStoreMode = 'commit' | 'provisional';
|
|
46
56
|
/** Exact action the hosted Dexter consent window is being asked to perform. */
|
|
47
57
|
type CeremonyOperation = 'signin' | 'create' | 'continue' | 'recover' | 'sign';
|
|
48
58
|
/** Minimal vault identity transferred to Dexter's hosted signing window. */
|
|
@@ -107,8 +117,19 @@ interface RecoverWalletConfig extends DexterConnectConfig {
|
|
|
107
117
|
* discoverable passkey (no empty account-picker sheet). Falls back to the
|
|
108
118
|
* normal modal wherever unsupported. */
|
|
109
119
|
preferImmediate?: boolean;
|
|
120
|
+
/** See `PasskeyLoginConfig.walletStore`. */
|
|
121
|
+
walletStore?: WalletStoreMode;
|
|
110
122
|
onPhase?: (phase: CeremonyPhase) => void;
|
|
111
123
|
}
|
|
124
|
+
/** Configuration for `passkeyLogin`. */
|
|
125
|
+
interface PasskeyLoginConfig extends DexterConnectConfig {
|
|
126
|
+
/**
|
|
127
|
+
* Wallet-store behavior after a successful passkey ceremony. Defaults to
|
|
128
|
+
* `commit` for backward compatibility. Use `provisional` when the returned
|
|
129
|
+
* wallet must pass a separate approval before becoming active.
|
|
130
|
+
*/
|
|
131
|
+
walletStore?: WalletStoreMode;
|
|
132
|
+
}
|
|
112
133
|
interface DexterConnectConfig {
|
|
113
134
|
/**
|
|
114
135
|
* Compatibility-only Dexter API base. Omit it or pass exactly
|
|
@@ -201,7 +222,7 @@ declare function createWallet(config?: CreateWalletConfig): Promise<CreateWallet
|
|
|
201
222
|
* Relays to dexter-api's ANON router — a first-time third-party user has no
|
|
202
223
|
* Supabase session, so the Supabase-gated router would 401.
|
|
203
224
|
*/
|
|
204
|
-
declare function passkeyLogin(config?:
|
|
225
|
+
declare function passkeyLogin(config?: PasskeyLoginConfig, onPhase?: (phase: CeremonyPhase) => void): Promise<SignInResult>;
|
|
205
226
|
type ContinueResult = ({
|
|
206
227
|
kind: 'signin';
|
|
207
228
|
} & SignInResult) | ({
|
|
@@ -351,4 +372,4 @@ declare function syncAcceptedPasskeys(args: {
|
|
|
351
372
|
rpId?: string;
|
|
352
373
|
}): Promise<boolean>;
|
|
353
374
|
|
|
354
|
-
export { ACTIVE_WALLET_STORAGE_KEY as A,
|
|
375
|
+
export { ACTIVE_WALLET_STORAGE_KEY as A, passkeySignalSupport as B, type ConnectVault as C, type DexterConnectConfig as D, prunePasskey as E, renamePasskey as F, resolveIdentity as G, type HostedSignRequestPayload as H, type IdentityKind as I, setActiveHandle as J, subscribe as K, switchWallet as L, syncAcceptedPasskeys as M, usdToAtomic as N, type PasskeyLoginConfig as P, type RecoverWalletConfig as R, SESSION_TTL_30D as S, type WalletStoreMode as W, type RecoverOutcome as a, type CeremonyPhase as b, type CeremonyOperation as c, ConnectError as d, type ContinueResult as e, type CreateWalletConfig as f, type CreateWalletResult as g, type HostedSignResult as h, type HostedSignVaultIdentity as i, type IdentityInput as j, type PasskeyLoginTokens as k, type PasskeySignalSupport as l, type RecoverVault as m, type ResolvedIdentity as n, type SignInResult as o, type SpendPolicy as p, type StoredWallet as q, authoredPolicy as r, continueWithDexter as s, createWallet as t, ejectActiveWallet as u, forgetWallet as v, getActiveHandle as w, getCredentialId as x, listWallets as y, passkeyLogin as z };
|