@yodlpay/react-native 0.8.2 → 0.10.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 +13 -12
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +132 -180
- package/dist/index.d.mts +132 -180
- package/dist/index.mjs +2 -2
- package/package.json +16 -17
package/dist/index.d.mts
CHANGED
|
@@ -1,128 +1,28 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/theme/schemas.d.ts
|
|
8
|
-
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
9
|
-
declare const yodlThemeModeSchema: z.ZodEnum<{
|
|
10
|
-
system: "system";
|
|
11
|
-
light: "light";
|
|
12
|
-
dark: "dark";
|
|
13
|
-
}>;
|
|
14
|
-
/** What `system` resolves to once the host appearance is known. */
|
|
15
|
-
/**
|
|
16
|
-
* One customizable Yodl theme: a light/dark palette pair plus optional media.
|
|
17
|
-
* `font` and the radii sit at the top level rather than inside a palette
|
|
18
|
-
* because none of them is a color and none varies by mode.
|
|
19
|
-
*
|
|
20
|
-
* `radiusControl` is the one radius most integrators set; `radiusSurface`
|
|
21
|
-
* defaults to it (clamped, so a pill control does not make cards lozenges) and
|
|
22
|
-
* exists for themes that want cards and sheets to differ from their buttons.
|
|
23
|
-
*/
|
|
24
|
-
declare const yodlThemeSchema: z.ZodObject<{
|
|
25
|
-
name: z.ZodOptional<z.ZodString>;
|
|
26
|
-
font: z.ZodOptional<z.ZodEnum<{
|
|
27
|
-
system: "system";
|
|
28
|
-
inter: "inter";
|
|
29
|
-
geist: "geist";
|
|
30
|
-
mono: "mono";
|
|
31
|
-
}>>;
|
|
32
|
-
radiusControl: z.ZodOptional<z.ZodString>;
|
|
33
|
-
radiusSurface: z.ZodOptional<z.ZodString>;
|
|
34
|
-
light: z.ZodOptional<z.ZodObject<{
|
|
35
|
-
bg: z.ZodOptional<z.ZodString>;
|
|
36
|
-
surface: z.ZodOptional<z.ZodString>;
|
|
37
|
-
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
38
|
-
text: z.ZodOptional<z.ZodString>;
|
|
39
|
-
textSecondary: z.ZodOptional<z.ZodString>;
|
|
40
|
-
textMuted: z.ZodOptional<z.ZodString>;
|
|
41
|
-
border: z.ZodOptional<z.ZodString>;
|
|
42
|
-
success: z.ZodOptional<z.ZodString>;
|
|
43
|
-
error: z.ZodOptional<z.ZodString>;
|
|
44
|
-
warning: z.ZodOptional<z.ZodString>;
|
|
45
|
-
accent: z.ZodOptional<z.ZodString>;
|
|
46
|
-
bgDeep: z.ZodOptional<z.ZodString>;
|
|
47
|
-
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
48
|
-
skeleton: z.ZodOptional<z.ZodString>;
|
|
49
|
-
accentStrong: z.ZodOptional<z.ZodString>;
|
|
50
|
-
accentDeep: z.ZodOptional<z.ZodString>;
|
|
51
|
-
brandSurface: z.ZodOptional<z.ZodString>;
|
|
52
|
-
brandSheet: z.ZodOptional<z.ZodString>;
|
|
53
|
-
brandText: z.ZodOptional<z.ZodString>;
|
|
54
|
-
brandButton: z.ZodOptional<z.ZodString>;
|
|
55
|
-
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
56
|
-
}, z.core.$strip>>;
|
|
57
|
-
dark: z.ZodOptional<z.ZodObject<{
|
|
58
|
-
bg: z.ZodOptional<z.ZodString>;
|
|
59
|
-
surface: z.ZodOptional<z.ZodString>;
|
|
60
|
-
surfaceSecondary: z.ZodOptional<z.ZodString>;
|
|
61
|
-
text: z.ZodOptional<z.ZodString>;
|
|
62
|
-
textSecondary: z.ZodOptional<z.ZodString>;
|
|
63
|
-
textMuted: z.ZodOptional<z.ZodString>;
|
|
64
|
-
border: z.ZodOptional<z.ZodString>;
|
|
65
|
-
success: z.ZodOptional<z.ZodString>;
|
|
66
|
-
error: z.ZodOptional<z.ZodString>;
|
|
67
|
-
warning: z.ZodOptional<z.ZodString>;
|
|
68
|
-
accent: z.ZodOptional<z.ZodString>;
|
|
69
|
-
bgDeep: z.ZodOptional<z.ZodString>;
|
|
70
|
-
surfaceHover: z.ZodOptional<z.ZodString>;
|
|
71
|
-
skeleton: z.ZodOptional<z.ZodString>;
|
|
72
|
-
accentStrong: z.ZodOptional<z.ZodString>;
|
|
73
|
-
accentDeep: z.ZodOptional<z.ZodString>;
|
|
74
|
-
brandSurface: z.ZodOptional<z.ZodString>;
|
|
75
|
-
brandSheet: z.ZodOptional<z.ZodString>;
|
|
76
|
-
brandText: z.ZodOptional<z.ZodString>;
|
|
77
|
-
brandButton: z.ZodOptional<z.ZodString>;
|
|
78
|
-
brandButtonText: z.ZodOptional<z.ZodString>;
|
|
79
|
-
}, z.core.$strip>>;
|
|
80
|
-
images: z.ZodOptional<z.ZodObject<{
|
|
81
|
-
light: z.ZodOptional<z.ZodObject<{
|
|
82
|
-
payBackground: z.ZodOptional<z.ZodString>;
|
|
83
|
-
processing: z.ZodOptional<z.ZodString>;
|
|
84
|
-
loading: z.ZodOptional<z.ZodString>;
|
|
85
|
-
}, z.core.$strip>>;
|
|
86
|
-
dark: z.ZodOptional<z.ZodObject<{
|
|
87
|
-
payBackground: z.ZodOptional<z.ZodString>;
|
|
88
|
-
processing: z.ZodOptional<z.ZodString>;
|
|
89
|
-
loading: z.ZodOptional<z.ZodString>;
|
|
90
|
-
}, z.core.$strip>>;
|
|
91
|
-
}, z.core.$strict>>;
|
|
92
|
-
}, z.core.$strip>;
|
|
93
|
-
/**
|
|
94
|
-
* The complete host-controlled theme state for one hosted session. `theme: null` means
|
|
95
|
-
* host-controlled stock Yodl, which is distinct from "no host authority at all" — the
|
|
96
|
-
* latter is expressed by not sending an envelope. Versioned so the protocol can change
|
|
97
|
-
* without silently misinterpreting older payloads.
|
|
98
|
-
*/
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/theme/contract.d.ts
|
|
101
|
-
type YodlThemeMode = output<typeof yodlThemeModeSchema>;
|
|
102
|
-
type YodlTheme = output<typeof yodlThemeSchema>;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/types.d.ts
|
|
105
|
-
/** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
|
|
106
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
107
|
-
[key: string]: JsonValue;
|
|
108
|
-
};
|
|
3
|
+
//#region ../sdk-core/dist/messages-BnJRdNU0.d.mts
|
|
4
|
+
/** submitted: on-chain, not yet indexed by Yodl. processing: indexed, not settled (incl. a failure whose refund is in flight). */
|
|
5
|
+
type PaymentStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
109
6
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
7
|
+
* Where a payment payload's figures came from. `optimistic` means Yodl's backend
|
|
8
|
+
* has not indexed the transaction yet, so every figure is the paying device's
|
|
9
|
+
* own pre-submit data. Independent of `status`: a payload can be `indexed` while
|
|
10
|
+
* the payment is still processing.
|
|
112
11
|
*/
|
|
113
|
-
|
|
114
|
-
request: (args: {
|
|
115
|
-
method: string;
|
|
116
|
-
params?: JsonValue[] | object;
|
|
117
|
-
}) => Promise<JsonValue>;
|
|
118
|
-
}
|
|
119
|
-
type SupportedChainIds = number[];
|
|
120
|
-
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
12
|
+
type YodlPaymentDetailsSource = 'optimistic' | 'indexed';
|
|
121
13
|
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
122
14
|
/** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
|
|
123
15
|
type YodlNavigateOnSubmit = 'always' | 'never';
|
|
16
|
+
/**
|
|
17
|
+
* Nullability here follows what the hosted page actually emits, not what is
|
|
18
|
+
* convenient to consume: it forwards a receipt's own `null`s rather than
|
|
19
|
+
* normalising them, so a host that assumes `string` will crash on a real
|
|
20
|
+
* payment. Narrow at the call site.
|
|
21
|
+
*/
|
|
124
22
|
interface YodlPaymentDetails {
|
|
125
|
-
status:
|
|
23
|
+
status: PaymentStatus;
|
|
24
|
+
/** Optional: hosted builds older than the one that introduced it omit it. */
|
|
25
|
+
source?: YodlPaymentDetailsSource;
|
|
126
26
|
transaction: {
|
|
127
27
|
hash: string;
|
|
128
28
|
chainId?: string | number;
|
|
@@ -135,7 +35,7 @@ interface YodlPaymentDetails {
|
|
|
135
35
|
recipient?: {
|
|
136
36
|
type?: string;
|
|
137
37
|
title?: string;
|
|
138
|
-
subtitle?: string;
|
|
38
|
+
subtitle?: string | null;
|
|
139
39
|
iconUrl?: string | null;
|
|
140
40
|
};
|
|
141
41
|
invoice?: {
|
|
@@ -145,7 +45,7 @@ interface YodlPaymentDetails {
|
|
|
145
45
|
settlementCurrency?: string;
|
|
146
46
|
} | null;
|
|
147
47
|
token?: {
|
|
148
|
-
symbol?: string;
|
|
48
|
+
symbol?: string | null;
|
|
149
49
|
amountGross?: string;
|
|
150
50
|
amountNet?: string;
|
|
151
51
|
};
|
|
@@ -154,7 +54,7 @@ interface YodlPaymentDetails {
|
|
|
154
54
|
};
|
|
155
55
|
recovery?: {
|
|
156
56
|
refundTxHash?: string | null;
|
|
157
|
-
status?:
|
|
57
|
+
status?: string;
|
|
158
58
|
} | null;
|
|
159
59
|
rewards?: {
|
|
160
60
|
points?: number;
|
|
@@ -162,8 +62,104 @@ interface YodlPaymentDetails {
|
|
|
162
62
|
streakMultiplier?: string;
|
|
163
63
|
berserMultiplier?: number;
|
|
164
64
|
};
|
|
165
|
-
raw?:
|
|
65
|
+
raw?: unknown;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../sdk-core/dist/index-CmnifaLY.d.mts
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/evm/wallet-provider.d.ts
|
|
71
|
+
/**
|
|
72
|
+
* An EIP-1193 provider, declared structurally so anything shaped like one
|
|
73
|
+
* satisfies it — a browser wallet, a host-injected WebView provider, or a
|
|
74
|
+
* decorator such as `withYodl7702`.
|
|
75
|
+
*
|
|
76
|
+
* Deliberately *not* viem's `EIP1193Provider`, which is
|
|
77
|
+
* `EIP1193Events & { request: EIP1193RequestFn<EIP1474Methods> }` and so makes
|
|
78
|
+
* `on`/`removeListener` mandatory. Two providers this package has to accept
|
|
79
|
+
* cannot promise them: `withYodl7702` re-exposes them only when the provider it
|
|
80
|
+
* wraps has them, and a host bridge injected into a WebView frequently
|
|
81
|
+
* implements `request` alone. Nothing here subscribes to provider events — the
|
|
82
|
+
* chain switch polls `eth_chainId` instead — so requiring them would be asking
|
|
83
|
+
* for a capability this package never uses. viem's `custom()` types its own
|
|
84
|
+
* argument just as loosely, so no cast is needed on the way in either.
|
|
85
|
+
*
|
|
86
|
+
* `request` is declared as a method rather than a property on purpose: method
|
|
87
|
+
* bivariance is what lets a provider typed `params?: JsonValue[] | object`
|
|
88
|
+
* satisfy this without a cast.
|
|
89
|
+
*/
|
|
90
|
+
interface EIP1193Provider {
|
|
91
|
+
request(args: {
|
|
92
|
+
method: string;
|
|
93
|
+
params?: readonly unknown[] | object;
|
|
94
|
+
}): Promise<unknown>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../sdk-core/dist/host-COukZkft.d.mts
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/theme/contract.d.ts
|
|
100
|
+
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
101
|
+
type YodlThemeMode = 'system' | 'light' | 'dark';
|
|
102
|
+
/**
|
|
103
|
+
* One per-mode palette. Every key is optional — missing keys fall back to the
|
|
104
|
+
* stock Yodl palette, and the fine-tune keys are derived from their core keys
|
|
105
|
+
* downstream. Colors are hex, `rgb()` or `rgba()`.
|
|
106
|
+
*/
|
|
107
|
+
interface YodlThemeModeTokens {
|
|
108
|
+
bg?: string | undefined;
|
|
109
|
+
surface?: string | undefined;
|
|
110
|
+
surfaceSecondary?: string | undefined;
|
|
111
|
+
text?: string | undefined;
|
|
112
|
+
textSecondary?: string | undefined;
|
|
113
|
+
textMuted?: string | undefined;
|
|
114
|
+
border?: string | undefined;
|
|
115
|
+
success?: string | undefined;
|
|
116
|
+
error?: string | undefined;
|
|
117
|
+
warning?: string | undefined;
|
|
118
|
+
accent?: string | undefined;
|
|
119
|
+
bgDeep?: string | undefined;
|
|
120
|
+
surfaceHover?: string | undefined;
|
|
121
|
+
skeleton?: string | undefined;
|
|
122
|
+
accentStrong?: string | undefined;
|
|
123
|
+
accentDeep?: string | undefined;
|
|
124
|
+
brandSurface?: string | undefined;
|
|
125
|
+
brandSheet?: string | undefined;
|
|
126
|
+
brandText?: string | undefined;
|
|
127
|
+
brandButton?: string | undefined;
|
|
128
|
+
brandButtonText?: string | undefined;
|
|
129
|
+
}
|
|
130
|
+
/** The faces the hosted UI ships; see `THEME_FONT_VALUES` for why it is closed. */
|
|
131
|
+
type YodlThemeFont = 'system' | 'inter' | 'geist' | 'mono';
|
|
132
|
+
/** The three media slots the hosted UI can theme, for a single mode. https URLs only. */
|
|
133
|
+
interface YodlThemeImages {
|
|
134
|
+
/** Full-bleed backdrop behind the payment (amount entry) screen. */
|
|
135
|
+
payBackground?: string | undefined;
|
|
136
|
+
/** Alias for `loading` (used when it is unset). */
|
|
137
|
+
processing?: string | undefined;
|
|
138
|
+
/** Full-screen splash on the in-app loading screens; video or any `<img>` format. */
|
|
139
|
+
loading?: string | undefined;
|
|
166
140
|
}
|
|
141
|
+
/** Media is per mode. */
|
|
142
|
+
interface YodlThemeImageSets {
|
|
143
|
+
light?: YodlThemeImages | undefined;
|
|
144
|
+
dark?: YodlThemeImages | undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* One customizable Yodl theme: a light/dark palette pair plus optional media.
|
|
148
|
+
* `font` and the radii sit at the top level because none of them is a color
|
|
149
|
+
* and none varies by mode. `radiusSurface` defaults to `radiusControl`.
|
|
150
|
+
*/
|
|
151
|
+
interface YodlTheme {
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
font?: YodlThemeFont | undefined;
|
|
154
|
+
radiusControl?: string | undefined;
|
|
155
|
+
radiusSurface?: string | undefined;
|
|
156
|
+
light?: YodlThemeModeTokens | undefined;
|
|
157
|
+
dark?: YodlThemeModeTokens | undefined;
|
|
158
|
+
images?: YodlThemeImageSets | undefined;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/types.d.ts
|
|
162
|
+
type SupportedChainIds = number[];
|
|
167
163
|
/** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
|
|
168
164
|
interface YodlWallet {
|
|
169
165
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
@@ -262,18 +258,7 @@ type YodlDashboardProps = YodlComponentProps;
|
|
|
262
258
|
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
263
259
|
* The Yodl UI is origin-locked to that host.
|
|
264
260
|
*/
|
|
265
|
-
declare function YodlDashboard({
|
|
266
|
-
onTransactionSent,
|
|
267
|
-
onPaymentDetails,
|
|
268
|
-
onError,
|
|
269
|
-
fetchEmailAttestation,
|
|
270
|
-
renderLoading,
|
|
271
|
-
onReady,
|
|
272
|
-
style,
|
|
273
|
-
backgroundColor,
|
|
274
|
-
theme,
|
|
275
|
-
themeMode
|
|
276
|
-
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
261
|
+
declare function YodlDashboard({ onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlDashboardProps): import("react").JSX.Element;
|
|
277
262
|
//#endregion
|
|
278
263
|
//#region src/components/YodlPayment.d.ts
|
|
279
264
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
@@ -292,20 +277,7 @@ interface YodlPaymentProps extends YodlComponentProps {
|
|
|
292
277
|
* (e.g. the `/resolve` screen on the configured host). The Yodl UI is
|
|
293
278
|
* origin-locked to that host. Renders nothing for empty/unsupported QR data.
|
|
294
279
|
*/
|
|
295
|
-
declare function YodlPayment({
|
|
296
|
-
qrData,
|
|
297
|
-
navigateOnSubmit,
|
|
298
|
-
onTransactionSent,
|
|
299
|
-
onPaymentDetails,
|
|
300
|
-
onError,
|
|
301
|
-
fetchEmailAttestation,
|
|
302
|
-
renderLoading,
|
|
303
|
-
onReady,
|
|
304
|
-
style,
|
|
305
|
-
backgroundColor,
|
|
306
|
-
theme,
|
|
307
|
-
themeMode
|
|
308
|
-
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
280
|
+
declare function YodlPayment({ qrData, navigateOnSubmit, onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlPaymentProps): import("react").JSX.Element | null;
|
|
309
281
|
//#endregion
|
|
310
282
|
//#region src/components/YodlSignup.d.ts
|
|
311
283
|
interface YodlSignupProps extends YodlVisualProps {
|
|
@@ -329,30 +301,18 @@ interface YodlSignupProps extends YodlVisualProps {
|
|
|
329
301
|
* verification code entry, and the final signed-up screen, while callbacks let
|
|
330
302
|
* the native app observe status and completion.
|
|
331
303
|
*/
|
|
332
|
-
declare function YodlSignup({
|
|
333
|
-
onStatusChange,
|
|
334
|
-
onSignedUp,
|
|
335
|
-
onError,
|
|
336
|
-
onDismiss,
|
|
337
|
-
fetchEmailAttestation,
|
|
338
|
-
renderLoading,
|
|
339
|
-
onReady,
|
|
340
|
-
style,
|
|
341
|
-
backgroundColor,
|
|
342
|
-
theme,
|
|
343
|
-
themeMode
|
|
344
|
-
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
304
|
+
declare function YodlSignup({ onStatusChange, onSignedUp, onError, onDismiss, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlSignupProps): import("react").JSX.Element;
|
|
345
305
|
//#endregion
|
|
346
306
|
//#region src/sdk/yodl.d.ts
|
|
347
307
|
/**
|
|
348
308
|
* App-host configuration for the Yodl React Native SDK.
|
|
349
|
-
* Injected once via {@link
|
|
309
|
+
* Injected once via {@link createYodlSdk}.
|
|
350
310
|
*
|
|
351
311
|
* No RPC endpoint is needed: the embedded Yodl UI reads chain state through its
|
|
352
312
|
* own provider, and the injected wallet bridge only forwards signing/wallet
|
|
353
313
|
* methods to the host wallet.
|
|
354
314
|
*/
|
|
355
|
-
interface
|
|
315
|
+
interface YodlSdkConfig {
|
|
356
316
|
/** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
|
|
357
317
|
integrationAddress: `0x${string}`;
|
|
358
318
|
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
@@ -361,7 +321,7 @@ interface YodlConfig {
|
|
|
361
321
|
supportedChainIds: SupportedChainIds;
|
|
362
322
|
}
|
|
363
323
|
/** Config with defaults applied — what components read from the instance. */
|
|
364
|
-
type
|
|
324
|
+
type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
|
|
365
325
|
yodlUiBaseUrl: string;
|
|
366
326
|
};
|
|
367
327
|
/**
|
|
@@ -369,20 +329,20 @@ type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
|
|
|
369
329
|
* and the components read at runtime. Stateless QR helpers are exported as
|
|
370
330
|
* standalone functions (e.g. {@link isPaymentQr}) rather than instance methods.
|
|
371
331
|
*/
|
|
372
|
-
declare class
|
|
373
|
-
readonly config:
|
|
374
|
-
constructor(config:
|
|
332
|
+
declare class YodlSdk {
|
|
333
|
+
readonly config: ResolvedYodlSdkConfig;
|
|
334
|
+
constructor(config: YodlSdkConfig);
|
|
375
335
|
}
|
|
376
336
|
/**
|
|
377
337
|
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
378
|
-
* `@yodlpay/sdk-core`'s `
|
|
338
|
+
* `@yodlpay/sdk-core`'s `createYodlClient` / config-once convention.
|
|
379
339
|
*/
|
|
380
|
-
declare function
|
|
340
|
+
declare function createYodlSdk(config: YodlSdkConfig): YodlSdk;
|
|
381
341
|
//#endregion
|
|
382
342
|
//#region src/provider/context.d.ts
|
|
383
343
|
interface YodlProviderProps extends YodlHostThemeProps {
|
|
384
|
-
/** The SDK instance created via
|
|
385
|
-
sdk:
|
|
344
|
+
/** The SDK instance created via createYodlSdk(). */
|
|
345
|
+
sdk: YodlSdk;
|
|
386
346
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
387
347
|
provider: YodlWallet['provider'];
|
|
388
348
|
/** Connected wallet address. */
|
|
@@ -395,15 +355,7 @@ interface YodlProviderProps extends YodlHostThemeProps {
|
|
|
395
355
|
* Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
|
|
396
356
|
* the optional host theme state to the Yodl components via React context.
|
|
397
357
|
*/
|
|
398
|
-
declare function YodlProvider({
|
|
399
|
-
sdk,
|
|
400
|
-
provider,
|
|
401
|
-
address,
|
|
402
|
-
chainId,
|
|
403
|
-
theme,
|
|
404
|
-
themeMode,
|
|
405
|
-
children
|
|
406
|
-
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
358
|
+
declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMode, children }: YodlProviderProps): import("react").JSX.Element;
|
|
407
359
|
//#endregion
|
|
408
360
|
//#region src/sdk/qr.d.ts
|
|
409
361
|
/**
|
|
@@ -417,4 +369,4 @@ declare function YodlProvider({
|
|
|
417
369
|
*/
|
|
418
370
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
419
371
|
//#endregion
|
|
420
|
-
export { type EIP1193Provider, type
|
|
372
|
+
export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";const h=/^0x[0-9a-fA-F]{40}$/,g=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,_=/^https:\/\/[^\s"\\]+$/,v=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,y=new Set([`system`,`inter`,`geist`,`mono`]),b=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],x=[`payBackground`,`processing`,`loading`];function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ee(e,t){if(!S(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of b){let i=e[r];if(i!==void 0){if(typeof i!=`string`||!g.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function C(e,t){if(!S(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of x){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!_.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function w(e){if(!S(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=C(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function T(e){if(!S(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}if(e.font!==void 0){if(typeof e.font!=`string`||!y.has(e.font))return{success:!1,error:`font: must be one of ${[...y].join(`, `)}`};t.font=e.font}for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!v.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=ee(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=w(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function E(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function D(e,t){return typeof e==`string`&&t.test(e)}function O(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function k(e){if(!S(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!E(r,128))}const A=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function j(e){if(!S(e)||!O(e,A))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!E(r,128)||!E(i,64)||!D(a,h))}const M={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function N(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function P(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:T(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:N(a,n)},error:o.length>0?o.join(`; `):null}}function F(e,t){let n=M[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function te(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function I(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function ne(e,t){return JSON.stringify(I(e,t))}function L(e,t,n,r){let{envelope:i,error:a}=P(e,t,n);return a&&r?.(a),i}function re(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=P(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function R(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const z=e(null);function ie({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>L(i,o,c,R),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(z.Provider,{value:u,children:s})}function ae(){let e=n(z);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function B(e,t){let n=ae(),r=a(()=>re(n.hostTheme,e,t,n.systemScheme,R),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function V(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function H(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function U(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function W(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function oe(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function se(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ce(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const le=/^0x[a-fA-F0-9]{40}$/;function ue(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!le.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function de(e){return{"X-Yodl-Integration-Id":ue(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.8.2`}}function fe(e,t){let n=e.yodlUiBaseUrl?se(e.yodlUiBaseUrl):null;if(!(!n||!ce(t,n)))return de(e)}let pe=0;function me(){return pe+=1,`yodl-${Date.now().toString(36)}-${pe.toString(36)}`}function he(e,t=me){return{sessionId:t(),initialHostTheme:e}}function ge(e,t){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}})}function _e(e,t,n){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n})}function G(e){return`0x${e.toString(16)}`}function ve(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function ye(e,t){let n=K(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:G(t.chainId)}}:{}}}function be(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function xe(e){return{state:e,decision:{kind:`ignore`}}}function Se(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ce(e,t,n){return!j(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?xe(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Se(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Se(e,t.requestId,`address_mismatch`):Se(e,t.requestId,`not_supported`)}function we(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Te=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Ee(e){return Te.some(t=>t===e)}function De(e,t,n){if(!Ee(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=W((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Oe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>W(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function Me(e){let t=G(e.chainId);return`(function() {
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";const h=/^0x[a-fA-F0-9]{40}$/;function g(e){return typeof e==`string`&&h.test(e)}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const v=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function y(e){if(e===void 0)return!0;if(!_(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function b(e){if(!_(e))return!1;switch(e.type){case`yodl_payment_details`:return _(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return y(e.error);case`yodl_signup_status`:return typeof e.status==`string`&&v.has(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params);default:return!1}}const x=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,S=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,C=/^https:\/\/[^\s"\\]+$/,ee=[`system`,`inter`,`geist`,`mono`],w=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],T=[`payBackground`,`processing`,`loading`];function E(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function D(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function te(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const O=new Set([`system`,`light`,`dark`]);function k(e){return typeof e==`string`&&O.has(e)}const A=new Set(ee);function j(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of w){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!x.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function M(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of T){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!C.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function N(e){if(!_(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=M(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function P(e){if(!_(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}if(e.font!==void 0){if(typeof e.font!=`string`||!A.has(e.font))return{success:!1,error:`font: must be one of ${[...A].join(`, `)}`};t.font=e.font}for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!S.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=j(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=N(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function F(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function I(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function L(e){if(!_(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!F(r,128))}const R=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function z(e){if(!_(e)||!I(e,R))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!F(r,128)||!F(i,64)||!g(a))}const B={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function ne(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function re(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:P(e),i=t===void 0||k(t),a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:ne(a,n)},error:o.length>0?o.join(`; `):null}}function ie(e,t){let n=B[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function ae(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function V(e,t){return JSON.stringify(E(e,t))}function oe(e,t,n,r){let{envelope:i,error:a}=re(e,t,n);return a&&r?.(a),i}function se(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=re(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function H(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ce=e(null);function le({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>oe(i,o,c,H),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(ce.Provider,{value:u,children:s})}function ue(){let e=n(ce);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function de(e,t){let n=ue(),r=a(()=>se(n.hostTheme,e,t,n.systemScheme,H),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function fe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!g(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function pe(e,t){return{"X-Yodl-Integration-Id":fe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function U(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function me(e){return e.code===4001||/rejected|denied/i.test(e.message)}const he=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ge=[...he,`not supported`,`not available`];function _e(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ve(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||_e(e,he):_e(e,ge)}function ye(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function be(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const xe={name:`@yodlpay/react-native`,version:`0.10.0`};function Se(e){return pe(e,xe)}function Ce(e,t){let n=e.yodlUiBaseUrl?ye(e.yodlUiBaseUrl):null;if(!(!n||!be(t,n)))return Se(e)}let we=0;function Te(){return we+=1,`yodl-${Date.now().toString(36)}-${we.toString(36)}`}function Ee(e,t=Te){return{sessionId:t(),initialHostTheme:e}}function W(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function De(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function Oe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>De(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function G(e){return`0x${e.toString(16)}`}function Me(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function Ne(e,t){let n=K(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:G(t.chainId)}}:{}}}function Pe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Fe(e){return{state:e,decision:{kind:`ignore`}}}function Ie(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Le(e,t,n){return!z(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Fe(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ie(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Ie(e,t.requestId,`address_mismatch`):Ie(e,t.requestId,`not_supported`)}function Re(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const ze=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Be(e){return ze.some(t=>t===e)}function Ve(e,t,n){if(!Be(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=De((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function He(e){let t=G(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,4 @@ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLay
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function Ne(e){return JSON.stringify(e)}function Pe(e){return{state:e,message:null,readyAccepted:!1}}function Fe(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:ne(e.sessionId,e.currentTheme),readyAccepted:t}}function Ie(e,t){let n=Ne(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Le(e,t){let n=Ne(t);if(n===e.currentFingerprint)return Pe(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Fe(r,!1):Pe(r)}function Re(e,t){return!k(t)||t.sessionId!==e.sessionId?Pe(e):Fe({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function ze(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Be(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null,fetchEmailAttestation:b}=e,x=o(null),S=o(K(s)),ee=o(c),C=o(c),w=o(new Set),T=o(v),E=o(_?Ie(_,y):null),D=o(_?be(_):null),O=o(b);i(()=>{T.current=v},[v]),i(()=>{O.current=b},[b]),i(()=>{E.current=_?Ie(_,y):null},[y,_]),i(()=>{D.current=_?be(_):null},[_]);let k=t(e=>{w.current.has(e)||(w.current.add(e),u?.(e))},[u]);r(()=>{let e=ye({address:S.current,propChainId:ee.current,activeChainId:C.current},{address:s,chainId:c});e&&(S.current=e.nextAddress,ee.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&ze(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&ze(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!E.current)return;let e=Le(E.current,v);E.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let A=a(()=>Me({address:s,chainId:c}),[s,c]),j=t(async(e,t,r)=>{try{let i=De(t,r,l);if(`error`in i){q(x,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(x,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,ze(x,`chainChanged`,i.chainIdHex))}catch(t){let n=H(t,`Chain request failed`);q(x,e,void 0,U(n)),h?.(n)}},[n,l,h]),M=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>G(e))];q(x,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=H(n,`Capabilities unavailable`);if(!oe(r)){q(x,e,void 0,U(r));return}q(x,e,ve(Oe(t,l),`unsupported`))}},[n,s,l]),N=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&k(i),q(x,e,r)}catch(t){q(x,e,void 0,U(H(t,`Failed to get call status`)))}},[n,k]),P=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&k(i),q(x,e,i)}catch(t){let n=H(t,`Request failed`),r=V(n);q(x,e,void 0,r?{code:4001,message:n.message}:U(n)),r||h?.(n)}},[n,k,h]),F=t((e,t)=>{let n=D.current;n&&(D.current=we(n,e),x.current?.postMessage(_e(n.sessionId,e,t)))},[]),te=t(async(e,t)=>{let n=O.current;if(!n){F(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}D.current?.sessionId===e&&F(t.requestId,a)},[F]),I=t(e=>{let t=D.current;if(!t)return;let n=Ce(t,e,{walletAddress:S.current,supported:!!O.current});if(D.current=n.state,n.decision.kind===`reject`){F(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&te(t.sessionId,n.decision.request)},[te,F]);return{uiRef:x,injectedJavaScript:A,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!E.current){g?.();return}let e=Le(E.current,T.current);E.current=e.state,e.message&&x.current?.postMessage(e.message);let n=Re(E.current,t);if(E.current=n.state,!n.readyAccepted)return;n.message&&x.current?.postMessage(n.message);let r=D.current;r&&x.current?.postMessage(ge(r.sessionId,!!O.current)),g?.();return}if(t.type===`yodl_email_attestation_request`){I(t);return}if(t.type===`yodl_payment_details`){d?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;Ee(r)?j(n,r,i):r===`wallet_getCapabilities`?M(n,i):r===`wallet_getCallsStatus`?N(n,i):P(n,r,i)},[j,M,N,P,I,d,f,p,m,h,g])}}function Ve(e){return f(He,{...e},e.uri)}function He({uri:e,sdkConfig:n,provider:l,address:d,chainId:h,supportedChainIds:g,onTransactionSent:_,onPaymentDetails:v,onSignupStatusChange:y,onSignedUp:b,onSignupDismissed:x,onError:S,style:ee,backgroundColor:C,hostTheme:w=null,fetchEmailAttestation:T,renderLoading:E,onReady:D,sharedCookiesEnabled:O=!0,thirdPartyCookiesEnabled:k=!0,onLoadStart:A,...j}){let[M]=s(()=>he(w)),N=F(w,C),P=N.background,[I,ne]=s(null),L=I===M.sessionId,re=o(D);i(()=>{re.current=D},[D]);let R=o(!1),z=t(()=>{ne(M.sessionId),!R.current&&(R.current=!0,re.current?.())},[M.sessionId]);r(()=>{if(L)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,L]);let{uiRef:ie,injectedJavaScript:ae,onMessage:B}=Be({provider:l,address:d,chainId:h,supportedChainIds:g,onReady:z,sessionId:M.sessionId,hostTheme:w,initialHostTheme:M.initialHostTheme,..._!==void 0&&{onTransactionSent:_},...v!==void 0&&{onPaymentDetails:v},...y!==void 0&&{onSignupStatusChange:y},...b!==void 0&&{onSignedUp:b},...x!==void 0&&{onSignupDismissed:x},...S!==void 0&&{onError:S},...T!==void 0&&{fetchEmailAttestation:T}}),V=a(()=>se(e),[e]),H=a(()=>{let t=fe(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),U=a(()=>e=>!V||!e?.url?!1:ce(e.url,V)||e.url.startsWith(`about:`),[V]),W=L?null:E?E():f(c,{color:N.spinner});return p(u,{style:[Ue.container,{backgroundColor:P},ee],children:[f(m,{ref:ie,source:H,originWhitelist:V?[V]:[],onShouldStartLoadWithRequest:U,javaScriptEnabled:!0,sharedCookiesEnabled:O,thirdPartyCookiesEnabled:k,injectedJavaScriptBeforeContentLoaded:ae,injectedJavaScriptObject:te(M.sessionId,M.initialHostTheme,n.integrationAddress),onMessage:B,...A!==void 0&&{onLoadStart:A},style:[Ue.ui,{backgroundColor:P}],...j}),W&&f(u,{style:[Ue.overlay,{backgroundColor:P}],children:W})]})}const Ue=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function We({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=B(l,u);return f(Ve,{uri:a(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]),sdkConfig:g.config,provider:d,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{fetchEmailAttestation:r},...i!==void 0&&{renderLoading:i},...o!==void 0&&{onReady:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function Ge(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ke(e){if(Array.isArray(e))return e}function qe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Je(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ye(e,t,n){return t&&Je(e.prototype,t),n&&Je(e,n),e}function Xe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Ze(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qe(e,t){return Ke(e)||Xe(e,t)||et(e,t)||Ze()}function $e(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function et(e,t){if(e){if(typeof e==`string`)return Ge(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ge(e,t)}}var tt=Object.defineProperty,nt=function(e,t,n){return t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},rt=function(e,t){for(var n in t)tt(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return nt(e,(t===void 0?`undefined`:$e(t))===`symbol`?t:t+``,n)},it=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function at(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=it[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function ot(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function Y(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=Y(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function st(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=at(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=st(e,n),e}function ct(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Z(e,t){return{id:e,length:t.length,value:t}}function lt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var ut=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;qe(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return Ye(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return lt({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=Qe(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function dt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}rt({},{ProxyType:function(){return Q},anyId:function(){return dt},billPayment:function(){return lt},botBarcode:function(){return ft},slipVerify:function(){return pt},trueMoney:function(){return ht},trueMoneySlipVerify:function(){return gt}});function ft(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ut(t,n,r,i).toString()}function pt(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function mt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function ht(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,mt(r))),X(Y(a),`63`)}function gt(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function _t(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function vt(e){if(Array.isArray(e))return e}function yt(e){if(Array.isArray(e))return _t(e)}function bt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function xt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function St(e,t,n){return t&&xt(e.prototype,t),n&&xt(e,n),e}function Ct(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Tt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Et(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ct(e,t,n[t])})}return e}function kt(e,t){return vt(e)||Tt(e,t)||jt(e,t)||Et()}function At(e){return yt(e)||wt(e)||jt(e)||Dt()}function jt(e,t){if(e){if(typeof e==`string`)return _t(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _t(e,t)}}rt({},{anyId:function(){return Pt},bcelOneProof:function(){return Nt},billPayment:function(){return Ft},slipVerify:function(){return It},trueMoneySlipVerify:function(){return Lt}});var Mt=function(){function e(t,n){bt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return St(e,[{key:`getTag`,value:function(e,t){return ct(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=X(Y(At(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=st(e.slice(0,-4)))return null;var r=ot(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=ot(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Mt(e,r)}function Nt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Pt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Q).find(function(e){var n=kt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=kt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Ot({type:o,target:c},u!==void 0&&{amount:u})}function Ft(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Ot({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function It(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Lt(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Rt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function zt(e){return e?e.getTagValue(`58`)??null:null}function Bt(e){let t=[];for(let[n,r]of Object.entries(Rt))r.includes(e)&&t.push(n);return t}function Vt(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=zt($(r));if(e){let n=Bt(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Ht(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function Ut(e){return Ht(e,`/sdk/signup`)}const Wt=`always`;function Gt(e,t,n=Wt){return!e||typeof e!=`string`||e.trim().length===0||!Vt(e).find(e=>e.action===`resolve`)?null:Ht(t,`/resolve`,{data:e,navigateOnSubmit:n===Wt?void 0:n})}function Kt({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=B(d,p),b=a(()=>Gt(e,v.config.yodlUiBaseUrl,t),[e,v.config.yodlUiBaseUrl,t]);return b?f(Ve,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{renderLoading:s},...c!==void 0&&{onReady:c},...l!==void 0&&{style:l},...u!==void 0&&{backgroundColor:u}}):null}function qt({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=B(u,d);return f(Ve,{uri:a(()=>Ut(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]),sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{fetchEmailAttestation:i},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function Jt(e){return(Array.isArray(e)?e:[e]).some(e=>Vt(e).some(e=>e.action===`resolve`))}var Yt=class{config;constructor(e){let t=ue(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Xt(e){return new Yt(e)}export{Yt as Yodl,We as YodlDashboard,Kt as YodlPayment,ie as YodlProvider,qt as YodlSignup,Xt as createSdk,Jt as isPaymentQr};
|
|
228
|
+
true;`}function Ue(e){return JSON.stringify(e)}function We(e){return{state:e,message:null,readyAccepted:!1}}function Ge(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:V(e.sessionId,e.currentTheme),readyAccepted:t}}function Ke(e,t){let n=Ue(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function qe(e,t){let n=Ue(t);if(n===e.currentFingerprint)return We(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Ge(r,!1):We(r)}function Je(e,t){return!L(t)||t.sessionId!==e.sessionId?We(e):Ge({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function Ye(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Xe(e){return _(e)&&`type`in e}function Ze(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Qe(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null,fetchEmailAttestation:x}=e,S=o(null),C=o(K(s)),ee=o(c),w=o(c),T=o(new Set),E=o(v),O=o(_?Ke(_,y):null),k=o(_?Pe(_):null),A=o(x);i(()=>{E.current=v},[v]),i(()=>{A.current=x},[x]),i(()=>{O.current=_?Ke(_,y):null},[y,_]),i(()=>{k.current=_?Pe(_):null},[_]);let j=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=Ne({address:C.current,propChainId:ee.current,activeChainId:w.current},{address:s,chainId:c});e&&(C.current=e.nextAddress,ee.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&Ye(S,`accountsChanged`,e.accountsChanged),e.chainChanged&&Ye(S,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!O.current)return;let e=qe(O.current,v);O.current=e.state,e.message&&S.current?.postMessage(e.message)},[v]);let M=a(()=>He({address:s,chainId:c}),[s,c]),N=t(async(e,t,r)=>{try{let i=Ve(t,r,l);if(`error`in i){q(S,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(S,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,Ye(S,`chainChanged`,i.chainIdHex))}catch(t){let n=U(t,`Chain request failed`);q(S,e,void 0,W(n)),h?.(n)}},[n,l,h]),P=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>G(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});q(S,e,i)}catch(n){let r=U(n,`Capabilities unavailable`);if(!ve(r)){q(S,e,void 0,W(r));return}q(S,e,Me(Oe(t,l),`unsupported`))}},[n,s,l]),F=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&j(i),q(S,e,r)}catch(t){let n=U(t,`Failed to get call status`);q(S,e,void 0,W(n))}},[n,j]),I=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&j(i),q(S,e,i)}catch(t){let n=U(t,`Request failed`),r=me(n);q(S,e,void 0,r?{code:4001,message:n.message}:W(n)),r||h?.(n)}},[n,j,h]),L=t((e,t)=>{let n=k.current;n&&(k.current=Re(n,e),S.current?.postMessage(JSON.stringify(te(n.sessionId,e,t))))},[]),R=t(async(e,t)=>{let n=A.current;if(!n){L(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}k.current?.sessionId===e&&L(t.requestId,a)},[L]),z=t(e=>{let t=k.current;if(!t)return;let n=Le(t,e,{walletAddress:C.current,supported:!!A.current});if(k.current=n.state,n.decision.kind===`reject`){L(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&R(t.sessionId,n.decision.request)},[R,L]),B=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(Ze(e.error,`Payment details error`));return;case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(Ze(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return;case`ethereum_rpc_request`:{let{id:t,method:n,params:r}=e;Be(n)?N(t,n,r):n===`wallet_getCapabilities`?P(t,r):n===`wallet_getCallsStatus`?F(t,r):I(t,n,r);return}}},[N,P,F,I,d,f,p,m,h]);return{uiRef:S,injectedJavaScript:M,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Xe(t)){if(t.type===`yodl_ready`){if(!O.current){g?.();return}let e=qe(O.current,E.current);O.current=e.state,e.message&&S.current?.postMessage(e.message);let n=Je(O.current,t);if(O.current=n.state,!n.readyAccepted)return;n.message&&S.current?.postMessage(n.message);let r=k.current;r&&S.current?.postMessage(JSON.stringify(D(r.sessionId,!!A.current))),g?.();return}if(t.type===`yodl_email_attestation_request`){z(t);return}b(t)&&B(t)}},[B,z,g])}}function $e(e){return f(et,{...e},e.uri)}function et({uri:e,sdkConfig:n,provider:l,address:d,chainId:h,supportedChainIds:g,onTransactionSent:_,onPaymentDetails:v,onSignupStatusChange:y,onSignedUp:b,onSignupDismissed:x,onError:S,style:C,backgroundColor:ee,hostTheme:w=null,fetchEmailAttestation:T,renderLoading:E,onReady:D,sharedCookiesEnabled:te=!0,thirdPartyCookiesEnabled:O=!0,onLoadStart:k,...A}){let[j]=s(()=>Ee(w)),M=ie(w,ee),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(D);i(()=>{L.current=D},[D]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:B,injectedJavaScript:ne,onMessage:re}=Qe({provider:l,address:d,chainId:h,supportedChainIds:g,onReady:z,sessionId:j.sessionId,hostTheme:w,initialHostTheme:j.initialHostTheme,..._!==void 0&&{onTransactionSent:_},...v!==void 0&&{onPaymentDetails:v},...y!==void 0&&{onSignupStatusChange:y},...b!==void 0&&{onSignedUp:b},...x!==void 0&&{onSignupDismissed:x},...S!==void 0&&{onError:S},...T!==void 0&&{fetchEmailAttestation:T}}),V=a(()=>ye(e),[e]),oe=a(()=>{let t=Ce(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),se=a(()=>e=>!V||!e?.url?!1:be(e.url,V)||e.url.startsWith(`about:`),[V]),H=I?null:E?E():f(c,{color:M.spinner});return p(u,{style:[tt.container,{backgroundColor:N},C],children:[f(m,{ref:B,source:oe,originWhitelist:V?[V]:[],onShouldStartLoadWithRequest:se,javaScriptEnabled:!0,sharedCookiesEnabled:te,thirdPartyCookiesEnabled:O,injectedJavaScriptBeforeContentLoaded:ne,injectedJavaScriptObject:ae(j.sessionId,j.initialHostTheme,n.integrationAddress),onMessage:re,...k!==void 0&&{onLoadStart:k},style:[tt.ui,{backgroundColor:N}],...A}),H&&f(u,{style:[tt.overlay,{backgroundColor:N}],children:H})]})}const tt=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function nt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=de(l,u),v=a(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]);return f($e,{uri:v,sdkConfig:g.config,provider:d,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{fetchEmailAttestation:r},...i!==void 0&&{renderLoading:i},...o!==void 0&&{onReady:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function rt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function it(e){if(Array.isArray(e))return e}function at(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t,n){return t&&ot(e.prototype,t),n&&ot(e,n),e}function ct(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function lt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t){return it(e)||ct(e,t)||ft(e,t)||lt()}function dt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ft(e,t){if(e){if(typeof e==`string`)return rt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rt(e,t)}}var pt=Object.defineProperty,mt=function(e,t,n){return t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},ht=function(e,t){for(var n in t)pt(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return mt(e,(t===void 0?`undefined`:dt(t))===`symbol`?t:t+``,n)},gt=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function _t(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=gt[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function vt(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function Y(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=Y(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function yt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=_t(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=yt(e,n),e}function bt(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Z(e,t){return{id:e,length:t.length,value:t}}function xt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var St=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;at(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return st(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return xt({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=ut(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function Ct(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}ht({},{ProxyType:function(){return Q},anyId:function(){return Ct},billPayment:function(){return xt},botBarcode:function(){return wt},slipVerify:function(){return Tt},trueMoney:function(){return Dt},trueMoneySlipVerify:function(){return Ot}});function wt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new St(t,n,r,i).toString()}function Tt(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function Et(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Dt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,Et(r))),X(Y(a),`63`)}function Ot(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function kt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function At(e){if(Array.isArray(e))return e}function jt(e){if(Array.isArray(e))return kt(e)}function Mt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Nt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Pt(e,t,n){return t&&Nt(e.prototype,t),n&&Nt(e,n),e}function Ft(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Lt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Rt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ft(e,t,n[t])})}return e}function Vt(e,t){return At(e)||Lt(e,t)||Ut(e,t)||Rt()}function Ht(e){return jt(e)||It(e)||Ut(e)||zt()}function Ut(e,t){if(e){if(typeof e==`string`)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kt(e,t)}}ht({},{anyId:function(){return Kt},bcelOneProof:function(){return Gt},billPayment:function(){return qt},slipVerify:function(){return Jt},trueMoneySlipVerify:function(){return Yt}});var Wt=function(){function e(t,n){Mt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Pt(e,[{key:`getTag`,value:function(e,t){return bt(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=X(Y(Ht(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=yt(e.slice(0,-4)))return null;var r=vt(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=vt(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Wt(e,r)}function Gt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Kt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Q).find(function(e){var n=Vt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Vt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Bt({type:o,target:c},u!==void 0&&{amount:u})}function qt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Bt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Jt(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Yt(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Xt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Zt(e){return e?e.getTagValue(`58`)??null:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(Xt))r.includes(e)&&t.push(n);return t}function $t(e){return e.toLowerCase().startsWith(`upi://`)}function en(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim(),r=[];try{let e=Zt($(n));if(e){let n=Qt(e);for(let e of n)(!t||t.includes(e))&&r.push({provider:e,action:`resolve`});if(r.length>0)return r}}catch{}return $t(n)&&(!t||t.includes(`aeon`))?[{provider:`aeon`,action:`resolve`}]:r}function tn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function nn(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function rn(e){return nn(e,`/sdk/signup`)}const an=`always`;function on(e,t,n=an){return!e||typeof e!=`string`||e.trim().length===0||tn(en(e)).length===0?null:nn(t,`/resolve`,{data:e,navigateOnSubmit:n===an?void 0:n})}function sn({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=de(d,p),b=a(()=>on(e,v.config.yodlUiBaseUrl,t),[e,v.config.yodlUiBaseUrl,t]);return b?f($e,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{renderLoading:s},...c!==void 0&&{onReady:c},...l!==void 0&&{style:l},...u!==void 0&&{backgroundColor:u}}):null}function cn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=de(u,d),y=a(()=>rn(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]);return f($e,{uri:y,sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{fetchEmailAttestation:i},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function ln(e){return(Array.isArray(e)?e:[e]).some(e=>tn(en(e)).length>0)}var un=class{config;constructor(e){let t=fe(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function dn(e){return new un(e)}export{nt as YodlDashboard,sn as YodlPayment,le as YodlProvider,un as YodlSdk,cn as YodlSignup,dn as createYodlSdk,ln as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"react-native": {
|
|
30
|
-
"types": "./dist/index.d.
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
31
|
"default": "./dist/index.cjs"
|
|
32
32
|
},
|
|
33
33
|
"import": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"types": "./dist/index.d.cts",
|
|
39
39
|
"default": "./dist/index.cjs"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
42
43
|
},
|
|
43
44
|
"repository": {
|
|
44
45
|
"type": "git",
|
|
@@ -61,30 +62,28 @@
|
|
|
61
62
|
"THIRD_PARTY_NOTICES.txt"
|
|
62
63
|
],
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"react": "
|
|
65
|
+
"react": "^19.2.8",
|
|
65
66
|
"react-native": ">=0.72.0",
|
|
66
67
|
"react-native-webview": ">=13.0.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
70
|
-
"@types/
|
|
71
|
-
"
|
|
70
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
71
|
+
"@types/node": "^22.19.19",
|
|
72
|
+
"@types/react": "^19.2.18",
|
|
73
|
+
"publint": "^0.3.24",
|
|
72
74
|
"react": "^19.0.0",
|
|
73
|
-
"react-native": "^0.
|
|
74
|
-
"react-native-webview": "
|
|
75
|
-
"tsdown": "^0.22.
|
|
76
|
-
"typescript": "^5.
|
|
77
|
-
"vitest": "^4.1.
|
|
78
|
-
"@yodlpay/sdk-core": "0.
|
|
79
|
-
},
|
|
80
|
-
"dependencies": {
|
|
81
|
-
"zod": "^4.4.3"
|
|
75
|
+
"react-native": "^0.87.0",
|
|
76
|
+
"react-native-webview": "13.16.1",
|
|
77
|
+
"tsdown": "^0.22.14",
|
|
78
|
+
"typescript": "^5.9.0",
|
|
79
|
+
"vitest": "^4.1.11",
|
|
80
|
+
"@yodlpay/sdk-core": "0.13.0"
|
|
82
81
|
},
|
|
83
82
|
"scripts": {
|
|
84
83
|
"build": "tsdown",
|
|
85
84
|
"typecheck": "tsc --noEmit",
|
|
86
85
|
"test": "vitest run",
|
|
87
86
|
"test:watch": "vitest",
|
|
88
|
-
"lint": "
|
|
87
|
+
"lint": "eslint . --max-warnings 0"
|
|
89
88
|
}
|
|
90
89
|
}
|