@daimo/sdk 1.6.0 → 1.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/client/createDaimoClient.d.ts +7 -3
- package/dist/client/createDaimoClient.d.ts.map +1 -1
- package/dist/client/createDaimoClient.js +8 -3
- package/dist/client/createDaimoClient.js.map +1 -1
- package/dist/common/api.d.ts +7 -5
- package/dist/common/api.d.ts.map +1 -1
- package/dist/common/api.js +13 -12
- package/dist/common/api.js.map +1 -1
- package/dist/common/api.test.d.ts +2 -0
- package/dist/common/api.test.d.ts.map +1 -0
- package/dist/common/api.test.js +21 -0
- package/dist/common/api.test.js.map +1 -0
- package/dist/common/constants.d.ts +5 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +5 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/frameMessages.d.ts +26 -0
- package/dist/common/frameMessages.d.ts.map +1 -0
- package/dist/common/frameMessages.js +54 -0
- package/dist/common/frameMessages.js.map +1 -0
- package/dist/common/frameMessages.test.d.ts +2 -0
- package/dist/common/frameMessages.test.d.ts.map +1 -0
- package/dist/common/frameMessages.test.js +42 -0
- package/dist/common/frameMessages.test.js.map +1 -0
- package/dist/native/DaimoFrameRN.d.ts +71 -0
- package/dist/native/DaimoFrameRN.d.ts.map +1 -0
- package/dist/native/DaimoFrameRN.js +238 -0
- package/dist/native/DaimoFrameRN.js.map +1 -0
- package/dist/native/index.d.ts +5 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +10 -0
- package/dist/native/index.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/web/api/index.d.ts +24 -0
- package/dist/web/api/index.d.ts.map +1 -1
- package/dist/web/api/index.js +6 -1
- package/dist/web/api/index.js.map +1 -1
- package/dist/web/api/navTree.d.ts +2 -1
- package/dist/web/api/navTree.d.ts.map +1 -1
- package/dist/web/components/BankLogo.d.ts +8 -0
- package/dist/web/components/BankLogo.d.ts.map +1 -0
- package/dist/web/components/BankLogo.js +9 -0
- package/dist/web/components/BankLogo.js.map +1 -0
- package/dist/web/components/ChooseOptionPage.d.ts.map +1 -1
- package/dist/web/components/ChooseOptionPage.js +4 -0
- package/dist/web/components/ChooseOptionPage.js.map +1 -1
- package/dist/web/components/DaimoFrame.d.ts +30 -18
- package/dist/web/components/DaimoFrame.d.ts.map +1 -1
- package/dist/web/components/DaimoFrame.js +55 -56
- package/dist/web/components/DaimoFrame.js.map +1 -1
- package/dist/web/components/DaimoModal.d.ts +16 -1
- package/dist/web/components/DaimoModal.d.ts.map +1 -1
- package/dist/web/components/DaimoModal.js +109 -34
- package/dist/web/components/DaimoModal.js.map +1 -1
- package/dist/web/components/DaimoRampPreview.d.ts +12 -0
- package/dist/web/components/DaimoRampPreview.d.ts.map +1 -0
- package/dist/web/components/DaimoRampPreview.js +21 -0
- package/dist/web/components/DaimoRampPreview.js.map +1 -0
- package/dist/web/components/ExchangePage.d.ts.map +1 -1
- package/dist/web/components/ExchangePage.js +6 -1
- package/dist/web/components/ExchangePage.js.map +1 -1
- package/dist/web/components/ExternalPaymentPage.d.ts.map +1 -1
- package/dist/web/components/ExternalPaymentPage.js +3 -2
- package/dist/web/components/ExternalPaymentPage.js.map +1 -1
- package/dist/web/components/ModalChrome.d.ts +9 -12
- package/dist/web/components/ModalChrome.d.ts.map +1 -1
- package/dist/web/components/ModalChrome.js +40 -41
- package/dist/web/components/ModalChrome.js.map +1 -1
- package/dist/web/components/account/AccountApplePayPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountApplePayPage.js +16 -23
- package/dist/web/components/account/AccountApplePayPage.js.map +1 -1
- package/dist/web/components/account/AccountBankPickerPage.d.ts +1 -3
- package/dist/web/components/account/AccountBankPickerPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountBankPickerPage.js +1 -5
- package/dist/web/components/account/AccountBankPickerPage.js.map +1 -1
- package/dist/web/components/account/AccountDeeplinkPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountDeeplinkPage.js +7 -1
- package/dist/web/components/account/AccountDeeplinkPage.js.map +1 -1
- package/dist/web/components/account/AccountEmailPage.d.ts +2 -1
- package/dist/web/components/account/AccountEmailPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountEmailPage.js +2 -2
- package/dist/web/components/account/AccountEmailPage.js.map +1 -1
- package/dist/web/components/account/AccountEnrollmentUpdatePage.d.ts.map +1 -1
- package/dist/web/components/account/AccountEnrollmentUpdatePage.js +2 -1
- package/dist/web/components/account/AccountEnrollmentUpdatePage.js.map +1 -1
- package/dist/web/components/account/AccountFlowProvider.d.ts +8 -1
- package/dist/web/components/account/AccountFlowProvider.d.ts.map +1 -1
- package/dist/web/components/account/AccountFlowProvider.js +38 -3
- package/dist/web/components/account/AccountFlowProvider.js.map +1 -1
- package/dist/web/components/account/AccountInteracConfirmPage.d.ts +13 -0
- package/dist/web/components/account/AccountInteracConfirmPage.d.ts.map +1 -0
- package/dist/web/components/account/AccountInteracConfirmPage.js +55 -0
- package/dist/web/components/account/AccountInteracConfirmPage.js.map +1 -0
- package/dist/web/components/account/AccountInteracConfirmPage.test.d.ts +2 -0
- package/dist/web/components/account/AccountInteracConfirmPage.test.d.ts.map +1 -0
- package/dist/web/components/account/AccountInteracConfirmPage.test.js +20 -0
- package/dist/web/components/account/AccountInteracConfirmPage.test.js.map +1 -0
- package/dist/web/components/account/AccountOtpPage.d.ts +1 -1
- package/dist/web/components/account/AccountOtpPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountOtpPage.js +4 -2
- package/dist/web/components/account/AccountOtpPage.js.map +1 -1
- package/dist/web/components/account/AccountPaymentPage.d.ts +1 -1
- package/dist/web/components/account/AccountPaymentPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountPaymentPage.js +1 -13
- package/dist/web/components/account/AccountPaymentPage.js.map +1 -1
- package/dist/web/components/account/AccountStatusPage.d.ts +4 -1
- package/dist/web/components/account/AccountStatusPage.d.ts.map +1 -1
- package/dist/web/components/account/AccountStatusPage.js +2 -2
- package/dist/web/components/account/AccountStatusPage.js.map +1 -1
- package/dist/web/components/account/accountNav.d.ts +8 -2
- package/dist/web/components/account/accountNav.d.ts.map +1 -1
- package/dist/web/components/account/accountNav.js +20 -2
- package/dist/web/components/account/accountNav.js.map +1 -1
- package/dist/web/components/account/accountNav.test.js +37 -3
- package/dist/web/components/account/accountNav.test.js.map +1 -1
- package/dist/web/components/frameMessages.d.ts +2 -37
- package/dist/web/components/frameMessages.d.ts.map +1 -1
- package/dist/web/components/frameMessages.js +4 -86
- package/dist/web/components/frameMessages.js.map +1 -1
- package/dist/web/components/shared.d.ts.map +1 -1
- package/dist/web/components/shared.js +6 -1
- package/dist/web/components/shared.js.map +1 -1
- package/dist/web/hooks/formatUserError.d.ts.map +1 -1
- package/dist/web/hooks/formatUserError.js +10 -0
- package/dist/web/hooks/formatUserError.js.map +1 -1
- package/dist/web/hooks/formatUserError.test.d.ts +2 -0
- package/dist/web/hooks/formatUserError.test.d.ts.map +1 -0
- package/dist/web/hooks/formatUserError.test.js +36 -0
- package/dist/web/hooks/formatUserError.test.js.map +1 -0
- package/dist/web/hooks/locales/en.d.ts +13 -0
- package/dist/web/hooks/locales/en.d.ts.map +1 -1
- package/dist/web/hooks/locales/en.js +16 -3
- 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 +16 -3
- 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 +16 -3
- 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 +16 -3
- package/dist/web/hooks/locales/ko.js.map +1 -1
- package/dist/web/hooks/locales/pt.d.ts.map +1 -1
- package/dist/web/hooks/locales/pt.js +16 -3
- package/dist/web/hooks/locales/pt.js.map +1 -1
- package/dist/web/hooks/locales/zh.d.ts.map +1 -1
- package/dist/web/hooks/locales/zh.js +16 -3
- package/dist/web/hooks/locales/zh.js.map +1 -1
- package/dist/web/hooks/types.d.ts +4 -1
- package/dist/web/hooks/types.d.ts.map +1 -1
- package/dist/web/hooks/types.js.map +1 -1
- package/dist/web/hooks/useSessionNav.d.ts +6 -1
- package/dist/web/hooks/useSessionNav.d.ts.map +1 -1
- package/dist/web/hooks/useSessionNav.js +56 -22
- package/dist/web/hooks/useSessionNav.js.map +1 -1
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +1 -0
- package/dist/web/index.js.map +1 -1
- package/dist/web/styles.css +1 -1
- package/dist/web/theme.css +1 -1
- package/package.json +18 -4
- package/dist/web/components/ProgressPulse.d.ts +0 -14
- package/dist/web/components/ProgressPulse.d.ts.map +0 -1
- package/dist/web/components/ProgressPulse.js +0 -15
- package/dist/web/components/ProgressPulse.js.map +0 -1
- package/dist/web/components/account/AccountBankTransferSubmittedPage.d.ts +0 -15
- package/dist/web/components/account/AccountBankTransferSubmittedPage.d.ts.map +0 -1
- package/dist/web/components/account/AccountBankTransferSubmittedPage.js +0 -33
- package/dist/web/components/account/AccountBankTransferSubmittedPage.js.map +0 -1
- package/dist/web/components/account/AccountReadyPage.d.ts +0 -2
- package/dist/web/components/account/AccountReadyPage.d.ts.map +0 -1
- package/dist/web/components/account/AccountReadyPage.js +0 -7
- package/dist/web/components/account/AccountReadyPage.js.map +0 -1
- package/dist/web/components/account/AccountRipioOtpPage.d.ts +0 -7
- package/dist/web/components/account/AccountRipioOtpPage.d.ts.map +0 -1
- package/dist/web/components/account/AccountRipioOtpPage.js +0 -53
- package/dist/web/components/account/AccountRipioOtpPage.js.map +0 -1
- package/dist/web/hooks/useCreateDeposit.d.ts +0 -20
- package/dist/web/hooks/useCreateDeposit.d.ts.map +0 -1
- package/dist/web/hooks/useCreateDeposit.js +0 -54
- package/dist/web/hooks/useCreateDeposit.js.map +0 -1
- package/dist/web/isDesktopBrowser.d.ts +0 -2
- package/dist/web/isDesktopBrowser.d.ts.map +0 -1
- package/dist/web/isDesktopBrowser.js +0 -6
- package/dist/web/isDesktopBrowser.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState, } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
+
import { DAIMO_BASE_URL } from "../../common/constants.js";
|
|
5
6
|
import { DAIMO_FRAME_PARENT_ORIGIN_PARAM, parseDaimoFrameMessage, } from "./frameMessages.js";
|
|
6
7
|
import { CloseIcon } from "./icons.js";
|
|
7
8
|
import { ContactSupportButton, ErrorMessage } from "./shared.js";
|
|
8
|
-
const DEFAULT_BASE_URL = "https://daimo.com";
|
|
9
9
|
const INITIAL_HEIGHT = 420;
|
|
10
10
|
/** Show the error fallback if the iframe hasn't rendered content within this. */
|
|
11
11
|
const LOAD_TIMEOUT_MS = 15000;
|
|
@@ -29,14 +29,8 @@ const scrimStyle = {
|
|
|
29
29
|
padding: 12,
|
|
30
30
|
paddingBottom: "calc(12px + env(safe-area-inset-bottom))",
|
|
31
31
|
};
|
|
32
|
-
const fullscreenScrimStyle = {
|
|
33
|
-
...scrimStyle,
|
|
34
|
-
alignItems: "stretch",
|
|
35
|
-
padding: 0,
|
|
36
|
-
paddingBottom: 0,
|
|
37
|
-
};
|
|
38
32
|
// Rounded surface that clips the content-sized iframe to four corners. Hidden
|
|
39
|
-
// (opacity 0) until the
|
|
33
|
+
// (opacity 0) until the flow reports its first height, so the user never
|
|
40
34
|
// sees an empty shadowed bubble while the iframe loads.
|
|
41
35
|
const bubbleStyle = {
|
|
42
36
|
width: "100%",
|
|
@@ -50,13 +44,11 @@ const bubbleStyle = {
|
|
|
50
44
|
// `transition` is set inline: opacity always animates, height only after the
|
|
51
45
|
// first appearance (see `animateHeight`).
|
|
52
46
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
borderRadius: 0,
|
|
59
|
-
boxShadow: "none",
|
|
47
|
+
// Inline embed surface: fills the host container's width, height follows the
|
|
48
|
+
// content. No chrome — the host owns rounding, borders, and dismissal.
|
|
49
|
+
const embedStyle = {
|
|
50
|
+
width: "100%",
|
|
51
|
+
overflow: "hidden",
|
|
60
52
|
};
|
|
61
53
|
const iframeStyle = {
|
|
62
54
|
display: "block",
|
|
@@ -95,20 +87,26 @@ const closeButtonStyle = {
|
|
|
95
87
|
cursor: "pointer",
|
|
96
88
|
};
|
|
97
89
|
/**
|
|
98
|
-
* Hosted Daimo
|
|
90
|
+
* Hosted Daimo deposit flow, embedded as an iframe.
|
|
99
91
|
*
|
|
100
|
-
* `DaimoFrame` loads `/webview` in content-only (`embed`) mode
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
92
|
+
* `DaimoFrame` loads `/webview` in content-only (`embed`) mode and sizes the
|
|
93
|
+
* iframe to the height the content reports over `postMessage`. No wallet
|
|
94
|
+
* libraries or app providers required. The surface stays hidden until the
|
|
95
|
+
* flow's first content arrives; if nothing loads within
|
|
104
96
|
* {@link LOAD_TIMEOUT_MS}, a dismissable error card is shown instead.
|
|
105
97
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
98
|
+
* With `layout="modal"` (default) the iframe renders inside a fixed, dimmed
|
|
99
|
+
* scrim portaled to `document.body`. With `layout="embed"` it renders inline
|
|
100
|
+
* where the component is placed, so the host can wrap it in its own modal or
|
|
101
|
+
* page layout.
|
|
102
|
+
*
|
|
103
|
+
* The modal's dimming scrim is `position: fixed` on purpose: iOS 26 derives
|
|
104
|
+
* the safe-area strip colors (notch / home indicator) from the
|
|
105
|
+
* `background-color` of fixed/sticky elements near the viewport edges (falling
|
|
106
|
+
* back to `body`). An `absolute` scrim is never sampled, so the strips would
|
|
107
|
+
* stay light — the fixed scrim's semi-transparent background instead tints
|
|
108
|
+
* them to match the dimmed page. See
|
|
109
|
+
* https://nasedk.in/blog/ios26-safari-toolbar-colors/.
|
|
112
110
|
*
|
|
113
111
|
* @example
|
|
114
112
|
* ```tsx
|
|
@@ -120,16 +118,16 @@ const closeButtonStyle = {
|
|
|
120
118
|
* />
|
|
121
119
|
* ```
|
|
122
120
|
*/
|
|
123
|
-
export function DaimoFrame({ sessionId, clientSecret, layout = "modal", onClose, onOpen, onPaymentStarted, onPaymentCompleted, baseUrl =
|
|
121
|
+
export function DaimoFrame({ sessionId, clientSecret, layout = "modal", onClose, onOpen, onPaymentStarted, onPaymentCompleted, baseUrl = DAIMO_BASE_URL, }) {
|
|
124
122
|
const [parentOrigin, setParentOrigin] = useState(null);
|
|
125
123
|
const src = useMemo(() => parentOrigin
|
|
126
124
|
? getFrameSrc(baseUrl, sessionId, clientSecret, parentOrigin)
|
|
127
125
|
: null, [baseUrl, clientSecret, parentOrigin, sessionId]);
|
|
126
|
+
const iframeRef = useRef(null);
|
|
128
127
|
const [height, setHeight] = useState(INITIAL_HEIGHT);
|
|
129
128
|
const [mounted, setMounted] = useState(false);
|
|
130
129
|
const [status, setStatus] = useState("loading");
|
|
131
|
-
|
|
132
|
-
// Height animates only after the bubble's first appearance, so revealing it
|
|
130
|
+
// Height animates only after the surface's first appearance, so revealing it
|
|
133
131
|
// doesn't animate from INITIAL_HEIGHT down to the first measured (skeleton)
|
|
134
132
|
// height. Only later growth (skeleton -> content) animates.
|
|
135
133
|
const [animateHeight, setAnimateHeight] = useState(false);
|
|
@@ -141,11 +139,14 @@ export function DaimoFrame({ sessionId, clientSecret, layout = "modal", onClose,
|
|
|
141
139
|
useEffect(() => {
|
|
142
140
|
if (!src)
|
|
143
141
|
return;
|
|
144
|
-
// Only trust messages from
|
|
142
|
+
// Only trust messages from our own iframe: match both the frame origin
|
|
143
|
+
// and the sending window, so two DaimoFrames on one page don't cross-talk.
|
|
145
144
|
const frameOrigin = new URL(src, window.location.href).origin;
|
|
146
145
|
const handleMessage = (event) => {
|
|
147
146
|
if (event.origin !== frameOrigin)
|
|
148
147
|
return;
|
|
148
|
+
if (event.source !== iframeRef.current?.contentWindow)
|
|
149
|
+
return;
|
|
149
150
|
const message = parseDaimoFrameMessage(event.data);
|
|
150
151
|
if (!message)
|
|
151
152
|
return;
|
|
@@ -161,24 +162,18 @@ export function DaimoFrame({ sessionId, clientSecret, layout = "modal", onClose,
|
|
|
161
162
|
setHeight(message.payload.height);
|
|
162
163
|
setStatus("loaded");
|
|
163
164
|
}
|
|
164
|
-
if (message.type === "framePresentationChanged") {
|
|
165
|
-
setPresentationMode(message.payload.mode);
|
|
166
|
-
}
|
|
167
165
|
};
|
|
168
166
|
window.addEventListener("message", handleMessage);
|
|
169
167
|
return () => window.removeEventListener("message", handleMessage);
|
|
170
168
|
}, [onClose, onOpen, onPaymentCompleted, onPaymentStarted, src]);
|
|
171
|
-
|
|
172
|
-
setPresentationMode("content");
|
|
173
|
-
}, [src]);
|
|
174
|
-
// Fall back to the error card if the checkout never reports content.
|
|
169
|
+
// Fall back to the error card if the flow never reports content.
|
|
175
170
|
useEffect(() => {
|
|
176
171
|
if (status !== "loading")
|
|
177
172
|
return;
|
|
178
173
|
const id = setTimeout(() => setStatus("error"), LOAD_TIMEOUT_MS);
|
|
179
174
|
return () => clearTimeout(id);
|
|
180
175
|
}, [status]);
|
|
181
|
-
// Enable the height transition one frame after the
|
|
176
|
+
// Enable the height transition one frame after the surface first appears, so
|
|
182
177
|
// its reveal snaps to the first height instead of animating down to it.
|
|
183
178
|
useEffect(() => {
|
|
184
179
|
if (status !== "loaded" || animateHeight)
|
|
@@ -186,25 +181,29 @@ export function DaimoFrame({ sessionId, clientSecret, layout = "modal", onClose,
|
|
|
186
181
|
const id = requestAnimationFrame(() => setAnimateHeight(true));
|
|
187
182
|
return () => cancelAnimationFrame(id);
|
|
188
183
|
}, [status, animateHeight]);
|
|
189
|
-
// `layout` is reserved for future modes; only "modal" is supported today.
|
|
190
|
-
void layout;
|
|
191
184
|
if (!mounted || !src)
|
|
192
185
|
return null;
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
const surfaceTransition = animateHeight
|
|
187
|
+
? "height 0.2s ease-in-out, opacity 0.2s ease-in-out"
|
|
188
|
+
: "opacity 0.2s ease-in-out";
|
|
189
|
+
const iframe = (_jsx("iframe", { ref: iframeRef, title: "Daimo", src: src, allow: "payment; clipboard-write", style: iframeStyle }));
|
|
190
|
+
if (layout === "embed") {
|
|
191
|
+
if (status === "error") {
|
|
192
|
+
return _jsx(DaimoFrameError, { sessionId: sessionId, onClose: onClose });
|
|
193
|
+
}
|
|
194
|
+
return (_jsx("div", { style: {
|
|
195
|
+
...embedStyle,
|
|
196
|
+
height,
|
|
197
|
+
opacity: status === "loaded" ? 1 : 0,
|
|
198
|
+
transition: surfaceTransition,
|
|
199
|
+
}, children: iframe }));
|
|
200
|
+
}
|
|
201
|
+
return createPortal(_jsx("div", { onClick: () => onClose?.(), style: scrimStyle, children: status === "error" ? (_jsx(DaimoFrameError, { sessionId: sessionId, onClose: onClose })) : (_jsx("div", { onClick: (e) => e.stopPropagation(), style: {
|
|
202
|
+
...bubbleStyle,
|
|
203
|
+
height,
|
|
201
204
|
opacity: status === "loaded" ? 1 : 0,
|
|
202
|
-
transition:
|
|
203
|
-
|
|
204
|
-
: animateHeight
|
|
205
|
-
? "height 0.2s ease-in-out, opacity 0.2s ease-in-out"
|
|
206
|
-
: "opacity 0.2s ease-in-out",
|
|
207
|
-
}, children: _jsx("iframe", { title: "Daimo", src: src, allow: "payment; clipboard-write", style: iframeStyle }) })) }), document.body);
|
|
205
|
+
transition: surfaceTransition,
|
|
206
|
+
}, children: iframe })) }), document.body);
|
|
208
207
|
}
|
|
209
208
|
function getFrameSrc(baseUrl, sessionId, clientSecret, parentOrigin) {
|
|
210
209
|
const base = baseUrl.replace(/\/$/, "");
|
|
@@ -218,6 +217,6 @@ function getFrameSrc(baseUrl, sessionId, clientSecret, parentOrigin) {
|
|
|
218
217
|
}
|
|
219
218
|
/** Dismissable "couldn't load" card with a contact-support mailto link. */
|
|
220
219
|
function DaimoFrameError({ sessionId, onClose, }) {
|
|
221
|
-
return (_jsxs("div", { onClick: (e) => e.stopPropagation(), style: errorCardStyle, children: [_jsx("button", { type: "button", "aria-label": "Close", onClick: () => onClose?.(), style: closeButtonStyle, children: _jsx(CloseIcon, {}) }), _jsx(ErrorMessage, { message: "Couldn't load. Offline?" }), _jsx(ContactSupportButton, { subject: "Couldn't load Daimo
|
|
220
|
+
return (_jsxs("div", { onClick: (e) => e.stopPropagation(), style: errorCardStyle, children: [_jsx("button", { type: "button", "aria-label": "Close", onClick: () => onClose?.(), style: closeButtonStyle, children: _jsx(CloseIcon, {}) }), _jsx(ErrorMessage, { message: "Couldn't load. Offline?" }), _jsx(ContactSupportButton, { subject: "Couldn't load Daimo", info: { sessionId } })] }));
|
|
222
221
|
}
|
|
223
222
|
//# sourceMappingURL=DaimoFrame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DaimoFrame.js","sourceRoot":"","sources":["../../../src/web/components/DaimoFrame.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"DaimoFrame.js","sourceRoot":"","sources":["../../../src/web/components/DaimoFrame.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAEL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA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,CAAC,CAAC,CAAC,CAAC;gBACpC,UAAU,EAAE,iBAAiB;aAC9B,YAEA,MAAM,GACH,CACP,GACG,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAClB,OAAe,EACf,SAAiB,EACjB,YAAoB,EACpB,YAAoB;IAEpB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,OAAO,EAAE,SAAS;QAClB,EAAE,EAAE,YAAY;QAChB,MAAM,EAAE,OAAO;QACf,CAAC,+BAA+B,CAAC,EAAE,YAAY;KAChD,CAAC,CAAC;IACH,OAAO,GAAG,IAAI,YAAY,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,2EAA2E;AAC3E,SAAS,eAAe,CAAC,EACvB,SAAS,EACT,OAAO,GAIR;IACC,OAAO,CACL,eAAK,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,cAAc,aAC7D,iBACE,IAAI,EAAC,QAAQ,gBACF,OAAO,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAC1B,KAAK,EAAE,gBAAgB,YAEvB,KAAC,SAAS,KAAG,GACN,EACT,KAAC,YAAY,IAAC,OAAO,EAAC,yBAAyB,GAAG,EAClD,KAAC,oBAAoB,IACnB,OAAO,EAAC,qBAAqB,EAC7B,IAAI,EAAE,EAAE,SAAS,EAAE,GACnB,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
import type { DaimoCountryCode } from "../api/index.js";
|
|
2
3
|
import { type DaimoModalEventHandlers } from "../hooks/types.js";
|
|
3
4
|
import type { DaimoThemeMode } from "../../common/theme.js";
|
|
4
5
|
import { type DaimoPlatform } from "../platform.js";
|
|
5
|
-
export type
|
|
6
|
+
export type DaimoModalLocalizationProps = {
|
|
7
|
+
/** Override country used to localize auto payment-method sessions. */
|
|
8
|
+
countryCode?: DaimoCountryCode;
|
|
9
|
+
/** Called after the modal country picker successfully switches country. */
|
|
10
|
+
onCountryCodeChange?: (countryCode: DaimoCountryCode) => void;
|
|
11
|
+
};
|
|
12
|
+
type DaimoModalBaseProps = {
|
|
6
13
|
/** Unique session ID. Sessions are created server-side. */
|
|
7
14
|
sessionId: string;
|
|
8
15
|
/** Unique client secret, returned at session creation. */
|
|
@@ -15,6 +22,12 @@ export type DaimoModalProps = DaimoModalEventHandlers & {
|
|
|
15
22
|
connectToAddress?: Address;
|
|
16
23
|
/** Render inline instead of as a floating modal. */
|
|
17
24
|
embedded?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Show the close button even when `embedded`. Set only by the native webview
|
|
27
|
+
* surface (DaimoFrameRN), which has no chrome of its own and needs the flow's
|
|
28
|
+
* own close button. Web embedders own their chrome, so this stays off there.
|
|
29
|
+
*/
|
|
30
|
+
embeddedClose?: boolean;
|
|
18
31
|
/** Override the session's light/dark/system theme mode. */
|
|
19
32
|
themeMode?: DaimoThemeMode;
|
|
20
33
|
/** Caller's platform. Prefer "desktop" or "mobile"; legacy values still work. Auto-detected. */
|
|
@@ -31,5 +44,7 @@ export type DaimoModalProps = DaimoModalEventHandlers & {
|
|
|
31
44
|
/** Node to auto-navigate to on load (popup deep-link). */
|
|
32
45
|
startNodeId?: string;
|
|
33
46
|
};
|
|
47
|
+
export type DaimoModalProps = DaimoModalEventHandlers & DaimoModalLocalizationProps & DaimoModalBaseProps;
|
|
34
48
|
export declare function DaimoModal(props: DaimoModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
49
|
+
export {};
|
|
35
50
|
//# sourceMappingURL=DaimoModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DaimoModal.d.ts","sourceRoot":"","sources":["../../../src/web/components/DaimoModal.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"DaimoModal.d.ts","sourceRoot":"","sources":["../../../src/web/components/DaimoModal.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAEV,gBAAgB,EAIjB,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,mBAAmB,CAAC;AAY3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAmD/E,MAAM,MAAM,2BAA2B,GAAG;IACxC,sEAAsE;IACtE,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oEAAoE;IACpE,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,uBAAuB,GACnD,2BAA2B,GAC3B,mBAAmB,CAAC;AAiDtB,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,kDAqJhD"}
|
|
@@ -31,6 +31,7 @@ import { AccountCanadaBankPickerPage } from "./account/AccountBankPickerPage.js"
|
|
|
31
31
|
import { AccountEnrollmentUpdatePage } from "./account/AccountEnrollmentUpdatePage.js";
|
|
32
32
|
import { AccountCreatingWalletPage } from "./account/AccountCreatingWalletPage.js";
|
|
33
33
|
import { AccountDeeplinkPage } from "./account/AccountDeeplinkPage.js";
|
|
34
|
+
import { AccountInteracConfirmPage } from "./account/AccountInteracConfirmPage.js";
|
|
34
35
|
import { AccountApplePayPage } from "./account/AccountApplePayPage.js";
|
|
35
36
|
import { FiatPopupPage } from "./account/FiatPopupPage.js";
|
|
36
37
|
import { AccountEmailPage } from "./account/AccountEmailPage.js";
|
|
@@ -51,7 +52,12 @@ import { ModalChrome } from "./ModalChrome.js";
|
|
|
51
52
|
import { QRCode } from "./QRCode.js";
|
|
52
53
|
import { WaitingDepositAddressPage } from "./WaitingDepositAddressPage.js";
|
|
53
54
|
import { WalletAmountPage } from "./WalletAmountPage.js";
|
|
54
|
-
|
|
55
|
+
/** Fallback when the server predates the nav location fields. */
|
|
56
|
+
const UNKNOWN_LOCATION = {
|
|
57
|
+
countryCode: null,
|
|
58
|
+
countryName: "Location unknown",
|
|
59
|
+
emoji: "🌐",
|
|
60
|
+
};
|
|
55
61
|
function useModalCloseHandler(sessionId, clientSecret, getNodeCtx, isOpen, setIsOpen, onClose) {
|
|
56
62
|
const client = useDaimoClient();
|
|
57
63
|
const logNavEvent = createNavLogger(client);
|
|
@@ -74,7 +80,7 @@ function useModalCloseHandler(sessionId, clientSecret, getNodeCtx, isOpen, setIs
|
|
|
74
80
|
return { handleClose };
|
|
75
81
|
}
|
|
76
82
|
export function DaimoModal(props) {
|
|
77
|
-
const { sessionId, clientSecret, embedded = false, defaultOpen = true, onClose, } = props;
|
|
83
|
+
const { sessionId, clientSecret, embedded = false, defaultOpen = true, countryCode, onClose, } = props;
|
|
78
84
|
// Auto-detect browser language if setLocale() hasn't been called explicitly
|
|
79
85
|
autoDetectLocale();
|
|
80
86
|
const client = useDaimoClient();
|
|
@@ -89,15 +95,19 @@ export function DaimoModal(props) {
|
|
|
89
95
|
});
|
|
90
96
|
useEffect(() => {
|
|
91
97
|
client.internal.sessions
|
|
92
|
-
.retrieveWithNav(sessionId, clientSecret)
|
|
98
|
+
.retrieveWithNav(sessionId, clientSecret, countryCode ? { countryCode } : undefined)
|
|
93
99
|
.then((resp) => {
|
|
94
100
|
setLoaded({
|
|
95
101
|
session: { ...resp.session, clientSecret },
|
|
96
102
|
accountAuth: resp.accountAuth ?? null,
|
|
103
|
+
// Defensive defaults: keep the modal working against servers that
|
|
104
|
+
// predate the location fields.
|
|
105
|
+
location: resp.location ?? UNKNOWN_LOCATION,
|
|
106
|
+
locationOptions: resp.locationOptions ?? [],
|
|
97
107
|
});
|
|
98
108
|
})
|
|
99
109
|
.catch((err) => console.error("failed to fetch session:", err));
|
|
100
|
-
}, [sessionId, clientSecret]);
|
|
110
|
+
}, [sessionId, clientSecret, countryCode]);
|
|
101
111
|
// If the API returned account auth config and no AccountFlowProvider exists
|
|
102
112
|
// upstream (e.g. customer didn't pass privyAppId to DaimoSDKProvider),
|
|
103
113
|
// lazily wrap modal content so fiat flow works automatically.
|
|
@@ -116,7 +126,7 @@ export function DaimoModal(props) {
|
|
|
116
126
|
return null;
|
|
117
127
|
return (_jsx(EmbeddedContainer, { showFooterSpacer: false, themeMode: props.themeMode, children: _jsx(SkeletonContent, { rowCount: 3, showFooter: false }) }));
|
|
118
128
|
}
|
|
119
|
-
const content = (_jsx(DaimoModalInner, { ...props, session: loaded.session, accountAuth: loaded.accountAuth, isOpen: isOpen, setIsOpen: setIsOpen, closeRef: closeRef, setPageKey: setPageKey, setShowFooterSpacer: setShowFooterSpacer, setShowCloseButton: setShowCloseButton }));
|
|
129
|
+
const content = (_jsx(DaimoModalInner, { ...props, session: loaded.session, accountAuth: loaded.accountAuth, location: loaded.location, locationOptions: loaded.locationOptions, setLoaded: setLoaded, isOpen: isOpen, setIsOpen: setIsOpen, closeRef: closeRef, setPageKey: setPageKey, setShowFooterSpacer: setShowFooterSpacer, setShowCloseButton: setShowCloseButton }, loaded.location.countryCode ?? "unknown"));
|
|
120
130
|
const wrapped = needsAccountProvider && accountAuth ? (_jsx(AccountFlowProvider, { privyAppId: accountAuth.privyAppId, children: content })) : (content);
|
|
121
131
|
const handleClose = showCloseButton ? () => closeRef.current() : undefined;
|
|
122
132
|
const reserveLoadingHeight = pageKey == null || pageKey.startsWith("account-loading-");
|
|
@@ -137,7 +147,7 @@ const AUTOCONNECT_NAV = [
|
|
|
137
147
|
{ ...CONNECTED_WALLET_NODE, autoconnect: true },
|
|
138
148
|
];
|
|
139
149
|
const CONNECT_TO_ADDRESS_NAV = [CONNECTED_WALLET_NODE];
|
|
140
|
-
function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOpen, closeRef, setPageKey, setShowFooterSpacer, setShowCloseButton, embedded = false, connectToInjectedWallets = false, connectToAddress, platform, returnUrl, returnLabel, enableFiatPopup = false, startNodeId, onPaymentStarted, onPaymentCompleted, onOpen, onClose, }) {
|
|
150
|
+
function DaimoModalInner({ session: initialSession, accountAuth, location, locationOptions, setLoaded, isOpen, setIsOpen, closeRef, setPageKey, setShowFooterSpacer, setShowCloseButton, embedded = false, embeddedClose = false, connectToInjectedWallets = false, connectToAddress, platform, returnUrl, returnLabel, enableFiatPopup = false, startNodeId, onPaymentStarted, onPaymentCompleted, onCountryCodeChange, onOpen, onClose, }) {
|
|
141
151
|
const effectiveInitial = connectToAddress
|
|
142
152
|
? { ...initialSession, navTree: CONNECT_TO_ADDRESS_NAV }
|
|
143
153
|
: connectToInjectedWallets
|
|
@@ -145,6 +155,8 @@ function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOp
|
|
|
145
155
|
: initialSession;
|
|
146
156
|
const [pendingTxHash, setPendingTxHash] = useState();
|
|
147
157
|
const [pageCloseVisible, setPageCloseVisible] = useState(true);
|
|
158
|
+
const [loadingCountryCode, setLoadingCountryCode] = useState(null);
|
|
159
|
+
const client = useDaimoClient();
|
|
148
160
|
const { session, setSession } = useSessionPolling(effectiveInitial, isOpen, pendingTxHash);
|
|
149
161
|
const depositAddress = useDepositAddress(session);
|
|
150
162
|
const cwNode = findNodeByType("ConnectedWallet", session.navTree);
|
|
@@ -158,7 +170,21 @@ function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOp
|
|
|
158
170
|
const accountFlow = useAccountFlow();
|
|
159
171
|
const resolvedPlatform = platform ?? detectPlatform();
|
|
160
172
|
const desktop = isDesktop(resolvedPlatform);
|
|
161
|
-
const
|
|
173
|
+
const handleRecreate = useCallback((resp) => {
|
|
174
|
+
setLoaded({
|
|
175
|
+
session: resp.session,
|
|
176
|
+
accountAuth: resp.accountAuth ?? null,
|
|
177
|
+
location: resp.location ?? UNKNOWN_LOCATION,
|
|
178
|
+
locationOptions: resp.locationOptions ?? [],
|
|
179
|
+
});
|
|
180
|
+
}, [setLoaded]);
|
|
181
|
+
const nav = useSessionNav(session, setSession, isOpen, accountAuth, resolvedPlatform, walletFlow, accountFlow, {
|
|
182
|
+
enableFiatPopup,
|
|
183
|
+
startNodeId,
|
|
184
|
+
countryCode: location.countryCode ?? undefined,
|
|
185
|
+
onRecreate: handleRecreate,
|
|
186
|
+
});
|
|
187
|
+
const { handleReset } = nav;
|
|
162
188
|
useEffect(() => {
|
|
163
189
|
const top = nav.topEntry;
|
|
164
190
|
if (top?.type === "wallet-sending" && top.txHash) {
|
|
@@ -167,6 +193,46 @@ function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOp
|
|
|
167
193
|
}, [nav.topEntry]);
|
|
168
194
|
const { handleClose } = useModalCloseHandler(session.sessionId, session.clientSecret, nav.getNodeCtx, isOpen, setIsOpen, onClose);
|
|
169
195
|
closeRef.current = handleClose;
|
|
196
|
+
const handleCountrySelect = useCallback(async (countryCode) => {
|
|
197
|
+
if (countryCode === location.countryCode || loadingCountryCode != null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
setLoadingCountryCode(countryCode);
|
|
201
|
+
try {
|
|
202
|
+
const resp = await client.internal.sessions.retrieveWithNav(session.sessionId, session.clientSecret, { countryCode });
|
|
203
|
+
const nextSession = {
|
|
204
|
+
...resp.session,
|
|
205
|
+
clientSecret: session.clientSecret,
|
|
206
|
+
};
|
|
207
|
+
handleReset();
|
|
208
|
+
setSession(nextSession);
|
|
209
|
+
setLoaded({
|
|
210
|
+
session: nextSession,
|
|
211
|
+
accountAuth: resp.accountAuth ?? null,
|
|
212
|
+
location: resp.location ?? UNKNOWN_LOCATION,
|
|
213
|
+
locationOptions: resp.locationOptions ?? [],
|
|
214
|
+
});
|
|
215
|
+
if (resp.location.countryCode != null) {
|
|
216
|
+
onCountryCodeChange?.(resp.location.countryCode);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.error("failed to switch country:", error);
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
setLoadingCountryCode(null);
|
|
224
|
+
}
|
|
225
|
+
}, [
|
|
226
|
+
client,
|
|
227
|
+
session.sessionId,
|
|
228
|
+
session.clientSecret,
|
|
229
|
+
location.countryCode,
|
|
230
|
+
loadingCountryCode,
|
|
231
|
+
handleReset,
|
|
232
|
+
setSession,
|
|
233
|
+
setLoaded,
|
|
234
|
+
onCountryCodeChange,
|
|
235
|
+
]);
|
|
170
236
|
usePaymentCallbacks(session, isOpen, {
|
|
171
237
|
onOpen,
|
|
172
238
|
onPaymentStarted,
|
|
@@ -216,29 +282,20 @@ function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOp
|
|
|
216
282
|
setModalCloseVisible: setPageCloseVisible,
|
|
217
283
|
});
|
|
218
284
|
}
|
|
219
|
-
const closeVisible = !embedded && showClose && pageCloseVisible;
|
|
220
|
-
const account = ACCOUNT_CHROME_ENABLED &&
|
|
221
|
-
accountFlow?.isAuthenticated &&
|
|
222
|
-
accountFlow.email &&
|
|
223
|
-
pageCloseVisible
|
|
224
|
-
? {
|
|
225
|
-
email: accountFlow.email,
|
|
226
|
-
onLogout: async () => {
|
|
227
|
-
await accountFlow.logout();
|
|
228
|
-
if (isAccountFlow)
|
|
229
|
-
nav.handleAccountLogout();
|
|
230
|
-
},
|
|
231
|
-
}
|
|
232
|
-
: null;
|
|
285
|
+
const closeVisible = (!embedded || embeddedClose) && showClose && pageCloseVisible;
|
|
233
286
|
const close = closeVisible ? { onClose: handleClose } : null;
|
|
287
|
+
const showCountryPicker =
|
|
288
|
+
// Server sends locations only when switching affects the nav
|
|
289
|
+
// (paymentMethods auto sessions); empty means hide the picker.
|
|
290
|
+
locationOptions.length > 0 &&
|
|
291
|
+
(embedded || closeVisible) &&
|
|
292
|
+
!connectToInjectedWallets &&
|
|
293
|
+
!connectToAddress &&
|
|
294
|
+
!startNodeId &&
|
|
295
|
+
(!nav.topEntry ||
|
|
296
|
+
(nav.topEntry.type === "choose-option" && !nav.canGoBack));
|
|
234
297
|
let chrome = { type: "none" };
|
|
235
|
-
if (
|
|
236
|
-
chrome = { type: "account-close", account, close };
|
|
237
|
-
}
|
|
238
|
-
else if (account) {
|
|
239
|
-
chrome = { type: "account", account };
|
|
240
|
-
}
|
|
241
|
-
else if (close) {
|
|
298
|
+
if (close) {
|
|
242
299
|
chrome = { type: "close", close };
|
|
243
300
|
}
|
|
244
301
|
const isFirstPage = useRef(true);
|
|
@@ -250,7 +307,17 @@ function DaimoModalInner({ session: initialSession, accountAuth, isOpen, setIsOp
|
|
|
250
307
|
useEffect(() => {
|
|
251
308
|
isFirstPage.current = false;
|
|
252
309
|
}, []);
|
|
253
|
-
return (_jsx(ModalChrome, { controls: chrome,
|
|
310
|
+
return (_jsx(ModalChrome, { controls: chrome, country: showCountryPicker
|
|
311
|
+
? {
|
|
312
|
+
location,
|
|
313
|
+
options: locationOptions,
|
|
314
|
+
loadingCountryCode,
|
|
315
|
+
onSelect: handleCountrySelect,
|
|
316
|
+
}
|
|
317
|
+
: null, children: (dismissAccount) => loadingCountryCode != null ? (
|
|
318
|
+
// Country switch in flight: skeleton the method list for a smooth
|
|
319
|
+
// swap instead of freezing the old list until the new nav lands.
|
|
320
|
+
_jsx(SkeletonContent, { rowCount: 4, showFooter: false })) : (_jsx("div", { onClick: dismissAccount ?? undefined, className: `${animate ? "daimo-page-enter " : ""}daimo-flex-1 daimo-min-h-0 daimo-flex daimo-flex-col`, children: content }, pageKey)) }));
|
|
254
321
|
}
|
|
255
322
|
function renderEntry(entry, ctx) {
|
|
256
323
|
if (!entry) {
|
|
@@ -312,8 +379,12 @@ function renderEntry(entry, ctx) {
|
|
|
312
379
|
}
|
|
313
380
|
case "account-loading":
|
|
314
381
|
return _jsx(LoadingMessage, {});
|
|
315
|
-
case "account-email":
|
|
316
|
-
|
|
382
|
+
case "account-email": {
|
|
383
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
384
|
+
if (node?.type !== "Fiat")
|
|
385
|
+
return null;
|
|
386
|
+
return (_jsx(AccountEmailPage, { methodLabel: node.title, onBack: ctx.canGoBack ? ctx.onBack : null, onOtpSent: () => ctx.onAccountAdvance("account-otp") }));
|
|
387
|
+
}
|
|
317
388
|
case "account-otp":
|
|
318
389
|
return (_jsx(AccountOtpPage, { onBack: ctx.onBack, onVerified: () => ctx.onAccountAdvance("account-creating-wallet") }));
|
|
319
390
|
case "account-creating-wallet":
|
|
@@ -334,10 +405,14 @@ function renderEntry(entry, ctx) {
|
|
|
334
405
|
return (_jsx(AccountEnrollmentUpdatePage, { update: entry.update, sessionId: ctx.session.sessionId, onBack: ctx.canGoBack ? ctx.onBack : null, onReady: () => ctx.onAccountAdvance(getAccountPaymentEntryTarget(entry.rail)) }));
|
|
335
406
|
case "account-payment": {
|
|
336
407
|
const advanceTarget = getAccountPaymentAdvanceTarget(entry.rail, ctx.platform);
|
|
337
|
-
return (_jsx(AccountPaymentPage, { rail: entry.rail, sessionId: ctx.session.sessionId, initialAmount: ctx.session.destination.amountUnits, platform: ctx.platform, baseUrl: ctx.session.baseUrl, startDepositOnAdvance: advanceTarget === "account-
|
|
408
|
+
return (_jsx(AccountPaymentPage, { rail: entry.rail, sessionId: ctx.session.sessionId, initialAmount: ctx.session.destination.amountUnits, platform: ctx.platform, baseUrl: ctx.session.baseUrl, startDepositOnAdvance: advanceTarget === "account-interac-confirm", onBack: ctx.canGoBack ? ctx.onBack : null, onAdvance: () => ctx.onAccountAdvance(advanceTarget) }));
|
|
338
409
|
}
|
|
339
410
|
case "account-canada-bank-picker":
|
|
340
|
-
return (_jsx(AccountCanadaBankPickerPage, { rail: entry.rail, sessionId: ctx.session.sessionId,
|
|
411
|
+
return (_jsx(AccountCanadaBankPickerPage, { rail: entry.rail, sessionId: ctx.session.sessionId, onBack: null, onSelect: () => ctx.onAccountAdvance("account-interac-confirm") }));
|
|
412
|
+
case "account-interac-confirm": {
|
|
413
|
+
const accountNode = findNode(entry.nodeId, ctx.session.navTree);
|
|
414
|
+
return (_jsx(AccountInteracConfirmPage, { sessionId: ctx.session.sessionId, baseUrl: ctx.session.baseUrl, platform: ctx.platform, icon: accountNode?.type === "Fiat" ? accountNode.icon : undefined, onBack: ctx.onBack, onAdvance: () => ctx.onAccountAdvance("account-deeplink") }));
|
|
415
|
+
}
|
|
341
416
|
case "account-apple-pay":
|
|
342
417
|
return (_jsx(AccountApplePayPage, { rail: entry.rail, sessionId: ctx.session.sessionId, clientSecret: ctx.session.clientSecret, actionVerb: ctx.displayVerb, initialAmount: ctx.session.destination.amountUnits, onBack: ctx.canGoBack ? ctx.onBack : null, onAdvance: () => ctx.onAccountAdvance("account-status") }));
|
|
343
418
|
case "account-bank-details":
|
|
@@ -347,7 +422,7 @@ function renderEntry(entry, ctx) {
|
|
|
347
422
|
return (_jsx(AccountDeeplinkPage, { sessionId: ctx.session.sessionId, clientSecret: ctx.session.clientSecret, baseUrl: ctx.session.baseUrl, platform: ctx.platform, icon: accountNode?.type === "Fiat" ? accountNode.icon : undefined, onBack: ctx.onBack, onAdvance: () => ctx.onAccountAdvance("account-status") }));
|
|
348
423
|
}
|
|
349
424
|
case "account-status":
|
|
350
|
-
return (_jsx(AccountStatusPage, { sessionId: ctx.session.sessionId, clientSecret: ctx.session.clientSecret, baseUrl: ctx.session.baseUrl }));
|
|
425
|
+
return (_jsx(AccountStatusPage, { sessionId: ctx.session.sessionId, clientSecret: ctx.session.clientSecret, baseUrl: ctx.session.baseUrl, initialStatus: entry.initialStatus }));
|
|
351
426
|
case "account-error":
|
|
352
427
|
return (_jsxs("div", { className: "daimo-flex daimo-flex-col daimo-flex-1 daimo-min-h-0", children: [_jsx(PageHeader, { title: t.error, onBack: ctx.canGoBack ? ctx.onBack : null }), _jsx(CenteredContent, { children: _jsx(SharedErrorMessage, { message: entry.message }) })] }));
|
|
353
428
|
default:
|