@yodlpay/react-native 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -5
- package/dist/index.cjs +6 -2
- package/dist/index.d.cts +66 -4
- package/dist/index.d.mts +66 -4
- package/dist/index.mjs +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -410,6 +410,7 @@ Returns a `YodlSdk` instance.
|
|
|
410
410
|
| `integrationAddress` | `string` | Yes | — | Your integration wallet address. Identifies you to Yodl and attributes payments on chain |
|
|
411
411
|
| `supportedChainIds` | `number[]` | Yes | — | Chain IDs the wallet can switch to |
|
|
412
412
|
| `yodlUiBaseUrl` | `string` | No | `https://sdk-webview.yodl.me` | Base URL for the Yodl UI |
|
|
413
|
+
| `tokenlist` | `YodlTokenInfo[]` | No | Yodl's token list | The tokens your users hold and pay with, as `TokenInfo` entries. The Yodl UI reads, shows and pays from these alone, including tokens Yodl's list doesn't carry. Each entry needs `extensions.coinGeckoId` or `extensions.peggedTo: 'USD'` to be priced, both strings |
|
|
413
414
|
|
|
414
415
|
`integrationAddress` must be a non-empty `0x` address. The SDK sends it with package metadata on Yodl-owned requests:
|
|
415
416
|
|
|
@@ -419,6 +420,12 @@ X-Yodl-SDK-Name: @yodlpay/react-native
|
|
|
419
420
|
X-Yodl-SDK-Version: <installed package version>
|
|
420
421
|
```
|
|
421
422
|
|
|
423
|
+
`tokenlist` is checked when `createYodlSdk` runs. A list the Yodl UI would reject, or would not receive as written, throws there with the entry and field named, for example `Yodl tokenlist[2].decimals must be a non-negative integer`. That covers an empty list, an entry that is not there (`null`, `undefined` or a hole in the array), a field of the wrong type, a hole in `tags`, and `extensions` that is not a plain object of strings, finite numbers, booleans and nulls: a `Map`, a `Date`, a class instance, or a `NaN` or `Infinity` value. An entry itself can be any object. Only `TokenInfo`'s fields are read from it and sent.
|
|
424
|
+
|
|
425
|
+
The list is read once, by `createYodlSdk`, and each Yodl component hands it to its page when the page loads. `sdk.config.tokenlist` is the checked copy and is frozen, so adding to it or editing an entry in place throws. Passing `<YodlProvider>` a new `sdk` is not enough to change it: the page of a mounted component has already read its list and is not reloaded for a new one. When the list changes while the app runs, for example after the user adds a token, create a new SDK with the whole new list, pass it to `<YodlProvider>`, and remount any Yodl component that is on screen, for example by changing its `key`. That restarts the component's flow. Components mounted afterwards load the new list.
|
|
426
|
+
|
|
427
|
+
`tokenlist` is not checked against `supportedChainIds`. A token on a chain outside `supportedChainIds` is accepted and sent, but a payment that needs the wallet to switch to that chain fails: the SDK answers the switch request with error `4902` without asking your wallet. List only tokens on chains in `supportedChainIds`.
|
|
428
|
+
|
|
422
429
|
Instance members:
|
|
423
430
|
|
|
424
431
|
- **`sdk.config`** — the resolved config (read-only).
|
|
@@ -474,7 +481,7 @@ Renders the hosted signup flow. Use this as a full-screen component inside `<Yod
|
|
|
474
481
|
| `onStatusChange` | `(status: 'checking' \| 'signed_out' \| 'signing_up' \| 'signed_up') => void` | No | Called when the hosted flow reports signup status |
|
|
475
482
|
| `onSignedUp` | `() => void` | No | Called when signup completes |
|
|
476
483
|
| `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
|
|
477
|
-
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or
|
|
484
|
+
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, RPC, or WebView errors. See [errors](#errors) |
|
|
478
485
|
|
|
479
486
|
### `<YodlPayment />`
|
|
480
487
|
|
|
@@ -486,9 +493,9 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
|
|
|
486
493
|
| `navigateOnSubmit` | `'always' \| 'never'` | No | Whether the hosted UI moves to its own status screen once the transaction is submitted. Defaults to `'always'` |
|
|
487
494
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
488
495
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
489
|
-
| `onError` | `(error: Error) => void` | No | Called on RPC
|
|
496
|
+
| `onError` | `(error: Error) => void` | No | Called on RPC, payment, or WebView errors. See [errors](#errors) |
|
|
490
497
|
|
|
491
|
-
`navigateOnSubmit="never"`
|
|
498
|
+
`navigateOnSubmit="never"` keeps the hosted UI on the payment screen exactly as it was at the hold: the control stays busy, nothing else is drawn, its URL does not change, and your app owns the transition after signing — drive it from `onTransactionSent` or `onPaymentDetails`. Note the moment: under `'always'` the hosted UI moves when the transaction is **submitted**, not when it settles. Under `'never'` it keeps polling from that screen, so `onPaymentDetails` still reports `'processing'` and then `'success'` or `'failure'` — you get a `'submitted'` message first, then the same stream `'always'` produces. A host that ignores both callbacks leaves the user on a busy screen, 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. The hosted UI reads the parameter once, on its first load, and removes it from the URL.
|
|
492
499
|
|
|
493
500
|
### `<YodlDashboard />`
|
|
494
501
|
|
|
@@ -498,7 +505,7 @@ Renders the full Yodl account dashboard. Also accepts all [shared visual props](
|
|
|
498
505
|
| ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
|
|
499
506
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
500
507
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
501
|
-
| `onError` | `(error: Error) => void` | No | Called on RPC errors
|
|
508
|
+
| `onError` | `(error: Error) => void` | No | Called on RPC or WebView errors. See [errors](#errors) |
|
|
502
509
|
|
|
503
510
|
### Loading and readiness
|
|
504
511
|
|
|
@@ -536,7 +543,17 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
|
|
|
536
543
|
|
|
537
544
|
`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.
|
|
538
545
|
|
|
539
|
-
**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.
|
|
546
|
+
**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. A page that failed to load reaches `onError` as a `YodlWebViewError` (see [errors](#errors)); pair it with your own network handling.
|
|
547
|
+
|
|
548
|
+
### Errors
|
|
549
|
+
|
|
550
|
+
`onError` receives one of three kinds of error:
|
|
551
|
+
|
|
552
|
+
- A `YodlUIError` when the hosted UI reported a failure. `code` is the hosted UI's own code, when it sent one.
|
|
553
|
+
- A `YodlWebViewError` when the WebView under the hosted UI failed, so the page could not report anything itself. `code` is `'load_failed'` (no network, DNS, TLS), `'http_error'` (`status` has the HTTP status), or `'process_terminated'` (the OS ended the web process; remount the component to load the page again). `url` is the page's URL without its query, which carries the scanned QR.
|
|
554
|
+
- Your wallet's own error when a request to your EIP-1193 provider failed. A user rejection is not reported.
|
|
555
|
+
|
|
556
|
+
Both classes are exported from `@yodlpay/react-native`, and an error tracker titles them by name rather than as a plain `Error`.
|
|
540
557
|
|
|
541
558
|
### Payment details events
|
|
542
559
|
|
|
@@ -544,6 +561,8 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
|
|
|
544
561
|
|
|
545
562
|
The Yodl UI emits generalized payment lifecycle details once it has payment status. The SDK forwards them to `onPaymentDetails`. Normalized fields cover transaction hash, chain, lifecycle status, recipient, invoice, token amounts, refund state, and rewards when available; the original payload may be included under `raw`. The SDK does not fetch transaction details itself — it only bridges UI messages.
|
|
546
563
|
|
|
564
|
+
`onError` during this sequence means the hosted UI has given up on the receipt: an expired session or a backend failure it cannot poll through. The 404 the backend answers while it is still indexing a fresh hash is not one of these. The poll expects it and keeps asking, and the details stream is unaffected. An older hosted build forwarded that 404 as `Payment not found for txHash=…` between `'submitted'` and `'processing'`; a host that still sees it can ignore it, since the terminal status arrives regardless.
|
|
565
|
+
|
|
547
566
|
## Security
|
|
548
567
|
|
|
549
568
|
`<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` inject an EIP-1193 provider bound to the user's wallet, so the underlying Yodl UI is **locked to the configured Yodl origin** and off-origin navigation is blocked (`onShouldStartLoadWithRequest`). This prevents origin spoofing and mid-request navigation that could intercept signed responses. The injected provider also enforces a 30 s pending-request timeout.
|
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");function i(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const a=/^0x[a-fA-F0-9]{40}$/;function o(e){return typeof e==`string`&&a.test(e)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const c=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function l(e){if(e===void 0)return!0;if(!s(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function u(e){if(!s(e))return!1;switch(e.type){case`yodl_payment_details`:return s(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return l(e.error);case`yodl_signup_status`:return d(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return f(e);default:return!1}}function d(e){return typeof e==`string`&&c.has(e)}function f(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const p=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,m=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,h=/^https:\/\/[^\s"\\]+$/,g=[`system`,`inter`,`geist`,`mono`],_=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],v=[`payBackground`,`processing`,`loading`];function y(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function ee(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function b(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const x=new Set([`system`,`light`,`dark`]);function S(e){return typeof e==`string`&&x.has(e)}const C=new Set(g);function w(e,t){if(!s(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of _){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!p.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function T(e,t){if(!s(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of v){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!h.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function E(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=T(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function D(e){if(!s(e))return{success:!1,error:`(root): expected an object`};let t=O(e);if(!t.success)return t;let n=te(e);if(!n.success)return n;let r=k(e);if(!r.success)return r;let i=A(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=E(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function O(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function te(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!C.has(e.font)?{success:!1,error:`font: must be one of ${[...C].join(`, `)}`}:{success:!0,data:{font:e.font}}}function k(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!m.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function A(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=w(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function j(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function M(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function N(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||!j(r,128))}const P=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function F(e){if(!s(e)||!M(e,P))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!j(r,128)||!j(i,64)||!o(a))}const I={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function L(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function R(e){let t=D(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function z(e){return e===void 0?{preference:`system`,error:null}:S(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function B(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:R(e),i=z(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:L(i.preference,n)},error:a.length>0?a.join(`; `):null}}function ne(e,t){let n=I[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function re(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function ie(e,t){return JSON.stringify(y(e,t))}function ae(e,t,n,r){let{envelope:i,error:a}=B(e,t,n);return a&&r?.(a),i}function oe(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=B(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function se(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ce=(0,e.createContext)(null);function le({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>ae(s,c,u,se),[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)(ce.Provider,{value:f,children:l})}function ue(){let t=(0,e.useContext)(ce);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function de(t,n){let r=ue(),i=(0,e.useMemo)(()=>oe(r.hostTheme,t,n,r.systemScheme,se),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function V(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=de(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function fe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!o(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function pe(e,t){return{"X-Yodl-Integration-Id":fe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function 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 me(e){return e.code===4001||/rejected|denied/i.test(e.message)}const he=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ge=[...he,`not supported`,`not available`];function _e(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ve(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||_e(e,he):_e(e,ge)}function ye(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function be(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const xe={name:`@yodlpay/react-native`,version:`0.11.0`};function Se(e){return pe(e,xe)}function Ce(e,t){let n=e.yodlUiBaseUrl?ye(e.yodlUiBaseUrl):null;if(!(!n||!be(t,n)))return Se(e)}let we=0;function Te(){return we+=1,`yodl-${Date.now().toString(36)}-${we.toString(36)}`}function Ee(e,t=Te){return{sessionId:t(),initialHostTheme:e}}function U(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function De(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function Oe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>De(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function W(e){return`0x${e.toString(16)}`}function Me(e,t=`unsupported`){let n={};for(let r of e)n[W(r)]={atomic:{status:t}};return n}function G(e){return e.toLowerCase()}function Ne(e,t){let n=G(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:W(t.chainId)}}:{}}}function Pe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Fe(e){return{state:e,decision:{kind:`ignore`}}}function K(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ie(e,t,n){return!F(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Fe(e):n.supported?G(t.address)===G(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?K(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}}:K(e,t.requestId,`address_mismatch`):K(e,t.requestId,`not_supported`)}function Le(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Re=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function ze(e){return Re.some(t=>t===e)}function Be(e,t,n){if(!ze(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=De((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=W(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Ve(e){let t=W(e.chainId);return`(function() {
|
|
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");function i(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const a=/^0x[a-fA-F0-9]{40}$/;function o(e){return typeof e==`string`&&a.test(e)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const c=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function l(e){if(e===void 0)return!0;if(!s(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function u(e){if(!s(e))return!1;switch(e.type){case`yodl_payment_details`:return s(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return l(e.error);case`yodl_signup_status`:return d(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return f(e);default:return!1}}function d(e){return typeof e==`string`&&c.has(e)}function f(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const p=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,m=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,h=/^https:\/\/[^\s"\\]+$/,g=[`system`,`inter`,`geist`,`mono`],_=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],v=[`payBackground`,`processing`,`loading`];function y(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function ee(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function te(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const b=new Set([`system`,`light`,`dark`]);function x(e){return typeof e==`string`&&b.has(e)}const S=new Set(g);function C(e,t){if(!s(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of _){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!p.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function w(e,t){if(!s(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of v){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!h.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function T(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=w(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function E(e){if(!s(e))return{success:!1,error:`(root): expected an object`};let t=D(e);if(!t.success)return t;let n=ne(e);if(!n.success)return n;let r=O(e);if(!r.success)return r;let i=k(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=T(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function D(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function ne(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!S.has(e.font)?{success:!1,error:`font: must be one of ${[...S].join(`, `)}`}:{success:!0,data:{font:e.font}}}function O(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!m.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function k(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=C(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function A(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function j(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function M(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||!A(r,128))}const N=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function P(e){if(!s(e)||!j(e,N))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!A(r,128)||!A(i,64)||!o(a))}function F(e){let[t=``]=e.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function I(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!o(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function L(e,t){return{"X-Yodl-Integration-Id":I(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function R(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 re(e){return e.code===4001||/rejected|denied/i.test(e.message)}const z=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],B=[...z,`not supported`,`not available`];function V(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ie(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||V(e,z):V(e,B)}function ae(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function oe(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const se={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function ce(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function le(e){let t=E(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function ue(e){return e===void 0?{preference:`system`,error:null}:x(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function de(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:le(e),i=ue(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:ce(i.preference,n)},error:a.length>0?a.join(`; `):null}}function fe(e,t){let n=se[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}const pe=/[\\"`\u0000-\u001f]|\$(?=\{)/g;function me(e){return e.replace(pe,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function he(e){return typeof e==`string`?me(e):Array.isArray(e)?e.map(he):s(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[me(e),he(t)])):e}function ge(e,t,n,r,i){return{yodl:he({version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{},...i?{tokenlist:i}:{}})}}function _e(e,t){return JSON.stringify(y(e,t))}function ve(e,t,n,r){let{envelope:i,error:a}=de(e,t,n);return a&&r?.(a),i}function ye(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=de(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function be(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const xe=(0,e.createContext)(null);function Se({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>ve(s,c,u,be),[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)(xe.Provider,{value:f,children:l})}function Ce(){let t=(0,e.useContext)(xe);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function we(t,n){let r=Ce(),i=(0,e.useMemo)(()=>ye(r.hostTheme,t,n,r.systemScheme,be),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function Te(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=we(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}const Ee={name:`@yodlpay/react-native`,version:`0.13.0`};function De(e){return L(e,Ee)}function Oe(e,t){let n=e.yodlUiBaseUrl?ae(e.yodlUiBaseUrl):null;if(!(!n||!oe(t,n)))return De(e)}var ke=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},H=class extends Error{code;url;status;constructor(e,t,n,r){super(t),this.name=`YodlWebViewError`,this.code=e,this.url=n===void 0?void 0:F(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Ae=0;function je(){return Ae+=1,`yodl-${Date.now().toString(36)}-${Ae.toString(36)}`}function Me(e,t=je){return{sessionId:t(),initialHostTheme:e}}function U(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function Ne(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 Pe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>Ne(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Fe(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ie(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Le(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Fe(t))return;let n=t.receipts;if(n?.length&&!n.some(Ie))return n[n.length-1]?.transactionHash}function W(e){return`0x${e.toString(16)}`}function Re(e,t=`unsupported`){let n={};for(let r of e)n[W(r)]={atomic:{status:t}};return n}function G(e){return e.toLowerCase()}function ze(e,t){let n=G(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:W(t.chainId)}}:{}}}function Be(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Ve(e){return{state:e,decision:{kind:`ignore`}}}function He(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ue(e,t,n){return!P(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Ve(e):n.supported?G(t.address)===G(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?He(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}}:He(e,t.requestId,`address_mismatch`):He(e,t.requestId,`not_supported`)}function We(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Ge=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Ke(e){return Ge.some(t=>t===e)}function qe(e,t,n){if(!Ke(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=Ne((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=W(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Je(e){let t=W(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,8 @@ 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 He(e){return JSON.stringify(e)}function Ue(e){return{state:e,message:null,readyAccepted:!1}}function We(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:ie(e.sessionId,e.currentTheme),readyAccepted:t}}function Ge(e,t){let n=He(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Ke(e,t){let n=He(t);if(n===e.currentFingerprint)return Ue(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?We(r,!1):Ue(r)}function qe(e,t){return!N(t)||t.sessionId!==e.sessionId?Ue(e):We({...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 Je(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Ye(e){return s(e)&&`type`in e}function Xe(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Ze(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:d,onError:f,onReady:p,sessionId:m,hostTheme:h=null,initialHostTheme:g=null,fetchEmailAttestation:_}=t,v=(0,e.useRef)(null),y=(0,e.useRef)(G(r)),x=(0,e.useRef)(i),S=(0,e.useRef)(i),C=(0,e.useRef)(new Set),w=(0,e.useRef)(h),T=(0,e.useRef)(m?Ge(m,g):null),E=(0,e.useRef)(m?Pe(m):null),D=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{w.current=h},[h]),(0,e.useLayoutEffect)(()=>{D.current=_},[_]),(0,e.useLayoutEffect)(()=>{T.current=m?Ge(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{E.current=m?Pe(m):null},[m]);let O=(0,e.useCallback)(e=>{C.current.has(e)||(C.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=Ne({address:y.current,propChainId:x.current,activeChainId:S.current},{address:r,chainId:i});e&&(y.current=e.nextAddress,x.current=e.nextPropChainId,S.current=e.nextActiveChainId,e.accountsChanged&&Je(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&Je(v,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!T.current)return;let e=Ke(T.current,h);T.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let te=(0,e.useMemo)(()=>Ve({address:r,chainId:i}),[r,i]),k=(0,e.useCallback)(async(e,t,r)=>{try{let i=Be(t,r,a);if(`error`in i){q(v,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(v,e,null),i.switchesActiveChain&&(S.current=i.requestedChainId,Je(v,`chainChanged`,i.chainIdHex))}catch(t){let n=H(t,`Chain request failed`);q(v,e,void 0,U(n)),f?.(n)}},[n,a,f]),A=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>W(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});q(v,e,o)}catch(n){let r=H(n,`Capabilities unavailable`);if(!ve(r)){q(v,e,void 0,U(r));return}q(v,e,Me(Oe(t,a),`unsupported`))}},[n,r,a]),j=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&O(i),q(v,e,r)}catch(t){let n=H(t,`Failed to get call status`);q(v,e,void 0,U(n))}},[n,O]),M=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&O(i),q(v,e,i)}catch(t){let n=H(t,`Request failed`),r=me(n);q(v,e,void 0,r?{code:4001,message:n.message}:U(n)),r||f?.(n)}},[n,O,f]),N=(0,e.useCallback)((e,t)=>{let n=E.current;n&&(E.current=Le(n,e),v.current?.postMessage(JSON.stringify(b(n.sessionId,e,t))))},[]),P=(0,e.useCallback)(async(e,t)=>{let n=D.current;if(!n){N(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)}E.current?.sessionId===e&&N(t.requestId,a)},[N]),F=(0,e.useCallback)(e=>{let t=E.current;if(!t)return;let n=Ie(t,e,{walletAddress:y.current,supported:!!D.current});if(E.current=n.state,n.decision.kind===`reject`){N(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&P(t.sessionId,n.decision.request)},[P,N]),I=(0,e.useCallback)((e,t,n)=>{ze(t)?k(e,t,n):t===`wallet_getCapabilities`?A(e,n):t===`wallet_getCallsStatus`?j(e,n):M(e,t,n)},[k,A,j,M]),L=(0,e.useCallback)(e=>{switch(e.type){case`yodl_signup_status`:c?.(e.status);return;case`yodl_signup_complete`:l?.();return;case`yodl_signup_error`:f?.(Xe(e.error,`Signup error`));return;case`yodl_signup_dismissed`:d?.();return}},[c,l,d,f]),R=(0,e.useCallback)(e=>{switch(e.type){case`yodl_payment_details`:s?.(e.details);return;case`yodl_payment_error`:f?.(Xe(e.error,`Payment details error`));return;case`ethereum_rpc_request`:I(e.id,e.method,e.params);return;default:L(e)}},[I,L,s,f]),z=(0,e.useCallback)(()=>{let e=E.current;e&&v.current?.postMessage(JSON.stringify(ee(e.sessionId,!!D.current)))},[]),B=(0,e.useCallback)(e=>{if(!T.current){p?.();return}let t=Ke(T.current,w.current);T.current=t.state,t.message&&v.current?.postMessage(t.message);let n=qe(T.current,e);T.current=n.state,n.readyAccepted&&(n.message&&v.current?.postMessage(n.message),z(),p?.())},[z,p]);return{uiRef:v,injectedJavaScript:te,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Ye(t)){if(t.type===`yodl_ready`){B(t);return}if(t.type===`yodl_email_attestation_request`){F(t);return}u(t)&&R(t)}},[R,F,B])}}function Qe(e){return(0,n.jsx)($e,{...e},e.uri)}function $e({uri:a,sdkConfig:o,provider:s,address:c,chainId:l,supportedChainIds:u,onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,style:_,backgroundColor:v,hostTheme:y=null,fetchEmailAttestation:ee,renderLoading:b,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...T}){let[E]=(0,e.useState)(()=>Ee(y)),D=ne(y,v),O=D.background,[te,k]=(0,e.useState)(null),A=te===E.sessionId,j=(0,e.useRef)(x);(0,e.useLayoutEffect)(()=>{j.current=x},[x]);let M=(0,e.useRef)(!1),N=(0,e.useCallback)(()=>{k(E.sessionId),!M.current&&(M.current=!0,j.current?.())},[E.sessionId]);(0,e.useEffect)(()=>{if(A)return;let e=setTimeout(N,8e3);return()=>clearTimeout(e)},[N,A]);let{uiRef:P,injectedJavaScript:F,onMessage:I}=Ze({provider:s,address:c,chainId:l,supportedChainIds:u,onReady:N,sessionId:E.sessionId,hostTheme:y,initialHostTheme:E.initialHostTheme,...i({onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,fetchEmailAttestation:ee})}),L=(0,e.useMemo)(()=>ye(a),[a]),R=(0,e.useMemo)(()=>{let e=Ce(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),z=(0,e.useMemo)(()=>e=>!L||!e?.url?!1:be(e.url,L)||e.url.startsWith(`about:`),[L]),B=A?null:b?b():(0,n.jsx)(t.ActivityIndicator,{color:D.spinner});return(0,n.jsxs)(t.View,{style:[et.container,{backgroundColor:O},_],children:[(0,n.jsx)(r.WebView,{ref:P,source:R,originWhitelist:L?[L]:[],onShouldStartLoadWithRequest:z,javaScriptEnabled:!0,sharedCookiesEnabled:S,thirdPartyCookiesEnabled:C,injectedJavaScriptBeforeContentLoaded:F,injectedJavaScriptObject:re(E.sessionId,E.initialHostTheme,o.integrationAddress,ee?{emailAttestation:!0}:void 0),onMessage:I,...w!==void 0&&{onLoadStart:w},style:[et.ui,{backgroundColor:O}],...T}),B&&(0,n.jsx)(t.View,{style:[et.overlay,{backgroundColor:O}],children:B})]})}const et=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function tt({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{sdk:p,hostProps:m}=V(d,f),h=(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]);return(0,n.jsx)(Qe,{uri:h,...m,...i({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})})}function nt(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 rt(e){if(Array.isArray(e))return e}function it(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function at(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 ot(e,t,n){return t&&at(e.prototype,t),n&&at(e,n),e}function st(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 ct(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lt(e,t){return rt(e)||st(e,t)||dt(e,t)||ct()}function ut(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function dt(e,t){if(e){if(typeof e==`string`)return nt(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 nt(e,t)}}var ft=Object.defineProperty,pt=function(e,t,n){return t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},mt=function(e,t){for(var n in t)ft(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return pt(e,(t===void 0?`undefined`:ut(t))===`symbol`?t:t+``,n)},ht=[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 gt(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=ht[(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 _t(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 vt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=gt(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+=vt(e,n),e}function yt(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 bt(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 xt=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;it(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 ot(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 bt({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=lt(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 St(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`)}mt({},{ProxyType:function(){return Q},anyId:function(){return St},billPayment:function(){return bt},botBarcode:function(){return Ct},slipVerify:function(){return wt},trueMoney:function(){return Et},trueMoneySlipVerify:function(){return Dt}});function Ct(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new xt(t,n,r,i).toString()}function wt(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 Tt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Et(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`,Tt(r))),X(Y(a),`63`)}function Dt(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 kt(e){if(Array.isArray(e))return e}function At(e){if(Array.isArray(e))return Ot(e)}function jt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Mt(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 Nt(e,t,n){return t&&Mt(e.prototype,t),n&&Mt(e,n),e}function Pt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ft(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function It(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Lt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zt(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){Pt(e,t,n[t])})}return e}function Bt(e,t){return kt(e)||It(e,t)||Ht(e,t)||Lt()}function Vt(e){return At(e)||Ft(e)||Ht(e)||Rt()}function Ht(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)}}mt({},{anyId:function(){return Gt},bcelOneProof:function(){return Wt},billPayment:function(){return Kt},slipVerify:function(){return qt},trueMoneySlipVerify:function(){return Jt}});var Ut=function(){"use strict";function e(t,n){jt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Nt(e,[{key:`getTag`,value:function(e,t){return yt(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(Vt(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=vt(e.slice(0,-4)))return null;var r=_t(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=_t(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 Ut(e,r)}function Wt(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 Gt(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=Bt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Bt(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 zt({type:o,target:c},u!==void 0&&{amount:u})}function Kt(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 zt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function qt(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 Jt(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 Yt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function Xt(e){return e?e.getTagValue(`58`)??null:null}function Zt(e){let t=[];for(let[n,r]of Object.entries(Yt))r.includes(e)&&t.push(n);return t}function Qt(e){return e.toLowerCase().startsWith(`upi://`)&&e.length>6}function $t(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function en(e,t){return!t||t.includes(e)}function tn(e,t){let n=[];try{let r=Xt($(e));if(!r)return n;for(let e of Zt(r))en(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function nn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if($t(n))return en(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=tn(n,t);return r.length>0?r:Qt(n)&&en(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function rn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function an(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 on(e){return an(e,`/sdk/signup`)}const sn=`always`;function cn(e,t,n=sn){return!e||typeof e!=`string`||e.trim().length===0||rn(nn(e)).length===0?null:an(t,`/resolve`,{data:e,navigateOnSubmit:n===sn?void 0:n})}function ln({qrData:t,navigateOnSubmit:r,onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f,theme:p,themeMode:m}){let{sdk:h,hostProps:g}=V(p,m),_=(0,e.useMemo)(()=>cn(t,h.config.yodlUiBaseUrl,r),[t,h.config.yodlUiBaseUrl,r]);return _?(0,n.jsx)(Qe,{uri:_,...g,...i({onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f})}):null}function un({onStatusChange:t,onSignedUp:r,onError:a,onDismiss:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{sdk:m,hostProps:h}=V(f,p),g=(0,e.useMemo)(()=>on(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]);return(0,n.jsx)(Qe,{uri:g,...h,...i({onSignupStatusChange:t,onSignedUp:r,onError:a,onSignupDismissed:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d})})}function dn(e){return(Array.isArray(e)?e:[e]).some(e=>rn(nn(e)).length>0)}var fn=class{config;constructor(e){let t=fe(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function pn(e){return new fn(e)}exports.YodlDashboard=tt,exports.YodlPayment=ln,exports.YodlProvider=le,exports.YodlSdk=fn,exports.YodlSignup=un,exports.createYodlSdk=pn,exports.isPaymentQr=dn;
|
|
228
|
+
true;`}function Ye(e){return JSON.stringify(e)}function Xe(e){return{state:e,message:null,readyAccepted:!1}}function Ze(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 Qe(e,t){let n=Ye(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function $e(e,t){let n=Ye(t);if(n===e.currentFingerprint)return Xe(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Ze(r,!1):Xe(r)}function et(e,t){return!M(t)||t.sessionId!==e.sessionId?Xe(e):Ze({...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 tt(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function nt(e){return s(e)&&`type`in e}function rt(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:l,onSignupDismissed:d,onError:f,onReady:p,sessionId:m,hostTheme:h=null,initialHostTheme:g=null,fetchEmailAttestation:_}=t,v=(0,e.useRef)(null),y=(0,e.useRef)(G(r)),b=(0,e.useRef)(i),x=(0,e.useRef)(i),S=(0,e.useRef)(new Set),C=(0,e.useRef)(h),w=(0,e.useRef)(m?Qe(m,g):null),T=(0,e.useRef)(m?Be(m):null),E=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{C.current=h},[h]),(0,e.useLayoutEffect)(()=>{E.current=_},[_]),(0,e.useLayoutEffect)(()=>{w.current=m?Qe(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{T.current=m?Be(m):null},[m]);let D=(0,e.useCallback)(e=>{S.current.has(e)||(S.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=ze({address:y.current,propChainId:b.current,activeChainId:x.current},{address:r,chainId:i});e&&(y.current=e.nextAddress,b.current=e.nextPropChainId,x.current=e.nextActiveChainId,e.accountsChanged&&tt(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&tt(v,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!w.current)return;let e=$e(w.current,h);w.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let ne=(0,e.useMemo)(()=>Je({address:r,chainId:i}),[r,i]),O=(0,e.useCallback)(async(e,t,r)=>{try{let i=qe(t,r,a);if(`error`in i){K(v,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),K(v,e,null),i.switchesActiveChain&&(x.current=i.requestedChainId,tt(v,`chainChanged`,i.chainIdHex))}catch(t){let n=R(t,`Chain request failed`);K(v,e,void 0,U(n)),f?.(n)}},[n,a,f]),k=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>W(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});K(v,e,o)}catch(n){let r=R(n,`Capabilities unavailable`);if(!ie(r)){K(v,e,void 0,U(r));return}K(v,e,Re(Pe(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=Le(r);i&&D(i),K(v,e,r)}catch(t){let n=R(t,`Failed to get call status`);K(v,e,void 0,U(n))}},[n,D]),j=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&D(i),K(v,e,i)}catch(t){let n=R(t,`Request failed`),r=re(n);K(v,e,void 0,r?{code:4001,message:n.message}:U(n)),r||f?.(n)}},[n,D,f]),M=(0,e.useCallback)((e,t)=>{let n=T.current;n&&(T.current=We(n,e),v.current?.postMessage(JSON.stringify(te(n.sessionId,e,t))))},[]),N=(0,e.useCallback)(async(e,t)=>{let n=E.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,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)}T.current?.sessionId===e&&M(t.requestId,a)},[M]),P=(0,e.useCallback)(e=>{let t=T.current;if(!t)return;let n=Ue(t,e,{walletAddress:y.current,supported:!!E.current});if(T.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]),F=(0,e.useCallback)((e,t,n)=>{Ke(t)?O(e,t,n):t===`wallet_getCapabilities`?k(e,n):t===`wallet_getCallsStatus`?A(e,n):j(e,t,n)},[O,k,A,j]),I=(0,e.useCallback)(e=>{switch(e.type){case`yodl_signup_status`:c?.(e.status);return;case`yodl_signup_complete`:l?.();return;case`yodl_signup_error`:f?.(new ke(e.error,`Signup error`));return;case`yodl_signup_dismissed`:d?.();return}},[c,l,d,f]),L=(0,e.useCallback)(e=>{switch(e.type){case`yodl_payment_details`:s?.(e.details);return;case`yodl_payment_error`:f?.(new ke(e.error,`Payment details error`));return;case`ethereum_rpc_request`:F(e.id,e.method,e.params);return;default:I(e)}},[F,I,s,f]),z=(0,e.useCallback)(()=>{let e=T.current;e&&v.current?.postMessage(JSON.stringify(ee(e.sessionId,!!E.current)))},[]),B=(0,e.useCallback)(e=>{if(!w.current){p?.();return}let t=$e(w.current,C.current);w.current=t.state,t.message&&v.current?.postMessage(t.message);let n=et(w.current,e);w.current=n.state,n.readyAccepted&&(n.message&&v.current?.postMessage(n.message),z(),p?.())},[z,p]);return{uiRef:v,injectedJavaScript:ne,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(nt(t)){if(t.type===`yodl_ready`){B(t);return}if(t.type===`yodl_email_attestation_request`){P(t);return}u(t)&&L(t)}},[L,P,B])}}function it(e){return(0,n.jsx)(at,{...e},e.uri)}function at({uri:a,sdkConfig:o,provider:s,address:c,chainId:l,supportedChainIds:u,onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,style:_,backgroundColor:v,hostTheme:y=null,fetchEmailAttestation:ee,renderLoading:te,onReady:b,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,onLoadStart:C,...w}){let[T]=(0,e.useState)(()=>Me(y)),E=fe(y,v),D=E.background,[ne,O]=(0,e.useState)(null),k=ne===T.sessionId,A=(0,e.useRef)(b);(0,e.useLayoutEffect)(()=>{A.current=b},[b]);let j=(0,e.useRef)(!1),M=(0,e.useCallback)(()=>{O(T.sessionId),!j.current&&(j.current=!0,A.current?.())},[T.sessionId]);(0,e.useEffect)(()=>{if(k)return;let e=setTimeout(M,8e3);return()=>clearTimeout(e)},[M,k]);let{uiRef:N,injectedJavaScript:P,onMessage:F}=rt({provider:s,address:c,chainId:l,supportedChainIds:u,onReady:M,sessionId:T.sessionId,hostTheme:y,initialHostTheme:T.initialHostTheme,...i({onTransactionSent:d,onPaymentDetails:f,onSignupStatusChange:p,onSignedUp:m,onSignupDismissed:h,onError:g,fetchEmailAttestation:ee})}),I=!!ee,L=(0,e.useMemo)(()=>ge(T.sessionId,T.initialHostTheme,o.integrationAddress,I?{emailAttestation:!0}:void 0,o.tokenlist),[T,o.integrationAddress,o.tokenlist,I]),R=(0,e.useMemo)(()=>ae(a),[a]),re=(0,e.useMemo)(()=>{let e=Oe(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),z=(0,e.useMemo)(()=>e=>!R||!e?.url?!1:oe(e.url,R)||e.url.startsWith(`about:`),[R]),B=(0,e.useMemo)(()=>{if(!g)return{};let e=e=>g(new H(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>g(new H(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>g(new H(`http_error`,`The Yodl UI answered HTTP ${e.statusCode}`,e.url,e.statusCode)),onRenderProcessGone:()=>e(a),onContentProcessDidTerminate:({nativeEvent:t})=>e(t.url)}},[g,a]),V=k?null:te?te():(0,n.jsx)(t.ActivityIndicator,{color:E.spinner});return(0,n.jsxs)(t.View,{style:[ot.container,{backgroundColor:D},_],children:[(0,n.jsx)(r.WebView,{ref:N,source:re,originWhitelist:R?[R]:[],onShouldStartLoadWithRequest:z,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:P,injectedJavaScriptObject:L,onMessage:F,...B,...C!==void 0&&{onLoadStart:C},style:[ot.ui,{backgroundColor:D}],...w}),V&&(0,n.jsx)(t.View,{style:[ot.overlay,{backgroundColor:D}],children:V})]})}const ot=t.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function st({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{sdk:p,hostProps:m}=Te(d,f),h=(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]);return(0,n.jsx)(it,{uri:h,...m,...i({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})})}function ct(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function lt(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 ut(e){if(Array.isArray(e))return e}function dt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ft(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function pt(e,t,n){return t&&ft(e.prototype,t),n&&ft(e,n),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.
|
|
229
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gt(e,t){return ut(e)||mt(e,t)||vt(e,t)||ht()}function _t(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function vt(e,t){if(e){if(typeof e==`string`)return lt(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 lt(e,t)}}var yt=Object.defineProperty,bt=function(e,t,n){return t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},xt=function(e,t){for(var n in t)yt(e,n,{get:t[n],enumerable:!0})},q=function(e,t,n){return bt(e,(t===void 0?`undefined`:_t(t))===`symbol`?t:t+``,n)},St=[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 Ct(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=65536+(r-55296<<10)+(i-56320),n++)}r>=55296&&r<=57343&&(r=65533),r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<65536?t.push(224|r>>12,128|r>>6&63,128|r&63):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return t}function wt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?Ct(e):e,r=!0,i=!1,a=void 0;try{for(var o=n[Symbol.iterator](),s;!(r=(s=o.next()).done);r=!0)t=St[(s.value^t>>8)&255]^t<<8}catch(e){i=!0,a=e}finally{try{!r&&o.return!=null&&o.return()}finally{if(i)throw a}}return(t^0)&65535}function Tt(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 Et(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=wt(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+=Et(e,n),e}function Dt(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 Ot(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 kt=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;dt(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 pt(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 Ot({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=gt(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 At(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`)}xt({},{ProxyType:function(){return Z},anyId:function(){return At},billPayment:function(){return Ot},botBarcode:function(){return jt},slipVerify:function(){return Mt},trueMoney:function(){return Pt},trueMoneySlipVerify:function(){return Ft}});function jt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new kt(t,n,r,i).toString()}function Mt(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 Pt(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 Ft(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 It(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 Lt(e){if(Array.isArray(e))return e}function Rt(e){if(Array.isArray(e))return It(e)}function zt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Bt(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 Vt(e,t,n){return t&&Bt(e.prototype,t),n&&Bt(e,n),e}function Ht(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ut(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Wt(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 Gt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
230
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kt(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
231
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qt(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){Ht(e,t,n[t])})}return e}function Jt(e,t){return Lt(e)||Wt(e,t)||Xt(e,t)||Gt()}function Yt(e){return Rt(e)||Ut(e)||Xt(e)||Kt()}function Xt(e,t){if(e){if(typeof e==`string`)return It(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 It(e,t)}}xt({},{anyId:function(){return $t},bcelOneProof:function(){return Qt},billPayment:function(){return en},slipVerify:function(){return tn},trueMoneySlipVerify:function(){return nn}});var Zt=function(){"use strict";function e(t,n){zt(this,e),q(this,`payload`),q(this,`tags`),this.payload=t,this.tags=n}return Vt(e,[{key:`getTag`,value:function(e,t){return Dt(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(Yt(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function Q(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Et(e.slice(0,-4)))return null;var r=Tt(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=Tt(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 Zt(e,r)}function Qt(e){var t=Q(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 $t(e){var t=Q(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=Jt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Jt(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 qt({type:o,target:c},u!==void 0&&{amount:u})}function en(e){var t=Q(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 qt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function tn(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=Q(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 nn(e){var t=Q(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 rn=/^QR[A-Z0-9]{6}TT /;function an(e){return e.getTagValue(`59`)===`PAYOO`||rn.test(e.getTagValue(`62`,`08`)??``)}function on(e){return e.getTagValue(`26`,`00`)===`A000000775`&&e.getTagValue(`38`,`00`)!==`A000000727`}function sn(e){if(e.getTagValue(`58`)===`VN`){if(an(e))return`payoo`;if(on(e))return`vnpay`}}const cn={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],bcvsdk:[],holdstation:[`VN`],gaian:[`PH`],mtpelerin:[],mock:[]};function ln(e){return e?e.getTagValue(`58`)??null:null}function un(e){let t=[];for(let[n,r]of Object.entries(cn))r.includes(e)&&t.push(n);return t}const dn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function fn(e){return dn.test(e)}const pn=[`SPC`,`BCD`];function mn(e){let t=e.indexOf(`
|
|
232
|
+
`);return t<=0?!1:pn.includes(e.slice(0,t).trimEnd())}function hn(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`?t.hostname===`bluecode.biz`||t.hostname.endsWith(`.bluecode.biz`):!1}function gn(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function _n(e,t){return!t||t.includes(e)}function vn(e,t){let n=[];try{let r=Q(e);if(r&&sn(r))return n;let i=ln(r);if(!i)return n;for(let e of un(i))_n(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function $(e,t){return _n(e,t)?[{provider:e,action:`resolve`}]:[]}function yn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(gn(n))return $(`mock`,t);if(mn(n))return $(`mtpelerin`,t);if(hn(n))return $(`bcvsdk`,t);let r=vn(n,t);return r.length>0?r:fn(n)?$(`aeon`,t):r}function bn(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 xn(e){return bn(e,`/sdk/signup`)}const Sn=`always`;function Cn(e,t,n=Sn){return!e||typeof e!=`string`||e.trim().length===0||ct(yn(e)).length===0?null:bn(t,`/resolve`,{data:e,navigateOnSubmit:n===Sn?void 0:n})}function wn({qrData:t,navigateOnSubmit:r,onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f,theme:p,themeMode:m}){let{sdk:h,hostProps:g}=Te(p,m),_=(0,e.useMemo)(()=>Cn(t,h.config.yodlUiBaseUrl,r),[t,h.config.yodlUiBaseUrl,r]);return _?(0,n.jsx)(it,{uri:_,...g,...i({onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f})}):null}function Tn({onStatusChange:t,onSignedUp:r,onError:a,onDismiss:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{sdk:m,hostProps:h}=Te(f,p),g=(0,e.useMemo)(()=>xn(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]);return(0,n.jsx)(it,{uri:g,...h,...i({onSignupStatusChange:t,onSignedUp:r,onError:a,onSignupDismissed:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d})})}function En(e){return(Array.isArray(e)?e:[e]).some(e=>ct(yn(e)).length>0)}function Dn(e){return typeof e==`string`}function On(e){return t=>t===void 0||e(t)}function kn(e){return e==null||typeof e==`string`||typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`}function An(e){if(!s(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function jn(e){return e==null||typeof e==`string`}const Mn={chainId:[e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,`a positive integer`],address:[o,`a 0x address`],decimals:[e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,`a non-negative integer`],name:[Dn,`a string`],symbol:[Dn,`a string`],logoURI:[On(Dn),`a string`],tags:[On(e=>Array.isArray(e)&&Array.from(e).every(Dn)),`an array of strings`],extensions:[On(e=>An(e)&&Object.values(e).every(kn)&&jn(e.coinGeckoId)&&jn(e.peggedTo)),`a plain object of strings, finite numbers, booleans and nulls, with a string coinGeckoId and peggedTo`]};function Nn(e){return Array.isArray(e)?Object.freeze(e.slice()):s(e)?Object.freeze({...e}):e}function Pn(e,t){if(!s(e))throw Error(`Yodl tokenlist[${t}] must be an object`);let n={};for(let[r,[i,a]]of Object.entries(Mn)){let o=e[r];if(!i(o))throw Error(`Yodl tokenlist[${t}].${r} must be ${a}`);o!==void 0&&(n[r]=Nn(o))}return Object.freeze(n)}function Fn(e){if(e!==void 0){if(!Array.isArray(e)||e.length===0)throw Error(`Yodl tokenlist must be an array of at least one token — omit it to use Yodl's token list`);return Object.freeze(Array.from(e,Pn))}}var In=class{config;constructor(e){let t=I(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);let r=Fn(e.tokenlist);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n],...r&&{tokenlist:r}}}};function Ln(e){return new In(e)}exports.YodlDashboard=st,exports.YodlPayment=wn,exports.YodlProvider=Se,exports.YodlSdk=In,exports.YodlSignup=Tn,exports.YodlUIError=ke,exports.YodlWebViewError=H,exports.createYodlSdk=Ln,exports.isPaymentQr=En;
|
package/dist/index.d.cts
CHANGED
|
@@ -64,8 +64,13 @@ interface YodlPaymentDetails {
|
|
|
64
64
|
};
|
|
65
65
|
raw?: unknown;
|
|
66
66
|
}
|
|
67
|
+
/** What a failure message carries; both fields are optional on the wire. */
|
|
68
|
+
interface YodlBridgeError {
|
|
69
|
+
message?: string;
|
|
70
|
+
code?: string | number;
|
|
71
|
+
}
|
|
67
72
|
//#endregion
|
|
68
|
-
//#region ../sdk-core/dist/index-
|
|
73
|
+
//#region ../sdk-core/dist/index-VrfsdpLV.d.mts
|
|
69
74
|
//#endregion
|
|
70
75
|
//#region src/evm/wallet-provider.d.ts
|
|
71
76
|
/**
|
|
@@ -94,7 +99,11 @@ interface EIP1193Provider {
|
|
|
94
99
|
}): Promise<unknown>;
|
|
95
100
|
}
|
|
96
101
|
//#endregion
|
|
97
|
-
//#region ../sdk-core/dist/
|
|
102
|
+
//#region ../sdk-core/dist/address-DvixT1-I.d.mts
|
|
103
|
+
/** viem's `Address`, spelled without importing viem. Assignable in both directions. */
|
|
104
|
+
type EvmAddress = `0x${string}`;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../sdk-core/dist/host-yT_7bLyu.d.mts
|
|
98
107
|
//#endregion
|
|
99
108
|
//#region src/theme/contract.d.ts
|
|
100
109
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -157,6 +166,20 @@ interface YodlTheme {
|
|
|
157
166
|
dark?: YodlThemeModeTokens | undefined;
|
|
158
167
|
images?: YodlThemeImageSets | undefined;
|
|
159
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* One entry of a host's token list: `@yodlpay/tokenlists`' `TokenInfo`, spelled
|
|
171
|
+
* with `EvmAddress` so these declarations need no viem. A `TokenInfo` is one.
|
|
172
|
+
*/
|
|
173
|
+
interface YodlTokenInfo {
|
|
174
|
+
chainId: number;
|
|
175
|
+
address: EvmAddress;
|
|
176
|
+
decimals: number;
|
|
177
|
+
name: string;
|
|
178
|
+
symbol: string;
|
|
179
|
+
logoURI?: string | undefined;
|
|
180
|
+
tags?: string[] | undefined;
|
|
181
|
+
extensions?: Record<string, string | number | boolean | null | undefined> | undefined;
|
|
182
|
+
}
|
|
160
183
|
//#endregion
|
|
161
184
|
//#region src/types.d.ts
|
|
162
185
|
type SupportedChainIds = number[];
|
|
@@ -319,8 +342,19 @@ interface YodlSdkConfig {
|
|
|
319
342
|
yodlUiBaseUrl?: string;
|
|
320
343
|
/** Chain IDs the host wallet can switch to. */
|
|
321
344
|
supportedChainIds: SupportedChainIds;
|
|
345
|
+
/**
|
|
346
|
+
* The tokens your users hold and pay with, as token list entries
|
|
347
|
+
* (`TokenInfo` from `@yodlpay/tokenlists`, or your own). The Yodl UI reads,
|
|
348
|
+
* shows and pays from these alone, including tokens Yodl's own list does not
|
|
349
|
+
* carry. Omit it to use Yodl's token list.
|
|
350
|
+
*/
|
|
351
|
+
tokenlist?: readonly YodlTokenInfo[];
|
|
322
352
|
}
|
|
323
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Config with defaults applied — what components read from the instance.
|
|
355
|
+
* `tokenlist` stays `readonly`, as it came in: it was checked entry by entry,
|
|
356
|
+
* and an entry pushed on later would reach the Yodl UI unchecked.
|
|
357
|
+
*/
|
|
324
358
|
type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
|
|
325
359
|
yodlUiBaseUrl: string;
|
|
326
360
|
};
|
|
@@ -369,4 +403,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
|
|
|
369
403
|
*/
|
|
370
404
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
371
405
|
//#endregion
|
|
372
|
-
|
|
406
|
+
//#region src/yodl-ui/errors.d.ts
|
|
407
|
+
/**
|
|
408
|
+
* A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
|
|
409
|
+
* `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
|
|
410
|
+
* what tells a host — and an error tracker, which titles an error by its name —
|
|
411
|
+
* that the Yodl UI raised it rather than the wallet.
|
|
412
|
+
*/
|
|
413
|
+
declare class YodlUIError extends Error {
|
|
414
|
+
readonly code?: string | number | undefined;
|
|
415
|
+
constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
|
|
416
|
+
}
|
|
417
|
+
/** Why the WebView under the Yodl UI failed. */
|
|
418
|
+
type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
|
|
419
|
+
/**
|
|
420
|
+
* The WebView under the Yodl UI failed, leaving the page in no state to report
|
|
421
|
+
* anything itself: it did not load (`load_failed`), its document answered an
|
|
422
|
+
* HTTP error (`http_error`), or the OS ended its web process
|
|
423
|
+
* (`process_terminated`).
|
|
424
|
+
*/
|
|
425
|
+
declare class YodlWebViewError extends Error {
|
|
426
|
+
readonly code: YodlWebViewErrorCode;
|
|
427
|
+
/** The page's URL without its query, which carries the scanned QR payload. */
|
|
428
|
+
readonly url?: string | undefined;
|
|
429
|
+
/** The HTTP status, for `http_error`. */
|
|
430
|
+
readonly status?: number | undefined;
|
|
431
|
+
constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, type YodlTokenInfo, YodlUIError, YodlWebViewError, type YodlWebViewErrorCode, createYodlSdk, isPaymentQr };
|
package/dist/index.d.mts
CHANGED
|
@@ -64,8 +64,13 @@ interface YodlPaymentDetails {
|
|
|
64
64
|
};
|
|
65
65
|
raw?: unknown;
|
|
66
66
|
}
|
|
67
|
+
/** What a failure message carries; both fields are optional on the wire. */
|
|
68
|
+
interface YodlBridgeError {
|
|
69
|
+
message?: string;
|
|
70
|
+
code?: string | number;
|
|
71
|
+
}
|
|
67
72
|
//#endregion
|
|
68
|
-
//#region ../sdk-core/dist/index-
|
|
73
|
+
//#region ../sdk-core/dist/index-VrfsdpLV.d.mts
|
|
69
74
|
//#endregion
|
|
70
75
|
//#region src/evm/wallet-provider.d.ts
|
|
71
76
|
/**
|
|
@@ -94,7 +99,11 @@ interface EIP1193Provider {
|
|
|
94
99
|
}): Promise<unknown>;
|
|
95
100
|
}
|
|
96
101
|
//#endregion
|
|
97
|
-
//#region ../sdk-core/dist/
|
|
102
|
+
//#region ../sdk-core/dist/address-DvixT1-I.d.mts
|
|
103
|
+
/** viem's `Address`, spelled without importing viem. Assignable in both directions. */
|
|
104
|
+
type EvmAddress = `0x${string}`;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../sdk-core/dist/host-yT_7bLyu.d.mts
|
|
98
107
|
//#endregion
|
|
99
108
|
//#region src/theme/contract.d.ts
|
|
100
109
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -157,6 +166,20 @@ interface YodlTheme {
|
|
|
157
166
|
dark?: YodlThemeModeTokens | undefined;
|
|
158
167
|
images?: YodlThemeImageSets | undefined;
|
|
159
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* One entry of a host's token list: `@yodlpay/tokenlists`' `TokenInfo`, spelled
|
|
171
|
+
* with `EvmAddress` so these declarations need no viem. A `TokenInfo` is one.
|
|
172
|
+
*/
|
|
173
|
+
interface YodlTokenInfo {
|
|
174
|
+
chainId: number;
|
|
175
|
+
address: EvmAddress;
|
|
176
|
+
decimals: number;
|
|
177
|
+
name: string;
|
|
178
|
+
symbol: string;
|
|
179
|
+
logoURI?: string | undefined;
|
|
180
|
+
tags?: string[] | undefined;
|
|
181
|
+
extensions?: Record<string, string | number | boolean | null | undefined> | undefined;
|
|
182
|
+
}
|
|
160
183
|
//#endregion
|
|
161
184
|
//#region src/types.d.ts
|
|
162
185
|
type SupportedChainIds = number[];
|
|
@@ -319,8 +342,19 @@ interface YodlSdkConfig {
|
|
|
319
342
|
yodlUiBaseUrl?: string;
|
|
320
343
|
/** Chain IDs the host wallet can switch to. */
|
|
321
344
|
supportedChainIds: SupportedChainIds;
|
|
345
|
+
/**
|
|
346
|
+
* The tokens your users hold and pay with, as token list entries
|
|
347
|
+
* (`TokenInfo` from `@yodlpay/tokenlists`, or your own). The Yodl UI reads,
|
|
348
|
+
* shows and pays from these alone, including tokens Yodl's own list does not
|
|
349
|
+
* carry. Omit it to use Yodl's token list.
|
|
350
|
+
*/
|
|
351
|
+
tokenlist?: readonly YodlTokenInfo[];
|
|
322
352
|
}
|
|
323
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Config with defaults applied — what components read from the instance.
|
|
355
|
+
* `tokenlist` stays `readonly`, as it came in: it was checked entry by entry,
|
|
356
|
+
* and an entry pushed on later would reach the Yodl UI unchecked.
|
|
357
|
+
*/
|
|
324
358
|
type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
|
|
325
359
|
yodlUiBaseUrl: string;
|
|
326
360
|
};
|
|
@@ -369,4 +403,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
|
|
|
369
403
|
*/
|
|
370
404
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
371
405
|
//#endregion
|
|
372
|
-
|
|
406
|
+
//#region src/yodl-ui/errors.d.ts
|
|
407
|
+
/**
|
|
408
|
+
* A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
|
|
409
|
+
* `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
|
|
410
|
+
* what tells a host — and an error tracker, which titles an error by its name —
|
|
411
|
+
* that the Yodl UI raised it rather than the wallet.
|
|
412
|
+
*/
|
|
413
|
+
declare class YodlUIError extends Error {
|
|
414
|
+
readonly code?: string | number | undefined;
|
|
415
|
+
constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
|
|
416
|
+
}
|
|
417
|
+
/** Why the WebView under the Yodl UI failed. */
|
|
418
|
+
type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
|
|
419
|
+
/**
|
|
420
|
+
* The WebView under the Yodl UI failed, leaving the page in no state to report
|
|
421
|
+
* anything itself: it did not load (`load_failed`), its document answered an
|
|
422
|
+
* HTTP error (`http_error`), or the OS ended its web process
|
|
423
|
+
* (`process_terminated`).
|
|
424
|
+
*/
|
|
425
|
+
declare class YodlWebViewError extends Error {
|
|
426
|
+
readonly code: YodlWebViewErrorCode;
|
|
427
|
+
/** The page's URL without its query, which carries the scanned QR payload. */
|
|
428
|
+
readonly url?: string | undefined;
|
|
429
|
+
/** The HTTP status, for `http_error`. */
|
|
430
|
+
readonly status?: number | undefined;
|
|
431
|
+
constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, type YodlTokenInfo, YodlUIError, YodlWebViewError, type YodlWebViewErrorCode, createYodlSdk, isPaymentQr };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";function h(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const g=/^0x[a-fA-F0-9]{40}$/;function _(e){return typeof e==`string`&&g.test(e)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function b(e){if(e===void 0)return!0;if(!v(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function ee(e){if(!v(e))return!1;switch(e.type){case`yodl_payment_details`:return v(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return b(e.error);case`yodl_signup_status`:return x(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return S(e);default:return!1}}function x(e){return typeof e==`string`&&y.has(e)}function S(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const C=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,w=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,T=/^https:\/\/[^\s"\\]+$/,E=[`system`,`inter`,`geist`,`mono`],D=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],O=[`payBackground`,`processing`,`loading`];function k(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function te(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function ne(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const A=new Set([`system`,`light`,`dark`]);function j(e){return typeof e==`string`&&A.has(e)}const M=new Set(E);function N(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of D){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!C.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(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of O){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!T.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function F(e){if(!v(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 I(e){if(!v(e))return{success:!1,error:`(root): expected an object`};let t=L(e);if(!t.success)return t;let n=R(e);if(!n.success)return n;let r=z(e);if(!r.success)return r;let i=B(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=F(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function L(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function R(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!M.has(e.font)?{success:!1,error:`font: must be one of ${[...M].join(`, `)}`}:{success:!0,data:{font:e.font}}}function z(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!w.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function B(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=N(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function V(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function H(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function U(e){if(!v(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!V(r,128))}const re=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function ie(e){if(!v(e)||!H(e,re))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!V(r,128)||!V(i,64)||!_(a))}const ae={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function oe(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function se(e){let t=I(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function ce(e){return e===void 0?{preference:`system`,error:null}:j(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function le(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:se(e),i=ce(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:oe(i.preference,n)},error:a.length>0?a.join(`; `):null}}function ue(e,t){let n=ae[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function de(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function fe(e,t){return JSON.stringify(k(e,t))}function pe(e,t,n,r){let{envelope:i,error:a}=le(e,t,n);return a&&r?.(a),i}function me(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=le(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function he(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ge=e(null);function _e({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>pe(i,o,c,he),[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(ge.Provider,{value:u,children:s})}function ve(){let e=n(ge);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function ye(e,t){let n=ve(),r=a(()=>me(n.hostTheme,e,t,n.systemScheme,he),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function be(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=ye(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function xe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!_(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function Se(e,t){return{"X-Yodl-Integration-Id":xe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function W(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 Ce(e){return e.code===4001||/rejected|denied/i.test(e.message)}const we=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],Te=[...we,`not supported`,`not available`];function Ee(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function De(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||Ee(e,we):Ee(e,Te)}function Oe(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function ke(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Ae={name:`@yodlpay/react-native`,version:`0.11.0`};function je(e){return Se(e,Ae)}function Me(e,t){let n=e.yodlUiBaseUrl?Oe(e.yodlUiBaseUrl):null;if(!(!n||!ke(t,n)))return je(e)}let Ne=0;function Pe(){return Ne+=1,`yodl-${Date.now().toString(36)}-${Ne.toString(36)}`}function Fe(e,t=Pe){return{sessionId:t(),initialHostTheme:e}}function G(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function Ie(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 Le(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>Ie(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Re(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function ze(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Be(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Re(t))return;let n=t.receipts;if(n?.length&&!n.some(ze))return n[n.length-1]?.transactionHash}function K(e){return`0x${e.toString(16)}`}function Ve(e,t=`unsupported`){let n={};for(let r of e)n[K(r)]={atomic:{status:t}};return n}function q(e){return e.toLowerCase()}function He(e,t){let n=q(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:K(t.chainId)}}:{}}}function Ue(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function We(e){return{state:e,decision:{kind:`ignore`}}}function Ge(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ke(e,t,n){return!ie(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?We(e):n.supported?q(t.address)===q(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ge(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}}:Ge(e,t.requestId,`address_mismatch`):Ge(e,t.requestId,`not_supported`)}function qe(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Je=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Ye(e){return Je.some(t=>t===e)}function Xe(e,t,n){if(!Ye(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=Ie((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=K(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Ze(e){let t=K(e.chainId);return`(function() {
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";function h(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}const g=/^0x[a-fA-F0-9]{40}$/;function _(e){return typeof e==`string`&&g.test(e)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const y=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function b(e){if(e===void 0)return!0;if(!v(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function ee(e){if(!v(e))return!1;switch(e.type){case`yodl_payment_details`:return v(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return b(e.error);case`yodl_signup_status`:return x(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return S(e);default:return!1}}function x(e){return typeof e==`string`&&y.has(e)}function S(e){return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params)}const te=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,C=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,w=/^https:\/\/[^\s"\\]+$/,T=[`system`,`inter`,`geist`,`mono`],E=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],D=[`payBackground`,`processing`,`loading`];function O(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{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function re(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const k=new Set([`system`,`light`,`dark`]);function A(e){return typeof e==`string`&&k.has(e)}const j=new Set(T);function M(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of E){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!te.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function N(e,t){if(!v(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of D){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!w.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function P(e){if(!v(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=N(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function F(e){if(!v(e))return{success:!1,error:`(root): expected an object`};let t=I(e);if(!t.success)return t;let n=L(e);if(!n.success)return n;let r=R(e);if(!r.success)return r;let i=z(e);if(!i.success)return i;let a={...t.data,...n.data,...r.data,...i.data};if(e.images!==void 0){let t=P(e.images);if(!t.success)return t;a.images=t.data}return{success:!0,data:a}}function I(e){return e.name===void 0?{success:!0,data:{}}:typeof e.name!=`string`||e.name.length>64?{success:!1,error:`name: must be a string of at most 64 characters`}:{success:!0,data:{name:e.name}}}function L(e){return e.font===void 0?{success:!0,data:{}}:typeof e.font!=`string`||!j.has(e.font)?{success:!1,error:`font: must be one of ${[...j].join(`, `)}`}:{success:!0,data:{font:e.font}}}function R(e){let t={};for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!C.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}return{success:!0,data:t}}function z(e){let t={};for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=M(e[n],n);if(!r.success)return r;t[n]=r.data}return{success:!0,data:t}}function B(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function V(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function H(e){if(!v(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!B(r,128))}const ie=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function U(e){if(!v(e)||!V(e,ie))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!B(r,128)||!B(i,64)||!_(a))}function ae(e){let[t=``]=e.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function oe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!_(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function se(e,t){return{"X-Yodl-Integration-Id":oe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function W(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 ce(e){return e.code===4001||/rejected|denied/i.test(e.message)}const le=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ue=[...le,`not supported`,`not available`];function de(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function fe(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||de(e,le):de(e,ue)}function pe(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function me(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const he={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function ge(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function _e(e){let t=F(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function ve(e){return e===void 0?{preference:`system`,error:null}:A(e)?{preference:e,error:null}:{preference:`system`,error:`Invalid Yodl themeMode — themeMode must be system, light or dark`}}function ye(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:_e(e),i=ve(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:ge(i.preference,n)},error:a.length>0?a.join(`; `):null}}function be(e,t){let n=he[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}const xe=/[\\"`\u0000-\u001f]|\$(?=\{)/g;function Se(e){return e.replace(xe,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function Ce(e){return typeof e==`string`?Se(e):Array.isArray(e)?e.map(Ce):v(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[Se(e),Ce(t)])):e}function we(e,t,n,r,i){return{yodl:Ce({version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{},...i?{tokenlist:i}:{}})}}function Te(e,t){return JSON.stringify(O(e,t))}function Ee(e,t,n,r){let{envelope:i,error:a}=ye(e,t,n);return a&&r?.(a),i}function De(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=ye(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function Oe(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ke=e(null);function Ae({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>Ee(i,o,c,Oe),[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(ke.Provider,{value:u,children:s})}function je(){let e=n(ke);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function Me(e,t){let n=je(),r=a(()=>De(n.hostTheme,e,t,n.systemScheme,Oe),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function Ne(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=Me(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}const Pe={name:`@yodlpay/react-native`,version:`0.13.0`};function Fe(e){return se(e,Pe)}function Ie(e,t){let n=e.yodlUiBaseUrl?pe(e.yodlUiBaseUrl):null;if(!(!n||!me(t,n)))return Fe(e)}var Le=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},G=class extends Error{code;url;status;constructor(e,t,n,r){super(t),this.name=`YodlWebViewError`,this.code=e,this.url=n===void 0?void 0:ae(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Re=0;function ze(){return Re+=1,`yodl-${Date.now().toString(36)}-${Re.toString(36)}`}function Be(e,t=ze){return{sessionId:t(),initialHostTheme:e}}function K(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function Ve(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 He(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>Ve(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Ue(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function We(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Ge(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Ue(t))return;let n=t.receipts;if(n?.length&&!n.some(We))return n[n.length-1]?.transactionHash}function q(e){return`0x${e.toString(16)}`}function Ke(e,t=`unsupported`){let n={};for(let r of e)n[q(r)]={atomic:{status:t}};return n}function qe(e){return e.toLowerCase()}function Je(e,t){let n=qe(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:q(t.chainId)}}:{}}}function Ye(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Xe(e){return{state:e,decision:{kind:`ignore`}}}function Ze(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Qe(e,t,n){return!U(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Xe(e):n.supported?qe(t.address)===qe(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ze(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}}:Ze(e,t.requestId,`address_mismatch`):Ze(e,t.requestId,`not_supported`)}function $e(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const et=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function tt(e){return et.some(t=>t===e)}function nt(e,t,n){if(!tt(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=Ve((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=q(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function rt(e){let t=q(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,8 @@ 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 Qe(e){return JSON.stringify(e)}function $e(e){return{state:e,message:null,readyAccepted:!1}}function et(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:fe(e.sessionId,e.currentTheme),readyAccepted:t}}function tt(e,t){let n=Qe(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function nt(e,t){let n=Qe(t);if(n===e.currentFingerprint)return $e(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?et(r,!1):$e(r)}function rt(e,t){return!U(t)||t.sessionId!==e.sessionId?$e(e):et({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function J(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 it(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function at(e){return v(e)&&`type`in e}function ot(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function st(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(q(s)),C=o(c),w=o(c),T=o(new Set),E=o(v),D=o(_?tt(_,y):null),O=o(_?Ue(_):null),k=o(b);i(()=>{E.current=v},[v]),i(()=>{k.current=b},[b]),i(()=>{D.current=_?tt(_,y):null},[y,_]),i(()=>{O.current=_?Ue(_):null},[_]);let A=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=He({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&&it(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&it(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!D.current)return;let e=nt(D.current,v);D.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let j=a(()=>Ze({address:s,chainId:c}),[s,c]),M=t(async(e,t,r)=>{try{let i=Xe(t,r,l);if(`error`in i){J(x,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),J(x,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,it(x,`chainChanged`,i.chainIdHex))}catch(t){let n=W(t,`Chain request failed`);J(x,e,void 0,G(n)),h?.(n)}},[n,l,h]),N=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>K(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});J(x,e,i)}catch(n){let r=W(n,`Capabilities unavailable`);if(!De(r)){J(x,e,void 0,G(r));return}J(x,e,Ve(Le(t,l),`unsupported`))}},[n,s,l]),P=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Be(r);i&&A(i),J(x,e,r)}catch(t){let n=W(t,`Failed to get call status`);J(x,e,void 0,G(n))}},[n,A]),F=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&A(i),J(x,e,i)}catch(t){let n=W(t,`Request failed`),r=Ce(n);J(x,e,void 0,r?{code:4001,message:n.message}:G(n)),r||h?.(n)}},[n,A,h]),I=t((e,t)=>{let n=O.current;n&&(O.current=qe(n,e),x.current?.postMessage(JSON.stringify(ne(n.sessionId,e,t))))},[]),L=t(async(e,t)=>{let n=k.current;if(!n){I(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)}O.current?.sessionId===e&&I(t.requestId,a)},[I]),R=t(e=>{let t=O.current;if(!t)return;let n=Ke(t,e,{walletAddress:S.current,supported:!!k.current});if(O.current=n.state,n.decision.kind===`reject`){I(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&L(t.sessionId,n.decision.request)},[L,I]),z=t((e,t,n)=>{Ye(t)?M(e,t,n):t===`wallet_getCapabilities`?N(e,n):t===`wallet_getCallsStatus`?P(e,n):F(e,t,n)},[M,N,P,F]),B=t(e=>{switch(e.type){case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(ot(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return}},[f,p,m,h]),V=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(ot(e.error,`Payment details error`));return;case`ethereum_rpc_request`:z(e.id,e.method,e.params);return;default:B(e)}},[z,B,d,h]),H=t(()=>{let e=O.current;e&&x.current?.postMessage(JSON.stringify(te(e.sessionId,!!k.current)))},[]),U=t(e=>{if(!D.current){g?.();return}let t=nt(D.current,E.current);D.current=t.state,t.message&&x.current?.postMessage(t.message);let n=rt(D.current,e);D.current=n.state,n.readyAccepted&&(n.message&&x.current?.postMessage(n.message),H(),g?.())},[H,g]);return{uiRef:x,injectedJavaScript:j,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(at(t)){if(t.type===`yodl_ready`){U(t);return}if(t.type===`yodl_email_attestation_request`){R(t);return}ee(t)&&V(t)}},[V,R,U])}}function ct(e){return f(lt,{...e},e.uri)}function lt({uri:e,sdkConfig:n,provider:l,address:d,chainId:g,supportedChainIds:_,onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,style:C,backgroundColor:w,hostTheme:T=null,fetchEmailAttestation:E,renderLoading:D,onReady:O,sharedCookiesEnabled:k=!0,thirdPartyCookiesEnabled:te=!0,onLoadStart:ne,...A}){let[j]=s(()=>Fe(T)),M=ue(T,w),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(O);i(()=>{L.current=O},[O]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:B,injectedJavaScript:V,onMessage:H}=st({provider:l,address:d,chainId:g,supportedChainIds:_,onReady:z,sessionId:j.sessionId,hostTheme:T,initialHostTheme:j.initialHostTheme,...h({onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,fetchEmailAttestation:E})}),U=a(()=>Oe(e),[e]),re=a(()=>{let t=Me(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),ie=a(()=>e=>!U||!e?.url?!1:ke(e.url,U)||e.url.startsWith(`about:`),[U]),ae=I?null:D?D():f(c,{color:M.spinner});return p(u,{style:[ut.container,{backgroundColor:N},C],children:[f(m,{ref:B,source:re,originWhitelist:U?[U]:[],onShouldStartLoadWithRequest:ie,javaScriptEnabled:!0,sharedCookiesEnabled:k,thirdPartyCookiesEnabled:te,injectedJavaScriptBeforeContentLoaded:V,injectedJavaScriptObject:de(j.sessionId,j.initialHostTheme,n.integrationAddress,E?{emailAttestation:!0}:void 0),onMessage:H,...ne!==void 0&&{onLoadStart:ne},style:[ut.ui,{backgroundColor:N}],...A}),ae&&f(u,{style:[ut.overlay,{backgroundColor:N}],children:ae})]})}const ut=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function dt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{sdk:d,hostProps:p}=be(l,u),m=a(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]);return f(ct,{uri:m,...p,...h({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c})})}function ft(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 pt(e){if(Array.isArray(e))return e}function mt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ht(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 gt(e,t,n){return t&&ht(e.prototype,t),n&&ht(e,n),e}function _t(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 vt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yt(e,t){return pt(e)||_t(e,t)||xt(e,t)||vt()}function bt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function xt(e,t){if(e){if(typeof e==`string`)return ft(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 ft(e,t)}}var St=Object.defineProperty,Ct=function(e,t,n){return t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},wt=function(e,t){for(var n in t)St(e,n,{get:t[n],enumerable:!0})},Y=function(e,t,n){return Ct(e,(t===void 0?`undefined`:bt(t))===`symbol`?t:t+``,n)},Tt=[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 Et(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=Tt[(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 Dt(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 X(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+=X(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 Ot(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Et(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Z(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Ot(e,n),e}function kt(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 Q(e,t){return{id:e,length:t.length,value:t}}function At(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Q(`00`,`A000000677010112`),Q(`01`,t),Q(`02`,r)];i&&o.push(Q(`03`,i));var s=[Q(`00`,`01`),Q(`01`,n?`12`:`11`),Q(`30`,X(o)),Q(`53`,`764`),Q(`58`,`TH`)];return n&&s.push(Q(`54`,Number(n).toFixed(2))),a&&s.push(Q(`62`,X([Q(`07`,a)]))),Z(X(s),`63`)}var jt=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;mt(this,e),Y(this,`billerId`),Y(this,`ref1`),Y(this,`ref2`),Y(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return gt(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 At({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=yt(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}(),Mt=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Mt||{});function Nt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=X([Q(`00`,`A000000677010111`),Q(Mt[t],n)]),a=[Q(`00`,`01`),Q(`01`,r?`12`:`11`),Q(`29`,i),Q(`53`,`764`),Q(`58`,`TH`)];return r&&a.push(Q(`54`,Number(r).toFixed(2))),Z(X(a),`63`)}wt({},{ProxyType:function(){return Mt},anyId:function(){return Nt},billPayment:function(){return At},botBarcode:function(){return Pt},slipVerify:function(){return Ft},trueMoney:function(){return Lt},trueMoneySlipVerify:function(){return Rt}});function Pt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new jt(t,n,r,i).toString()}function Ft(e){var t=e.sendingBank,n=e.transRef;return Z(X([Q(`00`,X([Q(`00`,`000001`),Q(`01`,t),Q(`02`,n)])),Q(`51`,`TH`)]),`91`)}function It(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Lt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=X([Q(`00`,`A000000677010111`),Q(`03`,`14000${t}`)]),a=[Q(`00`,`01`),Q(`01`,n?`12`:`11`),Q(`29`,i),Q(`53`,`764`),Q(`58`,`TH`)];return n&&a.push(Q(`54`,Number(n).toFixed(2))),r&&a.push(Q(`81`,It(r))),Z(X(a),`63`)}function Rt(e){var t=e.eventType,n=e.transactionId,r=e.date;return Z(X([Q(`00`,X([Q(`00`,`01`),Q(`01`,`01`),Q(`02`,t),Q(`03`,n),Q(`04`,r)]))]),`91`,!1)}function zt(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 Bt(e){if(Array.isArray(e))return e}function Vt(e){if(Array.isArray(e))return zt(e)}function Ht(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 Wt(e,t,n){return t&&Ut(e.prototype,t),n&&Ut(e,n),e}function Gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function qt(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 Jt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xt(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){Gt(e,t,n[t])})}return e}function Zt(e,t){return Bt(e)||qt(e,t)||$t(e,t)||Jt()}function Qt(e){return Vt(e)||Kt(e)||$t(e)||Yt()}function $t(e,t){if(e){if(typeof e==`string`)return zt(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 zt(e,t)}}wt({},{anyId:function(){return nn},bcelOneProof:function(){return tn},billPayment:function(){return rn},slipVerify:function(){return an},trueMoneySlipVerify:function(){return on}});var en=function(){function e(t,n){Ht(this,e),Y(this,`payload`),Y(this,`tags`),this.payload=t,this.tags=n}return Wt(e,[{key:`getTag`,value:function(e,t){return kt(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=Z(X(Qt(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Ot(e.slice(0,-4)))return null;var r=Dt(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=Dt(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 en(e,r)}function tn(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 nn(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(Mt).find(function(e){var n=Zt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Zt(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 Xt({type:o,target:c},u!==void 0&&{amount:u})}function rn(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 Xt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function an(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 on(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 sn={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function cn(e){return e?e.getTagValue(`58`)??null:null}function ln(e){let t=[];for(let[n,r]of Object.entries(sn))r.includes(e)&&t.push(n);return t}function un(e){return e.toLowerCase().startsWith(`upi://`)&&e.length>6}function dn(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function fn(e,t){return!t||t.includes(e)}function pn(e,t){let n=[];try{let r=cn($(e));if(!r)return n;for(let e of ln(r))fn(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function mn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(dn(n))return fn(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=pn(n,t);return r.length>0?r:un(n)&&fn(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function hn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function gn(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 _n(e){return gn(e,`/sdk/signup`)}const vn=`always`;function yn(e,t,n=vn){return!e||typeof e!=`string`||e.trim().length===0||hn(mn(e)).length===0?null:gn(t,`/resolve`,{data:e,navigateOnSubmit:n===vn?void 0:n})}function bn({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{sdk:m,hostProps:g}=be(d,p),_=a(()=>yn(e,m.config.yodlUiBaseUrl,t),[e,m.config.yodlUiBaseUrl,t]);return _?f(ct,{uri:_,...g,...h({onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})}):null}function xn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{sdk:p,hostProps:m}=be(u,d),g=a(()=>_n(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]);return f(ct,{uri:g,...m,...h({onSignupStatusChange:e,onSignedUp:t,onError:n,onSignupDismissed:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l})})}function Sn(e){return(Array.isArray(e)?e:[e]).some(e=>hn(mn(e)).length>0)}var Cn=class{config;constructor(e){let t=xe(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 wn(e){return new Cn(e)}export{dt as YodlDashboard,bn as YodlPayment,_e as YodlProvider,Cn as YodlSdk,xn as YodlSignup,wn as createYodlSdk,Sn as isPaymentQr};
|
|
228
|
+
true;`}function it(e){return JSON.stringify(e)}function at(e){return{state:e,message:null,readyAccepted:!1}}function ot(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:Te(e.sessionId,e.currentTheme),readyAccepted:t}}function st(e,t){let n=it(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function ct(e,t){let n=it(t);if(n===e.currentFingerprint)return at(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?ot(r,!1):at(r)}function lt(e,t){return!H(t)||t.sessionId!==e.sessionId?at(e):ot({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function J(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 ut(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function dt(e){return v(e)&&`type`in e}function ft(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(qe(s)),te=o(c),C=o(c),w=o(new Set),T=o(v),E=o(_?st(_,y):null),D=o(_?Ye(_):null),O=o(b);i(()=>{T.current=v},[v]),i(()=>{O.current=b},[b]),i(()=>{E.current=_?st(_,y):null},[y,_]),i(()=>{D.current=_?Ye(_):null},[_]);let k=t(e=>{w.current.has(e)||(w.current.add(e),u?.(e))},[u]);r(()=>{let e=Je({address:S.current,propChainId:te.current,activeChainId:C.current},{address:s,chainId:c});e&&(S.current=e.nextAddress,te.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&ut(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&ut(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!E.current)return;let e=ct(E.current,v);E.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let A=a(()=>rt({address:s,chainId:c}),[s,c]),j=t(async(e,t,r)=>{try{let i=nt(t,r,l);if(`error`in i){J(x,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),J(x,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,ut(x,`chainChanged`,i.chainIdHex))}catch(t){let n=W(t,`Chain request failed`);J(x,e,void 0,K(n)),h?.(n)}},[n,l,h]),M=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>q(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});J(x,e,i)}catch(n){let r=W(n,`Capabilities unavailable`);if(!fe(r)){J(x,e,void 0,K(r));return}J(x,e,Ke(He(t,l),`unsupported`))}},[n,s,l]),N=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Ge(r);i&&k(i),J(x,e,r)}catch(t){let n=W(t,`Failed to get call status`);J(x,e,void 0,K(n))}},[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),J(x,e,i)}catch(t){let n=W(t,`Request failed`),r=ce(n);J(x,e,void 0,r?{code:4001,message:n.message}:K(n)),r||h?.(n)}},[n,k,h]),F=t((e,t)=>{let n=D.current;n&&(D.current=$e(n,e),x.current?.postMessage(JSON.stringify(re(n.sessionId,e,t))))},[]),I=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]),L=t(e=>{let t=D.current;if(!t)return;let n=Qe(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`&&I(t.sessionId,n.decision.request)},[I,F]),R=t((e,t,n)=>{tt(t)?j(e,t,n):t===`wallet_getCapabilities`?M(e,n):t===`wallet_getCallsStatus`?N(e,n):P(e,t,n)},[j,M,N,P]),z=t(e=>{switch(e.type){case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(new Le(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return}},[f,p,m,h]),B=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(new Le(e.error,`Payment details error`));return;case`ethereum_rpc_request`:R(e.id,e.method,e.params);return;default:z(e)}},[R,z,d,h]),V=t(()=>{let e=D.current;e&&x.current?.postMessage(JSON.stringify(ne(e.sessionId,!!O.current)))},[]),H=t(e=>{if(!E.current){g?.();return}let t=ct(E.current,T.current);E.current=t.state,t.message&&x.current?.postMessage(t.message);let n=lt(E.current,e);E.current=n.state,n.readyAccepted&&(n.message&&x.current?.postMessage(n.message),V(),g?.())},[V,g]);return{uiRef:x,injectedJavaScript:A,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(dt(t)){if(t.type===`yodl_ready`){H(t);return}if(t.type===`yodl_email_attestation_request`){L(t);return}ee(t)&&B(t)}},[B,L,H])}}function pt(e){return f(mt,{...e},e.uri)}function mt({uri:e,sdkConfig:n,provider:l,address:d,chainId:g,supportedChainIds:_,onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,style:te,backgroundColor:C,hostTheme:w=null,fetchEmailAttestation:T,renderLoading:E,onReady:D,sharedCookiesEnabled:O=!0,thirdPartyCookiesEnabled:ne=!0,onLoadStart:re,...k}){let[A]=s(()=>Be(w)),j=be(w,C),M=j.background,[N,P]=s(null),F=N===A.sessionId,I=o(D);i(()=>{I.current=D},[D]);let L=o(!1),R=t(()=>{P(A.sessionId),!L.current&&(L.current=!0,I.current?.())},[A.sessionId]);r(()=>{if(F)return;let e=setTimeout(R,8e3);return()=>clearTimeout(e)},[R,F]);let{uiRef:z,injectedJavaScript:B,onMessage:V}=ft({provider:l,address:d,chainId:g,supportedChainIds:_,onReady:R,sessionId:A.sessionId,hostTheme:w,initialHostTheme:A.initialHostTheme,...h({onTransactionSent:v,onPaymentDetails:y,onSignupStatusChange:b,onSignedUp:ee,onSignupDismissed:x,onError:S,fetchEmailAttestation:T})}),H=!!T,ie=a(()=>we(A.sessionId,A.initialHostTheme,n.integrationAddress,H?{emailAttestation:!0}:void 0,n.tokenlist),[A,n.integrationAddress,n.tokenlist,H]),U=a(()=>pe(e),[e]),ae=a(()=>{let t=Ie(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),oe=a(()=>e=>!U||!e?.url?!1:me(e.url,U)||e.url.startsWith(`about:`),[U]),se=a(()=>{if(!S)return{};let t=e=>S(new G(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>S(new G(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>S(new G(`http_error`,`The Yodl UI answered HTTP ${e.statusCode}`,e.url,e.statusCode)),onRenderProcessGone:()=>t(e),onContentProcessDidTerminate:({nativeEvent:e})=>t(e.url)}},[S,e]),W=F?null:E?E():f(c,{color:j.spinner});return p(u,{style:[ht.container,{backgroundColor:M},te],children:[f(m,{ref:z,source:ae,originWhitelist:U?[U]:[],onShouldStartLoadWithRequest:oe,javaScriptEnabled:!0,sharedCookiesEnabled:O,thirdPartyCookiesEnabled:ne,injectedJavaScriptBeforeContentLoaded:B,injectedJavaScriptObject:ie,onMessage:V,...se,...re!==void 0&&{onLoadStart:re},style:[ht.ui,{backgroundColor:M}],...k}),W&&f(u,{style:[ht.overlay,{backgroundColor:M}],children:W})]})}const ht=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function gt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{sdk:d,hostProps:p}=Ne(l,u),m=a(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]);return f(pt,{uri:m,...p,...h({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c})})}function _t(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function vt(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 yt(e){if(Array.isArray(e))return 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){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.
|
|
229
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tt(e,t){return yt(e)||Ct(e,t)||Dt(e,t)||wt()}function Et(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function Dt(e,t){if(e){if(typeof e==`string`)return vt(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 vt(e,t)}}var Ot=Object.defineProperty,kt=function(e,t,n){return t in e?Ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},At=function(e,t){for(var n in t)Ot(e,n,{get:t[n],enumerable:!0})},Y=function(e,t,n){return kt(e,(t===void 0?`undefined`:Et(t))===`symbol`?t:t+``,n)},jt=[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 Mt(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=65536+(r-55296<<10)+(i-56320),n++)}r>=55296&&r<=57343&&(r=65533),r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<65536?t.push(224|r>>12,128|r>>6&63,128|r&63):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return t}function Nt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?Mt(e):e,r=!0,i=!1,a=void 0;try{for(var o=n[Symbol.iterator](),s;!(r=(s=o.next()).done);r=!0)t=jt[(s.value^t>>8)&255]^t<<8}catch(e){i=!0,a=e}finally{try{!r&&o.return!=null&&o.return()}finally{if(i)throw a}}return(t^0)&65535}function Pt(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 X(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+=X(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 Ft(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Nt(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Z(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Ft(e,n),e}function It(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 Q(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=[Q(`00`,`A000000677010112`),Q(`01`,t),Q(`02`,r)];i&&o.push(Q(`03`,i));var s=[Q(`00`,`01`),Q(`01`,n?`12`:`11`),Q(`30`,X(o)),Q(`53`,`764`),Q(`58`,`TH`)];return n&&s.push(Q(`54`,Number(n).toFixed(2))),a&&s.push(Q(`62`,X([Q(`07`,a)]))),Z(X(s),`63`)}var Rt=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;bt(this,e),Y(this,`billerId`),Y(this,`ref1`),Y(this,`ref2`),Y(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return St(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return 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=Tt(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}(),zt=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(zt||{});function Bt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=X([Q(`00`,`A000000677010111`),Q(zt[t],n)]),a=[Q(`00`,`01`),Q(`01`,r?`12`:`11`),Q(`29`,i),Q(`53`,`764`),Q(`58`,`TH`)];return r&&a.push(Q(`54`,Number(r).toFixed(2))),Z(X(a),`63`)}At({},{ProxyType:function(){return zt},anyId:function(){return Bt},billPayment:function(){return Lt},botBarcode:function(){return Vt},slipVerify:function(){return Ht},trueMoney:function(){return Wt},trueMoneySlipVerify:function(){return Gt}});function Vt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Rt(t,n,r,i).toString()}function Ht(e){var t=e.sendingBank,n=e.transRef;return Z(X([Q(`00`,X([Q(`00`,`000001`),Q(`01`,t),Q(`02`,n)])),Q(`51`,`TH`)]),`91`)}function Ut(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Wt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=X([Q(`00`,`A000000677010111`),Q(`03`,`14000${t}`)]),a=[Q(`00`,`01`),Q(`01`,n?`12`:`11`),Q(`29`,i),Q(`53`,`764`),Q(`58`,`TH`)];return n&&a.push(Q(`54`,Number(n).toFixed(2))),r&&a.push(Q(`81`,Ut(r))),Z(X(a),`63`)}function Gt(e){var t=e.eventType,n=e.transactionId,r=e.date;return Z(X([Q(`00`,X([Q(`00`,`01`),Q(`01`,`01`),Q(`02`,t),Q(`03`,n),Q(`04`,r)]))]),`91`,!1)}function Kt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function qt(e){if(Array.isArray(e))return e}function Jt(e){if(Array.isArray(e))return Kt(e)}function Yt(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 Zt(e,t,n){return t&&Xt(e.prototype,t),n&&Xt(e,n),e}function Qt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $t(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function en(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 tn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
230
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nn(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
231
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rn(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){Qt(e,t,n[t])})}return e}function an(e,t){return qt(e)||en(e,t)||sn(e,t)||tn()}function on(e){return Jt(e)||$t(e)||sn(e)||nn()}function sn(e,t){if(e){if(typeof e==`string`)return Kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kt(e,t)}}At({},{anyId:function(){return un},bcelOneProof:function(){return ln},billPayment:function(){return dn},slipVerify:function(){return fn},trueMoneySlipVerify:function(){return pn}});var cn=function(){function e(t,n){Yt(this,e),Y(this,`payload`),Y(this,`tags`),this.payload=t,this.tags=n}return Zt(e,[{key:`getTag`,value:function(e,t){return It(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=Z(X(on(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=Ft(e.slice(0,-4)))return null;var r=Pt(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=Pt(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 cn(e,r)}function ln(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 un(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(zt).find(function(e){var n=an(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=an(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 rn({type:o,target:c},u!==void 0&&{amount:u})}function dn(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 rn({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function fn(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 pn(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 mn=/^QR[A-Z0-9]{6}TT /;function hn(e){return e.getTagValue(`59`)===`PAYOO`||mn.test(e.getTagValue(`62`,`08`)??``)}function gn(e){return e.getTagValue(`26`,`00`)===`A000000775`&&e.getTagValue(`38`,`00`)!==`A000000727`}function _n(e){if(e.getTagValue(`58`)===`VN`){if(hn(e))return`payoo`;if(gn(e))return`vnpay`}}const vn={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],bcvsdk:[],holdstation:[`VN`],gaian:[`PH`],mtpelerin:[],mock:[]};function yn(e){return e?e.getTagValue(`58`)??null:null}function bn(e){let t=[];for(let[n,r]of Object.entries(vn))r.includes(e)&&t.push(n);return t}const xn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function Sn(e){return xn.test(e)}const Cn=[`SPC`,`BCD`];function wn(e){let t=e.indexOf(`
|
|
232
|
+
`);return t<=0?!1:Cn.includes(e.slice(0,t).trimEnd())}function Tn(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`?t.hostname===`bluecode.biz`||t.hostname.endsWith(`.bluecode.biz`):!1}function En(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function Dn(e,t){return!t||t.includes(e)}function On(e,t){let n=[];try{let r=$(e);if(r&&_n(r))return n;let i=yn(r);if(!i)return n;for(let e of bn(i))Dn(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function kn(e,t){return Dn(e,t)?[{provider:e,action:`resolve`}]:[]}function An(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(En(n))return kn(`mock`,t);if(wn(n))return kn(`mtpelerin`,t);if(Tn(n))return kn(`bcvsdk`,t);let r=On(n,t);return r.length>0?r:Sn(n)?kn(`aeon`,t):r}function jn(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 Mn(e){return jn(e,`/sdk/signup`)}const Nn=`always`;function Pn(e,t,n=Nn){return!e||typeof e!=`string`||e.trim().length===0||_t(An(e)).length===0?null:jn(t,`/resolve`,{data:e,navigateOnSubmit:n===Nn?void 0:n})}function Fn({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{sdk:m,hostProps:g}=Ne(d,p),_=a(()=>Pn(e,m.config.yodlUiBaseUrl,t),[e,m.config.yodlUiBaseUrl,t]);return _?f(pt,{uri:_,...g,...h({onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})}):null}function In({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{sdk:p,hostProps:m}=Ne(u,d),g=a(()=>Mn(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]);return f(pt,{uri:g,...m,...h({onSignupStatusChange:e,onSignedUp:t,onError:n,onSignupDismissed:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l})})}function Ln(e){return(Array.isArray(e)?e:[e]).some(e=>_t(An(e)).length>0)}function Rn(e){return typeof e==`string`}function zn(e){return t=>t===void 0||e(t)}function Bn(e){return e==null||typeof e==`string`||typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`}function Vn(e){if(!v(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Hn(e){return e==null||typeof e==`string`}const Un={chainId:[e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,`a positive integer`],address:[_,`a 0x address`],decimals:[e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,`a non-negative integer`],name:[Rn,`a string`],symbol:[Rn,`a string`],logoURI:[zn(Rn),`a string`],tags:[zn(e=>Array.isArray(e)&&Array.from(e).every(Rn)),`an array of strings`],extensions:[zn(e=>Vn(e)&&Object.values(e).every(Bn)&&Hn(e.coinGeckoId)&&Hn(e.peggedTo)),`a plain object of strings, finite numbers, booleans and nulls, with a string coinGeckoId and peggedTo`]};function Wn(e){return Array.isArray(e)?Object.freeze(e.slice()):v(e)?Object.freeze({...e}):e}function Gn(e,t){if(!v(e))throw Error(`Yodl tokenlist[${t}] must be an object`);let n={};for(let[r,[i,a]]of Object.entries(Un)){let o=e[r];if(!i(o))throw Error(`Yodl tokenlist[${t}].${r} must be ${a}`);o!==void 0&&(n[r]=Wn(o))}return Object.freeze(n)}function Kn(e){if(e!==void 0){if(!Array.isArray(e)||e.length===0)throw Error(`Yodl tokenlist must be an array of at least one token — omit it to use Yodl's token list`);return Object.freeze(Array.from(e,Gn))}}var qn=class{config;constructor(e){let t=oe(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);let r=Kn(e.tokenlist);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n],...r&&{tokenlist:r}}}};function Jn(e){return new qn(e)}export{gt as YodlDashboard,Fn as YodlPayment,Ae as YodlProvider,qn as YodlSdk,In as YodlSignup,Le as YodlUIError,G as YodlWebViewError,Jn as createYodlSdk,Ln as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"tsdown": "^0.22.14",
|
|
78
78
|
"typescript": "^5.9.0",
|
|
79
79
|
"vitest": "^4.1.11",
|
|
80
|
-
"@yodlpay/sdk-core": "0.
|
|
80
|
+
"@yodlpay/sdk-core": "0.29.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsdown",
|