@yodlpay/react-native 0.10.1 → 0.12.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 +17 -5
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +36 -3
- package/dist/index.d.mts +36 -3
- package/dist/index.mjs +5 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -474,7 +474,7 @@ Renders the hosted signup flow. Use this as a full-screen component inside `<Yod
|
|
|
474
474
|
| `onStatusChange` | `(status: 'checking' \| 'signed_out' \| 'signing_up' \| 'signed_up') => void` | No | Called when the hosted flow reports signup status |
|
|
475
475
|
| `onSignedUp` | `() => void` | No | Called when signup completes |
|
|
476
476
|
| `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
|
|
477
|
-
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or
|
|
477
|
+
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, RPC, or WebView errors. See [errors](#errors) |
|
|
478
478
|
|
|
479
479
|
### `<YodlPayment />`
|
|
480
480
|
|
|
@@ -486,9 +486,9 @@ Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is e
|
|
|
486
486
|
| `navigateOnSubmit` | `'always' \| 'never'` | No | Whether the hosted UI moves to its own status screen once the transaction is submitted. Defaults to `'always'` |
|
|
487
487
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
488
488
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
489
|
-
| `onError` | `(error: Error) => void` | No | Called on RPC
|
|
489
|
+
| `onError` | `(error: Error) => void` | No | Called on RPC, payment, or WebView errors. See [errors](#errors) |
|
|
490
490
|
|
|
491
|
-
`navigateOnSubmit="never"`
|
|
491
|
+
`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
492
|
|
|
493
493
|
### `<YodlDashboard />`
|
|
494
494
|
|
|
@@ -498,7 +498,7 @@ Renders the full Yodl account dashboard. Also accepts all [shared visual props](
|
|
|
498
498
|
| ------------------- | --------------------------------------- | -------- | -------------------------------------------------- |
|
|
499
499
|
| `onTransactionSent` | `(txHash: string) => void` | No | Called after a transaction is sent |
|
|
500
500
|
| `onPaymentDetails` | `(details: YodlPaymentDetails) => void` | No | Called with payment lifecycle details from the UI |
|
|
501
|
-
| `onError` | `(error: Error) => void` | No | Called on RPC errors
|
|
501
|
+
| `onError` | `(error: Error) => void` | No | Called on RPC or WebView errors. See [errors](#errors) |
|
|
502
502
|
|
|
503
503
|
### Loading and readiness
|
|
504
504
|
|
|
@@ -536,7 +536,17 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
|
|
|
536
536
|
|
|
537
537
|
`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
538
|
|
|
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.
|
|
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. A page that failed to load reaches `onError` as a `YodlWebViewError` (see [errors](#errors)); pair it with your own network handling.
|
|
540
|
+
|
|
541
|
+
### Errors
|
|
542
|
+
|
|
543
|
+
`onError` receives one of three kinds of error:
|
|
544
|
+
|
|
545
|
+
- A `YodlUIError` when the hosted UI reported a failure. `code` is the hosted UI's own code, when it sent one.
|
|
546
|
+
- 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.
|
|
547
|
+
- Your wallet's own error when a request to your EIP-1193 provider failed. A user rejection is not reported.
|
|
548
|
+
|
|
549
|
+
Both classes are exported from `@yodlpay/react-native`, and an error tracker titles them by name rather than as a plain `Error`.
|
|
540
550
|
|
|
541
551
|
### Payment details events
|
|
542
552
|
|
|
@@ -544,6 +554,8 @@ Until the hosted UI reports it has painted, the SDK covers the WebView with an o
|
|
|
544
554
|
|
|
545
555
|
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
556
|
|
|
557
|
+
`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.
|
|
558
|
+
|
|
547
559
|
## Security
|
|
548
560
|
|
|
549
561
|
`<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");const i=/^0x[a-fA-F0-9]{40}$/;function a(e){return typeof e==`string`&&i.test(e)}function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const s=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function c(e){if(e===void 0)return!0;if(!o(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 l(e){if(!o(e))return!1;switch(e.type){case`yodl_payment_details`:return o(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return c(e.error);case`yodl_signup_status`:return typeof e.status==`string`&&s.has(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params);default:return!1}}const u=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,d=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,f=/^https:\/\/[^\s"\\]+$/,p=[`system`,`inter`,`geist`,`mono`],m=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],h=[`payBackground`,`processing`,`loading`];function g(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function _(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function v(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const y=new Set([`system`,`light`,`dark`]);function b(e){return typeof e==`string`&&y.has(e)}const x=new Set(p);function S(e,t){if(!o(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of m){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!u.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function C(e,t){if(!o(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of h){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!f.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function w(e){if(!o(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=C(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function T(e){if(!o(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}if(e.font!==void 0){if(typeof e.font!=`string`||!x.has(e.font))return{success:!1,error:`font: must be one of ${[...x].join(`, `)}`};t.font=e.font}for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!d.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=S(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=w(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function E(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function D(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function O(e){if(!o(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!E(r,128))}const k=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function ee(e){if(!o(e)||!D(e,k))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:s}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!E(r,128)||!E(i,64)||!a(s))}const A={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function j(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function M(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:T(e),i=t===void 0||b(t),a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:j(a,n)},error:o.length>0?o.join(`; `):null}}function N(e,t){let n=A[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function P(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function F(e,t){return JSON.stringify(g(e,t))}function I(e,t,n,r){let{envelope:i,error:a}=M(e,t,n);return a&&r?.(a),i}function L(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=M(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function R(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const z=(0,e.createContext)(null);function te({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>I(s,c,u,R),[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)(z.Provider,{value:f,children:l})}function ne(){let t=(0,e.useContext)(z);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function B(t,n){let r=ne(),i=(0,e.useMemo)(()=>L(r.hostTheme,t,n,r.systemScheme,R),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function re(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!a(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function ie(e,t){return{"X-Yodl-Integration-Id":re(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function V(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 ae(e){return e.code===4001||/rejected|denied/i.test(e.message)}const oe=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],se=[...oe,`not supported`,`not available`];function ce(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function le(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||ce(e,oe):ce(e,se)}function ue(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function de(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const fe={name:`@yodlpay/react-native`,version:`0.10.1`};function pe(e){return ie(e,fe)}function me(e,t){let n=e.yodlUiBaseUrl?ue(e.yodlUiBaseUrl):null;if(!(!n||!de(t,n)))return pe(e)}let he=0;function ge(){return he+=1,`yodl-${Date.now().toString(36)}-${he.toString(36)}`}function _e(e,t=ge){return{sessionId:t(),initialHostTheme:e}}function H(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 ye(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 be(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function xe(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!be(t))return;let n=t.receipts;if(n?.length&&!n.some(xe))return n[n.length-1]?.transactionHash}function U(e){return`0x${e.toString(16)}`}function Ce(e,t=`unsupported`){let n={};for(let r of e)n[U(r)]={atomic:{status:t}};return n}function W(e){return e.toLowerCase()}function we(e,t){let n=W(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:U(t.chainId)}}:{}}}function Te(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Ee(e){return{state:e,decision:{kind:`ignore`}}}function G(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function De(e,t,n){return!ee(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Ee(e):n.supported?W(t.address)===W(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?G(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}}:G(e,t.requestId,`address_mismatch`):G(e,t.requestId,`not_supported`)}function Oe(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const ke=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Ae(e){return ke.some(t=>t===e)}function je(e,t,n){if(!Ae(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=U(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function Me(e){let t=U(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 b(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function ee(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 V(e,t){return JSON.stringify(y(e,t))}function ie(e,t,n,r){let{envelope:i,error:a}=B(e,t,n);return a&&r?.(a),i}function ae(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 oe(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const se=(0,e.createContext)(null);function ce({sdk:r,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>ie(s,c,u,oe),[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)(se.Provider,{value:f,children:l})}function le(){let t=(0,e.useContext)(se);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function ue(t,n){let r=le(),i=(0,e.useMemo)(()=>ae(r.hostTheme,t,n,r.systemScheme,oe),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function de(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=ue(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.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function pe(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 me(e,t){return{"X-Yodl-Integration-Id":pe(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 he(e){return e.code===4001||/rejected|denied/i.test(e.message)}const ge=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],_e=[...ge,`not supported`,`not available`];function ve(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ye(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||ve(e,ge):ve(e,_e)}function be(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function xe(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Se={name:`@yodlpay/react-native`,version:`0.12.0`};function Ce(e){return me(e,Se)}function we(e,t){let n=e.yodlUiBaseUrl?be(e.yodlUiBaseUrl):null;if(!(!n||!xe(t,n)))return Ce(e)}var Te=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},U=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:fe(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Ee=0;function De(){return Ee+=1,`yodl-${Date.now().toString(36)}-${Ee.toString(36)}`}function Oe(e,t=De){return{sessionId:t(),initialHostTheme:e}}function W(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function ke(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 Ae(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>ke(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function je(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Me(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Ne(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!je(t))return;let n=t.receipts;if(n?.length&&!n.some(Me))return n[n.length-1]?.transactionHash}function G(e){return`0x${e.toString(16)}`}function Pe(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function Fe(e,t){let n=K(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:G(t.chainId)}}:{}}}function Ie(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Le(e){return{state:e,decision:{kind:`ignore`}}}function Re(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function ze(e,t,n){return!F(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Le(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Re(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}}:Re(e,t.requestId,`address_mismatch`):Re(e,t.requestId,`not_supported`)}function Be(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Ve=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function He(e){return Ve.some(t=>t===e)}function Ue(e,t,n){if(!He(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=ke((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function We(e){let t=G(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,7 @@ 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 Ne(e){return JSON.stringify(e)}function K(e){return{state:e,message:null,readyAccepted:!1}}function Pe(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:F(e.sessionId,e.currentTheme),readyAccepted:t}}function Fe(e,t){let n=Ne(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Ie(e,t){let n=Ne(t);if(n===e.currentFingerprint)return K(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Pe(r,!1):K(r)}function Le(e,t){return!O(t)||t.sessionId!==e.sessionId?K(e):Pe({...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 Re(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ze(e){return o(e)&&`type`in e}function Be(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Ve(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:s,onSignupStatusChange:c,onSignedUp:u,onSignupDismissed:d,onError:f,onReady:p,sessionId:m,hostTheme:h=null,initialHostTheme:g=null,fetchEmailAttestation:y}=t,b=(0,e.useRef)(null),x=(0,e.useRef)(W(r)),S=(0,e.useRef)(i),C=(0,e.useRef)(i),w=(0,e.useRef)(new Set),T=(0,e.useRef)(h),E=(0,e.useRef)(m?Fe(m,g):null),D=(0,e.useRef)(m?Te(m):null),O=(0,e.useRef)(y);(0,e.useLayoutEffect)(()=>{T.current=h},[h]),(0,e.useLayoutEffect)(()=>{O.current=y},[y]),(0,e.useLayoutEffect)(()=>{E.current=m?Fe(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{D.current=m?Te(m):null},[m]);let k=(0,e.useCallback)(e=>{w.current.has(e)||(w.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=we({address:x.current,propChainId:S.current,activeChainId:C.current},{address:r,chainId:i});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&Re(b,`accountsChanged`,e.accountsChanged),e.chainChanged&&Re(b,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!E.current)return;let e=Ie(E.current,h);E.current=e.state,e.message&&b.current?.postMessage(e.message)},[h]);let ee=(0,e.useMemo)(()=>Me({address:r,chainId:i}),[r,i]),A=(0,e.useCallback)(async(e,t,r)=>{try{let i=je(t,r,a);if(`error`in i){q(b,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(b,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,Re(b,`chainChanged`,i.chainIdHex))}catch(t){let n=V(t,`Chain request failed`);q(b,e,void 0,H(n)),f?.(n)}},[n,a,f]),j=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>U(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});q(b,e,o)}catch(n){let r=V(n,`Capabilities unavailable`);if(!le(r)){q(b,e,void 0,H(r));return}q(b,e,Ce(ye(t,a),`unsupported`))}},[n,r,a]),M=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Se(r);i&&k(i),q(b,e,r)}catch(t){let n=V(t,`Failed to get call status`);q(b,e,void 0,H(n))}},[n,k]),N=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&k(i),q(b,e,i)}catch(t){let n=V(t,`Request failed`),r=ae(n);q(b,e,void 0,r?{code:4001,message:n.message}:H(n)),r||f?.(n)}},[n,k,f]),P=(0,e.useCallback)((e,t)=>{let n=D.current;n&&(D.current=Oe(n,e),b.current?.postMessage(JSON.stringify(v(n.sessionId,e,t))))},[]),F=(0,e.useCallback)(async(e,t)=>{let n=O.current;if(!n){P(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,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&&P(t.requestId,a)},[P]),I=(0,e.useCallback)(e=>{let t=D.current;if(!t)return;let n=De(t,e,{walletAddress:x.current,supported:!!O.current});if(D.current=n.state,n.decision.kind===`reject`){P(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&F(t.sessionId,n.decision.request)},[F,P]),L=(0,e.useCallback)(e=>{switch(e.type){case`yodl_payment_details`:s?.(e.details);return;case`yodl_payment_error`:f?.(Be(e.error,`Payment details error`));return;case`yodl_signup_status`:c?.(e.status);return;case`yodl_signup_complete`:u?.();return;case`yodl_signup_error`:f?.(Be(e.error,`Signup error`));return;case`yodl_signup_dismissed`:d?.();return;case`ethereum_rpc_request`:{let{id:t,method:n,params:r}=e;Ae(n)?A(t,n,r):n===`wallet_getCapabilities`?j(t,r):n===`wallet_getCallsStatus`?M(t,r):N(t,n,r);return}}},[A,j,M,N,s,c,u,d,f]);return{uiRef:b,injectedJavaScript:ee,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(ze(t)){if(t.type===`yodl_ready`){if(!E.current){p?.();return}let e=Ie(E.current,T.current);E.current=e.state,e.message&&b.current?.postMessage(e.message);let n=Le(E.current,t);if(E.current=n.state,!n.readyAccepted)return;n.message&&b.current?.postMessage(n.message);let r=D.current;r&&b.current?.postMessage(JSON.stringify(_(r.sessionId,!!O.current))),p?.();return}if(t.type===`yodl_email_attestation_request`){I(t);return}l(t)&&L(t)}},[L,I,p])}}function He(e){return(0,n.jsx)(Ue,{...e},e.uri)}function Ue({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,style:g,backgroundColor:_,hostTheme:v=null,fetchEmailAttestation:y,renderLoading:b,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...T}){let[E]=(0,e.useState)(()=>_e(v)),D=N(v,_),O=D.background,[k,ee]=(0,e.useState)(null),A=k===E.sessionId,j=(0,e.useRef)(x);(0,e.useLayoutEffect)(()=>{j.current=x},[x]);let M=(0,e.useRef)(!1),F=(0,e.useCallback)(()=>{ee(E.sessionId),!M.current&&(M.current=!0,j.current?.())},[E.sessionId]);(0,e.useEffect)(()=>{if(A)return;let e=setTimeout(F,8e3);return()=>clearTimeout(e)},[F,A]);let{uiRef:I,injectedJavaScript:L,onMessage:R}=Ve({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:F,sessionId:E.sessionId,hostTheme:v,initialHostTheme:E.initialHostTheme,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onSignupStatusChange:f},...p!==void 0&&{onSignedUp:p},...m!==void 0&&{onSignupDismissed:m},...h!==void 0&&{onError:h},...y!==void 0&&{fetchEmailAttestation:y}}),z=(0,e.useMemo)(()=>ue(i),[i]),te=(0,e.useMemo)(()=>{let e=me(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),ne=(0,e.useMemo)(()=>e=>!z||!e?.url?!1:de(e.url,z)||e.url.startsWith(`about:`),[z]),B=A?null:b?b():(0,n.jsx)(t.ActivityIndicator,{color:D.spinner});return(0,n.jsxs)(t.View,{style:[We.container,{backgroundColor:O},g],children:[(0,n.jsx)(r.WebView,{ref:I,source:te,originWhitelist:z?[z]:[],onShouldStartLoadWithRequest:ne,javaScriptEnabled:!0,sharedCookiesEnabled:S,thirdPartyCookiesEnabled:C,injectedJavaScriptBeforeContentLoaded:L,injectedJavaScriptObject:P(E.sessionId,E.initialHostTheme,a.integrationAddress),onMessage:R,...w!==void 0&&{onLoadStart:w},style:[We.ui,{backgroundColor:O}],...T}),B&&(0,n.jsx)(t.View,{style:[We.overlay,{backgroundColor:O}],children:B})]})}const We=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 Ge({onTransactionSent:t,onPaymentDetails:r,onError:i,fetchEmailAttestation:a,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:f,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=B(u,d),v=(0,e.useMemo)(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]);return(0,n.jsx)(He,{uri:v,sdkConfig:g.config,provider:f,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...t!==void 0&&{onTransactionSent:t},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{fetchEmailAttestation:a},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function Ke(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 qe(e){if(Array.isArray(e))return e}function Je(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ye(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 Xe(e,t,n){return t&&Ye(e.prototype,t),n&&Ye(e,n),e}function Ze(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Qe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $e(e,t){return qe(e)||Ze(e,t)||tt(e,t)||Qe()}function et(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function tt(e,t){if(e){if(typeof e==`string`)return Ke(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 Ke(e,t)}}var nt=Object.defineProperty,rt=function(e,t,n){return t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},it=function(e,t){for(var n in t)nt(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return rt(e,(t===void 0?`undefined`:et(t))===`symbol`?t:t+``,n)},at=[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 ot(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=at[(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 st(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 ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ot(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+=ct(e,n),e}function lt(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 ut(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 dt=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;Je(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 Xe(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 ut({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=$e(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 ft(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`)}it({},{ProxyType:function(){return Q},anyId:function(){return ft},billPayment:function(){return ut},botBarcode:function(){return pt},slipVerify:function(){return mt},trueMoney:function(){return gt},trueMoneySlipVerify:function(){return _t}});function pt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new dt(t,n,r,i).toString()}function mt(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 ht(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function gt(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`,ht(r))),X(Y(a),`63`)}function _t(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 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){if(Array.isArray(e))return vt(e)}function xt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function St(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 Ct(e,t,n){return t&&St(e.prototype,t),n&&St(e,n),e}function wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Et(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 Dt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kt(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){wt(e,t,n[t])})}return e}function At(e,t){return yt(e)||Et(e,t)||Mt(e,t)||Dt()}function jt(e){return bt(e)||Tt(e)||Mt(e)||Ot()}function Mt(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)}}it({},{anyId:function(){return Ft},bcelOneProof:function(){return Pt},billPayment:function(){return It},slipVerify:function(){return Lt},trueMoneySlipVerify:function(){return Rt}});var Nt=function(){"use strict";function e(t,n){xt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Ct(e,[{key:`getTag`,value:function(e,t){return lt(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(jt(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()!=ct(e.slice(0,-4)))return null;var r=st(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=st(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 Nt(e,r)}function Pt(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 Ft(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=At(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=At(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 kt({type:o,target:c},u!==void 0&&{amount:u})}function It(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 kt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Lt(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 Rt(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 zt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Bt(e){return e?e.getTagValue(`58`)??null:null}function Vt(e){let t=[];for(let[n,r]of Object.entries(zt))r.includes(e)&&t.push(n);return t}function Ht(e){return e.toLowerCase().startsWith(`upi://`)}function Ut(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim(),r=[];try{let e=Bt($(n));if(e){let n=Vt(e);for(let e of n)(!t||t.includes(e))&&r.push({provider:e,action:`resolve`});if(r.length>0)return r}}catch{}return Ht(n)&&(!t||t.includes(`aeon`))?[{provider:`aeon`,action:`resolve`}]:r}function Wt(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function Gt(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 Kt(e){return Gt(e,`/sdk/signup`)}const qt=`always`;function Jt(e,t,n=qt){return!e||typeof e!=`string`||e.trim().length===0||Wt(Ut(e)).length===0?null:Gt(t,`/resolve`,{data:e,navigateOnSubmit:n===qt?void 0:n})}function Yt({qrData:t,navigateOnSubmit:r,onTransactionSent:i,onPaymentDetails:a,onError:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d,theme:f,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=B(f,p),b=(0,e.useMemo)(()=>Jt(t,v.config.yodlUiBaseUrl,r),[t,v.config.yodlUiBaseUrl,r]);return b?(0,n.jsx)(He,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...i!==void 0&&{onTransactionSent:i},...a!==void 0&&{onPaymentDetails:a},...o!==void 0&&{onError:o},...s!==void 0&&{fetchEmailAttestation:s},...c!==void 0&&{renderLoading:c},...l!==void 0&&{onReady:l},...u!==void 0&&{style:u},...d!==void 0&&{backgroundColor:d}}):null}function Xt({onStatusChange:t,onSignedUp:r,onError:i,onDismiss:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:f}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=B(d,f),y=(0,e.useMemo)(()=>Kt(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]);return(0,n.jsx)(He,{uri:y,sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...t!==void 0&&{onSignupStatusChange:t},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{renderLoading:s},...c!==void 0&&{onReady:c},...l!==void 0&&{style:l},...u!==void 0&&{backgroundColor:u}})}function Zt(e){return(Array.isArray(e)?e:[e]).some(e=>Wt(Ut(e)).length>0)}var Qt=class{config;constructor(e){let t=re(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 $t(e){return new Qt(e)}exports.YodlDashboard=Ge,exports.YodlPayment=Yt,exports.YodlProvider=te,exports.YodlSdk=Qt,exports.YodlSignup=Xt,exports.createYodlSdk=$t,exports.isPaymentQr=Zt;
|
|
228
|
+
true;`}function Ge(e){return JSON.stringify(e)}function Ke(e){return{state:e,message:null,readyAccepted:!1}}function qe(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:V(e.sessionId,e.currentTheme),readyAccepted:t}}function Je(e,t){let n=Ge(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Ye(e,t){let n=Ge(t);if(n===e.currentFingerprint)return Ke(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?qe(r,!1):Ke(r)}function Xe(e,t){return!N(t)||t.sessionId!==e.sessionId?Ke(e):qe({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function Ze(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Qe(e){return s(e)&&`type`in e}function $e(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)(K(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?Je(m,g):null),E=(0,e.useRef)(m?Ie(m):null),D=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{w.current=h},[h]),(0,e.useLayoutEffect)(()=>{D.current=_},[_]),(0,e.useLayoutEffect)(()=>{T.current=m?Je(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{E.current=m?Ie(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=Fe({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&&Ze(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&Ze(v,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]),(0,e.useEffect)(()=>{if(!T.current)return;let e=Ye(T.current,h);T.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let te=(0,e.useMemo)(()=>We({address:r,chainId:i}),[r,i]),k=(0,e.useCallback)(async(e,t,r)=>{try{let i=Ue(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,Ze(v,`chainChanged`,i.chainIdHex))}catch(t){let n=H(t,`Chain request failed`);q(v,e,void 0,W(n)),f?.(n)}},[n,a,f]),A=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>G(e))],o=await n.request({method:`wallet_getCapabilities`,params:i});q(v,e,o)}catch(n){let r=H(n,`Capabilities unavailable`);if(!ye(r)){q(v,e,void 0,W(r));return}q(v,e,Pe(Ae(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=Ne(r);i&&O(i),q(v,e,r)}catch(t){let n=H(t,`Failed to get call status`);q(v,e,void 0,W(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=he(n);q(v,e,void 0,r?{code:4001,message:n.message}:W(n)),r||f?.(n)}},[n,O,f]),N=(0,e.useCallback)((e,t)=>{let n=E.current;n&&(E.current=Be(n,e),v.current?.postMessage(JSON.stringify(ee(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=ze(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)=>{He(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?.(new Te(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?.(new Te(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(b(e.sessionId,!!D.current)))},[]),B=(0,e.useCallback)(e=>{if(!T.current){p?.();return}let t=Ye(T.current,w.current);T.current=t.state,t.message&&v.current?.postMessage(t.message);let n=Xe(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(Qe(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 et(e){return(0,n.jsx)(tt,{...e},e.uri)}function tt({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:b,renderLoading:ee,onReady:x,sharedCookiesEnabled:S=!0,thirdPartyCookiesEnabled:C=!0,onLoadStart:w,...T}){let[E]=(0,e.useState)(()=>Oe(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}=$e({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:b})}),L=(0,e.useMemo)(()=>be(a),[a]),R=(0,e.useMemo)(()=>{let e=we(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),z=(0,e.useMemo)(()=>e=>!L||!e?.url?!1:xe(e.url,L)||e.url.startsWith(`about:`),[L]),B=(0,e.useMemo)(()=>{if(!g)return{};let e=e=>g(new U(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>g(new U(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>g(new U(`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=A?null:ee?ee():(0,n.jsx)(t.ActivityIndicator,{color:D.spinner});return(0,n.jsxs)(t.View,{style:[nt.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,b?{emailAttestation:!0}:void 0),onMessage:I,...B,...w!==void 0&&{onLoadStart:w},style:[nt.ui,{backgroundColor:O}],...T}),V&&(0,n.jsx)(t.View,{style:[nt.overlay,{backgroundColor:O}],children:V})]})}const nt=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 rt({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}=de(d,f),h=(0,e.useMemo)(()=>p.config.yodlUiBaseUrl.replace(/\/$/,``),[p.config.yodlUiBaseUrl]);return(0,n.jsx)(et,{uri:h,...m,...i({onTransactionSent:t,onPaymentDetails:r,onError:a,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})})}function it(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function at(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 ot(e){if(Array.isArray(e))return e}function st(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ct(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function lt(e,t,n){return t&&ct(e.prototype,t),n&&ct(e,n),e}function ut(e,t){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 dt(){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 ft(e,t){return ot(e)||ut(e,t)||mt(e,t)||dt()}function pt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function mt(e,t){if(e){if(typeof e==`string`)return at(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 at(e,t)}}var ht=Object.defineProperty,gt=function(e,t,n){return t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},_t=function(e,t){for(var n in t)ht(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return gt(e,(t===void 0?`undefined`:pt(t))===`symbol`?t:t+``,n)},vt=[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 yt(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 bt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?yt(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=vt[(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 xt(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function Y(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=Y(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function St(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=bt(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=St(e,n),e}function Ct(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Z(e,t){return{id:e,length:t.length,value:t}}function wt(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 Tt=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;st(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 lt(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 wt({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=ft(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function Et(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}_t({},{ProxyType:function(){return Q},anyId:function(){return Et},billPayment:function(){return wt},botBarcode:function(){return Dt},slipVerify:function(){return Ot},trueMoney:function(){return At},trueMoneySlipVerify:function(){return jt}});function Dt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Tt(t,n,r,i).toString()}function Ot(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 kt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function At(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`,kt(r))),X(Y(a),`63`)}function jt(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 Mt(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 Nt(e){if(Array.isArray(e))return e}function Pt(e){if(Array.isArray(e))return Mt(e)}function Ft(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function It(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Lt(e,t,n){return t&&It(e.prototype,t),n&&It(e,n),e}function Rt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Bt(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.
|
|
230
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ht(){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 Ut(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){Rt(e,t,n[t])})}return e}function Wt(e,t){return Nt(e)||Bt(e,t)||Kt(e,t)||Vt()}function Gt(e){return Pt(e)||zt(e)||Kt(e)||Ht()}function Kt(e,t){if(e){if(typeof e==`string`)return Mt(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 Mt(e,t)}}_t({},{anyId:function(){return Yt},bcelOneProof:function(){return Jt},billPayment:function(){return Xt},slipVerify:function(){return Zt},trueMoneySlipVerify:function(){return Qt}});var qt=function(){"use strict";function e(t,n){Ft(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Lt(e,[{key:`getTag`,value:function(e,t){return Ct(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=X(Y(Gt(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()!=St(e.slice(0,-4)))return null;var r=xt(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=xt(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 qt(e,r)}function Jt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Yt(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=Wt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Wt(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 Ut({type:o,target:c},u!==void 0&&{amount:u})}function Xt(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 Ut({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Zt(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 Qt(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 $t={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function en(e){return e?e.getTagValue(`58`)??null:null}function tn(e){let t=[];for(let[n,r]of Object.entries($t))r.includes(e)&&t.push(n);return t}const nn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function rn(e){return nn.test(e)}function an(e){return e.startsWith(`YODLMOCK1:`)&&e.length>10}function on(e,t){return!t||t.includes(e)}function sn(e,t){let n=[];try{let r=en($(e));if(!r)return n;for(let e of tn(r))on(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function cn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(an(n))return on(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=sn(n,t);return r.length>0?r:rn(n)&&on(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]:r}function ln(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 un(e){return ln(e,`/sdk/signup`)}const dn=`always`;function fn(e,t,n=dn){return!e||typeof e!=`string`||e.trim().length===0||it(cn(e)).length===0?null:ln(t,`/resolve`,{data:e,navigateOnSubmit:n===dn?void 0:n})}function pn({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}=de(p,m),_=(0,e.useMemo)(()=>fn(t,h.config.yodlUiBaseUrl,r),[t,h.config.yodlUiBaseUrl,r]);return _?(0,n.jsx)(et,{uri:_,...g,...i({onTransactionSent:a,onPaymentDetails:o,onError:s,fetchEmailAttestation:c,renderLoading:l,onReady:u,style:d,backgroundColor:f})}):null}function mn({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}=de(f,p),g=(0,e.useMemo)(()=>un(m.config.yodlUiBaseUrl),[m.config.yodlUiBaseUrl]);return(0,n.jsx)(et,{uri:g,...h,...i({onSignupStatusChange:t,onSignedUp:r,onError:a,onSignupDismissed:o,fetchEmailAttestation:s,renderLoading:c,onReady:l,style:u,backgroundColor:d})})}function hn(e){return(Array.isArray(e)?e:[e]).some(e=>it(cn(e)).length>0)}var gn=class{config;constructor(e){let t=pe(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 _n(e){return new gn(e)}exports.YodlDashboard=rt,exports.YodlPayment=pn,exports.YodlProvider=ce,exports.YodlSdk=gn,exports.YodlSignup=mn,exports.YodlUIError=Te,exports.YodlWebViewError=U,exports.createYodlSdk=_n,exports.isPaymentQr=hn;
|
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-D5Dst92E.d.mts
|
|
69
74
|
//#endregion
|
|
70
75
|
//#region src/evm/wallet-provider.d.ts
|
|
71
76
|
/**
|
|
@@ -94,7 +99,7 @@ interface EIP1193Provider {
|
|
|
94
99
|
}): Promise<unknown>;
|
|
95
100
|
}
|
|
96
101
|
//#endregion
|
|
97
|
-
//#region ../sdk-core/dist/host-
|
|
102
|
+
//#region ../sdk-core/dist/host-ZrxGIHTY.d.mts
|
|
98
103
|
//#endregion
|
|
99
104
|
//#region src/theme/contract.d.ts
|
|
100
105
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -369,4 +374,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
|
|
|
369
374
|
*/
|
|
370
375
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
371
376
|
//#endregion
|
|
372
|
-
|
|
377
|
+
//#region src/yodl-ui/errors.d.ts
|
|
378
|
+
/**
|
|
379
|
+
* A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
|
|
380
|
+
* `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
|
|
381
|
+
* what tells a host — and an error tracker, which titles an error by its name —
|
|
382
|
+
* that the Yodl UI raised it rather than the wallet.
|
|
383
|
+
*/
|
|
384
|
+
declare class YodlUIError extends Error {
|
|
385
|
+
readonly code?: string | number | undefined;
|
|
386
|
+
constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
|
|
387
|
+
}
|
|
388
|
+
/** Why the WebView under the Yodl UI failed. */
|
|
389
|
+
type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
|
|
390
|
+
/**
|
|
391
|
+
* The WebView under the Yodl UI failed, leaving the page in no state to report
|
|
392
|
+
* anything itself: it did not load (`load_failed`), its document answered an
|
|
393
|
+
* HTTP error (`http_error`), or the OS ended its web process
|
|
394
|
+
* (`process_terminated`).
|
|
395
|
+
*/
|
|
396
|
+
declare class YodlWebViewError extends Error {
|
|
397
|
+
readonly code: YodlWebViewErrorCode;
|
|
398
|
+
/** The page's URL without its query, which carries the scanned QR payload. */
|
|
399
|
+
readonly url?: string | undefined;
|
|
400
|
+
/** The HTTP status, for `http_error`. */
|
|
401
|
+
readonly status?: number | undefined;
|
|
402
|
+
constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
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, 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-D5Dst92E.d.mts
|
|
69
74
|
//#endregion
|
|
70
75
|
//#region src/evm/wallet-provider.d.ts
|
|
71
76
|
/**
|
|
@@ -94,7 +99,7 @@ interface EIP1193Provider {
|
|
|
94
99
|
}): Promise<unknown>;
|
|
95
100
|
}
|
|
96
101
|
//#endregion
|
|
97
|
-
//#region ../sdk-core/dist/host-
|
|
102
|
+
//#region ../sdk-core/dist/host-ZrxGIHTY.d.mts
|
|
98
103
|
//#endregion
|
|
99
104
|
//#region src/theme/contract.d.ts
|
|
100
105
|
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
@@ -369,4 +374,32 @@ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMod
|
|
|
369
374
|
*/
|
|
370
375
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
371
376
|
//#endregion
|
|
372
|
-
|
|
377
|
+
//#region src/yodl-ui/errors.d.ts
|
|
378
|
+
/**
|
|
379
|
+
* A failure the Yodl UI reported over the bridge (`yodl_payment_error`,
|
|
380
|
+
* `yodl_signup_error`). `code` is the page's own, as it sent it; the class is
|
|
381
|
+
* what tells a host — and an error tracker, which titles an error by its name —
|
|
382
|
+
* that the Yodl UI raised it rather than the wallet.
|
|
383
|
+
*/
|
|
384
|
+
declare class YodlUIError extends Error {
|
|
385
|
+
readonly code?: string | number | undefined;
|
|
386
|
+
constructor(error: YodlBridgeError | undefined, fallbackMessage: string);
|
|
387
|
+
}
|
|
388
|
+
/** Why the WebView under the Yodl UI failed. */
|
|
389
|
+
type YodlWebViewErrorCode = 'load_failed' | 'http_error' | 'process_terminated';
|
|
390
|
+
/**
|
|
391
|
+
* The WebView under the Yodl UI failed, leaving the page in no state to report
|
|
392
|
+
* anything itself: it did not load (`load_failed`), its document answered an
|
|
393
|
+
* HTTP error (`http_error`), or the OS ended its web process
|
|
394
|
+
* (`process_terminated`).
|
|
395
|
+
*/
|
|
396
|
+
declare class YodlWebViewError extends Error {
|
|
397
|
+
readonly code: YodlWebViewErrorCode;
|
|
398
|
+
/** The page's URL without its query, which carries the scanned QR payload. */
|
|
399
|
+
readonly url?: string | undefined;
|
|
400
|
+
/** The HTTP status, for `http_error`. */
|
|
401
|
+
readonly status?: number | undefined;
|
|
402
|
+
constructor(code: YodlWebViewErrorCode, message: string, url?: string, status?: number);
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
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, 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";const h=/^0x[a-fA-F0-9]{40}$/;function g(e){return typeof e==`string`&&h.test(e)}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const v=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function y(e){if(e===void 0)return!0;if(!_(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function b(e){if(!_(e))return!1;switch(e.type){case`yodl_payment_details`:return _(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return y(e.error);case`yodl_signup_status`:return typeof e.status==`string`&&v.has(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params);default:return!1}}const x=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,S=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,C=/^https:\/\/[^\s"\\]+$/,ee=[`system`,`inter`,`geist`,`mono`],w=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],T=[`payBackground`,`processing`,`loading`];function E(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function D(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function te(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const O=new Set([`system`,`light`,`dark`]);function k(e){return typeof e==`string`&&O.has(e)}const A=new Set(ee);function j(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of w){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!x.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function M(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of T){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!C.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function N(e){if(!_(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=M(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function P(e){if(!_(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}if(e.font!==void 0){if(typeof e.font!=`string`||!A.has(e.font))return{success:!1,error:`font: must be one of ${[...A].join(`, `)}`};t.font=e.font}for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!S.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=j(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=N(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function F(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function I(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function L(e){if(!_(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!F(r,128))}const R=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function z(e){if(!_(e)||!I(e,R))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!F(r,128)||!F(i,64)||!g(a))}const B={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function ne(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function re(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:P(e),i=t===void 0||k(t),a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:ne(a,n)},error:o.length>0?o.join(`; `):null}}function ie(e,t){let n=B[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function ae(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function V(e,t){return JSON.stringify(E(e,t))}function oe(e,t,n,r){let{envelope:i,error:a}=re(e,t,n);return a&&r?.(a),i}function se(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=re(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function H(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ce=e(null);function le({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>oe(i,o,c,H),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(ce.Provider,{value:u,children:s})}function ue(){let e=n(ce);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function de(e,t){let n=ue(),r=a(()=>se(n.hostTheme,e,t,n.systemScheme,H),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function fe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!g(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function pe(e,t){return{"X-Yodl-Integration-Id":fe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function U(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function me(e){return e.code===4001||/rejected|denied/i.test(e.message)}const he=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ge=[...he,`not supported`,`not available`];function _e(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ve(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||_e(e,he):_e(e,ge)}function ye(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function be(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const xe={name:`@yodlpay/react-native`,version:`0.10.1`};function Se(e){return pe(e,xe)}function Ce(e,t){let n=e.yodlUiBaseUrl?ye(e.yodlUiBaseUrl):null;if(!(!n||!be(t,n)))return Se(e)}let we=0;function Te(){return we+=1,`yodl-${Date.now().toString(36)}-${we.toString(36)}`}function Ee(e,t=Te){return{sessionId:t(),initialHostTheme:e}}function W(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function De(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function Oe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>De(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function G(e){return`0x${e.toString(16)}`}function Me(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function Ne(e,t){let n=K(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:G(t.chainId)}}:{}}}function Pe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Fe(e){return{state:e,decision:{kind:`ignore`}}}function Ie(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Le(e,t,n){return!z(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Fe(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ie(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Ie(e,t.requestId,`address_mismatch`):Ie(e,t.requestId,`not_supported`)}function Re(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const ze=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Be(e){return ze.some(t=>t===e)}function Ve(e,t,n){if(!Be(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=De((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function He(e){let t=G(e.chainId);return`(function() {
|
|
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=re(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 re(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 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 ae(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))}const oe={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function se(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function ce(e){let t=I(e);return t.success?{theme:t.data,error:null}:{theme:null,error:`Invalid Yodl theme — ${t.error}`}}function le(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 ue(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?{theme:null,error:null}:ce(e),i=le(t),a=[r.error,i.error].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r.theme,preference:i.preference,resolved:se(i.preference,n)},error:a.length>0?a.join(`; `):null}}function de(e,t){let n=oe[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function fe(e,t,n,r){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{},...r?{authCapabilities:r}:{}}}}function pe(e,t){return JSON.stringify(k(e,t))}function me(e,t,n,r){let{envelope:i,error:a}=ue(e,t,n);return a&&r?.(a),i}function he(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=ue(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function ge(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const _e=e(null);function ve({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>me(i,o,c,ge),[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(_e.Provider,{value:u,children:s})}function ye(){let e=n(_e);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function be(e,t){let n=ye(),r=a(()=>he(n.hostTheme,e,t,n.systemScheme,ge),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function xe(e,t){let{provider:n,address:r,chainId:i,supportedChainIds:a,sdk:o,hostTheme:s}=be(e,t);return{sdk:o,hostProps:{sdkConfig:o.config,provider:n,address:r,chainId:i,supportedChainIds:a,hostTheme:s}}}function Se(e){let[t=``]=e.split(/[?#]/,1);return t.replace(/^([a-z][a-z\d+.-]*:\/\/)[^/]*@/i,`$1`)}function Ce(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 we(e,t){return{"X-Yodl-Integration-Id":Ce(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function U(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function Te(e){return e.code===4001||/rejected|denied/i.test(e.message)}const Ee=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],De=[...Ee,`not supported`,`not available`];function Oe(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ke(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||Oe(e,Ee):Oe(e,De)}function Ae(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function je(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const Me={name:`@yodlpay/react-native`,version:`0.12.0`};function Ne(e){return we(e,Me)}function Pe(e,t){let n=e.yodlUiBaseUrl?Ae(e.yodlUiBaseUrl):null;if(!(!n||!je(t,n)))return Ne(e)}var Fe=class extends Error{code;constructor(e,t){super(e?.message??t),this.name=`YodlUIError`,this.code=e?.code,Object.setPrototypeOf(this,new.target.prototype)}},W=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:Se(n),this.status=r,Object.setPrototypeOf(this,new.target.prototype)}};let Ie=0;function Le(){return Ie+=1,`yodl-${Date.now().toString(36)}-${Ie.toString(36)}`}function Re(e,t=Le){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 ze(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 Be(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>ze(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function Ve(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function He(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function Ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Ve(t))return;let n=t.receipts;if(n?.length&&!n.some(He))return n[n.length-1]?.transactionHash}function K(e){return`0x${e.toString(16)}`}function We(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 Ge(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 Ke(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function qe(e){return{state:e,decision:{kind:`ignore`}}}function Je(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Ye(e,t,n){return!ae(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?qe(e):n.supported?q(t.address)===q(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Je(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}}:Je(e,t.requestId,`address_mismatch`):Je(e,t.requestId,`not_supported`)}function Xe(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const Ze=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Qe(e){return Ze.some(t=>t===e)}function $e(e,t,n){if(!Qe(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=ze((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 et(e){let t=K(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,7 @@ 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 Ue(e){return JSON.stringify(e)}function We(e){return{state:e,message:null,readyAccepted:!1}}function Ge(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:V(e.sessionId,e.currentTheme),readyAccepted:t}}function Ke(e,t){let n=Ue(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function qe(e,t){let n=Ue(t);if(n===e.currentFingerprint)return We(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Ge(r,!1):We(r)}function Je(e,t){return!L(t)||t.sessionId!==e.sessionId?We(e):Ge({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function Ye(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Xe(e){return _(e)&&`type`in e}function Ze(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Qe(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null,fetchEmailAttestation:x}=e,S=o(null),C=o(K(s)),ee=o(c),w=o(c),T=o(new Set),E=o(v),O=o(_?Ke(_,y):null),k=o(_?Pe(_):null),A=o(x);i(()=>{E.current=v},[v]),i(()=>{A.current=x},[x]),i(()=>{O.current=_?Ke(_,y):null},[y,_]),i(()=>{k.current=_?Pe(_):null},[_]);let j=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=Ne({address:C.current,propChainId:ee.current,activeChainId:w.current},{address:s,chainId:c});e&&(C.current=e.nextAddress,ee.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&Ye(S,`accountsChanged`,e.accountsChanged),e.chainChanged&&Ye(S,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!O.current)return;let e=qe(O.current,v);O.current=e.state,e.message&&S.current?.postMessage(e.message)},[v]);let M=a(()=>He({address:s,chainId:c}),[s,c]),N=t(async(e,t,r)=>{try{let i=Ve(t,r,l);if(`error`in i){q(S,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(S,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,Ye(S,`chainChanged`,i.chainIdHex))}catch(t){let n=U(t,`Chain request failed`);q(S,e,void 0,W(n)),h?.(n)}},[n,l,h]),P=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>G(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});q(S,e,i)}catch(n){let r=U(n,`Capabilities unavailable`);if(!ve(r)){q(S,e,void 0,W(r));return}q(S,e,Me(Oe(t,l),`unsupported`))}},[n,s,l]),F=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&j(i),q(S,e,r)}catch(t){let n=U(t,`Failed to get call status`);q(S,e,void 0,W(n))}},[n,j]),I=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&j(i),q(S,e,i)}catch(t){let n=U(t,`Request failed`),r=me(n);q(S,e,void 0,r?{code:4001,message:n.message}:W(n)),r||h?.(n)}},[n,j,h]),L=t((e,t)=>{let n=k.current;n&&(k.current=Re(n,e),S.current?.postMessage(JSON.stringify(te(n.sessionId,e,t))))},[]),R=t(async(e,t)=>{let n=A.current;if(!n){L(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}k.current?.sessionId===e&&L(t.requestId,a)},[L]),z=t(e=>{let t=k.current;if(!t)return;let n=Le(t,e,{walletAddress:C.current,supported:!!A.current});if(k.current=n.state,n.decision.kind===`reject`){L(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&R(t.sessionId,n.decision.request)},[R,L]),B=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(Ze(e.error,`Payment details error`));return;case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(Ze(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return;case`ethereum_rpc_request`:{let{id:t,method:n,params:r}=e;Be(n)?N(t,n,r):n===`wallet_getCapabilities`?P(t,r):n===`wallet_getCallsStatus`?F(t,r):I(t,n,r);return}}},[N,P,F,I,d,f,p,m,h]);return{uiRef:S,injectedJavaScript:M,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Xe(t)){if(t.type===`yodl_ready`){if(!O.current){g?.();return}let e=qe(O.current,E.current);O.current=e.state,e.message&&S.current?.postMessage(e.message);let n=Je(O.current,t);if(O.current=n.state,!n.readyAccepted)return;n.message&&S.current?.postMessage(n.message);let r=k.current;r&&S.current?.postMessage(JSON.stringify(D(r.sessionId,!!A.current))),g?.();return}if(t.type===`yodl_email_attestation_request`){z(t);return}b(t)&&B(t)}},[B,z,g])}}function $e(e){return f(et,{...e},e.uri)}function et({uri:e,sdkConfig:n,provider:l,address:d,chainId:h,supportedChainIds:g,onTransactionSent:_,onPaymentDetails:v,onSignupStatusChange:y,onSignedUp:b,onSignupDismissed:x,onError:S,style:C,backgroundColor:ee,hostTheme:w=null,fetchEmailAttestation:T,renderLoading:E,onReady:D,sharedCookiesEnabled:te=!0,thirdPartyCookiesEnabled:O=!0,onLoadStart:k,...A}){let[j]=s(()=>Ee(w)),M=ie(w,ee),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(D);i(()=>{L.current=D},[D]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:B,injectedJavaScript:ne,onMessage:re}=Qe({provider:l,address:d,chainId:h,supportedChainIds:g,onReady:z,sessionId:j.sessionId,hostTheme:w,initialHostTheme:j.initialHostTheme,..._!==void 0&&{onTransactionSent:_},...v!==void 0&&{onPaymentDetails:v},...y!==void 0&&{onSignupStatusChange:y},...b!==void 0&&{onSignedUp:b},...x!==void 0&&{onSignupDismissed:x},...S!==void 0&&{onError:S},...T!==void 0&&{fetchEmailAttestation:T}}),V=a(()=>ye(e),[e]),oe=a(()=>{let t=Ce(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),se=a(()=>e=>!V||!e?.url?!1:be(e.url,V)||e.url.startsWith(`about:`),[V]),H=I?null:E?E():f(c,{color:M.spinner});return p(u,{style:[tt.container,{backgroundColor:N},C],children:[f(m,{ref:B,source:oe,originWhitelist:V?[V]:[],onShouldStartLoadWithRequest:se,javaScriptEnabled:!0,sharedCookiesEnabled:te,thirdPartyCookiesEnabled:O,injectedJavaScriptBeforeContentLoaded:ne,injectedJavaScriptObject:ae(j.sessionId,j.initialHostTheme,n.integrationAddress),onMessage:re,...k!==void 0&&{onLoadStart:k},style:[tt.ui,{backgroundColor:N}],...A}),H&&f(u,{style:[tt.overlay,{backgroundColor:N}],children:H})]})}const tt=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function nt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=de(l,u),v=a(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]);return f($e,{uri:v,sdkConfig:g.config,provider:d,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{fetchEmailAttestation:r},...i!==void 0&&{renderLoading:i},...o!==void 0&&{onReady:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function rt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function it(e){if(Array.isArray(e))return e}function at(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t,n){return t&&ot(e.prototype,t),n&&ot(e,n),e}function ct(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function lt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t){return it(e)||ct(e,t)||ft(e,t)||lt()}function dt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ft(e,t){if(e){if(typeof e==`string`)return rt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rt(e,t)}}var pt=Object.defineProperty,mt=function(e,t,n){return t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},ht=function(e,t){for(var n in t)pt(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return mt(e,(t===void 0?`undefined`:dt(t))===`symbol`?t:t+``,n)},gt=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function _t(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=gt[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function vt(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function Y(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=Y(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function yt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=_t(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=yt(e,n),e}function bt(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Z(e,t){return{id:e,length:t.length,value:t}}function xt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var St=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;at(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return st(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return xt({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=ut(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function Ct(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}ht({},{ProxyType:function(){return Q},anyId:function(){return Ct},billPayment:function(){return xt},botBarcode:function(){return wt},slipVerify:function(){return Tt},trueMoney:function(){return Dt},trueMoneySlipVerify:function(){return Ot}});function wt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new St(t,n,r,i).toString()}function Tt(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function Et(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Dt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,Et(r))),X(Y(a),`63`)}function Ot(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function kt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function At(e){if(Array.isArray(e))return e}function jt(e){if(Array.isArray(e))return kt(e)}function Mt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Nt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Pt(e,t,n){return t&&Nt(e.prototype,t),n&&Nt(e,n),e}function Ft(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Lt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Rt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ft(e,t,n[t])})}return e}function Vt(e,t){return At(e)||Lt(e,t)||Ut(e,t)||Rt()}function Ht(e){return jt(e)||It(e)||Ut(e)||zt()}function Ut(e,t){if(e){if(typeof e==`string`)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kt(e,t)}}ht({},{anyId:function(){return Kt},bcelOneProof:function(){return Gt},billPayment:function(){return qt},slipVerify:function(){return Jt},trueMoneySlipVerify:function(){return Yt}});var Wt=function(){function e(t,n){Mt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Pt(e,[{key:`getTag`,value:function(e,t){return bt(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=X(Y(Ht(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=yt(e.slice(0,-4)))return null;var r=vt(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=vt(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Wt(e,r)}function Gt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Kt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Q).find(function(e){var n=Vt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Vt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Bt({type:o,target:c},u!==void 0&&{amount:u})}function qt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Bt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Jt(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Yt(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Xt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Zt(e){return e?e.getTagValue(`58`)??null:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(Xt))r.includes(e)&&t.push(n);return t}function $t(e){return e.toLowerCase().startsWith(`upi://`)}function en(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim(),r=[];try{let e=Zt($(n));if(e){let n=Qt(e);for(let e of n)(!t||t.includes(e))&&r.push({provider:e,action:`resolve`});if(r.length>0)return r}}catch{}return $t(n)&&(!t||t.includes(`aeon`))?[{provider:`aeon`,action:`resolve`}]:r}function tn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function nn(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function rn(e){return nn(e,`/sdk/signup`)}const an=`always`;function on(e,t,n=an){return!e||typeof e!=`string`||e.trim().length===0||tn(en(e)).length===0?null:nn(t,`/resolve`,{data:e,navigateOnSubmit:n===an?void 0:n})}function sn({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=de(d,p),b=a(()=>on(e,v.config.yodlUiBaseUrl,t),[e,v.config.yodlUiBaseUrl,t]);return b?f($e,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{renderLoading:s},...c!==void 0&&{onReady:c},...l!==void 0&&{style:l},...u!==void 0&&{backgroundColor:u}}):null}function cn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=de(u,d),y=a(()=>rn(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]);return f($e,{uri:y,sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{fetchEmailAttestation:i},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function ln(e){return(Array.isArray(e)?e:[e]).some(e=>tn(en(e)).length>0)}var un=class{config;constructor(e){let t=fe(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function dn(e){return new un(e)}export{nt as YodlDashboard,sn as YodlPayment,le as YodlProvider,un as YodlSdk,cn as YodlSignup,dn as createYodlSdk,ln as isPaymentQr};
|
|
228
|
+
true;`}function tt(e){return JSON.stringify(e)}function nt(e){return{state:e,message:null,readyAccepted:!1}}function rt(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:pe(e.sessionId,e.currentTheme),readyAccepted:t}}function it(e,t){let n=tt(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function at(e,t){let n=tt(t);if(n===e.currentFingerprint)return nt(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?rt(r,!1):nt(r)}function ot(e,t){return!H(t)||t.sessionId!==e.sessionId?nt(e):rt({...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 st(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function ct(e){return v(e)&&`type`in e}function lt(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(_?it(_,y):null),O=o(_?Ke(_):null),k=o(b);i(()=>{E.current=v},[v]),i(()=>{k.current=b},[b]),i(()=>{D.current=_?it(_,y):null},[y,_]),i(()=>{O.current=_?Ke(_):null},[_]);let A=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=Ge({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&&st(x,`accountsChanged`,e.accountsChanged),e.chainChanged&&st(x,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!D.current)return;let e=at(D.current,v);D.current=e.state,e.message&&x.current?.postMessage(e.message)},[v]);let j=a(()=>et({address:s,chainId:c}),[s,c]),M=t(async(e,t,r)=>{try{let i=$e(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,st(x,`chainChanged`,i.chainIdHex))}catch(t){let n=U(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=U(n,`Capabilities unavailable`);if(!ke(r)){J(x,e,void 0,G(r));return}J(x,e,We(Be(t,l),`unsupported`))}},[n,s,l]),P=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=Ue(r);i&&A(i),J(x,e,r)}catch(t){let n=U(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=U(t,`Request failed`),r=Te(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=Xe(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=Ye(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)=>{Qe(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]),re=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 Fe(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 Fe(e.error,`Payment details error`));return;case`ethereum_rpc_request`:z(e.id,e.method,e.params);return;default:re(e)}},[z,re,d,h]),V=t(()=>{let e=O.current;e&&x.current?.postMessage(JSON.stringify(te(e.sessionId,!!k.current)))},[]),H=t(e=>{if(!D.current){g?.();return}let t=at(D.current,E.current);D.current=t.state,t.message&&x.current?.postMessage(t.message);let n=ot(D.current,e);D.current=n.state,n.readyAccepted&&(n.message&&x.current?.postMessage(n.message),V(),g?.())},[V,g]);return{uiRef:x,injectedJavaScript:j,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(ct(t)){if(t.type===`yodl_ready`){H(t);return}if(t.type===`yodl_email_attestation_request`){R(t);return}ee(t)&&B(t)}},[B,R,H])}}function ut(e){return f(dt,{...e},e.uri)}function dt({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(()=>Re(T)),M=de(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:re,injectedJavaScript:B,onMessage:V}=lt({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})}),H=a(()=>Ae(e),[e]),ie=a(()=>{let t=Pe(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),ae=a(()=>e=>!H||!e?.url?!1:je(e.url,H)||e.url.startsWith(`about:`),[H]),oe=a(()=>{if(!S)return{};let t=e=>S(new W(`process_terminated`,`The Yodl UI web process was terminated`,e));return{onError:({nativeEvent:e})=>S(new W(`load_failed`,`The Yodl UI failed to load: ${e.description}`,e.url)),onHttpError:({nativeEvent:e})=>S(new W(`http_error`,`The Yodl UI answered HTTP ${e.statusCode}`,e.url,e.statusCode)),onRenderProcessGone:()=>t(e),onContentProcessDidTerminate:({nativeEvent:e})=>t(e.url)}},[S,e]),se=I?null:D?D():f(c,{color:M.spinner});return p(u,{style:[ft.container,{backgroundColor:N},C],children:[f(m,{ref:re,source:ie,originWhitelist:H?[H]:[],onShouldStartLoadWithRequest:ae,javaScriptEnabled:!0,sharedCookiesEnabled:k,thirdPartyCookiesEnabled:te,injectedJavaScriptBeforeContentLoaded:B,injectedJavaScriptObject:fe(j.sessionId,j.initialHostTheme,n.integrationAddress,E?{emailAttestation:!0}:void 0),onMessage:V,...oe,...ne!==void 0&&{onLoadStart:ne},style:[ft.ui,{backgroundColor:N}],...A}),se&&f(u,{style:[ft.overlay,{backgroundColor:N}],children:se})]})}const ft=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function pt({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}=xe(l,u),m=a(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]);return f(ut,{uri:m,...p,...h({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c})})}function mt(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function ht(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function gt(e){if(Array.isArray(e))return e}function _t(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function vt(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 yt(e,t,n){return t&&vt(e.prototype,t),n&&vt(e,n),e}function bt(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 xt(){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 St(e,t){return gt(e)||bt(e,t)||wt(e,t)||xt()}function Ct(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function wt(e,t){if(e){if(typeof e==`string`)return ht(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ht(e,t)}}var Tt=Object.defineProperty,Et=function(e,t,n){return t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Dt=function(e,t){for(var n in t)Tt(e,n,{get:t[n],enumerable:!0})},Y=function(e,t,n){return Et(e,(t===void 0?`undefined`:Ct(t))===`symbol`?t:t+``,n)},Ot=[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 kt(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 At(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=typeof e==`string`?kt(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=Ot[(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 jt(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 Mt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=At(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Z(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=Mt(e,n),e}function Nt(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 Pt(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 Ft=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;_t(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 yt(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 Pt({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=St(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}(),It=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(It||{});function Lt(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=X([Q(`00`,`A000000677010111`),Q(It[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`)}Dt({},{ProxyType:function(){return It},anyId:function(){return Lt},billPayment:function(){return Pt},botBarcode:function(){return Rt},slipVerify:function(){return zt},trueMoney:function(){return Vt},trueMoneySlipVerify:function(){return Ht}});function Rt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new Ft(t,n,r,i).toString()}function zt(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 Bt(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Vt(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`,Bt(r))),Z(X(a),`63`)}function Ht(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 Ut(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 Wt(e){if(Array.isArray(e))return e}function Gt(e){if(Array.isArray(e))return Ut(e)}function Kt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function qt(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 Jt(e,t,n){return t&&qt(e.prototype,t),n&&qt(e,n),e}function Yt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Zt(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 Qt(){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 $t(){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 en(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){Yt(e,t,n[t])})}return e}function tn(e,t){return Wt(e)||Zt(e,t)||rn(e,t)||Qt()}function nn(e){return Gt(e)||Xt(e)||rn(e)||$t()}function rn(e,t){if(e){if(typeof e==`string`)return Ut(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 Ut(e,t)}}Dt({},{anyId:function(){return sn},bcelOneProof:function(){return on},billPayment:function(){return cn},slipVerify:function(){return ln},trueMoneySlipVerify:function(){return un}});var an=function(){function e(t,n){Kt(this,e),Y(this,`payload`),Y(this,`tags`),this.payload=t,this.tags=n}return Jt(e,[{key:`getTag`,value:function(e,t){return Nt(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(nn(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()!=Mt(e.slice(0,-4)))return null;var r=jt(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=jt(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 an(e,r)}function on(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 sn(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(It).find(function(e){var n=tn(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=tn(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 en({type:o,target:c},u!==void 0&&{amount:u})}function cn(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 en({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function ln(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 un(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 dn={aeon:[`PH`,`VN`,`BR`,`AR`,`CO`,`PE`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`],gaian:[`PH`],mock:[]};function fn(e){return e?e.getTagValue(`58`)??null:null}function pn(e){let t=[];for(let[n,r]of Object.entries(dn))r.includes(e)&&t.push(n);return t}const mn=/^[a-z0-9+/]{64,}={0,2}\|[0-9a-f]{16,64}$/i;function hn(e){return mn.test(e)}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=fn($(e));if(!r)return n;for(let e of pn(r))_n(e,t)&&n.push({provider:e,action:`resolve`})}catch{}return n}function yn(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim();if(gn(n))return _n(`mock`,t)?[{provider:`mock`,action:`resolve`}]:[];let r=vn(n,t);return r.length>0?r:hn(n)&&_n(`aeon`,t)?[{provider:`aeon`,action:`resolve`}]: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||mt(yn(e)).length===0?null:bn(t,`/resolve`,{data:e,navigateOnSubmit:n===Sn?void 0:n})}function wn({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}=xe(d,p),_=a(()=>Cn(e,m.config.yodlUiBaseUrl,t),[e,m.config.yodlUiBaseUrl,t]);return _?f(ut,{uri:_,...g,...h({onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u})}):null}function Tn({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}=xe(u,d),g=a(()=>xn(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]);return f(ut,{uri:g,...m,...h({onSignupStatusChange:e,onSignedUp:t,onError:n,onSignupDismissed:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l})})}function En(e){return(Array.isArray(e)?e:[e]).some(e=>mt(yn(e)).length>0)}var Dn=class{config;constructor(e){let t=Ce(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 On(e){return new Dn(e)}export{pt as YodlDashboard,wn as YodlPayment,ve as YodlProvider,Dn as YodlSdk,Tn as YodlSignup,Fe as YodlUIError,W as YodlWebViewError,On as createYodlSdk,En as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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.27.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsdown",
|