@daimo/sdk 1.4.2 → 1.5.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/client/createDaimoClient.d.ts +24 -6
- package/dist/client/createDaimoClient.d.ts.map +1 -1
- package/dist/client/createDaimoClient.js +47 -0
- package/dist/client/createDaimoClient.js.map +1 -1
- package/dist/common/account.d.ts +160 -21
- package/dist/common/account.d.ts.map +1 -1
- package/dist/common/account.js +12 -1
- package/dist/common/account.js.map +1 -1
- package/dist/common/api.d.ts +25 -12
- package/dist/common/api.d.ts.map +1 -1
- package/dist/common/api.js +11 -1
- package/dist/common/api.js.map +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/session.d.ts +27 -3
- package/dist/common/session.d.ts.map +1 -1
- package/dist/common/session.js.map +1 -1
- package/dist/common/theme.d.ts +47 -0
- package/dist/common/theme.d.ts.map +1 -0
- package/dist/common/theme.js +230 -0
- package/dist/common/theme.js.map +1 -0
- package/dist/common/token.d.ts +6 -0
- package/dist/common/token.d.ts.map +1 -1
- package/dist/common/token.js +47 -1
- package/dist/common/token.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/web/accountWallet.d.ts +15 -0
- package/dist/web/accountWallet.d.ts.map +1 -0
- package/dist/web/accountWallet.js +44 -0
- package/dist/web/accountWallet.js.map +1 -0
- package/dist/web/api/index.d.ts +17 -11
- package/dist/web/api/index.d.ts.map +1 -1
- package/dist/web/api/navTree.d.ts +27 -5
- package/dist/web/api/navTree.d.ts.map +1 -1
- package/dist/web/components/ApplePayLogo.d.ts +9 -0
- package/dist/web/components/ApplePayLogo.d.ts.map +1 -0
- package/dist/web/components/ApplePayLogo.js +15 -0
- package/dist/web/components/ApplePayLogo.js.map +1 -0
- package/dist/web/components/ChooseChainPage.d.ts.map +1 -1
- package/dist/web/components/ChooseChainPage.js +3 -3
- package/dist/web/components/ChooseChainPage.js.map +1 -1
- package/dist/web/components/ChooseOptionPage.d.ts.map +1 -1
- package/dist/web/components/ChooseOptionPage.js +20 -7
- package/dist/web/components/ChooseOptionPage.js.map +1 -1
- package/dist/web/components/ChooseWalletPage.js +12 -3
- package/dist/web/components/ChooseWalletPage.js.map +1 -1
- package/dist/web/components/ConfirmationPage.d.ts.map +1 -1
- package/dist/web/components/ConfirmationPage.js +2 -1
- package/dist/web/components/ConfirmationPage.js.map +1 -1
- package/dist/web/components/ConfirmationSpinner.d.ts +3 -1
- package/dist/web/components/ConfirmationSpinner.d.ts.map +1 -1
- package/dist/web/components/ConfirmationSpinner.js +7 -2
- package/dist/web/components/ConfirmationSpinner.js.map +1 -1
- package/dist/web/components/DaimoFrame.d.ts +51 -0
- package/dist/web/components/DaimoFrame.d.ts.map +1 -0
- package/dist/web/components/DaimoFrame.js +173 -0
- package/dist/web/components/DaimoFrame.js.map +1 -0
- package/dist/web/components/DaimoModal.d.ts.map +1 -1
- package/dist/web/components/DaimoModal.js +127 -52
- package/dist/web/components/DaimoModal.js.map +1 -1
- package/dist/web/components/DaimoModalPreview.d.ts +11 -0
- package/dist/web/components/DaimoModalPreview.d.ts.map +1 -0
- package/dist/web/components/DaimoModalPreview.js +98 -0
- package/dist/web/components/DaimoModalPreview.js.map +1 -0
- package/dist/web/components/DeeplinkPage.d.ts.map +1 -1
- package/dist/web/components/DeeplinkPage.js +4 -3
- package/dist/web/components/DeeplinkPage.js.map +1 -1
- package/dist/web/components/ErrorPage.d.ts.map +1 -1
- package/dist/web/components/ErrorPage.js +4 -1
- package/dist/web/components/ErrorPage.js.map +1 -1
- package/dist/web/components/ExchangePage.d.ts.map +1 -1
- package/dist/web/components/ExchangePage.js +8 -23
- package/dist/web/components/ExchangePage.js.map +1 -1
- package/dist/web/components/ExternalPaymentPage.d.ts +22 -0
- package/dist/web/components/ExternalPaymentPage.d.ts.map +1 -0
- package/dist/web/components/ExternalPaymentPage.js +24 -0
- package/dist/web/components/ExternalPaymentPage.js.map +1 -0
- package/dist/web/components/ModalChrome.d.ts +28 -0
- package/dist/web/components/ModalChrome.d.ts.map +1 -0
- package/dist/web/components/ModalChrome.js +64 -0
- package/dist/web/components/ModalChrome.js.map +1 -0
- package/dist/web/components/ModalSkeleton.d.ts.map +1 -1
- package/dist/web/components/ModalSkeleton.js +2 -4
- package/dist/web/components/ModalSkeleton.js.map +1 -1
- package/dist/web/components/SelectAmountPage.d.ts.map +1 -1
- package/dist/web/components/SelectAmountPage.js +2 -2
- package/dist/web/components/SelectAmountPage.js.map +1 -1
- package/dist/web/components/SelectTokenPage.d.ts.map +1 -1
- package/dist/web/components/SelectTokenPage.js +8 -7
- package/dist/web/components/SelectTokenPage.js.map +1 -1
- package/dist/web/components/Skeleton.d.ts +19 -0
- package/dist/web/components/Skeleton.d.ts.map +1 -0
- package/dist/web/components/Skeleton.js +21 -0
- package/dist/web/components/Skeleton.js.map +1 -0
- package/dist/web/components/StripeOnrampPage.d.ts +3 -27
- package/dist/web/components/StripeOnrampPage.d.ts.map +1 -1
- package/dist/web/components/StripeOnrampPage.js +7 -116
- package/dist/web/components/StripeOnrampPage.js.map +1 -1
- package/dist/web/components/TokenAmountEntry.d.ts +9 -3
- package/dist/web/components/TokenAmountEntry.d.ts.map +1 -1
- package/dist/web/components/TokenAmountEntry.js +49 -27
- package/dist/web/components/TokenAmountEntry.js.map +1 -1
- package/dist/web/components/WaitingDepositAddressPage.d.ts +39 -0
- package/dist/web/components/WaitingDepositAddressPage.d.ts.map +1 -1
- package/dist/web/components/WaitingDepositAddressPage.js +61 -32
- package/dist/web/components/WaitingDepositAddressPage.js.map +1 -1
- package/dist/web/components/WalletAmountPage.d.ts.map +1 -1
- package/dist/web/components/WalletAmountPage.js +7 -4
- package/dist/web/components/WalletAmountPage.js.map +1 -1
- package/dist/web/components/account/AccountApplePayPage.d.ts +1 -1
- package/dist/web/components/account/AccountApplePayPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountApplePayPage.js +26 -14
- package/dist/web/components/account/AccountApplePayPage.js.map +1 -1
- package/dist/web/components/account/AccountBankDetailsPage.d.ts +2 -1
- package/dist/web/components/account/AccountBankDetailsPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountBankDetailsPage.js +166 -54
- package/dist/web/components/account/AccountBankDetailsPage.js.map +1 -1
- package/dist/web/components/account/AccountBankPickerPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountBankPickerPage.js +15 -13
- package/dist/web/components/account/AccountBankPickerPage.js.map +1 -1
- package/dist/web/components/account/AccountBankTransferSubmittedPage.d.ts +3 -1
- package/dist/web/components/account/AccountBankTransferSubmittedPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountBankTransferSubmittedPage.js +9 -3
- package/dist/web/components/account/AccountBankTransferSubmittedPage.js.map +1 -1
- package/dist/web/components/account/AccountCreatingWalletPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountCreatingWalletPage.js +6 -4
- package/dist/web/components/account/AccountCreatingWalletPage.js.map +1 -1
- package/dist/web/components/account/AccountEmailPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountEmailPage.js +20 -14
- package/dist/web/components/account/AccountEmailPage.js.map +1 -1
- package/dist/web/components/account/AccountEnrollmentPage.d.ts +7 -3
- package/dist/web/components/account/AccountEnrollmentPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountEnrollmentPage.js +142 -107
- package/dist/web/components/account/AccountEnrollmentPage.js.map +1 -1
- package/dist/web/components/account/AccountEnrollmentUpdatePage.d.ts +10 -0
- package/dist/web/components/account/AccountEnrollmentUpdatePage.d.ts.map +1 -0
- package/dist/web/components/account/AccountEnrollmentUpdatePage.js +214 -0
- package/dist/web/components/account/AccountEnrollmentUpdatePage.js.map +1 -0
- package/dist/web/components/account/AccountFlowProvider.d.ts +1 -1
- package/dist/web/components/account/AccountFlowProvider.d.ts.map +1 -1
- package/dist/web/components/account/AccountFlowProvider.js +26 -20
- package/dist/web/components/account/AccountFlowProvider.js.map +1 -1
- package/dist/web/components/account/AccountKycInfoPage.d.ts +13 -0
- package/dist/web/components/account/AccountKycInfoPage.d.ts.map +1 -0
- package/dist/web/components/account/AccountKycInfoPage.js +37 -0
- package/dist/web/components/account/AccountKycInfoPage.js.map +1 -0
- package/dist/web/components/account/AccountOtpCodeEntry.d.ts +4 -1
- package/dist/web/components/account/AccountOtpCodeEntry.d.ts.map +1 -1
- package/dist/web/components/account/AccountOtpCodeEntry.js +46 -43
- package/dist/web/components/account/AccountOtpCodeEntry.js.map +1 -1
- package/dist/web/components/account/AccountPaymentPage.d.ts +3 -2
- package/dist/web/components/account/AccountPaymentPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountPaymentPage.js +30 -18
- package/dist/web/components/account/AccountPaymentPage.js.map +1 -1
- package/dist/web/components/account/AccountPhoneOtpPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountPhoneOtpPage.js +22 -9
- package/dist/web/components/account/AccountPhoneOtpPage.js.map +1 -1
- package/dist/web/components/account/AccountPhonePage.d.ts.map +1 -1
- package/dist/web/components/account/AccountPhonePage.js +30 -12
- package/dist/web/components/account/AccountPhonePage.js.map +1 -1
- package/dist/web/components/account/AccountRipioOtpPage.d.ts +7 -0
- package/dist/web/components/account/AccountRipioOtpPage.d.ts.map +1 -0
- package/dist/web/components/account/AccountRipioOtpPage.js +53 -0
- package/dist/web/components/account/AccountRipioOtpPage.js.map +1 -0
- package/dist/web/components/account/AccountStatusPage.d.ts +1 -3
- package/dist/web/components/account/AccountStatusPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountStatusPage.js +29 -39
- package/dist/web/components/account/AccountStatusPage.js.map +1 -1
- package/dist/web/components/account/accountNav.d.ts +1 -1
- package/dist/web/components/account/accountNav.d.ts.map +1 -1
- package/dist/web/components/account/accountNav.js +5 -1
- package/dist/web/components/account/accountNav.js.map +1 -1
- package/dist/web/components/account/formSchemas.d.ts +81 -0
- package/dist/web/components/account/formSchemas.d.ts.map +1 -0
- package/dist/web/components/account/formSchemas.js +80 -0
- package/dist/web/components/account/formSchemas.js.map +1 -0
- package/dist/web/components/account/formSchemas.test.d.ts +2 -0
- package/dist/web/components/account/formSchemas.test.d.ts.map +1 -0
- package/dist/web/components/account/formSchemas.test.js +57 -0
- package/dist/web/components/account/formSchemas.test.js.map +1 -0
- package/dist/web/components/account/kycRequirement.d.ts +14 -0
- package/dist/web/components/account/kycRequirement.d.ts.map +1 -0
- package/dist/web/components/account/kycRequirement.js +48 -0
- package/dist/web/components/account/kycRequirement.js.map +1 -0
- package/dist/web/components/account/phone.d.ts +2 -1
- package/dist/web/components/account/phone.d.ts.map +1 -1
- package/dist/web/components/account/phone.js +11 -2
- package/dist/web/components/account/phone.js.map +1 -1
- package/dist/web/components/buttons.d.ts +3 -2
- package/dist/web/components/buttons.d.ts.map +1 -1
- package/dist/web/components/buttons.js +4 -4
- package/dist/web/components/buttons.js.map +1 -1
- package/dist/web/components/containers.d.ts +7 -2
- package/dist/web/components/containers.d.ts.map +1 -1
- package/dist/web/components/containers.js +73 -30
- package/dist/web/components/containers.js.map +1 -1
- package/dist/web/components/formFields.d.ts +39 -0
- package/dist/web/components/formFields.d.ts.map +1 -0
- package/dist/web/components/formFields.js +70 -0
- package/dist/web/components/formFields.js.map +1 -0
- package/dist/web/components/icons.d.ts +17 -1
- package/dist/web/components/icons.d.ts.map +1 -1
- package/dist/web/components/icons.js +30 -2
- package/dist/web/components/icons.js.map +1 -1
- package/dist/web/components/shared.d.ts +1 -1
- package/dist/web/components/shared.d.ts.map +1 -1
- package/dist/web/components/shared.js +22 -22
- package/dist/web/components/shared.js.map +1 -1
- package/dist/web/formatAmount.d.ts +5 -0
- package/dist/web/formatAmount.d.ts.map +1 -0
- package/dist/web/formatAmount.js +53 -0
- package/dist/web/formatAmount.js.map +1 -0
- package/dist/web/formatAmount.test.d.ts +2 -0
- package/dist/web/formatAmount.test.d.ts.map +1 -0
- package/dist/web/formatAmount.test.js +43 -0
- package/dist/web/formatAmount.test.js.map +1 -0
- package/dist/web/hooks/accountAuthNav.d.ts +3 -0
- package/dist/web/hooks/accountAuthNav.d.ts.map +1 -0
- package/dist/web/hooks/accountAuthNav.js +24 -0
- package/dist/web/hooks/accountAuthNav.js.map +1 -0
- package/dist/web/hooks/accountAuthNav.test.d.ts +2 -0
- package/dist/web/hooks/accountAuthNav.test.d.ts.map +1 -0
- package/dist/web/hooks/accountAuthNav.test.js +32 -0
- package/dist/web/hooks/accountAuthNav.test.js.map +1 -0
- package/dist/web/hooks/formatUserError.d.ts.map +1 -1
- package/dist/web/hooks/formatUserError.js +13 -2
- package/dist/web/hooks/formatUserError.js.map +1 -1
- package/dist/web/hooks/locale.d.ts +2 -0
- package/dist/web/hooks/locale.d.ts.map +1 -1
- package/dist/web/hooks/locale.js +41 -4
- package/dist/web/hooks/locale.js.map +1 -1
- package/dist/web/hooks/locale.test.d.ts +2 -0
- package/dist/web/hooks/locale.test.d.ts.map +1 -0
- package/dist/web/hooks/locale.test.js +41 -0
- package/dist/web/hooks/locale.test.js.map +1 -0
- package/dist/web/hooks/locales/en.d.ts +26 -2
- package/dist/web/hooks/locales/en.d.ts.map +1 -1
- package/dist/web/hooks/locales/en.js +36 -12
- package/dist/web/hooks/locales/en.js.map +1 -1
- package/dist/web/hooks/locales/es.d.ts.map +1 -1
- package/dist/web/hooks/locales/es.js +35 -11
- package/dist/web/hooks/locales/es.js.map +1 -1
- package/dist/web/hooks/locales/ja.d.ts.map +1 -1
- package/dist/web/hooks/locales/ja.js +36 -12
- package/dist/web/hooks/locales/ja.js.map +1 -1
- package/dist/web/hooks/locales/ko.d.ts.map +1 -1
- package/dist/web/hooks/locales/ko.js +36 -12
- package/dist/web/hooks/locales/ko.js.map +1 -1
- package/dist/web/hooks/locales/pt.d.ts +4 -0
- package/dist/web/hooks/locales/pt.d.ts.map +1 -0
- package/dist/web/hooks/locales/pt.js +164 -0
- package/dist/web/hooks/locales/pt.js.map +1 -0
- package/dist/web/hooks/locales/zh.d.ts.map +1 -1
- package/dist/web/hooks/locales/zh.js +36 -12
- package/dist/web/hooks/locales/zh.js.map +1 -1
- package/dist/web/hooks/navEvent.js +2 -2
- package/dist/web/hooks/navEvent.js.map +1 -1
- package/dist/web/hooks/types.d.ts +15 -3
- package/dist/web/hooks/types.d.ts.map +1 -1
- package/dist/web/hooks/types.js.map +1 -1
- package/dist/web/hooks/useAccountFlow.d.ts +17 -11
- package/dist/web/hooks/useAccountFlow.d.ts.map +1 -1
- package/dist/web/hooks/useAccountFlow.js +71 -28
- package/dist/web/hooks/useAccountFlow.js.map +1 -1
- package/dist/web/hooks/useCreateDeposit.d.ts +1 -1
- package/dist/web/hooks/useCreateDeposit.d.ts.map +1 -1
- package/dist/web/hooks/useCreateDeposit.js +15 -103
- package/dist/web/hooks/useCreateDeposit.js.map +1 -1
- package/dist/web/hooks/useDraftDeposit.d.ts +2 -1
- package/dist/web/hooks/useDraftDeposit.d.ts.map +1 -1
- package/dist/web/hooks/useDraftDeposit.js +18 -1
- package/dist/web/hooks/useDraftDeposit.js.map +1 -1
- package/dist/web/hooks/useSessionNav.d.ts +6 -3
- package/dist/web/hooks/useSessionNav.d.ts.map +1 -1
- package/dist/web/hooks/useSessionNav.js +131 -39
- package/dist/web/hooks/useSessionNav.js.map +1 -1
- package/dist/web/hooks/useWalletFlow.d.ts.map +1 -1
- package/dist/web/hooks/useWalletFlow.js +74 -26
- package/dist/web/hooks/useWalletFlow.js.map +1 -1
- package/dist/web/hooks/walletError.d.ts +9 -0
- package/dist/web/hooks/walletError.d.ts.map +1 -0
- package/dist/web/hooks/walletError.js +16 -0
- package/dist/web/hooks/walletError.js.map +1 -0
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +3 -0
- package/dist/web/index.js.map +1 -1
- package/dist/web/styles.css +1 -1
- package/dist/web/theme.css +1 -1
- package/dist/web/theme.d.ts +7 -0
- package/dist/web/theme.d.ts.map +1 -0
- package/dist/web/theme.js +23 -0
- package/dist/web/theme.js.map +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useForm } from "react-hook-form";
|
|
5
|
+
import { useDaimoClient } from "../../hooks/DaimoClientContext.js";
|
|
6
|
+
import { formatUserError } from "../../hooks/formatUserError.js";
|
|
7
|
+
import { t } from "../../hooks/locale.js";
|
|
8
|
+
import { useAccountFlow } from "../../hooks/useAccountFlow.js";
|
|
9
|
+
import { PrimaryButton, SecondaryLinkButton } from "../buttons.js";
|
|
10
|
+
import { DaimoFormField, DaimoSegmentedNumberField, DaimoTextField, } from "../formFields.js";
|
|
11
|
+
import { CenteredContent, PageHeader } from "../shared.js";
|
|
12
|
+
import { digitsOnly, isDatePartInRange, zApplePayVerificationForm, } from "./formSchemas.js";
|
|
13
|
+
const applePayVerificationDefaults = {
|
|
14
|
+
ssnLast4: "",
|
|
15
|
+
dateOfBirth: { month: "", day: "", year: "" },
|
|
16
|
+
};
|
|
17
|
+
export function AccountEnrollmentUpdatePage({ update: initialUpdate, sessionId, onBack, onReady, }) {
|
|
18
|
+
const account = useAccountFlow();
|
|
19
|
+
const client = useDaimoClient();
|
|
20
|
+
const [update, setUpdate] = useState(initialUpdate);
|
|
21
|
+
const [error, setError] = useState(null);
|
|
22
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
23
|
+
const refresh = useCallback(async () => {
|
|
24
|
+
if (!account)
|
|
25
|
+
throw new Error("account flow missing");
|
|
26
|
+
const token = await account.getAccessToken();
|
|
27
|
+
if (!token)
|
|
28
|
+
throw new Error("not authenticated");
|
|
29
|
+
const result = await client.account.getEnrollmentUpdate({
|
|
30
|
+
bearerToken: token,
|
|
31
|
+
});
|
|
32
|
+
setUpdate(requireApplePayEnhancedVerification(result));
|
|
33
|
+
if (result.status === "complete")
|
|
34
|
+
onReady();
|
|
35
|
+
}, [account, client, onReady]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
void refresh().catch((err) => {
|
|
38
|
+
setError(formatUserError(err, "failed to check limits"));
|
|
39
|
+
});
|
|
40
|
+
}, [refresh]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (update.status !== "pending")
|
|
43
|
+
return;
|
|
44
|
+
const interval = window.setInterval(() => {
|
|
45
|
+
void refresh().catch((err) => {
|
|
46
|
+
setError(formatUserError(err, "failed to check limits"));
|
|
47
|
+
});
|
|
48
|
+
}, 2000);
|
|
49
|
+
return () => window.clearInterval(interval);
|
|
50
|
+
}, [update.status, refresh]);
|
|
51
|
+
const submit = useCallback(async (input) => {
|
|
52
|
+
if (!account)
|
|
53
|
+
throw new Error("account flow missing");
|
|
54
|
+
setIsSubmitting(true);
|
|
55
|
+
setError(null);
|
|
56
|
+
try {
|
|
57
|
+
const token = await account.getAccessToken();
|
|
58
|
+
if (!token)
|
|
59
|
+
throw new Error("not authenticated");
|
|
60
|
+
const result = await client.account.submitEnrollmentUpdate({
|
|
61
|
+
type: "apple_pay_enhanced_verification",
|
|
62
|
+
rail: "apple_pay",
|
|
63
|
+
...input,
|
|
64
|
+
}, { bearerToken: token });
|
|
65
|
+
setUpdate(requireApplePayEnhancedVerification(result));
|
|
66
|
+
if (result.status === "complete")
|
|
67
|
+
onReady();
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
setError(formatUserError(err, "couldn't verify your details. please try again."));
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
setIsSubmitting(false);
|
|
74
|
+
}
|
|
75
|
+
}, [account, client, onReady]);
|
|
76
|
+
return (_jsxs("div", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", children: [_jsx(PageHeader, { title: "Increase Apple Pay limits", onBack: onBack }), _jsx(EnrollmentUpdateContent, { update: update, sessionId: sessionId, email: account?.email, error: error, isSubmitting: isSubmitting, onSubmit: submit })] }));
|
|
77
|
+
}
|
|
78
|
+
function EnrollmentUpdateContent({ update, sessionId, email, error, isSubmitting, onSubmit, }) {
|
|
79
|
+
switch (update.status) {
|
|
80
|
+
case "pending":
|
|
81
|
+
return (_jsx(EnrollmentUpdateMessage, { title: "Checking your limits", description: "We're checking your update. This usually takes a few seconds.", error: error, icon: _jsx(Spinner, {}) }));
|
|
82
|
+
case "complete":
|
|
83
|
+
return (_jsx(EnrollmentUpdateMessage, { title: "Limits increased", description: "Your Apple Pay limits are updated." }));
|
|
84
|
+
case "unavailable":
|
|
85
|
+
return (_jsx(EnrollmentUpdateUnavailable, { sessionId: sessionId, email: email, error: error }));
|
|
86
|
+
case "required":
|
|
87
|
+
case "retry":
|
|
88
|
+
if (update.fields.length === 0) {
|
|
89
|
+
return (_jsx(EnrollmentUpdateUnavailable, { sessionId: sessionId, email: email, error: error }));
|
|
90
|
+
}
|
|
91
|
+
return (_jsx(EnrollmentUpdateForm, { status: update.status, error: error, isSubmitting: isSubmitting, onSubmit: onSubmit }));
|
|
92
|
+
default:
|
|
93
|
+
return assertUnreachable(update.status);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function EnrollmentUpdateForm({ status, error, isSubmitting, onSubmit, }) {
|
|
97
|
+
const { formState: { errors, isValid }, handleSubmit, register, reset, setValue, watch, } = useForm({
|
|
98
|
+
resolver: zodResolver(zApplePayVerificationForm),
|
|
99
|
+
mode: "onChange",
|
|
100
|
+
defaultValues: applePayVerificationDefaults,
|
|
101
|
+
});
|
|
102
|
+
const ssnLast4 = watch("ssnLast4");
|
|
103
|
+
const month = watch("dateOfBirth.month");
|
|
104
|
+
const day = watch("dateOfBirth.day");
|
|
105
|
+
const year = watch("dateOfBirth.year");
|
|
106
|
+
const monthInputRef = useRef(null);
|
|
107
|
+
const ssnField = register("ssnLast4");
|
|
108
|
+
const monthField = register("dateOfBirth.month");
|
|
109
|
+
const dayField = register("dateOfBirth.day");
|
|
110
|
+
const yearField = register("dateOfBirth.year");
|
|
111
|
+
const monthInvalid = month.length === 2 && !isDatePartInRange(month, 1, 12);
|
|
112
|
+
const dayInvalid = day.length === 2 && !isDatePartInRange(day, 1, 31);
|
|
113
|
+
const dateError = errors.dateOfBirth?.month?.message;
|
|
114
|
+
const description = status === "retry"
|
|
115
|
+
? "We couldn't verify those details. Check them and try again."
|
|
116
|
+
: "We need a few more details before Apple Pay can continue.";
|
|
117
|
+
const submit = handleSubmit(useCallback(async (input) => {
|
|
118
|
+
await onSubmit(input);
|
|
119
|
+
reset(applePayVerificationDefaults);
|
|
120
|
+
}, [onSubmit, reset]));
|
|
121
|
+
const setDatePart = (name, value) => {
|
|
122
|
+
setValue(name, value, {
|
|
123
|
+
shouldDirty: true,
|
|
124
|
+
shouldTouch: true,
|
|
125
|
+
shouldValidate: true,
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
return (_jsxs("form", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", onSubmit: (event) => {
|
|
129
|
+
void submit(event);
|
|
130
|
+
}, children: [_jsx(CenteredContent, { children: _jsxs("div", { className: "daimo-flex daimo-w-full daimo-max-w-xs daimo-flex-col daimo-gap-4", children: [_jsx("p", { className: "daimo-text-center daimo-text-sm daimo-leading-relaxed daimo-text-[var(--daimo-text-secondary)]", children: description }), _jsxs("div", { className: "daimo-flex daimo-flex-col daimo-gap-3", children: [_jsx(DaimoFormField, { label: "SSN last 4", error: errors.ssnLast4?.message, children: ({ id, describedBy, invalid }) => (_jsx(DaimoTextField, { ref: ssnField.ref, id: id, name: ssnField.name, onBlur: ssnField.onBlur, type: "password", inputMode: "numeric", autoComplete: "off", "data-lpignore": "true", "data-1p-ignore": true, pattern: "[0-9]*", maxLength: 4, value: ssnLast4, onChange: (event) => {
|
|
131
|
+
const value = digitsOnly(event.target.value, 4);
|
|
132
|
+
setDatePart("ssnLast4", value);
|
|
133
|
+
if (value.length === 4)
|
|
134
|
+
monthInputRef.current?.focus();
|
|
135
|
+
}, "aria-describedby": describedBy, invalid: invalid, placeholder: "1234", className: "daimo-px-4 daimo-py-3" })) }), _jsx(DaimoFormField, { label: "Date of birth", error: dateError, children: ({ id, describedBy }) => (_jsx(DaimoSegmentedNumberField, { describedBy: describedBy, segments: [
|
|
136
|
+
{
|
|
137
|
+
inputRef: (input) => {
|
|
138
|
+
monthField.ref(input);
|
|
139
|
+
monthInputRef.current = input;
|
|
140
|
+
},
|
|
141
|
+
id,
|
|
142
|
+
name: monthField.name,
|
|
143
|
+
onBlur: monthField.onBlur,
|
|
144
|
+
autoComplete: "bday-month",
|
|
145
|
+
value: month,
|
|
146
|
+
maxLength: 2,
|
|
147
|
+
placeholder: "MM",
|
|
148
|
+
ariaLabel: "birth month",
|
|
149
|
+
invalid: monthInvalid,
|
|
150
|
+
onValueChange: (value) => setDatePart("dateOfBirth.month", value),
|
|
151
|
+
canAutoAdvance: (value) => isDatePartInRange(value, 1, 12),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
inputRef: dayField.ref,
|
|
155
|
+
name: dayField.name,
|
|
156
|
+
onBlur: dayField.onBlur,
|
|
157
|
+
autoComplete: "bday-day",
|
|
158
|
+
value: day,
|
|
159
|
+
maxLength: 2,
|
|
160
|
+
placeholder: "DD",
|
|
161
|
+
ariaLabel: "birth day",
|
|
162
|
+
invalid: dayInvalid,
|
|
163
|
+
onValueChange: (value) => setDatePart("dateOfBirth.day", value),
|
|
164
|
+
canAutoAdvance: (value) => isDatePartInRange(value, 1, 31),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
inputRef: yearField.ref,
|
|
168
|
+
name: yearField.name,
|
|
169
|
+
onBlur: yearField.onBlur,
|
|
170
|
+
autoComplete: "bday-year",
|
|
171
|
+
value: year,
|
|
172
|
+
maxLength: 4,
|
|
173
|
+
placeholder: "YYYY",
|
|
174
|
+
ariaLabel: "birth year",
|
|
175
|
+
width: "minmax(0, 1.35fr)",
|
|
176
|
+
onValueChange: (value) => setDatePart("dateOfBirth.year", value),
|
|
177
|
+
},
|
|
178
|
+
] })) })] }), error && (_jsx("p", { className: "daimo-text-center daimo-text-xs daimo-text-[var(--daimo-error)]", children: error }))] }) }), _jsx("div", { className: "daimo-px-6 daimo-pb-6 daimo-flex daimo-flex-col daimo-items-center", children: _jsx(PrimaryButton, { type: "submit", disabled: !isValid || isSubmitting, children: isSubmitting ? "Checking" : "Submit" }) })] }));
|
|
179
|
+
}
|
|
180
|
+
function EnrollmentUpdateUnavailable({ sessionId, email, error, }) {
|
|
181
|
+
const subject = "Apple Pay limit increase";
|
|
182
|
+
const href = buildSupportHref({
|
|
183
|
+
subject,
|
|
184
|
+
info: {
|
|
185
|
+
"Session ID": sessionId,
|
|
186
|
+
Email: email,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return (_jsx(EnrollmentUpdateMessage, { description: "This Apple Pay account is not eligible for a limit increase right now.", error: error, action: _jsx(SecondaryLinkButton, { href: href, children: t.contactSupport }) }));
|
|
190
|
+
}
|
|
191
|
+
function buildSupportHref({ subject, info, }) {
|
|
192
|
+
const bodyLines = [
|
|
193
|
+
...Object.entries(info)
|
|
194
|
+
.filter((entry) => entry[1] != null)
|
|
195
|
+
.map(([key, value]) => `${key}: ${value}`),
|
|
196
|
+
"",
|
|
197
|
+
t.tellUsHowWeCanHelp,
|
|
198
|
+
];
|
|
199
|
+
const body = bodyLines.join("\n");
|
|
200
|
+
return `mailto:support@daimo.com?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
|
|
201
|
+
}
|
|
202
|
+
function EnrollmentUpdateMessage({ title, description, error, icon, action, }) {
|
|
203
|
+
return (_jsxs(CenteredContent, { children: [icon, _jsxs("div", { className: "daimo-flex daimo-max-w-[320px] daimo-flex-col daimo-gap-2 daimo-text-center", children: [title && (_jsx("h2", { className: "daimo-text-lg daimo-font-semibold daimo-text-[var(--daimo-text)]", children: title })), _jsx("p", { className: "daimo-text-sm daimo-leading-relaxed daimo-text-[var(--daimo-text-secondary)]", children: description })] }), error && (_jsx("p", { className: "daimo-max-w-[320px] daimo-text-center daimo-text-xs daimo-text-[var(--daimo-error)]", children: error })), action] }));
|
|
204
|
+
}
|
|
205
|
+
function requireApplePayEnhancedVerification(update) {
|
|
206
|
+
return update;
|
|
207
|
+
}
|
|
208
|
+
function assertUnreachable(value) {
|
|
209
|
+
throw new Error(`unhandled enrollment update: ${value}`);
|
|
210
|
+
}
|
|
211
|
+
function Spinner() {
|
|
212
|
+
return (_jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", className: "daimo-animate-spin", children: _jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) }));
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=AccountEnrollmentUpdatePage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountEnrollmentUpdatePage.js","sourceRoot":"","sources":["../../../../src/web/components/account/AccountEnrollmentUpdatePage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAO1C,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,uBAAuB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE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ReactNode;
|
|
5
5
|
};
|
|
6
|
-
export declare function AccountFlowProvider({ privyAppId, children }: AccountFlowProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function AccountFlowProvider({ privyAppId, children, }: AccountFlowProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=AccountFlowProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountFlowProvider.d.ts","sourceRoot":"","sources":["../../../../src/web/components/account/AccountFlowProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccountFlowProvider.d.ts","sourceRoot":"","sources":["../../../../src/web/components/account/AccountFlowProvider.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAAmC,MAAM,OAAO,CAAC;AAYxE,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,QAAQ,GACT,EAAE,wBAAwB,2CAmB1B"}
|
|
@@ -5,10 +5,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
* Renders PrivyProvider with the given appId. Inside, PrivyConsumer
|
|
6
6
|
* reads Privy hooks and registers them with the account flow state.
|
|
7
7
|
*/
|
|
8
|
-
import { PrivyProvider, useLoginWithEmail,
|
|
8
|
+
import { PrivyProvider, useLoginWithEmail, usePrivy, useWallets, } from "@privy-io/react-auth";
|
|
9
9
|
import { useCallback, useEffect, useMemo } from "react";
|
|
10
10
|
import { AccountFlowContext, useAccountFlowState, } from "../../hooks/useAccountFlow.js";
|
|
11
|
-
|
|
11
|
+
import { findCanonicalPrivyWallet, getCanonicalPrivyWalletAddress, hasPrivyEmbeddedWallet, } from "../../accountWallet.js";
|
|
12
|
+
export function AccountFlowProvider({ privyAppId, children, }) {
|
|
12
13
|
const accountFlow = useAccountFlowState();
|
|
13
14
|
return (_jsx(AccountFlowContext.Provider, { value: accountFlow, children: _jsxs(PrivyProvider, { appId: privyAppId, config: {
|
|
14
15
|
embeddedWallets: {
|
|
@@ -20,55 +21,60 @@ export function AccountFlowProvider({ privyAppId, children }) {
|
|
|
20
21
|
function PrivyConsumer({ accountFlow, }) {
|
|
21
22
|
const { ready, authenticated, logout, getAccessToken, createWallet, user } = usePrivy();
|
|
22
23
|
const { sendCode: rawSendCode, loginWithCode: rawLoginWithCode } = useLoginWithEmail();
|
|
23
|
-
const {
|
|
24
|
-
const { wallets } = useWallets();
|
|
24
|
+
const { wallets, ready: walletsReady } = useWallets();
|
|
25
25
|
const sendCode = useCallback(async (email) => {
|
|
26
26
|
await rawSendCode({ email });
|
|
27
27
|
}, [rawSendCode]);
|
|
28
28
|
const loginWithCode = useCallback(async (code) => {
|
|
29
29
|
await rawLoginWithCode({ code });
|
|
30
30
|
}, [rawLoginWithCode]);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const walletAddress = user?.wallet?.address ?? null;
|
|
31
|
+
const walletAddress = getCanonicalPrivyWalletAddress({
|
|
32
|
+
userWalletAddress: user?.wallet?.address,
|
|
33
|
+
linkedAccounts: user?.linkedAccounts ?? [],
|
|
34
|
+
connectedWallets: wallets,
|
|
35
|
+
});
|
|
36
|
+
const email = user?.email?.address ?? null;
|
|
38
37
|
const phoneNumber = user?.phone?.number ?? null;
|
|
39
|
-
const
|
|
38
|
+
const hasEmbeddedWallet = hasPrivyEmbeddedWallet([
|
|
39
|
+
...(user?.linkedAccounts ?? []),
|
|
40
|
+
...wallets,
|
|
41
|
+
]);
|
|
42
|
+
const signingWallet = findCanonicalPrivyWallet(wallets, walletAddress);
|
|
40
43
|
const signTypedData = useCallback(async (typedData) => {
|
|
41
|
-
if (!
|
|
42
|
-
throw new Error("no embedded wallet");
|
|
43
|
-
|
|
44
|
+
if (!signingWallet || !walletAddress) {
|
|
45
|
+
throw new Error("no canonical embedded wallet");
|
|
46
|
+
}
|
|
47
|
+
const provider = await signingWallet.getEthereumProvider();
|
|
44
48
|
const result = await provider.request({
|
|
45
49
|
method: "eth_signTypedData_v4",
|
|
46
50
|
params: [walletAddress, JSON.stringify(typedData)],
|
|
47
51
|
});
|
|
48
52
|
return result;
|
|
49
|
-
}, [
|
|
53
|
+
}, [signingWallet, walletAddress]);
|
|
50
54
|
const hooks = useMemo(() => ({
|
|
51
55
|
sendCode,
|
|
52
56
|
loginWithCode,
|
|
53
|
-
sendPhoneCode,
|
|
54
|
-
loginWithPhoneCode,
|
|
55
57
|
createWallet,
|
|
56
58
|
getAccessToken,
|
|
57
59
|
signTypedData,
|
|
58
60
|
logout,
|
|
59
61
|
ready,
|
|
60
62
|
authenticated,
|
|
63
|
+
email,
|
|
61
64
|
walletAddress,
|
|
65
|
+
walletsReady,
|
|
66
|
+
hasEmbeddedWallet,
|
|
62
67
|
phoneNumber,
|
|
63
68
|
}), [
|
|
64
69
|
ready,
|
|
65
70
|
authenticated,
|
|
71
|
+
email,
|
|
66
72
|
walletAddress,
|
|
73
|
+
walletsReady,
|
|
74
|
+
hasEmbeddedWallet,
|
|
67
75
|
phoneNumber,
|
|
68
76
|
sendCode,
|
|
69
77
|
loginWithCode,
|
|
70
|
-
sendPhoneCode,
|
|
71
|
-
loginWithPhoneCode,
|
|
72
78
|
createWallet,
|
|
73
79
|
getAccessToken,
|
|
74
80
|
signTypedData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountFlowProvider.js","sourceRoot":"","sources":["../../../../src/web/components/account/AccountFlowProvider.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"AccountFlowProvider.js","sourceRoot":"","sources":["../../../../src/web/components/account/AccountFlowProvider.tsx"],"names":[],"mappings":";A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CAAC,CAC/B,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,MAAM;QACN,KAAK;QACL,aAAa;QACb,KAAK;QACL,aAAa;QACb,YAAY;QACZ,iBAAiB;QACjB,WAAW;KACZ,CAAC,EACF;QACE,KAAK;QACL,aAAa;QACb,KAAK;QACL,aAAa;QACb,YAAY;QACZ,iBAAiB;QACjB,WAAW;QACX,QAAQ;QACR,aAAa;QACb,YAAY;QACZ,cAAc;QACd,aAAa;QACb,MAAM;KACP,CACF,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAEvC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NavNodeFiat } from "../../api/navTree.js";
|
|
2
|
+
type AccountKycInfoPageProps = {
|
|
3
|
+
node: NavNodeFiat;
|
|
4
|
+
onBack: (() => void) | null;
|
|
5
|
+
onContinue: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function AccountKycInfoPage({ node, onBack, onContinue, }: AccountKycInfoPageProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function AccountKycInfoSkeleton({ node, onBack, }: {
|
|
9
|
+
node: NavNodeFiat;
|
|
10
|
+
onBack: (() => void) | null;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=AccountKycInfoPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountKycInfoPage.d.ts","sourceRoot":"","sources":["../../../../src/web/components/account/AccountKycInfoPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAYxD,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,UAAU,GACX,EAAE,uBAAuB,2CA0BzB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7B,2CAgCA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { t } from "../../hooks/locale.js";
|
|
3
|
+
import { PrimaryButton } from "../buttons.js";
|
|
4
|
+
import { Skeleton } from "../Skeleton.js";
|
|
5
|
+
import { PageHeader } from "../shared.js";
|
|
6
|
+
import { getKycRequirement, KycIndicator, } from "./kycRequirement.js";
|
|
7
|
+
export function AccountKycInfoPage({ node, onBack, onContinue, }) {
|
|
8
|
+
const requirement = getKycRequirement(node.kycRequirement);
|
|
9
|
+
return (_jsxs("div", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", children: [_jsx(PageHeader, { title: "Verification", onBack: onBack }), _jsxs("div", { className: "daimo-flex-1 daimo-flex daimo-flex-col daimo-items-center daimo-justify-center daimo-gap-5 daimo-px-6 daimo-pt-4 daimo-pb-3", children: [_jsx(KycIndicator, { requirement: requirement, size: "lg", variant: "badge" }), _jsx("div", { className: "daimo-flex daimo-flex-col daimo-items-center daimo-gap-2 daimo-text-center", children: _jsx("div", { className: "daimo-flex daimo-flex-col daimo-gap-2", children: _jsx("h2", { className: "daimo-text-lg daimo-font-semibold daimo-leading-tight daimo-text-[var(--daimo-title)]", children: requirement.detailTitle }) }) }), _jsx(RequirementList, { requirement: requirement })] }), _jsx("div", { className: "daimo-px-6 daimo-pb-6 daimo-flex daimo-flex-col daimo-items-center", children: _jsx(PrimaryButton, { onClick: onContinue, children: t.continue }) })] }));
|
|
10
|
+
}
|
|
11
|
+
export function AccountKycInfoSkeleton({ node, onBack, }) {
|
|
12
|
+
const requirement = getKycRequirement(node.kycRequirement);
|
|
13
|
+
const rowCount = Math.max(requirement.requirements.length, 1);
|
|
14
|
+
return (_jsxs("div", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", "aria-busy": "true", "aria-label": t.loading, children: [_jsx(PageHeader, { title: "Verification", onBack: onBack }), _jsxs("div", { className: "daimo-flex-1 daimo-flex daimo-flex-col daimo-items-center daimo-justify-center daimo-gap-5 daimo-px-6 daimo-pt-4 daimo-pb-3", children: [_jsx(Skeleton, { className: "daimo-h-16 daimo-w-16", rounded: "full" }), _jsx(Skeleton, { className: "daimo-h-7 daimo-w-full daimo-max-w-[300px]", rounded: "sm" }), _jsx("div", { className: "daimo-flex daimo-w-full daimo-max-w-xs daimo-flex-col daimo-gap-2", children: Array.from({ length: rowCount }).map((_, index) => (_jsx(KycRequirementRowSkeleton, { delayMs: index * 90 }, index))) })] }), _jsx("div", { className: "daimo-px-6 daimo-pb-6 daimo-flex daimo-flex-col daimo-items-center", children: _jsx(Skeleton, { className: "daimo-h-[54px] daimo-w-full daimo-max-w-xs" }) })] }));
|
|
15
|
+
}
|
|
16
|
+
function RequirementList({ requirement }) {
|
|
17
|
+
const items = requirement.requirements;
|
|
18
|
+
return (_jsx("div", { className: "daimo-flex daimo-w-full daimo-max-w-xs daimo-flex-col daimo-gap-2", children: items.map((item) => (_jsx(RequirementRow, { label: item.label, requirement: requirement }, item.id))) }));
|
|
19
|
+
}
|
|
20
|
+
function KycRequirementRowSkeleton({ delayMs }) {
|
|
21
|
+
return (_jsxs("div", { className: "daimo-flex daimo-min-h-[44px] daimo-items-center daimo-gap-3 daimo-rounded-[var(--daimo-radius-md)] daimo-px-3 daimo-py-2.5", style: { backgroundColor: "var(--daimo-surface-secondary)" }, children: [_jsx(Skeleton, { className: "daimo-h-5 daimo-w-5 daimo-shrink-0", rounded: "full" }), _jsx(Skeleton, { className: "daimo-h-4 daimo-w-full daimo-max-w-[210px]", rounded: "sm", delayMs: delayMs })] }));
|
|
22
|
+
}
|
|
23
|
+
function RequirementRow({ label, requirement, }) {
|
|
24
|
+
return (_jsxs("div", { className: "daimo-flex daimo-min-h-[44px] daimo-items-center daimo-gap-3 daimo-rounded-[var(--daimo-radius-md)] daimo-px-3 daimo-py-2.5 daimo-text-left", style: { backgroundColor: "var(--daimo-surface-secondary)" }, children: [_jsx("span", { className: "daimo-flex daimo-h-5 daimo-w-5 daimo-shrink-0 daimo-items-center daimo-justify-center daimo-rounded-full daimo-text-[11px] daimo-font-bold", style: {
|
|
25
|
+
color: getAccentColor(requirement.kind),
|
|
26
|
+
backgroundColor: "var(--daimo-surface)",
|
|
27
|
+
}, children: _jsx(CheckGlyph, {}) }), _jsx("span", { className: "daimo-min-w-0 daimo-text-sm daimo-font-medium daimo-leading-snug daimo-text-[var(--daimo-text)]", children: label })] }));
|
|
28
|
+
}
|
|
29
|
+
function CheckGlyph() {
|
|
30
|
+
return (_jsx("svg", { "aria-hidden": "true", width: "13", height: "13", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M13 4.5 6.5 11 3 7.5" }) }));
|
|
31
|
+
}
|
|
32
|
+
function getAccentColor(kind) {
|
|
33
|
+
if (kind === "none")
|
|
34
|
+
return "var(--daimo-text-secondary)";
|
|
35
|
+
return "var(--daimo-brand-green)";
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=AccountKycInfoPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountKycInfoPage.js","sourceRoot":"","sources":["../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gC,EAAE,aAE5D,KAAC,QAAQ,IAAC,SAAS,EAAC,oCAAoC,EAAC,OAAO,EAAC,MAAM,GAAG,EAC1E,KAAC,QAAQ,IACP,SAAS,EAAC,4CAA4C,EACtD,OAAO,EAAC,IAAI,EACZ,OAAO,EAAE,OAAO,GAChB,IACE,CACP,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,EACtB,KAAK,EACL,WAAW,GAIZ;IACC,OAAO,CACL,eACE,SAAS,EAAC,6IAA6I,EACvJ,KAAK,EAAE,EAAE,eAAe,EAAE,gCAAgC,EAAE,aAE5D,eACE,SAAS,EAAC,4IAA4I,EACtJ,KAAK,EAAE;oBACL,KAAK,EAAE,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC;oBACvC,eAAe,EAAE,sBAAsB;iBACxC,YAED,KAAC,UAAU,KAAG,GACT,EACP,eAAM,SAAS,EAAC,iGAAiG,YAC9G,KAAK,GACD,IACH,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,CACL,6BACc,MAAM,EAClB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,YAEtB,eAAM,CAAC,EAAC,sBAAsB,GAAG,GAC7B,CACP,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAA4B;IAClD,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,6BAA6B,CAAC;IAC1D,OAAO,0BAA0B,CAAC;AACpC,CAAC"}
|
|
@@ -6,11 +6,14 @@ export type OtpVerifyOutcome = {
|
|
|
6
6
|
};
|
|
7
7
|
type AccountOtpCodeEntryProps = {
|
|
8
8
|
destination: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
message?: React.ReactNode;
|
|
11
|
+
invalidMessage?: string;
|
|
9
12
|
onBack: () => void;
|
|
10
13
|
onVerified: () => void;
|
|
11
14
|
onVerify: (code: string) => Promise<OtpVerifyOutcome>;
|
|
12
15
|
onResend: () => Promise<void>;
|
|
13
16
|
};
|
|
14
|
-
export declare function AccountOtpCodeEntry({ destination, onBack, onVerified, onVerify, onResend, }: AccountOtpCodeEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function AccountOtpCodeEntry({ destination, title, message, invalidMessage, onBack, onVerified, onVerify, onResend, }: AccountOtpCodeEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export {};
|
|
16
19
|
//# sourceMappingURL=AccountOtpCodeEntry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountOtpCodeEntry.d.ts","sourceRoot":"","sources":["../../../../src/web/components/account/AccountOtpCodeEntry.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccountOtpCodeEntry.d.ts","sourceRoot":"","sources":["../../../../src/web/components/account/AccountOtpCodeEntry.tsx"],"names":[],"mappings":"AAOA,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,KAAK,wBAAwB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtD,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;AAQF,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,KAAK,EACL,OAAO,EACP,cAAc,EACd,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB,2CA8I1B"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
3
|
import { t } from "../../hooks/locale.js";
|
|
4
4
|
import { useAccountFlow } from "../../hooks/useAccountFlow.js";
|
|
5
5
|
import { PrimaryButton, SecondaryLinkButton } from "../buttons.js";
|
|
6
|
-
import { CenteredContent, ErrorMessage, PageHeader
|
|
6
|
+
import { CenteredContent, ErrorMessage, PageHeader } from "../shared.js";
|
|
7
7
|
const OTP_LENGTH = 6;
|
|
8
8
|
const SUCCESS_DELAY_MS = 500;
|
|
9
9
|
const ERROR_DELAY_MS = 700;
|
|
10
|
-
export function AccountOtpCodeEntry({ destination, onBack, onVerified, onVerify, onResend, }) {
|
|
10
|
+
export function AccountOtpCodeEntry({ destination, title, message, invalidMessage, onBack, onVerified, onVerify, onResend, }) {
|
|
11
11
|
const account = useAccountFlow();
|
|
12
12
|
const [digits, setDigits] = useState(Array(OTP_LENGTH).fill(""));
|
|
13
13
|
const [status, setStatus] = useState("idle");
|
|
14
14
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
15
|
-
const
|
|
15
|
+
const inputRef = useRef(null);
|
|
16
16
|
const code = digits.join("");
|
|
17
17
|
const isComplete = code.length === OTP_LENGTH;
|
|
18
18
|
const busy = status !== "idle" || isSubmitting || !!account?.isLoggingIn;
|
|
@@ -21,81 +21,84 @@ export function AccountOtpCodeEntry({ destination, onBack, onVerified, onVerify,
|
|
|
21
21
|
if (submitCode.length !== OTP_LENGTH || busy)
|
|
22
22
|
return;
|
|
23
23
|
setIsSubmitting(true);
|
|
24
|
-
const outcome = await onVerify(submitCode)
|
|
24
|
+
const outcome = await onVerify(submitCode).catch((err) => ({
|
|
25
|
+
ok: false,
|
|
26
|
+
msg: err instanceof Error ? err.message : undefined,
|
|
27
|
+
}));
|
|
25
28
|
setIsSubmitting(false);
|
|
26
29
|
if (outcome.ok) {
|
|
27
30
|
setStatus("success");
|
|
28
31
|
window.setTimeout(() => onVerified(), SUCCESS_DELAY_MS);
|
|
29
32
|
}
|
|
30
33
|
else {
|
|
31
|
-
if (outcome.msg)
|
|
32
|
-
account?.setAuthError(outcome.msg);
|
|
34
|
+
if (outcome.msg || invalidMessage) {
|
|
35
|
+
account?.setAuthError(outcome.msg ?? invalidMessage ?? null);
|
|
36
|
+
}
|
|
33
37
|
setStatus("error");
|
|
34
38
|
window.setTimeout(() => {
|
|
35
39
|
setDigits(Array(OTP_LENGTH).fill(""));
|
|
36
40
|
setStatus("idle");
|
|
37
|
-
|
|
41
|
+
inputRef.current?.focus();
|
|
38
42
|
}, ERROR_DELAY_MS);
|
|
39
43
|
}
|
|
40
|
-
}, [code, busy, onVerify, onVerified, account]);
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
44
|
+
}, [code, busy, onVerify, onVerified, invalidMessage, account]);
|
|
45
|
+
const handleCodeValue = useCallback((value) => {
|
|
46
|
+
if (busy)
|
|
43
47
|
return;
|
|
44
48
|
if (account?.authError)
|
|
45
49
|
account.setAuthError(null);
|
|
46
|
-
const
|
|
47
|
-
next
|
|
50
|
+
const nextCode = normalizeOtpCode(value);
|
|
51
|
+
const next = codeToDigits(nextCode);
|
|
48
52
|
setDigits(next);
|
|
49
|
-
if (value && index < OTP_LENGTH - 1) {
|
|
50
|
-
inputsRef.current[index + 1]?.focus();
|
|
51
|
-
}
|
|
52
|
-
const nextCode = next.join("");
|
|
53
53
|
if (nextCode.length === OTP_LENGTH)
|
|
54
54
|
handleVerify(nextCode);
|
|
55
|
-
}, [
|
|
56
|
-
const handleKeyDown = useCallback((
|
|
55
|
+
}, [account, handleVerify, busy]);
|
|
56
|
+
const handleKeyDown = useCallback((e) => {
|
|
57
57
|
if (busy)
|
|
58
58
|
return;
|
|
59
|
-
if (e.key === "
|
|
60
|
-
inputsRef.current[index - 1]?.focus();
|
|
61
|
-
}
|
|
62
|
-
else if (e.key === "Enter" && isComplete) {
|
|
59
|
+
if (e.key === "Enter" && isComplete) {
|
|
63
60
|
e.preventDefault();
|
|
64
61
|
handleVerify();
|
|
65
62
|
}
|
|
66
|
-
}, [
|
|
63
|
+
}, [isComplete, handleVerify, busy]);
|
|
67
64
|
const handlePaste = useCallback((e) => {
|
|
68
65
|
e.preventDefault();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const pasted = e.clipboardData.getData("text").replace(/\D/g, "");
|
|
72
|
-
const next = [...digits];
|
|
73
|
-
for (let i = 0; i < OTP_LENGTH && i < pasted.length; i++) {
|
|
74
|
-
next[i] = pasted[i];
|
|
75
|
-
}
|
|
76
|
-
setDigits(next);
|
|
77
|
-
const focusIdx = Math.min(pasted.length, OTP_LENGTH - 1);
|
|
78
|
-
inputsRef.current[focusIdx]?.focus();
|
|
79
|
-
const nextCode = next.join("");
|
|
80
|
-
if (nextCode.length === OTP_LENGTH)
|
|
81
|
-
handleVerify(nextCode);
|
|
82
|
-
}, [digits, handleVerify, busy]);
|
|
66
|
+
handleCodeValue(e.clipboardData.getData("text"));
|
|
67
|
+
}, [handleCodeValue]);
|
|
83
68
|
const handleResend = useCallback(async () => {
|
|
84
69
|
setDigits(Array(OTP_LENGTH).fill(""));
|
|
85
70
|
setStatus("idle");
|
|
86
71
|
await onResend();
|
|
87
|
-
|
|
72
|
+
inputRef.current?.focus();
|
|
88
73
|
}, [onResend]);
|
|
89
|
-
|
|
74
|
+
const focusInputEnd = useCallback(() => {
|
|
75
|
+
const input = inputRef.current;
|
|
76
|
+
if (!input)
|
|
77
|
+
return;
|
|
78
|
+
input.setSelectionRange(code.length, code.length);
|
|
79
|
+
}, [code]);
|
|
80
|
+
return (_jsxs("div", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", children: [_jsx(PageHeader, { title: title ?? t.accountOtp, onBack: onBack }), _jsxs(CenteredContent, { children: [_jsx("p", { className: "daimo-text-sm daimo-text-[var(--daimo-text-secondary)] daimo-text-center", children: message ?? (_jsxs(_Fragment, { children: [t.accountOtpSent, " ", _jsx("strong", { children: destination })] })) }), _jsxs("div", { className: "daimo-relative daimo-flex daimo-justify-center daimo-rounded-[var(--daimo-radius-sm)] focus-within:daimo-ring-2 focus-within:daimo-ring-[var(--daimo-accent)] daimo-transition-shadow", children: [_jsx("input", { ref: inputRef, type: "text", inputMode: "numeric", autoComplete: "one-time-code", maxLength: OTP_LENGTH, value: code, disabled: busy, "aria-label": t.accountOtp, onChange: (e) => handleCodeValue(e.target.value), onKeyDown: handleKeyDown, onPaste: handlePaste, onFocus: focusInputEnd, autoFocus: true, className: "daimo-absolute daimo-inset-0 daimo-z-10 daimo-w-full daimo-h-full daimo-opacity-0 daimo-cursor-text disabled:daimo-cursor-default" }), _jsx("div", { "aria-hidden": "true", className: `daimo-flex daimo-gap-2 daimo-justify-center ${status === "error" ? "daimo-otp-shake" : ""}`, children: digits.map((digit, i) => (_jsx("div", { className: otpCellClass(status), children: digit }, i))) })] }), account?.authError && _jsx(ErrorMessage, { message: account.authError }), _jsx(SecondaryLinkButton, { onClick: handleResend, disabled: busy, children: t.accountResendCode })] }), _jsx("div", { className: "daimo-px-6 daimo-pb-6 daimo-flex daimo-flex-col daimo-items-center", children: _jsx(PrimaryButton, { onClick: () => handleVerify(), disabled: !isComplete || busy, children: isSubmitting || account?.isLoggingIn ? t.loading : t.accountVerify }) })] }));
|
|
90
81
|
}
|
|
91
|
-
const OTP_CELL_BASE = "daimo-w-10 daimo-h-12 daimo-text-center daimo-text-xl daimo-font-semibold daimo-rounded-[var(--daimo-radius-sm)] daimo-border-none daimo-outline-none daimo-transition-all daimo-caret-[var(--daimo-accent)]";
|
|
82
|
+
const OTP_CELL_BASE = "daimo-w-10 daimo-h-12 daimo-flex daimo-items-center daimo-justify-center daimo-text-center daimo-text-xl daimo-font-semibold daimo-rounded-[var(--daimo-radius-sm)] daimo-border-none daimo-outline-none daimo-transition-all daimo-caret-[var(--daimo-accent)]";
|
|
92
83
|
function otpCellClass(status) {
|
|
93
84
|
if (status === "success") {
|
|
94
|
-
return `${OTP_CELL_BASE} daimo-bg-[var(--daimo-
|
|
85
|
+
return `${OTP_CELL_BASE} daimo-bg-[var(--daimo-brand-green-light)] daimo-text-[var(--daimo-brand-green)] daimo-ring-2 daimo-ring-[var(--daimo-brand-green)]`;
|
|
95
86
|
}
|
|
96
87
|
if (status === "error") {
|
|
97
88
|
return `${OTP_CELL_BASE} daimo-bg-[var(--daimo-error-light)] daimo-text-[var(--daimo-error)] daimo-ring-2 daimo-ring-[var(--daimo-error)]`;
|
|
98
89
|
}
|
|
99
|
-
return `${OTP_CELL_BASE} daimo-bg-[var(--daimo-surface-secondary)] daimo-text-[var(--daimo-text)]
|
|
90
|
+
return `${OTP_CELL_BASE} daimo-bg-[var(--daimo-surface-secondary)] daimo-text-[var(--daimo-text)]`;
|
|
91
|
+
}
|
|
92
|
+
function normalizeOtpCode(value) {
|
|
93
|
+
return value.replace(/\D/g, "").slice(0, OTP_LENGTH);
|
|
94
|
+
}
|
|
95
|
+
function codeToDigits(code) {
|
|
96
|
+
const digits = Array(OTP_LENGTH).fill("");
|
|
97
|
+
for (let i = 0; i < OTP_LENGTH; i++) {
|
|
98
|
+
const digit = code[i];
|
|
99
|
+
if (digit)
|
|
100
|
+
digits[i] = digit;
|
|
101
|
+
}
|
|
102
|
+
return digits;
|
|
100
103
|
}
|
|
101
104
|
//# sourceMappingURL=AccountOtpCodeEntry.js.map
|