decane-connect-kit 2.7.6 → 2.8.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/index.cjs +312 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -6
- package/dist/index.d.ts +38 -6
- package/dist/index.js +312 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2017,6 +2017,18 @@ var ApiClient = class {
|
|
|
2017
2017
|
body: JSON.stringify({ email, code })
|
|
2018
2018
|
});
|
|
2019
2019
|
}
|
|
2020
|
+
async authPhoneStart(phone) {
|
|
2021
|
+
await this._request("/auth/phone/start", {
|
|
2022
|
+
method: "POST",
|
|
2023
|
+
body: JSON.stringify({ phone })
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
async authPhoneVerify(phone, code) {
|
|
2027
|
+
return this._request("/auth/phone/verify", {
|
|
2028
|
+
method: "POST",
|
|
2029
|
+
body: JSON.stringify({ phone, code })
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2020
2032
|
// GET /share (the server share itself) was removed as part of the TEE
|
|
2021
2033
|
// migration — the browser must never reconstruct the private key anymore.
|
|
2022
2034
|
// Only public addresses are fetched from the backend now.
|
|
@@ -2862,6 +2874,14 @@ async function verifyEmailCode(api, email, code) {
|
|
|
2862
2874
|
return api.authEmailVerify(email, code);
|
|
2863
2875
|
}
|
|
2864
2876
|
|
|
2877
|
+
// src/social/auth/phone.ts
|
|
2878
|
+
async function startPhoneAuth(api, phone) {
|
|
2879
|
+
await api.authPhoneStart(phone);
|
|
2880
|
+
}
|
|
2881
|
+
async function verifyPhoneCode(api, phone, code) {
|
|
2882
|
+
return api.authPhoneVerify(phone, code);
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2865
2885
|
// src/social/auth/kingschat.ts
|
|
2866
2886
|
init_errors();
|
|
2867
2887
|
var KINGSCHAT_AUTH_ORIGIN = "https://accounts.kingsch.at";
|
|
@@ -4069,6 +4089,14 @@ async function createDecaneConnect(config) {
|
|
|
4069
4089
|
const result = await verifyEmailCode(api, email, code);
|
|
4070
4090
|
return handleAuthResult(result);
|
|
4071
4091
|
},
|
|
4092
|
+
async connectWithPhone(phone) {
|
|
4093
|
+
await startPhoneAuth(api, phone);
|
|
4094
|
+
return { codeRequired: true };
|
|
4095
|
+
},
|
|
4096
|
+
async verifyPhoneCode(phone, code) {
|
|
4097
|
+
const result = await verifyPhoneCode(api, phone, code);
|
|
4098
|
+
return handleAuthResult(result);
|
|
4099
|
+
},
|
|
4072
4100
|
async canSignInWithPasskey() {
|
|
4073
4101
|
return await passkeyLoginCandidate() !== null;
|
|
4074
4102
|
},
|
|
@@ -4831,6 +4859,8 @@ function WalletSelector({
|
|
|
4831
4859
|
onKingsChatSignIn,
|
|
4832
4860
|
onEmailStart,
|
|
4833
4861
|
onEmailVerify,
|
|
4862
|
+
onPhoneStart,
|
|
4863
|
+
onPhoneVerify,
|
|
4834
4864
|
customAuthLabel,
|
|
4835
4865
|
onCustomAuthSignIn,
|
|
4836
4866
|
canUsePasskey = false,
|
|
@@ -4846,6 +4876,9 @@ function WalletSelector({
|
|
|
4846
4876
|
const [emailStep, setEmailStep] = useState("input");
|
|
4847
4877
|
const [emailVal, setEmailVal] = useState("");
|
|
4848
4878
|
const [codeVal, setCodeVal] = useState("");
|
|
4879
|
+
const [phoneStep, setPhoneStep] = useState("input");
|
|
4880
|
+
const [phoneVal, setPhoneVal] = useState("");
|
|
4881
|
+
const [phoneCode, setPhoneCode] = useState("");
|
|
4849
4882
|
const [socialLoad, setSocialLoad] = useState(false);
|
|
4850
4883
|
const [socialErr, setSocialErr] = useState("");
|
|
4851
4884
|
const [showOtherMethods, setShowOtherMethods] = useState(false);
|
|
@@ -4956,6 +4989,33 @@ function WalletSelector({
|
|
|
4956
4989
|
setSocialLoad(false);
|
|
4957
4990
|
}
|
|
4958
4991
|
}
|
|
4992
|
+
async function handlePhoneStart(e) {
|
|
4993
|
+
e.preventDefault();
|
|
4994
|
+
if (!onPhoneStart) return;
|
|
4995
|
+
setSocialLoad(true);
|
|
4996
|
+
setSocialErr("");
|
|
4997
|
+
try {
|
|
4998
|
+
await onPhoneStart(phoneVal);
|
|
4999
|
+
setPhoneStep("code");
|
|
5000
|
+
} catch (e2) {
|
|
5001
|
+
setSocialErr(e2.message);
|
|
5002
|
+
} finally {
|
|
5003
|
+
setSocialLoad(false);
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
async function handlePhoneVerify(e) {
|
|
5007
|
+
e.preventDefault();
|
|
5008
|
+
if (!onPhoneVerify) return;
|
|
5009
|
+
setSocialLoad(true);
|
|
5010
|
+
setSocialErr("");
|
|
5011
|
+
try {
|
|
5012
|
+
await onPhoneVerify(phoneVal, phoneCode);
|
|
5013
|
+
} catch (e2) {
|
|
5014
|
+
setSocialErr(e2.message);
|
|
5015
|
+
} finally {
|
|
5016
|
+
setSocialLoad(false);
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
4959
5019
|
const handleKey = useCallback(
|
|
4960
5020
|
(e) => {
|
|
4961
5021
|
if (e.key === "Escape") {
|
|
@@ -5491,6 +5551,126 @@ function WalletSelector({
|
|
|
5491
5551
|
}
|
|
5492
5552
|
},
|
|
5493
5553
|
socialLoad ? "Verifying\u2026" : "Verify"
|
|
5554
|
+
)))), !passkeyFirst && socialAuthMethods.includes("phone") && onPhoneStart && onPhoneVerify && (phoneStep === "input" ? /* @__PURE__ */ React2.createElement("form", { onSubmit: handlePhoneStart, style: { display: "flex", flexDirection: "column", gap: 8 } }, /* @__PURE__ */ React2.createElement(
|
|
5555
|
+
"input",
|
|
5556
|
+
{
|
|
5557
|
+
type: "tel",
|
|
5558
|
+
placeholder: "+234 801 234 5678",
|
|
5559
|
+
value: phoneVal,
|
|
5560
|
+
onChange: (e) => setPhoneVal(e.target.value),
|
|
5561
|
+
required: true,
|
|
5562
|
+
style: {
|
|
5563
|
+
width: "100%",
|
|
5564
|
+
padding: "10px 12px",
|
|
5565
|
+
background: "var(--dc-surface)",
|
|
5566
|
+
border: "1px solid var(--dc-border)",
|
|
5567
|
+
borderRadius: 10,
|
|
5568
|
+
color: "var(--dc-text)",
|
|
5569
|
+
fontSize: 13,
|
|
5570
|
+
fontFamily: "inherit",
|
|
5571
|
+
outline: "none",
|
|
5572
|
+
boxSizing: "border-box"
|
|
5573
|
+
},
|
|
5574
|
+
onFocus: (e) => {
|
|
5575
|
+
e.currentTarget.style.borderColor = "var(--dc-border-accent)";
|
|
5576
|
+
},
|
|
5577
|
+
onBlur: (e) => {
|
|
5578
|
+
e.currentTarget.style.borderColor = "var(--dc-border)";
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
), /* @__PURE__ */ React2.createElement(
|
|
5582
|
+
"button",
|
|
5583
|
+
{
|
|
5584
|
+
type: "submit",
|
|
5585
|
+
disabled: socialLoad || !phoneVal,
|
|
5586
|
+
style: {
|
|
5587
|
+
width: "100%",
|
|
5588
|
+
padding: "10px 16px",
|
|
5589
|
+
background: "var(--dc-accent)",
|
|
5590
|
+
color: "var(--dc-accent-text)",
|
|
5591
|
+
border: "none",
|
|
5592
|
+
borderRadius: 10,
|
|
5593
|
+
fontSize: 14,
|
|
5594
|
+
fontWeight: 700,
|
|
5595
|
+
cursor: socialLoad ? "not-allowed" : "pointer",
|
|
5596
|
+
fontFamily: "inherit",
|
|
5597
|
+
opacity: socialLoad || !phoneVal ? 0.6 : 1
|
|
5598
|
+
}
|
|
5599
|
+
},
|
|
5600
|
+
socialLoad ? "Sending\u2026" : "Send code"
|
|
5601
|
+
)) : /* @__PURE__ */ React2.createElement("form", { onSubmit: handlePhoneVerify, style: { display: "flex", flexDirection: "column", gap: 8 } }, /* @__PURE__ */ React2.createElement("p", { style: { margin: 0, fontSize: 12, color: "var(--dc-text-muted)", textAlign: "center" } }, "Code sent to ", /* @__PURE__ */ React2.createElement("strong", { style: { color: "var(--dc-text)" } }, phoneVal)), /* @__PURE__ */ React2.createElement(
|
|
5602
|
+
"input",
|
|
5603
|
+
{
|
|
5604
|
+
type: "text",
|
|
5605
|
+
inputMode: "numeric",
|
|
5606
|
+
placeholder: "6-digit code",
|
|
5607
|
+
value: phoneCode,
|
|
5608
|
+
onChange: (e) => setPhoneCode(e.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
5609
|
+
autoFocus: true,
|
|
5610
|
+
required: true,
|
|
5611
|
+
style: {
|
|
5612
|
+
width: "100%",
|
|
5613
|
+
padding: "10px 12px",
|
|
5614
|
+
background: "var(--dc-surface)",
|
|
5615
|
+
border: "1px solid var(--dc-border)",
|
|
5616
|
+
borderRadius: 10,
|
|
5617
|
+
color: "var(--dc-text)",
|
|
5618
|
+
fontSize: 20,
|
|
5619
|
+
fontFamily: "monospace",
|
|
5620
|
+
letterSpacing: 8,
|
|
5621
|
+
textAlign: "center",
|
|
5622
|
+
outline: "none",
|
|
5623
|
+
boxSizing: "border-box"
|
|
5624
|
+
},
|
|
5625
|
+
onFocus: (e) => {
|
|
5626
|
+
e.currentTarget.style.borderColor = "var(--dc-border-accent)";
|
|
5627
|
+
},
|
|
5628
|
+
onBlur: (e) => {
|
|
5629
|
+
e.currentTarget.style.borderColor = "var(--dc-border)";
|
|
5630
|
+
}
|
|
5631
|
+
}
|
|
5632
|
+
), /* @__PURE__ */ React2.createElement("div", { style: { display: "flex", gap: 8 } }, /* @__PURE__ */ React2.createElement(
|
|
5633
|
+
"button",
|
|
5634
|
+
{
|
|
5635
|
+
type: "button",
|
|
5636
|
+
onClick: () => {
|
|
5637
|
+
setPhoneStep("input");
|
|
5638
|
+
setPhoneCode("");
|
|
5639
|
+
setSocialErr("");
|
|
5640
|
+
},
|
|
5641
|
+
style: {
|
|
5642
|
+
flex: 1,
|
|
5643
|
+
padding: "9px 0",
|
|
5644
|
+
background: "transparent",
|
|
5645
|
+
border: "1px solid var(--dc-border)",
|
|
5646
|
+
borderRadius: 10,
|
|
5647
|
+
color: "var(--dc-text-muted)",
|
|
5648
|
+
fontSize: 13,
|
|
5649
|
+
cursor: "pointer",
|
|
5650
|
+
fontFamily: "inherit"
|
|
5651
|
+
}
|
|
5652
|
+
},
|
|
5653
|
+
"Back"
|
|
5654
|
+
), /* @__PURE__ */ React2.createElement(
|
|
5655
|
+
"button",
|
|
5656
|
+
{
|
|
5657
|
+
type: "submit",
|
|
5658
|
+
disabled: socialLoad || phoneCode.length < 6,
|
|
5659
|
+
style: {
|
|
5660
|
+
flex: 2,
|
|
5661
|
+
padding: "9px 0",
|
|
5662
|
+
background: "var(--dc-accent)",
|
|
5663
|
+
color: "var(--dc-accent-text)",
|
|
5664
|
+
border: "none",
|
|
5665
|
+
borderRadius: 10,
|
|
5666
|
+
fontSize: 13,
|
|
5667
|
+
fontWeight: 700,
|
|
5668
|
+
cursor: socialLoad || phoneCode.length < 6 ? "not-allowed" : "pointer",
|
|
5669
|
+
fontFamily: "inherit",
|
|
5670
|
+
opacity: socialLoad || phoneCode.length < 6 ? 0.6 : 1
|
|
5671
|
+
}
|
|
5672
|
+
},
|
|
5673
|
+
socialLoad ? "Verifying\u2026" : "Verify"
|
|
5494
5674
|
)))), !passkeyFirst && customAuthLabel && onCustomAuthSignIn && /* @__PURE__ */ React2.createElement(React2.Fragment, null, (socialAuthMethods.includes("google") || socialAuthMethods.includes("email")) && /* @__PURE__ */ React2.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10 } }, /* @__PURE__ */ React2.createElement("div", { style: { flex: 1, height: 1, background: "var(--dc-border)" } }), /* @__PURE__ */ React2.createElement("span", { style: { fontSize: 11, color: "var(--dc-text-muted)", whiteSpace: "nowrap" } }, "or"), /* @__PURE__ */ React2.createElement("div", { style: { flex: 1, height: 1, background: "var(--dc-border)" } })), /* @__PURE__ */ React2.createElement(
|
|
5495
5675
|
"button",
|
|
5496
5676
|
{
|
|
@@ -5621,6 +5801,8 @@ function SignInView({
|
|
|
5621
5801
|
onKingsChatSignIn,
|
|
5622
5802
|
onEmailStart,
|
|
5623
5803
|
onEmailVerify,
|
|
5804
|
+
onPhoneStart,
|
|
5805
|
+
onPhoneVerify,
|
|
5624
5806
|
authMethods,
|
|
5625
5807
|
resumeHint,
|
|
5626
5808
|
customAuthLabel,
|
|
@@ -5635,6 +5817,10 @@ function SignInView({
|
|
|
5635
5817
|
const [code, setCode] = useState2("");
|
|
5636
5818
|
const [emailSent, setEmailSent] = useState2(false);
|
|
5637
5819
|
const [emailLoading, setEmailLoading] = useState2(false);
|
|
5820
|
+
const [phone, setPhone] = useState2("");
|
|
5821
|
+
const [phoneCode, setPhoneCode] = useState2("");
|
|
5822
|
+
const [phoneSent, setPhoneSent] = useState2(false);
|
|
5823
|
+
const [phoneLoading, setPhoneLoading] = useState2(false);
|
|
5638
5824
|
const [customLoading, setCustomLoading] = useState2(false);
|
|
5639
5825
|
const [passkeyLoading, setPasskeyLoading] = useState2(false);
|
|
5640
5826
|
const [showOtherMethods, setShowOtherMethods] = useState2(false);
|
|
@@ -5702,6 +5888,33 @@ function SignInView({
|
|
|
5702
5888
|
setEmailLoading(false);
|
|
5703
5889
|
}
|
|
5704
5890
|
}
|
|
5891
|
+
async function handlePhoneStart(e) {
|
|
5892
|
+
e.preventDefault();
|
|
5893
|
+
if (!onPhoneStart) return;
|
|
5894
|
+
setError("");
|
|
5895
|
+
setPhoneLoading(true);
|
|
5896
|
+
try {
|
|
5897
|
+
await onPhoneStart(phone);
|
|
5898
|
+
setPhoneSent(true);
|
|
5899
|
+
} catch (e2) {
|
|
5900
|
+
setError(e2.message);
|
|
5901
|
+
} finally {
|
|
5902
|
+
setPhoneLoading(false);
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5905
|
+
async function handlePhoneVerify(e) {
|
|
5906
|
+
e.preventDefault();
|
|
5907
|
+
if (!onPhoneVerify) return;
|
|
5908
|
+
setError("");
|
|
5909
|
+
setPhoneLoading(true);
|
|
5910
|
+
try {
|
|
5911
|
+
await onPhoneVerify(phone, phoneCode);
|
|
5912
|
+
} catch (e2) {
|
|
5913
|
+
setError(e2.message);
|
|
5914
|
+
} finally {
|
|
5915
|
+
setPhoneLoading(false);
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5705
5918
|
async function handleCustomAuth() {
|
|
5706
5919
|
if (!onCustomAuthSignIn) return;
|
|
5707
5920
|
setError("");
|
|
@@ -5847,7 +6060,47 @@ function SignInView({
|
|
|
5847
6060
|
fontWeight: 700,
|
|
5848
6061
|
cursor: "pointer",
|
|
5849
6062
|
fontFamily: "inherit"
|
|
5850
|
-
} }, emailLoading ? "\u2026" : "Verify"))), !passkeyFirst &&
|
|
6063
|
+
} }, emailLoading ? "\u2026" : "Verify"))), !passkeyFirst && authMethods.includes("phone") && onPhoneStart && onPhoneVerify && /* @__PURE__ */ React3.createElement(React3.Fragment, null, (authMethods.includes("google") || authMethods.includes("email")) && /* @__PURE__ */ React3.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), !phoneSent ? /* @__PURE__ */ React3.createElement("form", { onSubmit: handlePhoneStart, style: { display: "flex", gap: 8 } }, /* @__PURE__ */ React3.createElement(
|
|
6064
|
+
"input",
|
|
6065
|
+
{
|
|
6066
|
+
type: "tel",
|
|
6067
|
+
required: true,
|
|
6068
|
+
placeholder: "+234 801 234 5678",
|
|
6069
|
+
value: phone,
|
|
6070
|
+
onChange: (e) => setPhone(e.target.value),
|
|
6071
|
+
style: { ...inputStyle, flex: 1 }
|
|
6072
|
+
}
|
|
6073
|
+
), /* @__PURE__ */ React3.createElement("button", { type: "submit", disabled: phoneLoading, style: {
|
|
6074
|
+
padding: "0 16px",
|
|
6075
|
+
background: "var(--dc-surface)",
|
|
6076
|
+
border: "1px solid var(--dc-border)",
|
|
6077
|
+
borderRadius: 8,
|
|
6078
|
+
color: "var(--dc-text)",
|
|
6079
|
+
fontSize: 13,
|
|
6080
|
+
cursor: "pointer",
|
|
6081
|
+
fontFamily: "inherit"
|
|
6082
|
+
} }, phoneLoading ? "\u2026" : "Send code")) : /* @__PURE__ */ React3.createElement("form", { onSubmit: handlePhoneVerify, style: { display: "flex", gap: 8 } }, /* @__PURE__ */ React3.createElement(
|
|
6083
|
+
"input",
|
|
6084
|
+
{
|
|
6085
|
+
placeholder: "6-digit code",
|
|
6086
|
+
value: phoneCode,
|
|
6087
|
+
maxLength: 6,
|
|
6088
|
+
autoFocus: true,
|
|
6089
|
+
inputMode: "numeric",
|
|
6090
|
+
onChange: (e) => setPhoneCode(e.target.value.replace(/\D/g, "")),
|
|
6091
|
+
style: { ...inputStyle, flex: 1, letterSpacing: 4, textAlign: "center" }
|
|
6092
|
+
}
|
|
6093
|
+
), /* @__PURE__ */ React3.createElement("button", { type: "submit", disabled: phoneLoading, style: {
|
|
6094
|
+
padding: "0 16px",
|
|
6095
|
+
background: "var(--dc-accent)",
|
|
6096
|
+
color: "var(--dc-accent-text)",
|
|
6097
|
+
border: "none",
|
|
6098
|
+
borderRadius: 8,
|
|
6099
|
+
fontSize: 13,
|
|
6100
|
+
fontWeight: 700,
|
|
6101
|
+
cursor: "pointer",
|
|
6102
|
+
fontFamily: "inherit"
|
|
6103
|
+
} }, phoneLoading ? "\u2026" : "Verify"))), !passkeyFirst && customAuthLabel && onCustomAuthSignIn && /* @__PURE__ */ React3.createElement(React3.Fragment, null, (authMethods.includes("google") || authMethods.includes("email")) && /* @__PURE__ */ React3.createElement("div", { style: { textAlign: "center", color: "var(--dc-text-muted)", fontSize: 12, margin: "10px 0" } }, "\u2014 or \u2014"), /* @__PURE__ */ React3.createElement(
|
|
5851
6104
|
"button",
|
|
5852
6105
|
{
|
|
5853
6106
|
onClick: handleCustomAuth,
|
|
@@ -5984,6 +6237,8 @@ function SocialWalletModal({
|
|
|
5984
6237
|
onKingsChatSignIn,
|
|
5985
6238
|
onEmailStart,
|
|
5986
6239
|
onEmailVerify,
|
|
6240
|
+
onPhoneStart,
|
|
6241
|
+
onPhoneVerify,
|
|
5987
6242
|
authMethods = ["google", "email"],
|
|
5988
6243
|
customAuthLabel,
|
|
5989
6244
|
onCustomAuthSignIn,
|
|
@@ -6118,6 +6373,8 @@ function SocialWalletModal({
|
|
|
6118
6373
|
onKingsChatSignIn,
|
|
6119
6374
|
onEmailStart,
|
|
6120
6375
|
onEmailVerify,
|
|
6376
|
+
onPhoneStart,
|
|
6377
|
+
onPhoneVerify,
|
|
6121
6378
|
authMethods,
|
|
6122
6379
|
resumeHint: socialAuth.needsReconnect ? "your wallet" : void 0,
|
|
6123
6380
|
customAuthLabel,
|
|
@@ -6484,6 +6741,23 @@ function DecaneKit({ config, children }) {
|
|
|
6484
6741
|
throw e;
|
|
6485
6742
|
}
|
|
6486
6743
|
}, [clearPhase]);
|
|
6744
|
+
const connectWithPhone = useCallback3(async (phone) => {
|
|
6745
|
+
const sdk = socialRef.current;
|
|
6746
|
+
if (!sdk) throw new Error("Social sign-in not configured");
|
|
6747
|
+
return sdk.connectWithPhone(phone);
|
|
6748
|
+
}, []);
|
|
6749
|
+
const verifyPhoneCode2 = useCallback3(async (phone, code) => {
|
|
6750
|
+
const sdk = socialRef.current;
|
|
6751
|
+
if (!sdk) throw new Error("Social sign-in not configured");
|
|
6752
|
+
try {
|
|
6753
|
+
const result = await sdk.verifyPhoneCode(phone, code);
|
|
6754
|
+
applyResult(result);
|
|
6755
|
+
setSelectorOpen(false);
|
|
6756
|
+
} catch (e) {
|
|
6757
|
+
clearPhase();
|
|
6758
|
+
throw e;
|
|
6759
|
+
}
|
|
6760
|
+
}, [clearPhase]);
|
|
6487
6761
|
const connectWithToken = useCallback3(async (token, opts) => {
|
|
6488
6762
|
const sdk = socialRef.current;
|
|
6489
6763
|
if (!sdk) throw new Error("Social sign-in not configured");
|
|
@@ -6636,6 +6910,8 @@ function DecaneKit({ config, children }) {
|
|
|
6636
6910
|
connectWithKingsChat,
|
|
6637
6911
|
connectWithEmail,
|
|
6638
6912
|
verifyEmailCode: verifyEmailCode2,
|
|
6913
|
+
connectWithPhone,
|
|
6914
|
+
verifyPhoneCode: verifyPhoneCode2,
|
|
6639
6915
|
connectWithToken,
|
|
6640
6916
|
customAuthLabel: customAuthConfig?.label,
|
|
6641
6917
|
connectWithCustomAuth: customAuthConfig ? connectWithCustomAuth : void 0,
|
|
@@ -6679,6 +6955,8 @@ function DecaneKit({ config, children }) {
|
|
|
6679
6955
|
onKingsChatSignIn: connectWithKingsChat,
|
|
6680
6956
|
onEmailStart: connectWithEmail,
|
|
6681
6957
|
onEmailVerify: verifyEmailCode2,
|
|
6958
|
+
onPhoneStart: connectWithPhone,
|
|
6959
|
+
onPhoneVerify: verifyPhoneCode2,
|
|
6682
6960
|
canUsePasskey: socialAuth.canUsePasskey,
|
|
6683
6961
|
passkeyAddress: socialAuth.addresses?.evm ?? socialAuth.addresses?.solana ?? null,
|
|
6684
6962
|
onPasskeySignIn: signInWithPasskey,
|
|
@@ -6701,6 +6979,8 @@ function DecaneKit({ config, children }) {
|
|
|
6701
6979
|
onKingsChatSignIn: connectWithKingsChat,
|
|
6702
6980
|
onEmailStart: connectWithEmail,
|
|
6703
6981
|
onEmailVerify: verifyEmailCode2,
|
|
6982
|
+
onPhoneStart: connectWithPhone,
|
|
6983
|
+
onPhoneVerify: verifyPhoneCode2,
|
|
6704
6984
|
authMethods: config?.social?.authMethods ?? ["google", "email"],
|
|
6705
6985
|
canUsePasskey: socialAuth.canUsePasskey,
|
|
6706
6986
|
passkeyAddress: socialAuth.addresses?.evm ?? socialAuth.addresses?.solana ?? null,
|
|
@@ -6732,6 +7012,8 @@ function useSocialAuth() {
|
|
|
6732
7012
|
connectWithGoogle,
|
|
6733
7013
|
connectWithEmail,
|
|
6734
7014
|
verifyEmailCode: verifyEmailCode2,
|
|
7015
|
+
connectWithPhone,
|
|
7016
|
+
verifyPhoneCode: verifyPhoneCode2,
|
|
6735
7017
|
connectWithToken,
|
|
6736
7018
|
customAuthLabel,
|
|
6737
7019
|
connectWithCustomAuth,
|
|
@@ -6741,6 +7023,7 @@ function useSocialAuth() {
|
|
|
6741
7023
|
} = useDecaneContext();
|
|
6742
7024
|
const [googleLoading, setGoogleLoading] = useState4(false);
|
|
6743
7025
|
const [emailLoading, setEmailLoading] = useState4(false);
|
|
7026
|
+
const [phoneLoading, setPhoneLoading] = useState4(false);
|
|
6744
7027
|
const [tokenLoading, setTokenLoading] = useState4(false);
|
|
6745
7028
|
const [customLoading, setCustomLoading] = useState4(false);
|
|
6746
7029
|
const [error, setError] = useState4(null);
|
|
@@ -6779,6 +7062,31 @@ function useSocialAuth() {
|
|
|
6779
7062
|
setEmailLoading(false);
|
|
6780
7063
|
}
|
|
6781
7064
|
}, [verifyEmailCode2]);
|
|
7065
|
+
const sendPhoneCode = useCallback4(async (phone) => {
|
|
7066
|
+
setPhoneLoading(true);
|
|
7067
|
+
setError(null);
|
|
7068
|
+
try {
|
|
7069
|
+
await connectWithPhone(phone);
|
|
7070
|
+
return { codeRequired: true };
|
|
7071
|
+
} catch (e) {
|
|
7072
|
+
setError(e.message);
|
|
7073
|
+
throw e;
|
|
7074
|
+
} finally {
|
|
7075
|
+
setPhoneLoading(false);
|
|
7076
|
+
}
|
|
7077
|
+
}, [connectWithPhone]);
|
|
7078
|
+
const confirmPhoneCode = useCallback4(async (phone, code) => {
|
|
7079
|
+
setPhoneLoading(true);
|
|
7080
|
+
setError(null);
|
|
7081
|
+
try {
|
|
7082
|
+
await verifyPhoneCode2(phone, code);
|
|
7083
|
+
} catch (e) {
|
|
7084
|
+
setError(e.message);
|
|
7085
|
+
throw e;
|
|
7086
|
+
} finally {
|
|
7087
|
+
setPhoneLoading(false);
|
|
7088
|
+
}
|
|
7089
|
+
}, [verifyPhoneCode2]);
|
|
6782
7090
|
const signInWithToken = useCallback4(async (token, opts) => {
|
|
6783
7091
|
setTokenLoading(true);
|
|
6784
7092
|
setError(null);
|
|
@@ -6849,6 +7157,7 @@ function useSocialAuth() {
|
|
|
6849
7157
|
needsReconnect: socialAuth.needsReconnect,
|
|
6850
7158
|
googleLoading,
|
|
6851
7159
|
emailLoading,
|
|
7160
|
+
phoneLoading,
|
|
6852
7161
|
tokenLoading,
|
|
6853
7162
|
customLoading,
|
|
6854
7163
|
customAuthLabel,
|
|
@@ -6857,6 +7166,8 @@ function useSocialAuth() {
|
|
|
6857
7166
|
signInWithGoogle,
|
|
6858
7167
|
sendEmailCode,
|
|
6859
7168
|
confirmEmailCode,
|
|
7169
|
+
sendPhoneCode,
|
|
7170
|
+
confirmPhoneCode,
|
|
6860
7171
|
signInWithToken,
|
|
6861
7172
|
signInWithCustomAuth: connectWithCustomAuth ? signInWithCustomAuth : void 0,
|
|
6862
7173
|
signInWithPasskey,
|