@yodlpay/react-native 0.7.0 → 0.8.1
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 +82 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +48 -7
- package/dist/index.d.mts +48 -7
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -240,9 +240,43 @@ const brandTheme: YodlTheme = {
|
|
|
240
240
|
- **Fine-tune** (derived from core when omitted): `bgDeep` `surfaceHover` `skeleton` `accentStrong` `accentDeep`
|
|
241
241
|
- **Brand:** `brandSurface` `brandSheet` `brandText` `brandButton` `brandButtonText`
|
|
242
242
|
|
|
243
|
+
Light accents are handled for you: icons drawn on an accent fill use white by default, and when white would drop below the 3:1 non-text contrast floor — a lime accent tests at 1.7:1 — near-black ink is substituted automatically. An accent white already reads on is left untouched. Where the accent is used *as text* it is mixed 45% toward `text` for the same reason.
|
|
244
|
+
|
|
245
|
+
Set `brandSurface` (or `brandSheet`) alone and readable text/button colors are picked from its luminance — a light brand surface gets near-black text and a dark button.
|
|
246
|
+
|
|
247
|
+
#### Shape and typography
|
|
248
|
+
|
|
249
|
+
`font`, `radiusControl` and `radiusSurface` are **top-level** keys, not palette keys — none is a color and none varies by mode.
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
const brandTheme: YodlTheme = {
|
|
253
|
+
font: 'geist',
|
|
254
|
+
radiusControl: '12px',
|
|
255
|
+
light: { bg: '#ffffff' },
|
|
256
|
+
};
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`font` is one of `'inter'` (stock), `'geist'`, `'mono'`, or `'system'`. It is a fixed list rather than a family name you supply, because **a font bundled in your app is not visible to the WebView that hosts the Yodl UI** — naming it would silently fall back to Inter and look like a bug. Ask us if you need a face that isn't listed.
|
|
260
|
+
|
|
261
|
+
`radiusControl` is the corner radius of every button, input and badge; stock is `9999px`, a full pill. Cards, list rows and sheets follow it in both directions — sharper *or* rounder than stock — with the rest of the surface scale derived proportionally:
|
|
262
|
+
|
|
263
|
+
| `radiusControl` | Buttons | Cards | Sheets |
|
|
264
|
+
| --- | --- | --- | --- |
|
|
265
|
+
| `'0'` | square | 0 | 0 |
|
|
266
|
+
| `'12px'` | 12px | 12px | 18px |
|
|
267
|
+
| `'32px'` | 32px | 32px | 48px |
|
|
268
|
+
| omitted (`9999px`) | pill | 16px | 24px |
|
|
269
|
+
|
|
270
|
+
The exception is a pill-scale value — 100px and up, or 50% and up (a smaller percentage like `'6%'` is an ordinary radius and surfaces follow it): that asks for a *shape* rather than a size, so buttons go pill while surfaces stay at their stock radius instead of becoming lozenges. Set `radiusSurface` when you want containers to differ from your buttons — pill buttons with square cards, or the very round cards a pill `radiusControl` won't produce on its own.
|
|
271
|
+
|
|
272
|
+
Circular elements — avatars, token icons, sheet grab handles, status rings — stay circular by design and follow neither key.
|
|
273
|
+
|
|
243
274
|
#### Validation
|
|
244
275
|
|
|
245
276
|
- Colors must be `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb(…)`, or `rgba(…)`.
|
|
277
|
+
- `font` must be one of the four listed values; anything else rejects the payload.
|
|
278
|
+
- `radiusControl` / `radiusSurface` must be a plain CSS length — a bare `0`, or a number of up to 4 digits with `px`, `rem`, `em`, or `%` (`.5rem` is as valid as `0.5rem`). A unitless number other than zero (`'4'` rather than `'4px'`) is not a CSS length and is rejected, as are expressions such as `calc(…)` and `var(…)`.
|
|
279
|
+
- **A single invalid key rejects the whole theme**, so the hosted UI falls back to stock rather than applying a half-valid palette. Validate with `safeParseYodlTheme()` before sending — it returns the offending key by name.
|
|
246
280
|
- Images go under `images.light` / `images.dark`, each with `payBackground`, `loading`, and `processing` slots (`processing` is only used when `loading` is unset). A `.mp4` URL plays as a looping muted video; anything else is an image.
|
|
247
281
|
- Image URLs must be `https://`, at most 2048 characters, with no whitespace, quotes, or backslashes.
|
|
248
282
|
- An invalid `theme` or `themeMode` never crashes — it falls back to stock Yodl and logs the error in `__DEV__`.
|
|
@@ -251,7 +285,7 @@ const brandTheme: YodlTheme = {
|
|
|
251
285
|
|
|
252
286
|
Changing `theme` / `themeMode` on a mounted component applies over the bridge **without reloading** — the active flow keeps its state.
|
|
253
287
|
|
|
254
|
-
> **Compatibility.** `yodlUiBaseUrl` must point at a current hosted UI that supports correlated readiness. Against an older build the
|
|
288
|
+
> **Compatibility.** `yodlUiBaseUrl` must point at a current hosted UI that supports correlated readiness. Against an older build the theme is never delivered, and the WebView is only revealed by the 8 s ceiling — showing stock Yodl colors rather than yours. See [Loading and readiness](#loading-and-readiness) and [Troubleshooting](#troubleshooting).
|
|
255
289
|
|
|
256
290
|
### Full example
|
|
257
291
|
|
|
@@ -424,8 +458,12 @@ Supplies the SDK instance and wallet state to the components. Render it once, hi
|
|
|
424
458
|
| `theme` | `YodlTheme` | No | Palette override; inherits the provider `theme` when omitted |
|
|
425
459
|
| `themeMode` | `'system' \| 'light' \| 'dark'` | No | Mode override; inherits the provider `themeMode` when omitted |
|
|
426
460
|
| `backgroundColor` | `string` | No | Color behind the WebView before first paint; overrides the theme background |
|
|
461
|
+
| `renderLoading` | `() => ReactElement \| null` | No | Replaces the loading overlay's contents; `null` suppresses the overlay entirely |
|
|
462
|
+
| `onReady` | `() => void` | No | Called once per mount, the first time the hosted UI is revealed |
|
|
427
463
|
| `style` | `ViewStyle` | No | Container style |
|
|
428
464
|
|
|
465
|
+
See [Loading and readiness](#loading-and-readiness) for `renderLoading` and `onReady`.
|
|
466
|
+
|
|
429
467
|
### `<YodlSignup />`
|
|
430
468
|
|
|
431
469
|
Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`. Also accepts all [shared visual props](#shared-visual-props).
|
|
@@ -444,10 +482,13 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
|
|
|
444
482
|
| Prop | Type | Required | Description |
|
|
445
483
|
| ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
|
|
446
484
|
| `qrData` | `string` | Yes | Raw scanned QR data string |
|
|
485
|
+
| `navigateOnSubmit` | `'always' \| 'never'` | No | Whether the hosted UI moves to its own status screen once the transaction is submitted. Defaults to `'always'` |
|
|
447
486
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
448
487
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
449
488
|
| `onError` | `(error: Error) => void` | No | Called on RPC / payment errors |
|
|
450
489
|
|
|
490
|
+
`navigateOnSubmit="never"` parks the hosted UI on a terminal "sent" frame so your app owns the transition after signing — drive it from `onTransactionSent` or `onPaymentDetails`. Note the moment: the hosted UI moves when the transaction is **submitted**, not when it settles. A host that ignores both callbacks leaves the user on that frame, which is why the default is `'always'`: omit the prop and the URL, and therefore the behavior, is unchanged. The prop feeds the WebView's URL and the WebView is keyed by it, so changing it on a mounted component reloads the hosted UI — pass a constant.
|
|
491
|
+
|
|
451
492
|
### `<YodlDashboard />`
|
|
452
493
|
|
|
453
494
|
Renders the full Yodl account dashboard. Also accepts all [shared visual props](#shared-visual-props).
|
|
@@ -458,6 +499,44 @@ Renders the full Yodl account dashboard. Also accepts all [shared visual props](
|
|
|
458
499
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
459
500
|
| `onError` | `(error: Error) => void` | No | Called on RPC errors |
|
|
460
501
|
|
|
502
|
+
### Loading and readiness
|
|
503
|
+
|
|
504
|
+
Until the hosted UI reports it has painted, the SDK covers the WebView with an overlay filled with `backgroundColor` and centered on an `ActivityIndicator`. That exists so the user never sees react-native-webview's hardcoded-white loading view or the document's default white before its CSS lands.
|
|
505
|
+
|
|
506
|
+
`renderLoading` and `onReady` are two ways to fix the two-loader cascade you get when your app's loading treatment and Yodl's don't match. They are **alternatives — pick one.** Using both is how you get two loaders.
|
|
507
|
+
|
|
508
|
+
**Recipe A — Yodl's overlay, your loader.** The SDK still owns the cover; you supply its contents. Nothing in your tree needs to know when the hosted UI is up, so `onReady` has no job here.
|
|
509
|
+
|
|
510
|
+
```tsx
|
|
511
|
+
<YodlPayment
|
|
512
|
+
qrData={qrData}
|
|
513
|
+
backgroundColor="#18181b"
|
|
514
|
+
renderLoading={() => <MyBrandLoader />}
|
|
515
|
+
/>
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
- **Returning an element** renders it centered on `backgroundColor`. The wrapper stays, so the no-white-flash guarantee is preserved.
|
|
519
|
+
- **Returning `null`** suppresses the overlay **entirely** — no view is mounted, so nothing is left over the WebView intercepting touches. `backgroundColor` is still painted behind the WebView.
|
|
520
|
+
- It is called on every render while loading, so keep it cheap.
|
|
521
|
+
|
|
522
|
+
**Recipe B — your own screen covers it.** Suppress Yodl's overlay so there is only one, and let `onReady` tell you when to take yours down.
|
|
523
|
+
|
|
524
|
+
```tsx
|
|
525
|
+
{!ready && <MyLoadingScreen />}
|
|
526
|
+
<YodlPayment
|
|
527
|
+
qrData={qrData}
|
|
528
|
+
backgroundColor="#18181b"
|
|
529
|
+
renderLoading={() => null}
|
|
530
|
+
onReady={() => setReady(true)}
|
|
531
|
+
/>
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
`onReady` is the only way to do this: `renderLoading` is called *during render*, so you cannot `setState` from it.
|
|
535
|
+
|
|
536
|
+
`onReady` fires **once per mount**, the first time the UI is revealed. It does not fire again. The hosted document re-posts readiness when it reloads, but the overlay has already lifted and does not come back, so there is nothing to re-announce — it lifts once and stays lifted.
|
|
537
|
+
|
|
538
|
+
**The reveal has a ceiling.** If nothing is heard from the hosted UI within 8 seconds, the SDK reveals anyway and fires `onReady`. It is a last resort for a page that is genuinely dead, not a routine path: a reveal on that timer arrives without the readiness handshake, so the hosted UI has not received your theme or the SDK's capability announcement. A current hosted build runs its own, shorter ceiling and always reports readiness first, so in practice you only reach 8 seconds when the UI never loaded at all. The ceiling reveals — it does not report an error. Use `onError` and your own network handling for that.
|
|
539
|
+
|
|
461
540
|
### Payment details events
|
|
462
541
|
|
|
463
542
|
`onPaymentDetails` is optional and additive — `onTransactionSent(txHash)` and `onError(error)` behavior is unchanged.
|
|
@@ -479,7 +558,8 @@ The bridge forwards EIP-5792 (`wallet_sendCalls`, `wallet_getCallsStatus`, `wall
|
|
|
479
558
|
| `Yodl components must be rendered inside <YodlProvider>` | A component is mounted outside the provider. Wrap it in `<YodlProvider>`. |
|
|
480
559
|
| Payment screen renders blank | `qrData` isn't a Yodl payment QR. Guard with `isPaymentQr(qrData)` before rendering `<YodlPayment>`. |
|
|
481
560
|
| `webview-action providers are not supported yet` | The scanned QR maps to a provider whose hosted webview flow isn't supported yet. Catch it (e.g. via `onError` or an error boundary) and prompt a retry. |
|
|
482
|
-
|
|
|
561
|
+
| Overlay lifts after ~8 s onto an unthemed or blank page | That's the reveal ceiling firing because the hosted UI never reported readiness — usually an unreachable `yodlUiBaseUrl`, a build that predates correlated readiness, or no network. A ceiling reveal carries no theme handshake, so a stale build also shows stock Yodl colors. Point `yodlUiBaseUrl` at a current hosted build. See [Loading and readiness](#loading-and-readiness). |
|
|
562
|
+
| Nothing is visible over the WebView while it loads | `renderLoading` returned `null`, which suppresses the overlay by design. Return an element instead, or omit the prop for the default indicator. |
|
|
483
563
|
|
|
484
564
|
## License
|
|
485
565
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react-native"),n=require("react/jsx-runtime"),r=require("react-native-webview");const i=/^0x[0-9a-fA-F]{40}$/,a=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,o=/^https:\/\/[^\s"\\]+$/,s=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react-native"),n=require("react/jsx-runtime"),r=require("react-native-webview");const i=/^0x[0-9a-fA-F]{40}$/,a=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\(\s*[\d.%\s,/]+\s*\))$/i,o=/^https:\/\/[^\s"\\]+$/,s=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,c=new Set([`system`,`inter`,`geist`,`mono`]),l=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],u=[`payBackground`,`processing`,`loading`];function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e,t){if(!d(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of l){let i=e[r];if(i!==void 0){if(typeof i!=`string`||!a.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function p(e,t){if(!d(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of u){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!o.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function m(e){if(!d(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=p(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function h(e){if(!d(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`||!c.has(e.font))return{success:!1,error:`font: must be one of ${[...c].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=f(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=m(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function g(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function _(e,t){return typeof e==`string`&&t.test(e)}function v(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function y(e){if(!d(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!g(r,128))}const b=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function x(e){if(!d(e)||!v(e,b))return!1;let{type:t,version:n,sessionId:r,requestId:a,address:o}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!g(r,128)||!g(a,64)||!_(o,i))}const S={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function C(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function w(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:h(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:C(a,n)},error:o.length>0?o.join(`; `):null}}function T(e,t){let n=S[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function E(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function ee(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 JSON.stringify(ee(e,t))}function O(e,t,n,r){let{envelope:i,error:a}=w(e,t,n);return a&&r?.(a),i}function k(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=w(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function A(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const j=(0,e.createContext)(null);function M({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>O(s,c,u,A),[s,c,u]),f=(0,e.useMemo)(()=>({sdk:r,provider:i,address:a,chainId:o,supportedChainIds:r.config.supportedChainIds,hostTheme:d,systemScheme:u}),[r,i,a,o,d,u]);return(0,n.jsx)(j.Provider,{value:f,children:l})}function N(){let t=(0,e.useContext)(j);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function P(t,n){let r=N(),i=(0,e.useMemo)(()=>k(r.hostTheme,t,n,r.systemScheme,A),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function F(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function I(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 L(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function R(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 z(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 te(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ne(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const re=/^0x[a-fA-F0-9]{40}$/;function B(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!re.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function V(e){return{"X-Yodl-Integration-Id":B(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.8.1`}}function ie(e,t){let n=e.yodlUiBaseUrl?te(e.yodlUiBaseUrl):null;if(!(!n||!ne(t,n)))return V(e)}let ae=0;function oe(){return ae+=1,`yodl-${Date.now().toString(36)}-${ae.toString(36)}`}function se(e,t=oe){return{sessionId:t(),initialHostTheme:e}}function ce(e,t){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}})}function le(e,t,n){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n})}function H(e){return`0x${e.toString(16)}`}function ue(e,t=`unsupported`){let n={};for(let r of e)n[H(r)]={atomic:{status:t}};return n}function U(e){return e.toLowerCase()}function de(e,t){let n=U(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:H(t.chainId)}}:{}}}function fe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function pe(e){return{state:e,decision:{kind:`ignore`}}}function W(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function me(e,t,n){return!x(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?pe(e):n.supported?U(t.address)===U(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?W(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}}:W(e,t.requestId,`address_mismatch`):W(e,t.requestId,`not_supported`)}function he(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const ge=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function _e(e){return ge.some(t=>t===e)}function ve(e,t,n){if(!_e(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=R((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=H(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function ye(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>R(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function be(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function xe(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!be(t))return;let n=t.receipts;if(n?.length&&!n.some(xe))return n[n.length-1]?.transactionHash}function Ce(e){let t=H(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 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function De(e){return JSON.stringify(e)}function B(e){return{state:e,message:null,readyAccepted:!1}}function V(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:E(e.sessionId,e.currentTheme),readyAccepted:t}}function H(e,t){let n=De(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Oe(e,t){let n=De(t);if(n===e.currentFingerprint)return B(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?V(r,!1):B(r)}function ke(e,t){return!_(t)||t.sessionId!==e.sessionId?B(e):V({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function U(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 W(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Ae(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:u,onError:d,onReady:f,sessionId:p,hostTheme:m=null,initialHostTheme:h=null,fetchEmailAttestation:g}=t,_=(0,e.useRef)(null),v=(0,e.useRef)(R(r)),y=(0,e.useRef)(i),b=(0,e.useRef)(i),x=(0,e.useRef)(new Set),S=(0,e.useRef)(m),C=(0,e.useRef)(p?H(p,h):null),w=(0,e.useRef)(p?he(p):null),T=(0,e.useRef)(g);(0,e.useLayoutEffect)(()=>{S.current=m},[m]),(0,e.useLayoutEffect)(()=>{T.current=g},[g]),(0,e.useLayoutEffect)(()=>{C.current=p?H(p,h):null},[h,p]),(0,e.useLayoutEffect)(()=>{w.current=p?he(p):null},[p]);let E=(0,e.useCallback)(e=>{x.current.has(e)||(x.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=me({address:v.current,propChainId:y.current,activeChainId:b.current},{address:r,chainId:i});e&&(v.current=e.nextAddress,y.current=e.nextPropChainId,b.current=e.nextActiveChainId,e.accountsChanged&&W(_,`accountsChanged`,e.accountsChanged),e.chainChanged&&W(_,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!C.current)return;let e=Oe(C.current,m);C.current=e.state,e.message&&_.current?.postMessage(e.message)},[m]);let D=(0,e.useMemo)(()=>Ee({address:r,chainId:i}),[r,i]),O=(0,e.useCallback)(async(e,t,r)=>{try{let i=xe(t,r,a);if(`error`in i){U(_,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),U(_,e,null),i.switchesActiveChain&&(b.current=i.requestedChainId,W(_,`chainChanged`,i.chainIdHex))}catch(t){let n=P(t,`Chain request failed`);U(_,e,void 0,F(n)),d?.(n)}},[n,a,d]),k=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>L(e))];U(_,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=P(n,`Capabilities unavailable`);if(!te(r)){U(_,e,void 0,F(r));return}U(_,e,pe(Se(t,a),`unsupported`))}},[n,r,a]),A=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Te(r);i&&E(i),U(_,e,r)}catch(t){U(_,e,void 0,F(P(t,`Failed to get call status`)))}},[n,E]),j=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&E(i),U(_,e,i)}catch(t){let n=P(t,`Request failed`),r=ee(n);U(_,e,void 0,r?{code:4001,message:n.message}:F(n)),r||d?.(n)}},[n,E,d]),M=(0,e.useCallback)((e,t)=>{let n=w.current;n&&(w.current=ve(n,e),_.current?.postMessage(fe(n.sessionId,e,t)))},[]),N=(0,e.useCallback)(async(e,t)=>{let n=T.current;if(!n){M(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,...t.email!==void 0&&{email:t.email},signal:r.signal}),i=e?.email??t.email;a=e?.token&&i?{status:`ok`,token:e.token,email:i}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}w.current?.sessionId===e&&M(t.requestId,a)},[M]),I=(0,e.useCallback)(e=>{let t=w.current;if(!t)return;let n=_e(t,e,{walletAddress:v.current,supported:!!T.current});if(w.current=n.state,n.decision.kind===`reject`){M(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&N(t.sessionId,n.decision.request)},[N,M]);return{uiRef:_,injectedJavaScript:D,onMessage:(0,e.useCallback)(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(!C.current){f?.();return}let e=Oe(C.current,S.current);C.current=e.state,e.message&&_.current?.postMessage(e.message);let n=ke(C.current,t);if(C.current=n.state,!n.readyAccepted)return;n.message&&_.current?.postMessage(n.message);let r=w.current;r&&_.current?.postMessage(de(r.sessionId,!!T.current)),f?.();return}if(t.type===`yodl_email_attestation_request`){I(t);return}if(t.type===`yodl_payment_details`){s?.(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),d?.(n);return}if(t.type===`yodl_signup_status`){c?.(t.status);return}if(t.type===`yodl_signup_complete`){l?.();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),d?.(n);return}if(t.type===`yodl_signup_dismissed`){u?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;be(r)?O(n,r,i):r===`wallet_getCapabilities`?k(n,i):r===`wallet_getCallsStatus`?A(n,i):j(n,r,i)},[O,k,A,j,I,s,c,l,u,d,f])}}function G(e){return(0,n.jsx)(je,{...e},e.uri)}function je({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,style:g,backgroundColor:_,hostTheme:v=null,fetchEmailAttestation:y,sharedCookiesEnabled:b=!0,thirdPartyCookiesEnabled:x=!0,onLoadStart:S,...T}){let[E]=(0,e.useState)(()=>ue(v)),D=C(v,_),O=D.background,[k,A]=(0,e.useState)(null),j=k===E.sessionId,{uiRef:M,injectedJavaScript:N,onMessage:ee}=Ae({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:(0,e.useCallback)(()=>{A(E.sessionId)},[E.sessionId]),sessionId:E.sessionId,hostTheme:v,initialHostTheme:E.initialHostTheme,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onSignupStatusChange:f},...p!==void 0&&{onSignedUp:p},...m!==void 0&&{onSignupDismissed:m},...h!==void 0&&{onError:h},...y!==void 0&&{fetchEmailAttestation:y}}),P=(0,e.useMemo)(()=>ne(i),[i]),F=(0,e.useMemo)(()=>{let e=se(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),I=(0,e.useMemo)(()=>e=>!P||!e?.url?!1:re(e.url,P)||e.url.startsWith(`about:`),[P]);return(0,n.jsxs)(t.View,{style:[K.container,{backgroundColor:O},g],children:[(0,n.jsx)(r.WebView,{ref:M,source:F,originWhitelist:P?[P]:[],onShouldStartLoadWithRequest:I,javaScriptEnabled:!0,sharedCookiesEnabled:b,thirdPartyCookiesEnabled:x,injectedJavaScriptBeforeContentLoaded:N,injectedJavaScriptObject:w(E.sessionId,E.initialHostTheme,a.integrationAddress),onMessage:ee,...S!==void 0&&{onLoadStart:S},style:[K.ui,{backgroundColor:O}],...T}),j?null:(0,n.jsx)(t.View,{style:[K.overlay,{backgroundColor:O}],children:(0,n.jsx)(t.ActivityIndicator,{color:D.spinner})})]})}const K=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...t.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function Me({onTransactionSent:t,onPaymentDetails:r,onError:i,fetchEmailAttestation:a,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:f,supportedChainIds:p,sdk:m,hostTheme:h}=N(c,l);return(0,n.jsx)(G,{uri:(0,e.useMemo)(()=>m.config.yodlUiBaseUrl.replace(/\/$/,``),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:u,address:d,chainId:f,supportedChainIds:p,hostTheme:h,...t!==void 0&&{onTransactionSent:t},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{fetchEmailAttestation:a},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}})}function Ne(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 Pe(e){if(Array.isArray(e))return e}function Fe(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ie(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 Le(e,t,n){return t&&Ie(e.prototype,t),n&&Ie(e,n),e}function Re(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 Be(e,t){return Pe(e)||Re(e,t)||He(e,t)||ze()}function Ve(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function He(e,t){if(e){if(typeof e==`string`)return Ne(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 Ne(e,t)}}var Ue=Object.defineProperty,We=function(e,t,n){return t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Ge=function(e,t){for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},q=function(e,t,n){return We(e,(t===void 0?`undefined`:Ve(t))===`symbol`?t:t+``,n)},Ke=[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 qe(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=Ke[(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 Je(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 J(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+=J(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 Ye(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=qe(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Ye(e,n),e}function Xe(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 X(e,t){return{id:e,length:t.length,value:t}}function Ze(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[X(`00`,`A000000677010112`),X(`01`,t),X(`02`,r)];i&&o.push(X(`03`,i));var s=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`30`,J(o)),X(`53`,`764`),X(`58`,`TH`)];return n&&s.push(X(`54`,Number(n).toFixed(2))),a&&s.push(X(`62`,J([X(`07`,a)]))),Y(J(s),`63`)}var Qe=function(){"use strict";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;Fe(this,e),q(this,`billerId`),q(this,`ref1`),q(this,`ref2`),q(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return Le(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 Ze({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=Be(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}(),Z=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Z||{});function $e(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=J([X(`00`,`A000000677010111`),X(Z[t],n)]),a=[X(`00`,`01`),X(`01`,r?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return r&&a.push(X(`54`,Number(r).toFixed(2))),Y(J(a),`63`)}Ge({},{ProxyType:function(){return Z},anyId:function(){return $e},billPayment:function(){return Ze},botBarcode:function(){return et},slipVerify:function(){return tt},trueMoney:function(){return rt},trueMoneySlipVerify:function(){return it}});function et(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Qe(t,n,r,i).toString()}function tt(e){var t=e.sendingBank,n=e.transRef;return Y(J([X(`00`,J([X(`00`,`000001`),X(`01`,t),X(`02`,n)])),X(`51`,`TH`)]),`91`)}function nt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function rt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=J([X(`00`,`A000000677010111`),X(`03`,`14000${t}`)]),a=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return n&&a.push(X(`54`,Number(n).toFixed(2))),r&&a.push(X(`81`,nt(r))),Y(J(a),`63`)}function it(e){var t=e.eventType,n=e.transactionId,r=e.date;return Y(J([X(`00`,J([X(`00`,`01`),X(`01`,`01`),X(`02`,t),X(`03`,n),X(`04`,r)]))]),`91`,!1)}function Q(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 ot(e){if(Array.isArray(e))return Q(e)}function st(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ct(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 lt(e,t,n){return t&&ct(e.prototype,t),n&&ct(e,n),e}function ut(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ft(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 pt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ht(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){ut(e,t,n[t])})}return e}function gt(e,t){return at(e)||ft(e,t)||vt(e,t)||pt()}function _t(e){return ot(e)||dt(e)||vt(e)||mt()}function vt(e,t){if(e){if(typeof e==`string`)return Q(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 Q(e,t)}}Ge({},{anyId:function(){return xt},bcelOneProof:function(){return bt},billPayment:function(){return St},slipVerify:function(){return Ct},trueMoneySlipVerify:function(){return wt}});var yt=function(){"use strict";function e(t,n){st(this,e),q(this,`payload`),q(this,`tags`),this.payload=t,this.tags=n}return lt(e,[{key:`getTag`,value:function(e,t){return Xe(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=Y(J(_t(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()!=Ye(e.slice(0,-4)))return null;var r=Je(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=Je(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 yt(e,r)}function bt(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 xt(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(Z).find(function(e){var n=gt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=gt(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 ht({type:o,target:c},u!==void 0&&{amount:u})}function St(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 ht({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Ct(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 wt(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 Tt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Et(e){return e?e.getTagValue(`58`)??null:null}function Dt(e){let t=[];for(let[n,r]of Object.entries(Tt))r.includes(e)&&t.push(n);return t}function Ot(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Et($(r));if(e){let n=Dt(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 kt(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Ot(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function At({qrData:t,onTransactionSent:r,onPaymentDetails:i,onError:a,fetchEmailAttestation:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:f,chainId:p,supportedChainIds:m,sdk:h,hostTheme:g}=N(l,u),_=(0,e.useMemo)(()=>kt(t,h.config.yodlUiBaseUrl),[t,h.config.yodlUiBaseUrl]);return _?(0,n.jsx)(G,{uri:_,sdkConfig:h.config,provider:d,address:f,chainId:p,supportedChainIds:m,hostTheme:g,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}}):null}function jt(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Mt({onStatusChange:t,onSignedUp:r,onError:i,onDismiss:a,fetchEmailAttestation:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:f,chainId:p,supportedChainIds:m,sdk:h,hostTheme:g}=N(l,u);return(0,n.jsx)(G,{uri:(0,e.useMemo)(()=>jt(h.config.yodlUiBaseUrl),[h.config.yodlUiBaseUrl]),sdkConfig:h.config,provider:d,address:f,chainId:p,supportedChainIds:m,hostTheme:g,...t!==void 0&&{onSignupStatusChange:t},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function Nt(e){return(Array.isArray(e)?e:[e]).some(e=>Ot(e).some(e=>e.action===`resolve`))}var Pt=class{config;constructor(e){let t=ae(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 Ft(e){return new Pt(e)}exports.Yodl=Pt,exports.YodlDashboard=Me,exports.YodlPayment=At,exports.YodlProvider=j,exports.YodlSignup=Mt,exports.createSdk=Ft,exports.isPaymentQr=Nt;
|
|
228
|
+
true;`}function we(e){return JSON.stringify(e)}function G(e){return{state:e,message:null,readyAccepted:!1}}function Te(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:D(e.sessionId,e.currentTheme),readyAccepted:t}}function Ee(e,t){let n=we(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function De(e,t){let n=we(t);if(n===e.currentFingerprint)return G(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Te(r,!1):G(r)}function Oe(e,t){return!y(t)||t.sessionId!==e.sessionId?G(e):Te({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function K(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 q(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ke(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:u,onError:d,onReady:f,sessionId:p,hostTheme:m=null,initialHostTheme:h=null,fetchEmailAttestation:g}=t,_=(0,e.useRef)(null),v=(0,e.useRef)(U(r)),y=(0,e.useRef)(i),b=(0,e.useRef)(i),x=(0,e.useRef)(new Set),S=(0,e.useRef)(m),C=(0,e.useRef)(p?Ee(p,h):null),w=(0,e.useRef)(p?fe(p):null),T=(0,e.useRef)(g);(0,e.useLayoutEffect)(()=>{S.current=m},[m]),(0,e.useLayoutEffect)(()=>{T.current=g},[g]),(0,e.useLayoutEffect)(()=>{C.current=p?Ee(p,h):null},[h,p]),(0,e.useLayoutEffect)(()=>{w.current=p?fe(p):null},[p]);let E=(0,e.useCallback)(e=>{x.current.has(e)||(x.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=de({address:v.current,propChainId:y.current,activeChainId:b.current},{address:r,chainId:i});e&&(v.current=e.nextAddress,y.current=e.nextPropChainId,b.current=e.nextActiveChainId,e.accountsChanged&&q(_,`accountsChanged`,e.accountsChanged),e.chainChanged&&q(_,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!C.current)return;let e=De(C.current,m);C.current=e.state,e.message&&_.current?.postMessage(e.message)},[m]);let ee=(0,e.useMemo)(()=>Ce({address:r,chainId:i}),[r,i]),D=(0,e.useCallback)(async(e,t,r)=>{try{let i=ve(t,r,a);if(`error`in i){K(_,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),K(_,e,null),i.switchesActiveChain&&(b.current=i.requestedChainId,q(_,`chainChanged`,i.chainIdHex))}catch(t){let n=I(t,`Chain request failed`);K(_,e,void 0,L(n)),d?.(n)}},[n,a,d]),O=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>H(e))];K(_,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=I(n,`Capabilities unavailable`);if(!z(r)){K(_,e,void 0,L(r));return}K(_,e,ue(ye(t,a),`unsupported`))}},[n,r,a]),k=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Se(r);i&&E(i),K(_,e,r)}catch(t){K(_,e,void 0,L(I(t,`Failed to get call status`)))}},[n,E]),A=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&E(i),K(_,e,i)}catch(t){let n=I(t,`Request failed`),r=F(n);K(_,e,void 0,r?{code:4001,message:n.message}:L(n)),r||d?.(n)}},[n,E,d]),j=(0,e.useCallback)((e,t)=>{let n=w.current;n&&(w.current=he(n,e),_.current?.postMessage(le(n.sessionId,e,t)))},[]),M=(0,e.useCallback)(async(e,t)=>{let n=T.current;if(!n){j(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)}w.current?.sessionId===e&&j(t.requestId,a)},[j]),N=(0,e.useCallback)(e=>{let t=w.current;if(!t)return;let n=me(t,e,{walletAddress:v.current,supported:!!T.current});if(w.current=n.state,n.decision.kind===`reject`){j(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&M(t.sessionId,n.decision.request)},[M,j]);return{uiRef:_,injectedJavaScript:ee,onMessage:(0,e.useCallback)(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(!C.current){f?.();return}let e=De(C.current,S.current);C.current=e.state,e.message&&_.current?.postMessage(e.message);let n=Oe(C.current,t);if(C.current=n.state,!n.readyAccepted)return;n.message&&_.current?.postMessage(n.message);let r=w.current;r&&_.current?.postMessage(ce(r.sessionId,!!T.current)),f?.();return}if(t.type===`yodl_email_attestation_request`){N(t);return}if(t.type===`yodl_payment_details`){s?.(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),d?.(n);return}if(t.type===`yodl_signup_status`){c?.(t.status);return}if(t.type===`yodl_signup_complete`){l?.();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),d?.(n);return}if(t.type===`yodl_signup_dismissed`){u?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;_e(r)?D(n,r,i):r===`wallet_getCapabilities`?O(n,i):r===`wallet_getCallsStatus`?k(n,i):A(n,r,i)},[D,O,k,A,N,s,c,l,u,d,f])}}function Ae(e){return(0,n.jsx)(je,{...e},e.uri)}function je({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,style:g,backgroundColor:_,hostTheme:v=null,fetchEmailAttestation:y,renderLoading:b,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...ee}){let[D]=(0,e.useState)(()=>se(v)),O=T(v,_),k=O.background,[A,j]=(0,e.useState)(null),M=A===D.sessionId,N=(0,e.useRef)(x);(0,e.useLayoutEffect)(()=>{N.current=x},[x]);let P=(0,e.useRef)(!1),F=(0,e.useCallback)(()=>{j(D.sessionId),!P.current&&(P.current=!0,N.current?.())},[D.sessionId]);(0,e.useEffect)(()=>{if(M)return;let e=setTimeout(F,8e3);return()=>clearTimeout(e)},[F,M]);let{uiRef:I,injectedJavaScript:L,onMessage:R}=ke({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:F,sessionId:D.sessionId,hostTheme:v,initialHostTheme:D.initialHostTheme,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onSignupStatusChange:f},...p!==void 0&&{onSignedUp:p},...m!==void 0&&{onSignupDismissed:m},...h!==void 0&&{onError:h},...y!==void 0&&{fetchEmailAttestation:y}}),z=(0,e.useMemo)(()=>te(i),[i]),re=(0,e.useMemo)(()=>{let e=ie(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),B=(0,e.useMemo)(()=>e=>!z||!e?.url?!1:ne(e.url,z)||e.url.startsWith(`about:`),[z]),V=M?null:b?b():(0,n.jsx)(t.ActivityIndicator,{color:O.spinner});return(0,n.jsxs)(t.View,{style:[Me.container,{backgroundColor:k},g],children:[(0,n.jsx)(r.WebView,{ref:I,source:re,originWhitelist:z?[z]:[],onShouldStartLoadWithRequest:B,javaScriptEnabled:!0,sharedCookiesEnabled:S,thirdPartyCookiesEnabled:C,injectedJavaScriptBeforeContentLoaded:L,injectedJavaScriptObject:E(D.sessionId,D.initialHostTheme,a.integrationAddress),onMessage:R,...w!==void 0&&{onLoadStart:w},style:[Me.ui,{backgroundColor:k}],...ee}),V&&(0,n.jsx)(t.View,{style:[Me.overlay,{backgroundColor:k}],children:V})]})}const Me=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...t.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function Ne({onTransactionSent:t,onPaymentDetails:r,onError:i,fetchEmailAttestation:a,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:f,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=P(u,d);return(0,n.jsx)(Ae,{uri:(0,e.useMemo)(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]),sdkConfig:g.config,provider:f,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...t!==void 0&&{onTransactionSent:t},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{fetchEmailAttestation:a},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function Pe(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 Fe(e){if(Array.isArray(e))return e}function Ie(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Le(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 Re(e,t,n){return t&&Le(e.prototype,t),n&&Le(e,n),e}function ze(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 Be(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ve(e,t){return Fe(e)||ze(e,t)||Ue(e,t)||Be()}function He(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Ue(e,t){if(e){if(typeof e==`string`)return Pe(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 Pe(e,t)}}var We=Object.defineProperty,Ge=function(e,t,n){return t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Ke=function(e,t){for(var n in t)We(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return Ge(e,(t===void 0?`undefined`:He(t))===`symbol`?t:t+``,n)},qe=[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 Je(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=qe[(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 Ye(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 Xe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Je(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+=Xe(e,n),e}function Ze(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 Qe(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 $e=function(){"use strict";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;Ie(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 Re(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 Qe({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=Ve(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 et(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`)}Ke({},{ProxyType:function(){return Q},anyId:function(){return et},billPayment:function(){return Qe},botBarcode:function(){return tt},slipVerify:function(){return nt},trueMoney:function(){return it},trueMoneySlipVerify:function(){return at}});function tt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new $e(t,n,r,i).toString()}function nt(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 rt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function it(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`,rt(r))),X(Y(a),`63`)}function at(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 ot(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 st(e){if(Array.isArray(e))return e}function ct(e){if(Array.isArray(e))return ot(e)}function lt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ut(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 dt(e,t,n){return t&&ut(e.prototype,t),n&&ut(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 pt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function mt(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 ht(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _t(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 st(e)||mt(e,t)||bt(e,t)||ht()}function yt(e){return ct(e)||pt(e)||bt(e)||gt()}function bt(e,t){if(e){if(typeof e==`string`)return ot(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 ot(e,t)}}Ke({},{anyId:function(){return Ct},bcelOneProof:function(){return St},billPayment:function(){return wt},slipVerify:function(){return Tt},trueMoneySlipVerify:function(){return Et}});var xt=function(){"use strict";function e(t,n){lt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return dt(e,[{key:`getTag`,value:function(e,t){return Ze(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(yt(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()!=Xe(e.slice(0,-4)))return null;var r=Ye(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=Ye(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 xt(e,r)}function St(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 Ct(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 _t({type:o,target:c},u!==void 0&&{amount:u})}function wt(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 _t({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Tt(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 Et(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 Dt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Ot(e){return e?e.getTagValue(`58`)??null:null}function kt(e){let t=[];for(let[n,r]of Object.entries(Dt))r.includes(e)&&t.push(n);return t}function At(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Ot($(r));if(e){let n=kt(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 jt(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 Mt(e){return jt(e,`/sdk/signup`)}const Nt=`always`;function Pt(e,t,n=Nt){return!e||typeof e!=`string`||e.trim().length===0||!At(e).find(e=>e.action===`resolve`)?null:jt(t,`/resolve`,{data:e,navigateOnSubmit:n===Nt?void 0:n})}function Ft({qrData:t,navigateOnSubmit:r,onTransactionSent:i,onPaymentDetails:a,onError:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=P(f,p),b=(0,e.useMemo)(()=>Pt(t,v.config.yodlUiBaseUrl,r),[t,v.config.yodlUiBaseUrl,r]);return b?(0,n.jsx)(Ae,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...i!==void 0&&{onTransactionSent:i},...a!==void 0&&{onPaymentDetails:a},...o!==void 0&&{onError:o},...s!==void 0&&{fetchEmailAttestation:s},...c!==void 0&&{renderLoading:c},...l!==void 0&&{onReady:l},...u!==void 0&&{style:u},...d!==void 0&&{backgroundColor:d}}):null}function It({onStatusChange:t,onSignedUp:r,onError:i,onDismiss:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=P(d,f);return(0,n.jsx)(Ae,{uri:(0,e.useMemo)(()=>Mt(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]),sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...t!==void 0&&{onSignupStatusChange:t},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...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}})}function Lt(e){return(Array.isArray(e)?e:[e]).some(e=>At(e).some(e=>e.action===`resolve`))}var Rt=class{config;constructor(e){let t=B(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 zt(e){return new Rt(e)}exports.Yodl=Rt,exports.YodlDashboard=Ne,exports.YodlPayment=Ft,exports.YodlProvider=M,exports.YodlSignup=It,exports.createSdk=zt,exports.isPaymentQr=Lt;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { output, z } from "zod";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
3
|
import { ViewStyle } from "react-native";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
|
-
//#region ../sdk-core/dist/host-
|
|
5
|
+
//#region ../sdk-core/dist/host-CpXzgaWd.d.mts
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/theme/schemas.d.ts
|
|
8
8
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -12,9 +12,25 @@ declare const yodlThemeModeSchema: z.ZodEnum<{
|
|
|
12
12
|
dark: "dark";
|
|
13
13
|
}>;
|
|
14
14
|
/** What `system` resolves to once the host appearance is known. */
|
|
15
|
-
/**
|
|
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
|
+
*/
|
|
16
24
|
declare const yodlThemeSchema: z.ZodObject<{
|
|
17
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>;
|
|
18
34
|
light: z.ZodOptional<z.ZodObject<{
|
|
19
35
|
bg: z.ZodOptional<z.ZodString>;
|
|
20
36
|
surface: z.ZodOptional<z.ZodString>;
|
|
@@ -103,6 +119,8 @@ interface EIP1193Provider {
|
|
|
103
119
|
type SupportedChainIds = number[];
|
|
104
120
|
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
105
121
|
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
122
|
+
/** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
|
|
123
|
+
type YodlNavigateOnSubmit = 'always' | 'never';
|
|
106
124
|
interface YodlPaymentDetails {
|
|
107
125
|
status: YodlPaymentLifecycleStatus;
|
|
108
126
|
transaction: {
|
|
@@ -178,15 +196,17 @@ interface YodlHostThemeProps {
|
|
|
178
196
|
interface YodlEmailAttestationRequest {
|
|
179
197
|
/** The wallet the hosted flow proved with SIWE. Mint `sub` for exactly this address. */
|
|
180
198
|
address: `0x${string}`;
|
|
181
|
-
/** The email the user entered on Yodl's register screen, when it has been collected. */
|
|
182
|
-
email?: string;
|
|
183
199
|
/** Aborted on timeout, unmount, or session change. Forward it into your fetch. */
|
|
184
200
|
signal: AbortSignal;
|
|
185
201
|
}
|
|
186
202
|
interface YodlEmailAttestation {
|
|
187
203
|
/** A compact JWS your backend signs. Never sign on-device. */
|
|
188
204
|
token: string;
|
|
189
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* The token's `email` claim — the address your backend verified. Return it always:
|
|
207
|
+
* it is what the Yodl account is created with, and a token without it is treated as
|
|
208
|
+
* a decline so the user falls back to the OTP.
|
|
209
|
+
*/
|
|
190
210
|
email?: string;
|
|
191
211
|
}
|
|
192
212
|
/**
|
|
@@ -215,6 +235,14 @@ interface YodlVisualProps extends YodlHostThemeProps {
|
|
|
215
235
|
* to the Yodl UI's dark theme (#18181b).
|
|
216
236
|
*/
|
|
217
237
|
backgroundColor?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Replaces the overlay covering the WebView until the Yodl UI has painted.
|
|
240
|
+
* Returning `null` suppresses it entirely, leaving nothing over the WebView to
|
|
241
|
+
* intercept touches. Called on every render while loading, so keep it cheap.
|
|
242
|
+
*/
|
|
243
|
+
renderLoading?: () => ReactElement | null;
|
|
244
|
+
/** Called once per mount, the first time the Yodl UI is revealed. */
|
|
245
|
+
onReady?: () => void;
|
|
218
246
|
}
|
|
219
247
|
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
220
248
|
interface YodlComponentProps extends YodlVisualProps, YodlEventHandlers {
|
|
@@ -239,6 +267,8 @@ declare function YodlDashboard({
|
|
|
239
267
|
onPaymentDetails,
|
|
240
268
|
onError,
|
|
241
269
|
fetchEmailAttestation,
|
|
270
|
+
renderLoading,
|
|
271
|
+
onReady,
|
|
242
272
|
style,
|
|
243
273
|
backgroundColor,
|
|
244
274
|
theme,
|
|
@@ -249,6 +279,12 @@ declare function YodlDashboard({
|
|
|
249
279
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
250
280
|
/** Raw scanned QR data. The component resolves it to the Yodl UI URL. */
|
|
251
281
|
qrData: string;
|
|
282
|
+
/**
|
|
283
|
+
* Whether the Yodl UI moves to its own status screen once the transaction is
|
|
284
|
+
* submitted. `'never'` parks it so the host owns what comes next. Changing it
|
|
285
|
+
* on a mounted component reloads the Yodl UI, so pass a constant.
|
|
286
|
+
*/
|
|
287
|
+
navigateOnSubmit?: YodlNavigateOnSubmit;
|
|
252
288
|
}
|
|
253
289
|
/**
|
|
254
290
|
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
@@ -258,10 +294,13 @@ interface YodlPaymentProps extends YodlComponentProps {
|
|
|
258
294
|
*/
|
|
259
295
|
declare function YodlPayment({
|
|
260
296
|
qrData,
|
|
297
|
+
navigateOnSubmit,
|
|
261
298
|
onTransactionSent,
|
|
262
299
|
onPaymentDetails,
|
|
263
300
|
onError,
|
|
264
301
|
fetchEmailAttestation,
|
|
302
|
+
renderLoading,
|
|
303
|
+
onReady,
|
|
265
304
|
style,
|
|
266
305
|
backgroundColor,
|
|
267
306
|
theme,
|
|
@@ -296,6 +335,8 @@ declare function YodlSignup({
|
|
|
296
335
|
onError,
|
|
297
336
|
onDismiss,
|
|
298
337
|
fetchEmailAttestation,
|
|
338
|
+
renderLoading,
|
|
339
|
+
onReady,
|
|
299
340
|
style,
|
|
300
341
|
backgroundColor,
|
|
301
342
|
theme,
|
|
@@ -376,4 +417,4 @@ declare function YodlProvider({
|
|
|
376
417
|
*/
|
|
377
418
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
378
419
|
//#endregion
|
|
379
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
|
|
420
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
3
|
import { output, z } from "zod";
|
|
4
4
|
|
|
5
|
-
//#region ../sdk-core/dist/host-
|
|
5
|
+
//#region ../sdk-core/dist/host-CpXzgaWd.d.mts
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/theme/schemas.d.ts
|
|
8
8
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -12,9 +12,25 @@ declare const yodlThemeModeSchema: z.ZodEnum<{
|
|
|
12
12
|
dark: "dark";
|
|
13
13
|
}>;
|
|
14
14
|
/** What `system` resolves to once the host appearance is known. */
|
|
15
|
-
/**
|
|
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
|
+
*/
|
|
16
24
|
declare const yodlThemeSchema: z.ZodObject<{
|
|
17
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>;
|
|
18
34
|
light: z.ZodOptional<z.ZodObject<{
|
|
19
35
|
bg: z.ZodOptional<z.ZodString>;
|
|
20
36
|
surface: z.ZodOptional<z.ZodString>;
|
|
@@ -103,6 +119,8 @@ interface EIP1193Provider {
|
|
|
103
119
|
type SupportedChainIds = number[];
|
|
104
120
|
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
105
121
|
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
122
|
+
/** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
|
|
123
|
+
type YodlNavigateOnSubmit = 'always' | 'never';
|
|
106
124
|
interface YodlPaymentDetails {
|
|
107
125
|
status: YodlPaymentLifecycleStatus;
|
|
108
126
|
transaction: {
|
|
@@ -178,15 +196,17 @@ interface YodlHostThemeProps {
|
|
|
178
196
|
interface YodlEmailAttestationRequest {
|
|
179
197
|
/** The wallet the hosted flow proved with SIWE. Mint `sub` for exactly this address. */
|
|
180
198
|
address: `0x${string}`;
|
|
181
|
-
/** The email the user entered on Yodl's register screen, when it has been collected. */
|
|
182
|
-
email?: string;
|
|
183
199
|
/** Aborted on timeout, unmount, or session change. Forward it into your fetch. */
|
|
184
200
|
signal: AbortSignal;
|
|
185
201
|
}
|
|
186
202
|
interface YodlEmailAttestation {
|
|
187
203
|
/** A compact JWS your backend signs. Never sign on-device. */
|
|
188
204
|
token: string;
|
|
189
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* The token's `email` claim — the address your backend verified. Return it always:
|
|
207
|
+
* it is what the Yodl account is created with, and a token without it is treated as
|
|
208
|
+
* a decline so the user falls back to the OTP.
|
|
209
|
+
*/
|
|
190
210
|
email?: string;
|
|
191
211
|
}
|
|
192
212
|
/**
|
|
@@ -215,6 +235,14 @@ interface YodlVisualProps extends YodlHostThemeProps {
|
|
|
215
235
|
* to the Yodl UI's dark theme (#18181b).
|
|
216
236
|
*/
|
|
217
237
|
backgroundColor?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Replaces the overlay covering the WebView until the Yodl UI has painted.
|
|
240
|
+
* Returning `null` suppresses it entirely, leaving nothing over the WebView to
|
|
241
|
+
* intercept touches. Called on every render while loading, so keep it cheap.
|
|
242
|
+
*/
|
|
243
|
+
renderLoading?: () => ReactElement | null;
|
|
244
|
+
/** Called once per mount, the first time the Yodl UI is revealed. */
|
|
245
|
+
onReady?: () => void;
|
|
218
246
|
}
|
|
219
247
|
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
220
248
|
interface YodlComponentProps extends YodlVisualProps, YodlEventHandlers {
|
|
@@ -239,6 +267,8 @@ declare function YodlDashboard({
|
|
|
239
267
|
onPaymentDetails,
|
|
240
268
|
onError,
|
|
241
269
|
fetchEmailAttestation,
|
|
270
|
+
renderLoading,
|
|
271
|
+
onReady,
|
|
242
272
|
style,
|
|
243
273
|
backgroundColor,
|
|
244
274
|
theme,
|
|
@@ -249,6 +279,12 @@ declare function YodlDashboard({
|
|
|
249
279
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
250
280
|
/** Raw scanned QR data. The component resolves it to the Yodl UI URL. */
|
|
251
281
|
qrData: string;
|
|
282
|
+
/**
|
|
283
|
+
* Whether the Yodl UI moves to its own status screen once the transaction is
|
|
284
|
+
* submitted. `'never'` parks it so the host owns what comes next. Changing it
|
|
285
|
+
* on a mounted component reloads the Yodl UI, so pass a constant.
|
|
286
|
+
*/
|
|
287
|
+
navigateOnSubmit?: YodlNavigateOnSubmit;
|
|
252
288
|
}
|
|
253
289
|
/**
|
|
254
290
|
* Renders the Yodl payment flow for a scanned QR code. Reads the SDK instance
|
|
@@ -258,10 +294,13 @@ interface YodlPaymentProps extends YodlComponentProps {
|
|
|
258
294
|
*/
|
|
259
295
|
declare function YodlPayment({
|
|
260
296
|
qrData,
|
|
297
|
+
navigateOnSubmit,
|
|
261
298
|
onTransactionSent,
|
|
262
299
|
onPaymentDetails,
|
|
263
300
|
onError,
|
|
264
301
|
fetchEmailAttestation,
|
|
302
|
+
renderLoading,
|
|
303
|
+
onReady,
|
|
265
304
|
style,
|
|
266
305
|
backgroundColor,
|
|
267
306
|
theme,
|
|
@@ -296,6 +335,8 @@ declare function YodlSignup({
|
|
|
296
335
|
onError,
|
|
297
336
|
onDismiss,
|
|
298
337
|
fetchEmailAttestation,
|
|
338
|
+
renderLoading,
|
|
339
|
+
onReady,
|
|
299
340
|
style,
|
|
300
341
|
backgroundColor,
|
|
301
342
|
theme,
|
|
@@ -376,4 +417,4 @@ declare function YodlProvider({
|
|
|
376
417
|
*/
|
|
377
418
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
378
419
|
//#endregion
|
|
379
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
|
|
420
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, 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=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],
|
|
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.1`}}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() {
|
|
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 Me(e){return JSON.stringify(e)}function K(e){return{state:e,message:null,readyAccepted:!1}}function Ne(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:F(e.sessionId,e.currentTheme),readyAccepted:t}}function Pe(e,t){let n=Me(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Fe(e,t){let n=Me(t);if(n===e.currentFingerprint)return K(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Ne(r,!1):K(r)}function Ie(e,t){return!O(t)||t.sessionId!==e.sessionId?K(e):Ne({...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 Le(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Re(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(W(s)),C=o(c),w=o(c),T=o(new Set),E=o(v),D=o(_?Pe(_,y):null),O=o(_?be(_):null),k=o(b);i(()=>{E.current=v},[v]),i(()=>{k.current=b},[b]),i(()=>{D.current=_?Pe(_,y):null},[y,_]),i(()=>{O.current=_?be(_):null},[_]);let A=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=ye({address:S.current,propChainId:C.current,activeChainId:w.current},{address:s,chainId:c});e&&(S.current=e.nextAddress,C.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&Le(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&Le(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!D.current)return;let e=Fe(D.current,v);D.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let j=a(()=>je({address:s,chainId:c}),[s,c]),M=t(async(e,t,r)=>{try{let i=Ee(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&&(w.current=i.requestedChainId,Le(x,`chainChanged`,i.chainIdHex))}catch(t){let n=V(t,`Chain request failed`);q(x,e,void 0,H(n)),h?.(n)}},[n,l,h]),N=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>U(e))];q(x,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=V(n,`Capabilities unavailable`);if(!oe(r)){q(x,e,void 0,H(r));return}q(x,e,ve(De(t,l),`unsupported`))}},[n,s,l]),ee=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Ae(r);i&&A(i),q(x,e,r)}catch(t){q(x,e,void 0,H(V(t,`Failed to get call status`)))}},[n,A]),te=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&A(i),q(x,e,i)}catch(t){let n=V(t,`Request failed`),r=ie(n);q(x,e,void 0,r?{code:4001,message:n.message}:H(n)),r||h?.(n)}},[n,A,h]),P=t((e,t)=>{let n=O.current;n&&(O.current=Ce(n,e),x.current?.postMessage(_e(n.sessionId,e,t)))},[]),F=t(async(e,t)=>{let n=k.current;if(!n){P(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,...t.email!==void 0&&{email:t.email},signal:r.signal}),i=e?.email??t.email;a=e?.token&&i?{status:`ok`,token:e.token,email:i}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}O.current?.sessionId===e&&P(t.requestId,a)},[P]),I=t(e=>{let t=O.current;if(!t)return;let n=Se(t,e,{walletAddress:S.current,supported:!!k.current});if(O.current=n.state,n.decision.kind===`reject`){P(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&F(t.sessionId,n.decision.request)},[F,P]);return{uiRef:x,injectedJavaScript:j,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(!D.current){g?.();return}let e=Fe(D.current,E.current);D.current=e.state,e.message&&x.current?.postMessage(e.message);let n=Ie(D.current,t);if(D.current=n.state,!n.readyAccepted)return;n.message&&x.current?.postMessage(n.message);let r=O.current;r&&x.current?.postMessage(ge(r.sessionId,!!k.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;Te(r)?M(n,r,i):r===`wallet_getCapabilities`?N(n,i):r===`wallet_getCallsStatus`?ee(n,i):te(n,r,i)},[M,N,ee,te,I,d,f,p,m,h,g])}}function ze(e){return f(Be,{...e},e.uri)}function Be({uri:e,sdkConfig:n,provider:r,address:i,chainId:o,supportedChainIds:l,onTransactionSent:d,onPaymentDetails:h,onSignupStatusChange:g,onSignedUp:_,onSignupDismissed:v,onError:y,style:b,backgroundColor:x,hostTheme:S=null,fetchEmailAttestation:C,sharedCookiesEnabled:w=!0,thirdPartyCookiesEnabled:T=!0,onLoadStart:E,...D}){let[O]=s(()=>he(S)),k=ee(S,x),A=k.background,[j,M]=s(null),N=j===O.sessionId,{uiRef:P,injectedJavaScript:F,onMessage:I}=Re({provider:r,address:i,chainId:o,supportedChainIds:l,onReady:t(()=>{M(O.sessionId)},[O.sessionId]),sessionId:O.sessionId,hostTheme:S,initialHostTheme:O.initialHostTheme,...d!==void 0&&{onTransactionSent:d},...h!==void 0&&{onPaymentDetails:h},...g!==void 0&&{onSignupStatusChange:g},..._!==void 0&&{onSignedUp:_},...v!==void 0&&{onSignupDismissed:v},...y!==void 0&&{onError:y},...C!==void 0&&{fetchEmailAttestation:C}}),L=a(()=>se(e),[e]),R=a(()=>{let t=fe(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),z=a(()=>e=>!L||!e?.url?!1:ce(e.url,L)||e.url.startsWith(`about:`),[L]);return p(u,{style:[Ve.container,{backgroundColor:A},b],children:[f(m,{ref:P,source:R,originWhitelist:L?[L]:[],onShouldStartLoadWithRequest:z,javaScriptEnabled:!0,sharedCookiesEnabled:w,thirdPartyCookiesEnabled:T,injectedJavaScriptBeforeContentLoaded:F,injectedJavaScriptObject:te(O.sessionId,O.initialHostTheme,n.integrationAddress),onMessage:I,...E!==void 0&&{onLoadStart:E},style:[Ve.ui,{backgroundColor:A}],...D}),N?null:f(u,{style:[Ve.overlay,{backgroundColor:A}],children:f(c,{color:k.spinner})})]})}const Ve=l.create({container:{flex:1},ui:{flex:1},overlay:{...l.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function He({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,style:i,backgroundColor:o,theme:s,themeMode:c}){let{provider:l,address:u,chainId:d,supportedChainIds:p,sdk:m,hostTheme:h}=B(s,c);return f(ze,{uri:a(()=>m.config.yodlUiBaseUrl.replace(/\/$/,``),[m.config.yodlUiBaseUrl]),sdkConfig:m.config,provider:l,address:u,chainId:d,supportedChainIds:p,hostTheme:h,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{fetchEmailAttestation:r},...i!==void 0&&{style:i},...o!==void 0&&{backgroundColor:o}})}function Ue(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 We(e){if(Array.isArray(e))return e}function Ge(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ke(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 qe(e,t,n){return t&&Ke(e.prototype,t),n&&Ke(e,n),e}function Je(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 Ye(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xe(e,t){return We(e)||Je(e,t)||Qe(e,t)||Ye()}function Ze(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Qe(e,t){if(e){if(typeof e==`string`)return Ue(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 Ue(e,t)}}var $e=Object.defineProperty,et=function(e,t,n){return t in e?$e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},tt=function(e,t){for(var n in t)$e(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return et(e,(t===void 0?`undefined`:Ze(t))===`symbol`?t:t+``,n)},nt=[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 rt(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=nt[(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 it(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 at(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=rt(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+=at(e,n),e}function ot(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 st(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 ct=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;Ge(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 qe(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 st({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=Xe(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 lt(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`)}tt({},{ProxyType:function(){return Q},anyId:function(){return lt},billPayment:function(){return st},botBarcode:function(){return ut},slipVerify:function(){return dt},trueMoney:function(){return pt},trueMoneySlipVerify:function(){return mt}});function ut(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ct(t,n,r,i).toString()}function dt(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 ft(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function pt(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`,ft(r))),X(Y(a),`63`)}function mt(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 ht(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 gt(e){if(Array.isArray(e))return e}function _t(e){if(Array.isArray(e))return ht(e)}function vt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function yt(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 bt(e,t,n){return t&&yt(e.prototype,t),n&&yt(e,n),e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function St(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(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 wt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Et(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){xt(e,t,n[t])})}return e}function Dt(e,t){return gt(e)||Ct(e,t)||kt(e,t)||wt()}function Ot(e){return _t(e)||St(e)||kt(e)||Tt()}function kt(e,t){if(e){if(typeof e==`string`)return ht(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 ht(e,t)}}tt({},{anyId:function(){return Mt},bcelOneProof:function(){return jt},billPayment:function(){return Nt},slipVerify:function(){return Pt},trueMoneySlipVerify:function(){return Ft}});var At=function(){function e(t,n){vt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return bt(e,[{key:`getTag`,value:function(e,t){return ot(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(Ot(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()!=at(e.slice(0,-4)))return null;var r=it(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=it(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 At(e,r)}function jt(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 Mt(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=Dt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Dt(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 Et({type:o,target:c},u!==void 0&&{amount:u})}function Nt(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 Et({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Pt(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 Ft(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 It={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Lt(e){return e?e.getTagValue(`58`)??null:null}function Rt(e){let t=[];for(let[n,r]of Object.entries(It))r.includes(e)&&t.push(n);return t}function zt(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Lt($(r));if(e){let n=Rt(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 Bt(e,t){return!e||typeof e!=`string`||e.trim().length===0||!zt(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Vt({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,fetchEmailAttestation:i,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:p,supportedChainIds:m,sdk:h,hostTheme:g}=B(c,l),_=a(()=>Bt(e,h.config.yodlUiBaseUrl),[e,h.config.yodlUiBaseUrl]);return _?f(ze,{uri:_,sdkConfig:h.config,provider:u,address:d,chainId:p,supportedChainIds:m,hostTheme:g,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...i!==void 0&&{fetchEmailAttestation:i},...o!==void 0&&{style:o},...s!==void 0&&{backgroundColor:s}}):null}function Ht(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Ut({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,style:o,backgroundColor:s,theme:c,themeMode:l}){let{provider:u,address:d,chainId:p,supportedChainIds:m,sdk:h,hostTheme:g}=B(c,l);return f(ze,{uri:a(()=>Ht(h.config.yodlUiBaseUrl),[h.config.yodlUiBaseUrl]),sdkConfig:h.config,provider:u,address:d,chainId:p,supportedChainIds:m,hostTheme:g,...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&&{style:o},...s!==void 0&&{backgroundColor:s}})}function Wt(e){return(Array.isArray(e)?e:[e]).some(e=>zt(e).some(e=>e.action===`resolve`))}var Gt=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 Kt(e){return new Gt(e)}export{Gt as Yodl,He as YodlDashboard,Vt as YodlPayment,ne as YodlProvider,Ut as YodlSignup,Kt as createSdk,Wt as isPaymentQr};
|
|
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:{...l.absoluteFillObject,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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"tsdown": "^0.22.0",
|
|
76
76
|
"typescript": "^5.7.2",
|
|
77
77
|
"vitest": "^4.1.7",
|
|
78
|
-
"@yodlpay/sdk-core": "0.
|
|
78
|
+
"@yodlpay/sdk-core": "0.8.0"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"zod": "^4.4.3"
|