decane-connect-kit 2.2.4 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +332 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +250 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2619,9 +2619,6 @@ function validatePin(pin) {
|
|
|
2619
2619
|
// src/social/crypto/passkey.ts
|
|
2620
2620
|
var import_browser2 = require("@simplewebauthn/browser");
|
|
2621
2621
|
init_errors();
|
|
2622
|
-
function b64u(u) {
|
|
2623
|
-
return btoa(String.fromCharCode(...u)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
2624
|
-
}
|
|
2625
2622
|
function fromB64u(s) {
|
|
2626
2623
|
return Uint8Array.from(atob(s.replace(/-/g, "+").replace(/_/g, "/")), (c) => c.charCodeAt(0));
|
|
2627
2624
|
}
|
|
@@ -2656,7 +2653,7 @@ async function authenticateWithPasskey(opts) {
|
|
|
2656
2653
|
...opts.optionsJSON,
|
|
2657
2654
|
extensions: {
|
|
2658
2655
|
...opts.optionsJSON.extensions,
|
|
2659
|
-
prf: { eval: { first:
|
|
2656
|
+
prf: { eval: { first: buf3(opts.prfSalt) } }
|
|
2660
2657
|
}
|
|
2661
2658
|
};
|
|
2662
2659
|
let response;
|
|
@@ -3339,6 +3336,7 @@ async function createDecaneConnect(config) {
|
|
|
3339
3336
|
}
|
|
3340
3337
|
async function passkeyLogin(stored) {
|
|
3341
3338
|
const userId = stored.userId;
|
|
3339
|
+
events.emit("wallet-unlocking");
|
|
3342
3340
|
const options = await api.getWebAuthnLoginOptions(userId, rpId);
|
|
3343
3341
|
if (!options) {
|
|
3344
3342
|
throw new NewDeviceError();
|
|
@@ -3372,8 +3370,10 @@ async function createDecaneConnect(config) {
|
|
|
3372
3370
|
async function handleAuthResult(result) {
|
|
3373
3371
|
let addresses;
|
|
3374
3372
|
if (!result.hasShare) {
|
|
3373
|
+
events.emit("wallet-creating");
|
|
3375
3374
|
addresses = await firstTimeSetup(result.userId, result.jwt);
|
|
3376
3375
|
} else {
|
|
3376
|
+
events.emit("wallet-unlocking");
|
|
3377
3377
|
addresses = await returningUserUnlock(result.userId, result.jwt);
|
|
3378
3378
|
}
|
|
3379
3379
|
auth = { jwt: result.jwt, userId: result.userId, addresses };
|
|
@@ -3712,8 +3712,8 @@ async function createDecaneConnect(config) {
|
|
|
3712
3712
|
function bufferToB64u(buf6) {
|
|
3713
3713
|
return btoa(String.fromCharCode(...buf6)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
3714
3714
|
}
|
|
3715
|
-
function b64uToBuffer(
|
|
3716
|
-
const b644 =
|
|
3715
|
+
function b64uToBuffer(b64u) {
|
|
3716
|
+
const b644 = b64u.replace(/-/g, "+").replace(/_/g, "/");
|
|
3717
3717
|
return Uint8Array.from(atob(b644), (c) => c.charCodeAt(0));
|
|
3718
3718
|
}
|
|
3719
3719
|
function toHex(bytes) {
|
|
@@ -4888,7 +4888,10 @@ function SignInView({
|
|
|
4888
4888
|
authMethods,
|
|
4889
4889
|
resumeHint,
|
|
4890
4890
|
customAuthLabel,
|
|
4891
|
-
onCustomAuthSignIn
|
|
4891
|
+
onCustomAuthSignIn,
|
|
4892
|
+
canUsePasskey,
|
|
4893
|
+
passkeyAddress,
|
|
4894
|
+
onPasskeySignIn
|
|
4892
4895
|
}) {
|
|
4893
4896
|
const [googleLoading, setGoogleLoading] = (0, import_react3.useState)(false);
|
|
4894
4897
|
const [email, setEmail] = (0, import_react3.useState)("");
|
|
@@ -4896,7 +4899,25 @@ function SignInView({
|
|
|
4896
4899
|
const [emailSent, setEmailSent] = (0, import_react3.useState)(false);
|
|
4897
4900
|
const [emailLoading, setEmailLoading] = (0, import_react3.useState)(false);
|
|
4898
4901
|
const [customLoading, setCustomLoading] = (0, import_react3.useState)(false);
|
|
4902
|
+
const [passkeyLoading, setPasskeyLoading] = (0, import_react3.useState)(false);
|
|
4903
|
+
const [showOtherMethods, setShowOtherMethods] = (0, import_react3.useState)(false);
|
|
4899
4904
|
const [error, setError] = (0, import_react3.useState)("");
|
|
4905
|
+
const passkeyFirst = !!canUsePasskey && !!onPasskeySignIn && !showOtherMethods;
|
|
4906
|
+
async function handlePasskey() {
|
|
4907
|
+
if (!onPasskeySignIn) return;
|
|
4908
|
+
setError("");
|
|
4909
|
+
setPasskeyLoading(true);
|
|
4910
|
+
try {
|
|
4911
|
+
await onPasskeySignIn();
|
|
4912
|
+
} catch (e) {
|
|
4913
|
+
const err = e;
|
|
4914
|
+
if (err?.name !== "UserCancelledError") {
|
|
4915
|
+
setError(err?.message ?? "Passkey sign-in failed");
|
|
4916
|
+
setShowOtherMethods(true);
|
|
4917
|
+
}
|
|
4918
|
+
setPasskeyLoading(false);
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4900
4921
|
async function handleGoogle() {
|
|
4901
4922
|
setError("");
|
|
4902
4923
|
setGoogleLoading(true);
|
|
@@ -4956,7 +4977,47 @@ function SignInView({
|
|
|
4956
4977
|
fontFamily: "inherit",
|
|
4957
4978
|
boxSizing: "border-box"
|
|
4958
4979
|
};
|
|
4959
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", { style: { padding: "0 16px 16px" } }, resumeHint && /* @__PURE__ */ import_react3.default.createElement("div", { style: { fontSize: 12, color: "var(--dc-text-muted)", marginBottom: 12, textAlign: "center" } }, "Welcome back \u2014 sign in again to resume ", resumeHint),
|
|
4980
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", { style: { padding: "0 16px 16px" } }, resumeHint && !passkeyFirst && /* @__PURE__ */ import_react3.default.createElement("div", { style: { fontSize: 12, color: "var(--dc-text-muted)", marginBottom: 12, textAlign: "center" } }, "Welcome back \u2014 sign in again to resume ", resumeHint), passkeyFirst && /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement("div", { style: { fontSize: 12, color: "var(--dc-text-muted)", marginBottom: 12, textAlign: "center" } }, "Welcome back \u2014 unlock to resume", passkeyAddress ? ` ${passkeyAddress.slice(0, 6)}\u2026${passkeyAddress.slice(-4)}` : ""), /* @__PURE__ */ import_react3.default.createElement(
|
|
4981
|
+
"button",
|
|
4982
|
+
{
|
|
4983
|
+
onClick: handlePasskey,
|
|
4984
|
+
disabled: passkeyLoading,
|
|
4985
|
+
style: {
|
|
4986
|
+
width: "100%",
|
|
4987
|
+
padding: "11px 0",
|
|
4988
|
+
background: "var(--dc-accent)",
|
|
4989
|
+
color: "var(--dc-accent-text)",
|
|
4990
|
+
border: "none",
|
|
4991
|
+
borderRadius: 10,
|
|
4992
|
+
fontSize: 13,
|
|
4993
|
+
fontWeight: 700,
|
|
4994
|
+
cursor: passkeyLoading ? "not-allowed" : "pointer",
|
|
4995
|
+
opacity: passkeyLoading ? 0.7 : 1,
|
|
4996
|
+
fontFamily: "inherit",
|
|
4997
|
+
display: "flex",
|
|
4998
|
+
alignItems: "center",
|
|
4999
|
+
justifyContent: "center",
|
|
5000
|
+
gap: 7
|
|
5001
|
+
}
|
|
5002
|
+
},
|
|
5003
|
+
passkeyLoading ? "Verifying\u2026" : "\u{1F513} Continue with passkey"
|
|
5004
|
+
), /* @__PURE__ */ import_react3.default.createElement(
|
|
5005
|
+
"button",
|
|
5006
|
+
{
|
|
5007
|
+
onClick: () => setShowOtherMethods(true),
|
|
5008
|
+
style: {
|
|
5009
|
+
width: "100%",
|
|
5010
|
+
marginTop: 10,
|
|
5011
|
+
background: "none",
|
|
5012
|
+
border: "none",
|
|
5013
|
+
color: "var(--dc-text-muted)",
|
|
5014
|
+
fontSize: 12,
|
|
5015
|
+
cursor: "pointer",
|
|
5016
|
+
fontFamily: "inherit"
|
|
5017
|
+
}
|
|
5018
|
+
},
|
|
5019
|
+
"Use email or Google instead"
|
|
5020
|
+
), error && /* @__PURE__ */ import_react3.default.createElement("div", { style: { marginTop: 10, fontSize: 12, color: "var(--dc-danger, #ff5533)" } }, error)), !passkeyFirst && authMethods.includes("google") && /* @__PURE__ */ import_react3.default.createElement(
|
|
4960
5021
|
"button",
|
|
4961
5022
|
{
|
|
4962
5023
|
onClick: handleGoogle,
|
|
@@ -4977,7 +5038,7 @@ function SignInView({
|
|
|
4977
5038
|
}
|
|
4978
5039
|
},
|
|
4979
5040
|
googleLoading ? "Redirecting\u2026" : "Continue with Google"
|
|
4980
|
-
), authMethods.includes("email") && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, authMethods.includes("google") && /* @__PURE__ */ import_react3.default.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), !emailSent ? /* @__PURE__ */ import_react3.default.createElement("form", { onSubmit: handleEmailStart, style: { display: "flex", gap: 8 } }, /* @__PURE__ */ import_react3.default.createElement(
|
|
5041
|
+
), !passkeyFirst && authMethods.includes("email") && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, authMethods.includes("google") && /* @__PURE__ */ import_react3.default.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), !emailSent ? /* @__PURE__ */ import_react3.default.createElement("form", { onSubmit: handleEmailStart, style: { display: "flex", gap: 8 } }, /* @__PURE__ */ import_react3.default.createElement(
|
|
4981
5042
|
"input",
|
|
4982
5043
|
{
|
|
4983
5044
|
type: "email",
|
|
@@ -5016,7 +5077,7 @@ function SignInView({
|
|
|
5016
5077
|
fontWeight: 700,
|
|
5017
5078
|
cursor: "pointer",
|
|
5018
5079
|
fontFamily: "inherit"
|
|
5019
|
-
} }, emailLoading ? "\u2026" : "Verify"))), customAuthLabel && onCustomAuthSignIn && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, (authMethods.includes("google") || authMethods.includes("email")) && /* @__PURE__ */ import_react3.default.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), /* @__PURE__ */ import_react3.default.createElement(
|
|
5080
|
+
} }, emailLoading ? "\u2026" : "Verify"))), !passkeyFirst && customAuthLabel && onCustomAuthSignIn && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, (authMethods.includes("google") || authMethods.includes("email")) && /* @__PURE__ */ import_react3.default.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), /* @__PURE__ */ import_react3.default.createElement(
|
|
5020
5081
|
"button",
|
|
5021
5082
|
{
|
|
5022
5083
|
onClick: handleCustomAuth,
|
|
@@ -5155,6 +5216,9 @@ function SocialWalletModal({
|
|
|
5155
5216
|
authMethods = ["google", "email"],
|
|
5156
5217
|
customAuthLabel,
|
|
5157
5218
|
onCustomAuthSignIn,
|
|
5219
|
+
canUsePasskey,
|
|
5220
|
+
passkeyAddress,
|
|
5221
|
+
onPasskeySignIn,
|
|
5158
5222
|
onRotateShares,
|
|
5159
5223
|
onExportPortableBackup,
|
|
5160
5224
|
rpcUrls,
|
|
@@ -5285,7 +5349,10 @@ function SocialWalletModal({
|
|
|
5285
5349
|
authMethods,
|
|
5286
5350
|
resumeHint: socialAuth.needsReconnect ? "your wallet" : void 0,
|
|
5287
5351
|
customAuthLabel,
|
|
5288
|
-
onCustomAuthSignIn
|
|
5352
|
+
onCustomAuthSignIn,
|
|
5353
|
+
canUsePasskey,
|
|
5354
|
+
passkeyAddress,
|
|
5355
|
+
onPasskeySignIn
|
|
5289
5356
|
}
|
|
5290
5357
|
) : /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement("div", { style: {
|
|
5291
5358
|
margin: "0 16px 14px",
|
|
@@ -5372,16 +5439,98 @@ function SocialWalletModal({
|
|
|
5372
5439
|
}
|
|
5373
5440
|
|
|
5374
5441
|
// src/ui/context.tsx
|
|
5442
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
5443
|
+
|
|
5444
|
+
// src/ui/StatusOverlay.tsx
|
|
5375
5445
|
var import_react4 = __toESM(require("react"), 1);
|
|
5446
|
+
var import_react_dom3 = require("react-dom");
|
|
5447
|
+
function injectTokens3(theme) {
|
|
5448
|
+
if (typeof document === "undefined") return;
|
|
5449
|
+
const resolved = theme === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : theme;
|
|
5450
|
+
let el = document.getElementById("decane-tokens");
|
|
5451
|
+
if (!el) {
|
|
5452
|
+
el = document.createElement("style");
|
|
5453
|
+
el.id = "decane-tokens";
|
|
5454
|
+
document.head.appendChild(el);
|
|
5455
|
+
}
|
|
5456
|
+
el.textContent = `:root { ${CSS_VARS[resolved]} }`;
|
|
5457
|
+
}
|
|
5458
|
+
function WalletStatusOverlay({
|
|
5459
|
+
phase,
|
|
5460
|
+
theme = "auto"
|
|
5461
|
+
}) {
|
|
5462
|
+
(0, import_react4.useEffect)(() => {
|
|
5463
|
+
if (!phase) return;
|
|
5464
|
+
injectTokens3(theme);
|
|
5465
|
+
if (theme !== "auto") return;
|
|
5466
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5467
|
+
const h = () => injectTokens3("auto");
|
|
5468
|
+
mq.addEventListener("change", h);
|
|
5469
|
+
return () => mq.removeEventListener("change", h);
|
|
5470
|
+
}, [phase, theme]);
|
|
5471
|
+
if (!phase || typeof document === "undefined") return null;
|
|
5472
|
+
const title = phase === "creating" ? "Creating your wallet" : "Unlocking your wallet";
|
|
5473
|
+
const sub = phase === "creating" ? "Generating your keys and splitting them across three shares so no single party ever holds your wallet. This takes a few seconds \u2014 please keep this tab open." : "Reopening your secure session\u2026";
|
|
5474
|
+
return (0, import_react_dom3.createPortal)(
|
|
5475
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
5476
|
+
"div",
|
|
5477
|
+
{
|
|
5478
|
+
role: "dialog",
|
|
5479
|
+
"aria-modal": "true",
|
|
5480
|
+
"aria-label": title,
|
|
5481
|
+
style: {
|
|
5482
|
+
position: "fixed",
|
|
5483
|
+
inset: 0,
|
|
5484
|
+
zIndex: 1e4,
|
|
5485
|
+
display: "flex",
|
|
5486
|
+
alignItems: "center",
|
|
5487
|
+
justifyContent: "center",
|
|
5488
|
+
padding: 16,
|
|
5489
|
+
fontFamily: "var(--dc-font-sans, system-ui, sans-serif)"
|
|
5490
|
+
}
|
|
5491
|
+
},
|
|
5492
|
+
/* @__PURE__ */ import_react4.default.createElement("div", { style: {
|
|
5493
|
+
position: "absolute",
|
|
5494
|
+
inset: 0,
|
|
5495
|
+
background: "var(--dc-bg-overlay, rgba(0,0,0,0.75))",
|
|
5496
|
+
backdropFilter: "blur(8px)",
|
|
5497
|
+
WebkitBackdropFilter: "blur(8px)"
|
|
5498
|
+
} }),
|
|
5499
|
+
/* @__PURE__ */ import_react4.default.createElement("div", { style: {
|
|
5500
|
+
position: "relative",
|
|
5501
|
+
background: "var(--dc-bg, #0D0D0B)",
|
|
5502
|
+
border: "1px solid var(--dc-border, #3D3C39)",
|
|
5503
|
+
borderRadius: 20,
|
|
5504
|
+
width: "100%",
|
|
5505
|
+
maxWidth: 340,
|
|
5506
|
+
padding: "30px 26px",
|
|
5507
|
+
textAlign: "center",
|
|
5508
|
+
boxShadow: "0 24px 64px rgba(0,0,0,0.6)"
|
|
5509
|
+
} }, /* @__PURE__ */ import_react4.default.createElement("div", { style: { display: "flex", justifyContent: "center", marginBottom: 18 } }, /* @__PURE__ */ import_react4.default.createElement("div", { style: { position: "relative", width: 60, height: 60, display: "flex", alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ import_react4.default.createElement("span", { style: {
|
|
5510
|
+
position: "absolute",
|
|
5511
|
+
inset: 0,
|
|
5512
|
+
borderRadius: "50%",
|
|
5513
|
+
border: "2px solid var(--dc-border, #3D3C39)",
|
|
5514
|
+
borderTopColor: "var(--dc-accent, #F5C800)",
|
|
5515
|
+
animation: "dc-status-spin 0.8s linear infinite"
|
|
5516
|
+
} }), /* @__PURE__ */ import_react4.default.createElement(DecaneMark, { size: 32 }))), /* @__PURE__ */ import_react4.default.createElement("div", { style: { fontSize: 16, fontWeight: 800, color: "var(--dc-text, #F9F9F7)", letterSpacing: "-0.02em", marginBottom: 7 } }, title), /* @__PURE__ */ import_react4.default.createElement("div", { style: { fontSize: 12, color: "var(--dc-text-muted, #8A8884)", lineHeight: 1.55 } }, sub), /* @__PURE__ */ import_react4.default.createElement("div", { style: { marginTop: 20, paddingTop: 14, borderTop: "1px solid var(--dc-border, #3D3C39)", display: "flex", alignItems: "center", justifyContent: "center", gap: 6 } }, /* @__PURE__ */ import_react4.default.createElement(DecaneMark, { size: 13, muted: true }), /* @__PURE__ */ import_react4.default.createElement(DecaneWordmark, { size: 11, muted: true }))),
|
|
5517
|
+
/* @__PURE__ */ import_react4.default.createElement("style", null, `@keyframes dc-status-spin { to { transform: rotate(360deg); } }`)
|
|
5518
|
+
),
|
|
5519
|
+
document.body
|
|
5520
|
+
);
|
|
5521
|
+
}
|
|
5522
|
+
|
|
5523
|
+
// src/ui/context.tsx
|
|
5376
5524
|
var DEFAULT_SOCIAL = {
|
|
5377
5525
|
addresses: null,
|
|
5378
5526
|
isNewUser: false,
|
|
5379
5527
|
isUnlocked: false,
|
|
5380
5528
|
sessionExpiresAt: null,
|
|
5381
5529
|
needsReconnect: false,
|
|
5382
|
-
canUsePasskey: false
|
|
5530
|
+
canUsePasskey: false,
|
|
5531
|
+
phase: null
|
|
5383
5532
|
};
|
|
5384
|
-
var DecaneContext = (0,
|
|
5533
|
+
var DecaneContext = (0, import_react5.createContext)(null);
|
|
5385
5534
|
function hasSocial(mode) {
|
|
5386
5535
|
return mode === "all" || mode === "social" || mode === "evm+social" || mode === "solana+social" || mode === "tron+social" || mode === "evm+tron+social";
|
|
5387
5536
|
}
|
|
@@ -5404,19 +5553,19 @@ function DecaneKit({ config, children }) {
|
|
|
5404
5553
|
`DecaneKit: config.social.apiKey is required for social sign-in (mode "${mode}"). Create an API key for this project in the dashboard.`
|
|
5405
5554
|
);
|
|
5406
5555
|
}
|
|
5407
|
-
const walletRef = (0,
|
|
5556
|
+
const walletRef = (0, import_react5.useRef)(null);
|
|
5408
5557
|
if (!walletRef.current) walletRef.current = createDecane(config);
|
|
5409
|
-
const socialRef = (0,
|
|
5410
|
-
const socialInitialized = (0,
|
|
5411
|
-
const [selectorOpen, setSelectorOpen] = (0,
|
|
5412
|
-
const [socialModalOpen, setSocialModalOpen] = (0,
|
|
5413
|
-
const [theme, setTheme] = (0,
|
|
5414
|
-
const [socialAuth, setSocialAuth] = (0,
|
|
5415
|
-
const openSelector = (0,
|
|
5416
|
-
const closeSelector = (0,
|
|
5417
|
-
const openSocialModal = (0,
|
|
5418
|
-
const closeSocialModal = (0,
|
|
5419
|
-
(0,
|
|
5558
|
+
const socialRef = (0, import_react5.useRef)(null);
|
|
5559
|
+
const socialInitialized = (0, import_react5.useRef)(false);
|
|
5560
|
+
const [selectorOpen, setSelectorOpen] = (0, import_react5.useState)(false);
|
|
5561
|
+
const [socialModalOpen, setSocialModalOpen] = (0, import_react5.useState)(false);
|
|
5562
|
+
const [theme, setTheme] = (0, import_react5.useState)(config?.theme ?? "auto");
|
|
5563
|
+
const [socialAuth, setSocialAuth] = (0, import_react5.useState)(DEFAULT_SOCIAL);
|
|
5564
|
+
const openSelector = (0, import_react5.useCallback)(() => setSelectorOpen(true), []);
|
|
5565
|
+
const closeSelector = (0, import_react5.useCallback)(() => setSelectorOpen(false), []);
|
|
5566
|
+
const openSocialModal = (0, import_react5.useCallback)(() => setSocialModalOpen(true), []);
|
|
5567
|
+
const closeSocialModal = (0, import_react5.useCallback)(() => setSocialModalOpen(false), []);
|
|
5568
|
+
(0, import_react5.useEffect)(() => {
|
|
5420
5569
|
if (!socialAuth.isUnlocked) return;
|
|
5421
5570
|
const id = setInterval(() => {
|
|
5422
5571
|
const sdk = socialRef.current;
|
|
@@ -5429,7 +5578,7 @@ function DecaneKit({ config, children }) {
|
|
|
5429
5578
|
}, 1e4);
|
|
5430
5579
|
return () => clearInterval(id);
|
|
5431
5580
|
}, [socialAuth.isUnlocked]);
|
|
5432
|
-
(0,
|
|
5581
|
+
(0, import_react5.useEffect)(() => {
|
|
5433
5582
|
if (!hasSocial(mode) || !config?.social || socialInitialized.current) return;
|
|
5434
5583
|
socialInitialized.current = true;
|
|
5435
5584
|
const {
|
|
@@ -5457,6 +5606,9 @@ function DecaneKit({ config, children }) {
|
|
|
5457
5606
|
() => setSocialAuth((p) => ({ ...p, isUnlocked: false, sessionExpiresAt: null }))
|
|
5458
5607
|
);
|
|
5459
5608
|
sdk.on("disconnected", () => setSocialAuth(DEFAULT_SOCIAL));
|
|
5609
|
+
sdk.on("wallet-creating", () => setSocialAuth((p) => ({ ...p, phase: "creating" })));
|
|
5610
|
+
sdk.on("wallet-unlocking", () => setSocialAuth((p) => ({ ...p, phase: "unlocking" })));
|
|
5611
|
+
sdk.on("connected", () => setSocialAuth((p) => ({ ...p, phase: null })));
|
|
5460
5612
|
const saved = sdk.getAddresses();
|
|
5461
5613
|
if (saved) {
|
|
5462
5614
|
setSocialAuth((p) => ({ ...p, addresses: saved, isUnlocked: false, needsReconnect: true }));
|
|
@@ -5465,7 +5617,10 @@ function DecaneKit({ config, children }) {
|
|
|
5465
5617
|
});
|
|
5466
5618
|
const params = new URLSearchParams(window.location.search);
|
|
5467
5619
|
if (params.has("decane_jwt") || params.has("decane_error")) {
|
|
5468
|
-
sdk.connectWithGoogle().then(applyResult).catch(
|
|
5620
|
+
sdk.connectWithGoogle().then(applyResult).catch((e) => {
|
|
5621
|
+
setSocialAuth((p) => p.phase ? { ...p, phase: null } : p);
|
|
5622
|
+
console.error(e);
|
|
5623
|
+
});
|
|
5469
5624
|
}
|
|
5470
5625
|
}).catch(console.error);
|
|
5471
5626
|
}, []);
|
|
@@ -5477,129 +5632,153 @@ function DecaneKit({ config, children }) {
|
|
|
5477
5632
|
isUnlocked: sdk?.isUnlocked() ?? false,
|
|
5478
5633
|
sessionExpiresAt: sdk?.sessionExpiresAt() ?? null,
|
|
5479
5634
|
needsReconnect: false,
|
|
5480
|
-
canUsePasskey: false
|
|
5635
|
+
canUsePasskey: false,
|
|
5636
|
+
phase: null
|
|
5481
5637
|
});
|
|
5482
5638
|
sdk?.canSignInWithPasskey().then((can) => setSocialAuth((p) => ({ ...p, canUsePasskey: can }))).catch(() => {
|
|
5483
5639
|
});
|
|
5484
5640
|
}
|
|
5485
|
-
const
|
|
5641
|
+
const clearPhase = (0, import_react5.useCallback)(() => setSocialAuth((p) => p.phase ? { ...p, phase: null } : p), []);
|
|
5642
|
+
const signInWithPasskey = (0, import_react5.useCallback)(async () => {
|
|
5486
5643
|
const sdk = socialRef.current;
|
|
5487
5644
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5645
|
+
try {
|
|
5646
|
+
const result = await sdk.signInWithPasskey();
|
|
5647
|
+
applyResult(result);
|
|
5648
|
+
setSelectorOpen(false);
|
|
5649
|
+
return result;
|
|
5650
|
+
} catch (e) {
|
|
5651
|
+
clearPhase();
|
|
5652
|
+
throw e;
|
|
5653
|
+
}
|
|
5654
|
+
}, [clearPhase]);
|
|
5655
|
+
const connectWithGoogle = (0, import_react5.useCallback)(async () => {
|
|
5494
5656
|
const sdk = socialRef.current;
|
|
5495
5657
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
5496
5658
|
await sdk.connectWithGoogle();
|
|
5497
5659
|
}, []);
|
|
5498
|
-
const connectWithEmail = (0,
|
|
5660
|
+
const connectWithEmail = (0, import_react5.useCallback)(async (email) => {
|
|
5499
5661
|
const sdk = socialRef.current;
|
|
5500
5662
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
5501
5663
|
return sdk.connectWithEmail(email);
|
|
5502
5664
|
}, []);
|
|
5503
|
-
const verifyEmailCode2 = (0,
|
|
5665
|
+
const verifyEmailCode2 = (0, import_react5.useCallback)(async (email, code) => {
|
|
5504
5666
|
const sdk = socialRef.current;
|
|
5505
5667
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5668
|
+
try {
|
|
5669
|
+
const result = await sdk.verifyEmailCode(email, code);
|
|
5670
|
+
applyResult(result);
|
|
5671
|
+
setSelectorOpen(false);
|
|
5672
|
+
} catch (e) {
|
|
5673
|
+
clearPhase();
|
|
5674
|
+
throw e;
|
|
5675
|
+
}
|
|
5676
|
+
}, [clearPhase]);
|
|
5677
|
+
const connectWithToken = (0, import_react5.useCallback)(async (token, opts) => {
|
|
5511
5678
|
const sdk = socialRef.current;
|
|
5512
5679
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5680
|
+
try {
|
|
5681
|
+
const result = await sdk.connectWithToken(token, opts);
|
|
5682
|
+
applyResult(result);
|
|
5683
|
+
setSelectorOpen(false);
|
|
5684
|
+
} catch (e) {
|
|
5685
|
+
clearPhase();
|
|
5686
|
+
throw e;
|
|
5687
|
+
}
|
|
5688
|
+
}, [clearPhase]);
|
|
5517
5689
|
const customAuthConfig = config?.social?.customAuth;
|
|
5518
|
-
const connectWithCustomAuth = (0,
|
|
5690
|
+
const connectWithCustomAuth = (0, import_react5.useCallback)(async () => {
|
|
5519
5691
|
if (!customAuthConfig) throw new Error("Custom auth not configured");
|
|
5520
5692
|
const token = await customAuthConfig.getToken();
|
|
5521
5693
|
await connectWithToken(token, customAuthConfig.providerId ? { providerId: customAuthConfig.providerId } : void 0);
|
|
5522
5694
|
}, [customAuthConfig, connectWithToken]);
|
|
5523
|
-
const socialUnlock = (0,
|
|
5695
|
+
const socialUnlock = (0, import_react5.useCallback)(async () => {
|
|
5524
5696
|
const sdk = socialRef.current;
|
|
5525
5697
|
if (!sdk) return;
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5698
|
+
setSocialAuth((p) => ({ ...p, phase: "unlocking" }));
|
|
5699
|
+
try {
|
|
5700
|
+
await sdk.unlock();
|
|
5701
|
+
setSocialAuth((p) => ({
|
|
5702
|
+
...p,
|
|
5703
|
+
isUnlocked: sdk.isUnlocked(),
|
|
5704
|
+
sessionExpiresAt: sdk.sessionExpiresAt(),
|
|
5705
|
+
needsReconnect: false,
|
|
5706
|
+
phase: null
|
|
5707
|
+
}));
|
|
5708
|
+
} catch (e) {
|
|
5709
|
+
clearPhase();
|
|
5710
|
+
throw e;
|
|
5711
|
+
}
|
|
5712
|
+
}, [clearPhase]);
|
|
5713
|
+
const socialDisconnect = (0, import_react5.useCallback)(async () => {
|
|
5535
5714
|
const sdk = socialRef.current;
|
|
5536
5715
|
if (!sdk) return;
|
|
5537
5716
|
await sdk.disconnect();
|
|
5538
5717
|
setSocialAuth(DEFAULT_SOCIAL);
|
|
5539
5718
|
}, []);
|
|
5540
|
-
const socialSignMessage = (0,
|
|
5719
|
+
const socialSignMessage = (0, import_react5.useCallback)(async (chain, message) => {
|
|
5541
5720
|
const sdk = socialRef.current;
|
|
5542
5721
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5543
5722
|
return sdk.signMessage({ chain, message });
|
|
5544
5723
|
}, []);
|
|
5545
|
-
const socialSendTransaction = (0,
|
|
5724
|
+
const socialSendTransaction = (0, import_react5.useCallback)(async (req) => {
|
|
5546
5725
|
const sdk = socialRef.current;
|
|
5547
5726
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5548
5727
|
return sdk.sendTransaction({ ...req, chain: req.chain });
|
|
5549
5728
|
}, []);
|
|
5550
|
-
const socialSignSolanaTransaction = (0,
|
|
5729
|
+
const socialSignSolanaTransaction = (0, import_react5.useCallback)(async (tx) => {
|
|
5551
5730
|
const sdk = socialRef.current;
|
|
5552
5731
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5553
5732
|
return sdk.signSolanaTransaction(tx);
|
|
5554
5733
|
}, []);
|
|
5555
|
-
const socialSignTypedData = (0,
|
|
5734
|
+
const socialSignTypedData = (0, import_react5.useCallback)(async (req) => {
|
|
5556
5735
|
const sdk = socialRef.current;
|
|
5557
5736
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5558
5737
|
return sdk.signTypedData({ ...req, chain: req.chain });
|
|
5559
5738
|
}, []);
|
|
5560
|
-
const socialGetBalance = (0,
|
|
5739
|
+
const socialGetBalance = (0, import_react5.useCallback)(async (chain) => {
|
|
5561
5740
|
const sdk = socialRef.current;
|
|
5562
5741
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5563
5742
|
return sdk.getBalance(chain);
|
|
5564
5743
|
}, []);
|
|
5565
|
-
const socialGetBalances = (0,
|
|
5744
|
+
const socialGetBalances = (0, import_react5.useCallback)(async () => {
|
|
5566
5745
|
const sdk = socialRef.current;
|
|
5567
5746
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5568
5747
|
return sdk.getBalances();
|
|
5569
5748
|
}, []);
|
|
5570
|
-
const socialRotateShares = (0,
|
|
5749
|
+
const socialRotateShares = (0, import_react5.useCallback)(async (opts) => {
|
|
5571
5750
|
const sdk = socialRef.current;
|
|
5572
5751
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5573
5752
|
return sdk.rotateShares(opts);
|
|
5574
5753
|
}, []);
|
|
5575
|
-
const socialExportPortableBackup = (0,
|
|
5754
|
+
const socialExportPortableBackup = (0, import_react5.useCallback)(async (opts) => {
|
|
5576
5755
|
const sdk = socialRef.current;
|
|
5577
5756
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5578
5757
|
return sdk.exportPortableBackup(opts);
|
|
5579
5758
|
}, []);
|
|
5580
|
-
const socialHasRecoveryShare = (0,
|
|
5759
|
+
const socialHasRecoveryShare = (0, import_react5.useCallback)(async () => {
|
|
5581
5760
|
const sdk = socialRef.current;
|
|
5582
5761
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5583
5762
|
return sdk.hasRecoveryShare();
|
|
5584
5763
|
}, []);
|
|
5585
|
-
const socialShouldPromptRecovery = (0,
|
|
5764
|
+
const socialShouldPromptRecovery = (0, import_react5.useCallback)(async () => {
|
|
5586
5765
|
const sdk = socialRef.current;
|
|
5587
5766
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5588
5767
|
return sdk.shouldPromptRecovery();
|
|
5589
5768
|
}, []);
|
|
5590
|
-
const socialDismissRecoveryPrompt = (0,
|
|
5769
|
+
const socialDismissRecoveryPrompt = (0, import_react5.useCallback)(async () => {
|
|
5591
5770
|
const sdk = socialRef.current;
|
|
5592
5771
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5593
5772
|
return sdk.dismissRecoveryPrompt();
|
|
5594
5773
|
}, []);
|
|
5595
|
-
const handleWalletConnect = (0,
|
|
5774
|
+
const handleWalletConnect = (0, import_react5.useCallback)(
|
|
5596
5775
|
(wallet, preference) => {
|
|
5597
5776
|
walletRef.current.connect(wallet, preference).catch(console.error);
|
|
5598
5777
|
},
|
|
5599
5778
|
[]
|
|
5600
5779
|
);
|
|
5601
5780
|
const networks = deriveNetworks(mode, config?.networks);
|
|
5602
|
-
return /* @__PURE__ */
|
|
5781
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
5603
5782
|
DecaneContext.Provider,
|
|
5604
5783
|
{
|
|
5605
5784
|
value: {
|
|
@@ -5637,7 +5816,7 @@ function DecaneKit({ config, children }) {
|
|
|
5637
5816
|
}
|
|
5638
5817
|
},
|
|
5639
5818
|
children,
|
|
5640
|
-
/* @__PURE__ */
|
|
5819
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
5641
5820
|
WalletSelector,
|
|
5642
5821
|
{
|
|
5643
5822
|
provider: walletRef.current,
|
|
@@ -5658,7 +5837,7 @@ function DecaneKit({ config, children }) {
|
|
|
5658
5837
|
onCustomAuthSignIn: customAuthConfig ? connectWithCustomAuth : void 0
|
|
5659
5838
|
}
|
|
5660
5839
|
),
|
|
5661
|
-
/* @__PURE__ */
|
|
5840
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
5662
5841
|
SocialWalletModal,
|
|
5663
5842
|
{
|
|
5664
5843
|
open: socialModalOpen,
|
|
@@ -5673,16 +5852,20 @@ function DecaneKit({ config, children }) {
|
|
|
5673
5852
|
onEmailStart: connectWithEmail,
|
|
5674
5853
|
onEmailVerify: verifyEmailCode2,
|
|
5675
5854
|
authMethods: config?.social?.authMethods ?? ["google", "email"],
|
|
5855
|
+
canUsePasskey: socialAuth.canUsePasskey,
|
|
5856
|
+
passkeyAddress: socialAuth.addresses?.evm ?? socialAuth.addresses?.solana ?? null,
|
|
5857
|
+
onPasskeySignIn: signInWithPasskey,
|
|
5676
5858
|
onRotateShares: socialRotateShares,
|
|
5677
5859
|
onExportPortableBackup: socialExportPortableBackup,
|
|
5678
5860
|
rpcUrls: config?.social?.rpcUrls,
|
|
5679
5861
|
chains: config?.social?.chains
|
|
5680
5862
|
}
|
|
5681
|
-
)
|
|
5863
|
+
),
|
|
5864
|
+
/* @__PURE__ */ import_react5.default.createElement(WalletStatusOverlay, { phase: socialAuth.phase, theme })
|
|
5682
5865
|
);
|
|
5683
5866
|
}
|
|
5684
5867
|
function useDecaneContext() {
|
|
5685
|
-
const ctx = (0,
|
|
5868
|
+
const ctx = (0, import_react5.useContext)(DecaneContext);
|
|
5686
5869
|
if (!ctx) {
|
|
5687
5870
|
throw new Error(
|
|
5688
5871
|
"Decane hooks must be called inside <DecaneKit>. Wrap your app: <DecaneKit config={...}><App /></DecaneKit>"
|
|
@@ -5692,7 +5875,7 @@ function useDecaneContext() {
|
|
|
5692
5875
|
}
|
|
5693
5876
|
|
|
5694
5877
|
// src/ui/hooks.ts
|
|
5695
|
-
var
|
|
5878
|
+
var import_react6 = require("react");
|
|
5696
5879
|
function useSocialAuth() {
|
|
5697
5880
|
const {
|
|
5698
5881
|
socialAuth,
|
|
@@ -5702,15 +5885,16 @@ function useSocialAuth() {
|
|
|
5702
5885
|
connectWithToken,
|
|
5703
5886
|
customAuthLabel,
|
|
5704
5887
|
connectWithCustomAuth,
|
|
5888
|
+
signInWithPasskey: ctxSignInWithPasskey,
|
|
5705
5889
|
socialUnlock,
|
|
5706
5890
|
socialDisconnect
|
|
5707
5891
|
} = useDecaneContext();
|
|
5708
|
-
const [googleLoading, setGoogleLoading] = (0,
|
|
5709
|
-
const [emailLoading, setEmailLoading] = (0,
|
|
5710
|
-
const [tokenLoading, setTokenLoading] = (0,
|
|
5711
|
-
const [customLoading, setCustomLoading] = (0,
|
|
5712
|
-
const [error, setError] = (0,
|
|
5713
|
-
const signInWithGoogle = (0,
|
|
5892
|
+
const [googleLoading, setGoogleLoading] = (0, import_react6.useState)(false);
|
|
5893
|
+
const [emailLoading, setEmailLoading] = (0, import_react6.useState)(false);
|
|
5894
|
+
const [tokenLoading, setTokenLoading] = (0, import_react6.useState)(false);
|
|
5895
|
+
const [customLoading, setCustomLoading] = (0, import_react6.useState)(false);
|
|
5896
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
5897
|
+
const signInWithGoogle = (0, import_react6.useCallback)(async () => {
|
|
5714
5898
|
setGoogleLoading(true);
|
|
5715
5899
|
setError(null);
|
|
5716
5900
|
try {
|
|
@@ -5720,7 +5904,7 @@ function useSocialAuth() {
|
|
|
5720
5904
|
setGoogleLoading(false);
|
|
5721
5905
|
}
|
|
5722
5906
|
}, [connectWithGoogle]);
|
|
5723
|
-
const sendEmailCode = (0,
|
|
5907
|
+
const sendEmailCode = (0, import_react6.useCallback)(async (email) => {
|
|
5724
5908
|
setEmailLoading(true);
|
|
5725
5909
|
setError(null);
|
|
5726
5910
|
try {
|
|
@@ -5733,7 +5917,7 @@ function useSocialAuth() {
|
|
|
5733
5917
|
setEmailLoading(false);
|
|
5734
5918
|
}
|
|
5735
5919
|
}, [connectWithEmail]);
|
|
5736
|
-
const confirmEmailCode = (0,
|
|
5920
|
+
const confirmEmailCode = (0, import_react6.useCallback)(async (email, code) => {
|
|
5737
5921
|
setEmailLoading(true);
|
|
5738
5922
|
setError(null);
|
|
5739
5923
|
try {
|
|
@@ -5745,7 +5929,7 @@ function useSocialAuth() {
|
|
|
5745
5929
|
setEmailLoading(false);
|
|
5746
5930
|
}
|
|
5747
5931
|
}, [verifyEmailCode2]);
|
|
5748
|
-
const signInWithToken = (0,
|
|
5932
|
+
const signInWithToken = (0, import_react6.useCallback)(async (token, opts) => {
|
|
5749
5933
|
setTokenLoading(true);
|
|
5750
5934
|
setError(null);
|
|
5751
5935
|
try {
|
|
@@ -5757,7 +5941,7 @@ function useSocialAuth() {
|
|
|
5757
5941
|
setTokenLoading(false);
|
|
5758
5942
|
}
|
|
5759
5943
|
}, [connectWithToken]);
|
|
5760
|
-
const signInWithCustomAuth = (0,
|
|
5944
|
+
const signInWithCustomAuth = (0, import_react6.useCallback)(async () => {
|
|
5761
5945
|
if (!connectWithCustomAuth) throw new Error("Custom auth not configured");
|
|
5762
5946
|
setCustomLoading(true);
|
|
5763
5947
|
setError(null);
|
|
@@ -5770,7 +5954,16 @@ function useSocialAuth() {
|
|
|
5770
5954
|
setCustomLoading(false);
|
|
5771
5955
|
}
|
|
5772
5956
|
}, [connectWithCustomAuth]);
|
|
5773
|
-
const
|
|
5957
|
+
const signInWithPasskey = (0, import_react6.useCallback)(async () => {
|
|
5958
|
+
setError(null);
|
|
5959
|
+
try {
|
|
5960
|
+
await ctxSignInWithPasskey();
|
|
5961
|
+
} catch (e) {
|
|
5962
|
+
setError(e.message);
|
|
5963
|
+
throw e;
|
|
5964
|
+
}
|
|
5965
|
+
}, [ctxSignInWithPasskey]);
|
|
5966
|
+
const unlock = (0, import_react6.useCallback)(async () => {
|
|
5774
5967
|
setError(null);
|
|
5775
5968
|
try {
|
|
5776
5969
|
await socialUnlock();
|
|
@@ -5779,7 +5972,7 @@ function useSocialAuth() {
|
|
|
5779
5972
|
throw e;
|
|
5780
5973
|
}
|
|
5781
5974
|
}, [socialUnlock]);
|
|
5782
|
-
const disconnect = (0,
|
|
5975
|
+
const disconnect = (0, import_react6.useCallback)(async () => {
|
|
5783
5976
|
setError(null);
|
|
5784
5977
|
try {
|
|
5785
5978
|
await socialDisconnect();
|
|
@@ -5794,6 +5987,11 @@ function useSocialAuth() {
|
|
|
5794
5987
|
isNewUser: socialAuth.isNewUser,
|
|
5795
5988
|
addresses: socialAuth.addresses,
|
|
5796
5989
|
sessionExpiresAt: socialAuth.sessionExpiresAt,
|
|
5990
|
+
// True when this device can skip the full sign-in and resume with a passkey.
|
|
5991
|
+
canUsePasskey: socialAuth.canUsePasskey,
|
|
5992
|
+
// Long-running work in progress, for driving your own status UI.
|
|
5993
|
+
phase: socialAuth.phase,
|
|
5994
|
+
isCreatingWallet: socialAuth.phase === "creating",
|
|
5797
5995
|
// True when addresses are known (from a previous visit) but there's no
|
|
5798
5996
|
// live session — unlock() will always throw in this state (every
|
|
5799
5997
|
// unlock requires a fresh JWT, and JWTs are never persisted). Route
|
|
@@ -5811,6 +6009,7 @@ function useSocialAuth() {
|
|
|
5811
6009
|
confirmEmailCode,
|
|
5812
6010
|
signInWithToken,
|
|
5813
6011
|
signInWithCustomAuth: connectWithCustomAuth ? signInWithCustomAuth : void 0,
|
|
6012
|
+
signInWithPasskey,
|
|
5814
6013
|
unlock,
|
|
5815
6014
|
disconnect
|
|
5816
6015
|
};
|
|
@@ -5835,8 +6034,8 @@ function useSocialWallet() {
|
|
|
5835
6034
|
closeSocialModal,
|
|
5836
6035
|
socialModalOpen
|
|
5837
6036
|
} = useDecaneContext();
|
|
5838
|
-
const [loading, setLoading] = (0,
|
|
5839
|
-
const [error, setError] = (0,
|
|
6037
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6038
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
5840
6039
|
async function run(fn) {
|
|
5841
6040
|
setLoading(true);
|
|
5842
6041
|
setError(null);
|
|
@@ -5850,31 +6049,31 @@ function useSocialWallet() {
|
|
|
5850
6049
|
setLoading(false);
|
|
5851
6050
|
}
|
|
5852
6051
|
}
|
|
5853
|
-
const signMessage = (0,
|
|
6052
|
+
const signMessage = (0, import_react6.useCallback)(
|
|
5854
6053
|
(chain, message) => run(() => socialSignMessage(chain, message)),
|
|
5855
6054
|
[socialSignMessage]
|
|
5856
6055
|
);
|
|
5857
|
-
const sendTransaction = (0,
|
|
6056
|
+
const sendTransaction = (0, import_react6.useCallback)(
|
|
5858
6057
|
(req) => run(() => socialSendTransaction(req)),
|
|
5859
6058
|
[socialSendTransaction]
|
|
5860
6059
|
);
|
|
5861
|
-
const signSolanaTransaction2 = (0,
|
|
6060
|
+
const signSolanaTransaction2 = (0, import_react6.useCallback)(
|
|
5862
6061
|
(tx) => run(() => socialSignSolanaTransaction(tx)),
|
|
5863
6062
|
[socialSignSolanaTransaction]
|
|
5864
6063
|
);
|
|
5865
|
-
const signTypedData = (0,
|
|
6064
|
+
const signTypedData = (0, import_react6.useCallback)(
|
|
5866
6065
|
(req) => run(() => socialSignTypedData(req)),
|
|
5867
6066
|
[socialSignTypedData]
|
|
5868
6067
|
);
|
|
5869
|
-
const getBalance = (0,
|
|
6068
|
+
const getBalance = (0, import_react6.useCallback)(
|
|
5870
6069
|
(chain) => run(() => socialGetBalance(chain)),
|
|
5871
6070
|
[socialGetBalance]
|
|
5872
6071
|
);
|
|
5873
|
-
const getBalances = (0,
|
|
6072
|
+
const getBalances = (0, import_react6.useCallback)(
|
|
5874
6073
|
() => run(() => socialGetBalances()),
|
|
5875
6074
|
[socialGetBalances]
|
|
5876
6075
|
);
|
|
5877
|
-
const unlock = (0,
|
|
6076
|
+
const unlock = (0, import_react6.useCallback)(async () => {
|
|
5878
6077
|
setError(null);
|
|
5879
6078
|
try {
|
|
5880
6079
|
await socialUnlock();
|
|
@@ -5883,7 +6082,7 @@ function useSocialWallet() {
|
|
|
5883
6082
|
throw e;
|
|
5884
6083
|
}
|
|
5885
6084
|
}, [socialUnlock]);
|
|
5886
|
-
const disconnect = (0,
|
|
6085
|
+
const disconnect = (0, import_react6.useCallback)(async () => {
|
|
5887
6086
|
setError(null);
|
|
5888
6087
|
try {
|
|
5889
6088
|
await socialDisconnect();
|
|
@@ -5892,23 +6091,23 @@ function useSocialWallet() {
|
|
|
5892
6091
|
throw e;
|
|
5893
6092
|
}
|
|
5894
6093
|
}, [socialDisconnect]);
|
|
5895
|
-
const rotateShares = (0,
|
|
6094
|
+
const rotateShares = (0, import_react6.useCallback)(
|
|
5896
6095
|
(opts) => run(() => socialRotateShares(opts)),
|
|
5897
6096
|
[socialRotateShares]
|
|
5898
6097
|
);
|
|
5899
|
-
const exportPortableBackup = (0,
|
|
6098
|
+
const exportPortableBackup = (0, import_react6.useCallback)(
|
|
5900
6099
|
(opts) => run(() => socialExportPortableBackup(opts)),
|
|
5901
6100
|
[socialExportPortableBackup]
|
|
5902
6101
|
);
|
|
5903
|
-
const hasRecoveryShare = (0,
|
|
6102
|
+
const hasRecoveryShare = (0, import_react6.useCallback)(
|
|
5904
6103
|
() => run(() => socialHasRecoveryShare()),
|
|
5905
6104
|
[socialHasRecoveryShare]
|
|
5906
6105
|
);
|
|
5907
|
-
const shouldPromptRecovery = (0,
|
|
6106
|
+
const shouldPromptRecovery = (0, import_react6.useCallback)(
|
|
5908
6107
|
() => run(() => socialShouldPromptRecovery()),
|
|
5909
6108
|
[socialShouldPromptRecovery]
|
|
5910
6109
|
);
|
|
5911
|
-
const dismissRecoveryPrompt = (0,
|
|
6110
|
+
const dismissRecoveryPrompt = (0, import_react6.useCallback)(
|
|
5912
6111
|
() => run(() => socialDismissRecoveryPrompt()),
|
|
5913
6112
|
[socialDismissRecoveryPrompt]
|
|
5914
6113
|
);
|
|
@@ -5924,6 +6123,10 @@ function useSocialWallet() {
|
|
|
5924
6123
|
// unlock requires a fresh JWT, and JWTs are never persisted). Route
|
|
5925
6124
|
// this into a real reconnect (signInWithGoogle / sendEmailCode), not unlock().
|
|
5926
6125
|
needsReconnect: socialAuth.needsReconnect,
|
|
6126
|
+
// Long-running work in progress ('creating' | 'unlocking' | null), for
|
|
6127
|
+
// driving your own status UI in addition to the SDK's built-in overlay.
|
|
6128
|
+
phase: socialAuth.phase,
|
|
6129
|
+
isCreatingWallet: socialAuth.phase === "creating",
|
|
5927
6130
|
// Modal
|
|
5928
6131
|
modalOpen: socialModalOpen,
|
|
5929
6132
|
openModal: openSocialModal,
|
|
@@ -5952,11 +6155,11 @@ function useSocialWallet() {
|
|
|
5952
6155
|
}
|
|
5953
6156
|
function useSocialBalance(chain) {
|
|
5954
6157
|
const { socialAuth, socialGetBalance } = useDecaneContext();
|
|
5955
|
-
const [balance, setBalance] = (0,
|
|
5956
|
-
const [loading, setLoading] = (0,
|
|
5957
|
-
const [error, setError] = (0,
|
|
6158
|
+
const [balance, setBalance] = (0, import_react6.useState)(null);
|
|
6159
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6160
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
5958
6161
|
const addrKey = `${socialAuth.addresses?.evm ?? ""}|${socialAuth.addresses?.solana ?? ""}`;
|
|
5959
|
-
const refetch = (0,
|
|
6162
|
+
const refetch = (0, import_react6.useCallback)(async () => {
|
|
5960
6163
|
if (!socialAuth.addresses) {
|
|
5961
6164
|
setBalance(null);
|
|
5962
6165
|
return;
|
|
@@ -5972,7 +6175,7 @@ function useSocialBalance(chain) {
|
|
|
5972
6175
|
setLoading(false);
|
|
5973
6176
|
}
|
|
5974
6177
|
}, [socialGetBalance, chain, socialAuth.addresses]);
|
|
5975
|
-
(0,
|
|
6178
|
+
(0, import_react6.useEffect)(() => {
|
|
5976
6179
|
let cancelled = false;
|
|
5977
6180
|
if (!socialAuth.addresses) {
|
|
5978
6181
|
setBalance(null);
|
|
@@ -6003,8 +6206,8 @@ function toDecaneError(err) {
|
|
|
6003
6206
|
}
|
|
6004
6207
|
function useDecane() {
|
|
6005
6208
|
const { provider, theme, setTheme } = useDecaneContext();
|
|
6006
|
-
const [, forceUpdate] = (0,
|
|
6007
|
-
(0,
|
|
6209
|
+
const [, forceUpdate] = (0, import_react6.useState)(0);
|
|
6210
|
+
(0, import_react6.useEffect)(() => {
|
|
6008
6211
|
const refresh = () => forceUpdate((n) => n + 1);
|
|
6009
6212
|
const events = [
|
|
6010
6213
|
"connect",
|
|
@@ -6043,10 +6246,10 @@ function useWalletSelector() {
|
|
|
6043
6246
|
}
|
|
6044
6247
|
function useChainSwitch() {
|
|
6045
6248
|
const { provider } = useDecaneContext();
|
|
6046
|
-
const [, forceUpdate] = (0,
|
|
6047
|
-
const [loading, setLoading] = (0,
|
|
6048
|
-
const [error, setError] = (0,
|
|
6049
|
-
(0,
|
|
6249
|
+
const [, forceUpdate] = (0, import_react6.useState)(0);
|
|
6250
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6251
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6252
|
+
(0, import_react6.useEffect)(() => {
|
|
6050
6253
|
const refresh = () => forceUpdate((n) => n + 1);
|
|
6051
6254
|
provider.on("connect", refresh);
|
|
6052
6255
|
provider.on("disconnect", refresh);
|
|
@@ -6055,7 +6258,7 @@ function useChainSwitch() {
|
|
|
6055
6258
|
provider.off("disconnect", refresh);
|
|
6056
6259
|
};
|
|
6057
6260
|
}, [provider]);
|
|
6058
|
-
const switchChain = (0,
|
|
6261
|
+
const switchChain = (0, import_react6.useCallback)(
|
|
6059
6262
|
async (chainId) => {
|
|
6060
6263
|
setLoading(true);
|
|
6061
6264
|
setError(null);
|
|
@@ -6109,10 +6312,10 @@ function resolveScope(provider, chainId, account) {
|
|
|
6109
6312
|
}
|
|
6110
6313
|
function useSignMessage() {
|
|
6111
6314
|
const { provider } = useDecaneContext();
|
|
6112
|
-
const [signature, setSignature] = (0,
|
|
6113
|
-
const [loading, setLoading] = (0,
|
|
6114
|
-
const [error, setError] = (0,
|
|
6115
|
-
const signMessage = (0,
|
|
6315
|
+
const [signature, setSignature] = (0, import_react6.useState)(null);
|
|
6316
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6317
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6318
|
+
const signMessage = (0, import_react6.useCallback)(
|
|
6116
6319
|
async (message, options) => {
|
|
6117
6320
|
const { chain, account } = resolveScope(
|
|
6118
6321
|
provider,
|
|
@@ -6138,7 +6341,7 @@ function useSignMessage() {
|
|
|
6138
6341
|
},
|
|
6139
6342
|
[provider]
|
|
6140
6343
|
);
|
|
6141
|
-
const reset = (0,
|
|
6344
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
6142
6345
|
setSignature(null);
|
|
6143
6346
|
setError(null);
|
|
6144
6347
|
}, []);
|
|
@@ -6146,10 +6349,10 @@ function useSignMessage() {
|
|
|
6146
6349
|
}
|
|
6147
6350
|
function useSendTransaction() {
|
|
6148
6351
|
const { provider } = useDecaneContext();
|
|
6149
|
-
const [txHash, setTxHash] = (0,
|
|
6150
|
-
const [loading, setLoading] = (0,
|
|
6151
|
-
const [error, setError] = (0,
|
|
6152
|
-
const sendTransaction = (0,
|
|
6352
|
+
const [txHash, setTxHash] = (0, import_react6.useState)(null);
|
|
6353
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6354
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6355
|
+
const sendTransaction = (0, import_react6.useCallback)(
|
|
6153
6356
|
async (tx, options) => {
|
|
6154
6357
|
const { chain, account } = resolveScope(
|
|
6155
6358
|
provider,
|
|
@@ -6176,7 +6379,7 @@ function useSendTransaction() {
|
|
|
6176
6379
|
},
|
|
6177
6380
|
[provider]
|
|
6178
6381
|
);
|
|
6179
|
-
const reset = (0,
|
|
6382
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
6180
6383
|
setTxHash(null);
|
|
6181
6384
|
setError(null);
|
|
6182
6385
|
}, []);
|
|
@@ -6184,10 +6387,10 @@ function useSendTransaction() {
|
|
|
6184
6387
|
}
|
|
6185
6388
|
function useSignTypedData() {
|
|
6186
6389
|
const { provider } = useDecaneContext();
|
|
6187
|
-
const [signature, setSignature] = (0,
|
|
6188
|
-
const [loading, setLoading] = (0,
|
|
6189
|
-
const [error, setError] = (0,
|
|
6190
|
-
const signTypedData = (0,
|
|
6390
|
+
const [signature, setSignature] = (0, import_react6.useState)(null);
|
|
6391
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
6392
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6393
|
+
const signTypedData = (0, import_react6.useCallback)(
|
|
6191
6394
|
async (typedData, options) => {
|
|
6192
6395
|
const { chain, account } = resolveScope(
|
|
6193
6396
|
provider,
|
|
@@ -6213,7 +6416,7 @@ function useSignTypedData() {
|
|
|
6213
6416
|
},
|
|
6214
6417
|
[provider]
|
|
6215
6418
|
);
|
|
6216
|
-
const reset = (0,
|
|
6419
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
6217
6420
|
setSignature(null);
|
|
6218
6421
|
setError(null);
|
|
6219
6422
|
}, []);
|