@yodlpay/react-native 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -11
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +172 -71
- package/dist/index.d.mts +172 -71
- package/dist/index.mjs +2 -2
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ Drop-in crypto payments for React Native. You bring an [EIP-1193](https://eips.e
|
|
|
15
15
|
The provider interface is always plain **EIP-1193**. Transaction **batching and paymasters** ride on top via **[EIP-5792](https://eips.ethereum.org/EIPS/eip-5792)** (`wallet_sendCalls`) — available when your wallet supports EIP-5792 natively, or through the optional [EIP-7702 add-on](#optional-eip-7702-fallback) for wallets that don't.
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import {
|
|
18
|
+
import { createYodlSdk, YodlProvider, YodlPayment } from '@yodlpay/react-native';
|
|
19
19
|
|
|
20
|
-
const sdk =
|
|
20
|
+
const sdk = createYodlSdk({
|
|
21
21
|
integrationAddress: '0x000000000000000000000000000000000000dEaD',
|
|
22
22
|
supportedChainIds: [1, 8453],
|
|
23
23
|
});
|
|
@@ -81,10 +81,10 @@ Then rebuild the app. That's the full install.
|
|
|
81
81
|
Three steps: create the SDK once, wrap your screen in `<YodlProvider>`, render `<YodlPayment>`.
|
|
82
82
|
|
|
83
83
|
```tsx
|
|
84
|
-
import {
|
|
84
|
+
import { createYodlSdk, isPaymentQr, YodlProvider, YodlPayment } from '@yodlpay/react-native';
|
|
85
85
|
|
|
86
86
|
// 1. Create the SDK once, app-wide.
|
|
87
|
-
const sdk =
|
|
87
|
+
const sdk = createYodlSdk({
|
|
88
88
|
integrationAddress: '0x000000000000000000000000000000000000dEaD', // your integration wallet address
|
|
89
89
|
supportedChainIds: [1, 8453],
|
|
90
90
|
});
|
|
@@ -138,7 +138,7 @@ Most apps just need the install above and a native rebuild. Edge cases:
|
|
|
138
138
|
|
|
139
139
|
## Usage
|
|
140
140
|
|
|
141
|
-
Create the SDK once with `
|
|
141
|
+
Create the SDK once with `createYodlSdk(config)` and supply wallet state at runtime via `<YodlProvider>`. Stateless helpers like `isPaymentQr(qrData)` are standalone exports — no SDK instance required to call them.
|
|
142
142
|
|
|
143
143
|
### Signup flow
|
|
144
144
|
|
|
@@ -278,6 +278,7 @@ Circular elements — avatars, token icons, sheet grab handles, status rings —
|
|
|
278
278
|
- `radiusControl` / `radiusSurface` must be a plain CSS length — a bare `0`, or a number of up to 4 digits with `px`, `rem`, `em`, or `%` (`.5rem` is as valid as `0.5rem`). A unitless number other than zero (`'4'` rather than `'4px'`) is not a CSS length and is rejected, as are expressions such as `calc(…)` and `var(…)`.
|
|
279
279
|
- **A single invalid key rejects the whole theme**, so the hosted UI falls back to stock rather than applying a half-valid palette. Validate with `safeParseYodlTheme()` before sending — it returns the offending key by name.
|
|
280
280
|
- Images go under `images.light` / `images.dark`, each with `payBackground`, `loading`, and `processing` slots. `loading` and `processing` are one visual slot: the hosted UI has a single splash state and renders `loading`, falling back to `processing` only when `loading` is unset — setting `loading` alone covers everything, and there is no need to set both. A video URL (`.mp4`, `.m4v`, `.webm`, `.mov`) plays as a looping muted video; anything else renders as an image, so every browser-supported image format works — including animated WebP, APNG, animated AVIF, and GIF. `.ogv` is excluded on purpose — iOS WebViews cannot decode Ogg/Theora, so it would blank the splash there.
|
|
281
|
+
- The `loading` splash renders **above the stepped caption**, in normal flow where the stock Yodl mark sits — not over the whole viewport. The media keeps its own aspect ratio and is scaled proportionally within maximum dimensions; it is not placed into a container of a set size. The maxima are 16rem wide, no more than 70% of the viewport width, and no more than 40% of its height. Width is applied first and the height follows from the asset's own ratio, so a wide asset occupies a shorter band than a square one and the vertical space taken varies by shape. Source pixel dimensions cannot bypass the maxima: a 4000px-wide asset is scaled down to the same width as a 400px-wide one of the same shape, only sharper. The fit is `contain`, so the media is only ever scaled down to stay within the maxima — never cropped to fill the viewport the way a background image would be — and the whole asset stays visible. Images and videos behave identically. Author roughly square (around 512×512) for predictable scaling, keep important detail away from the edges, and use `payBackground` for a full-screen backdrop.
|
|
281
282
|
- Image URLs must be `https://`, at most 2048 characters, with no whitespace, quotes, or backslashes.
|
|
282
283
|
- An invalid `theme` or `themeMode` never crashes — it falls back to stock Yodl and logs the error in `__DEV__`.
|
|
283
284
|
|
|
@@ -292,9 +293,9 @@ Changing `theme` / `themeMode` on a mounted component applies over the bridge **
|
|
|
292
293
|
**`sdk.ts`** — create the instance once, app-wide:
|
|
293
294
|
|
|
294
295
|
```tsx
|
|
295
|
-
import {
|
|
296
|
+
import { createYodlSdk } from '@yodlpay/react-native';
|
|
296
297
|
|
|
297
|
-
export const sdk =
|
|
298
|
+
export const sdk = createYodlSdk({
|
|
298
299
|
integrationAddress: '0x000000000000000000000000000000000000dEaD',
|
|
299
300
|
// yodlUiBaseUrl defaults to https://sdk-webview.yodl.me
|
|
300
301
|
supportedChainIds: [1, 42161, 8453, 137, 10, 56, 100],
|
|
@@ -400,9 +401,9 @@ Base SDK users can skip this entirely. Without it, a wallet that lacks native EI
|
|
|
400
401
|
|
|
401
402
|
## API Reference
|
|
402
403
|
|
|
403
|
-
### `
|
|
404
|
+
### `createYodlSdk(config)`
|
|
404
405
|
|
|
405
|
-
Returns a `
|
|
406
|
+
Returns a `YodlSdk` instance.
|
|
406
407
|
|
|
407
408
|
| Option | Type | Required | Default | Description |
|
|
408
409
|
| ------------------- | ----------------------------- | -------- | ----------------------------- | -------------------------------------------------------------------------- |
|
|
@@ -438,8 +439,8 @@ Supplies the SDK instance and wallet state to the components. Render it once, hi
|
|
|
438
439
|
|
|
439
440
|
| Prop | Type | Required | Description |
|
|
440
441
|
| ---------- | ----------------- | -------- | ------------------------------------- |
|
|
441
|
-
| `sdk` | `
|
|
442
|
-
| `provider` | `EIP1193Provider` | Yes | EIP-1193 provider from any wallet SDK. Prefer the wallet's native EIP-5792 support; only if it lacks it, wrap with `withYodl7702(...)` for the [EIP-7702 fallback](#optional-eip-7702-fallback) |
|
|
442
|
+
| `sdk` | `YodlSdk` | Yes | Instance from `createYodlSdk()` |
|
|
443
|
+
| `provider` | `EIP1193Provider` | Yes | EIP-1193 provider from any wallet SDK (`@yodlpay/sdk-core`'s type: `request` only, events not required; `withYodl7702` accepts and returns the same type, so no cast is needed). Prefer the wallet's native EIP-5792 support; only if it lacks it, wrap with `withYodl7702(...)` for the [EIP-7702 fallback](#optional-eip-7702-fallback) |
|
|
443
444
|
| `address` | `string` | Yes | Connected wallet address |
|
|
444
445
|
| `chainId` | `number` | Yes | Chain ID the wallet is currently on |
|
|
445
446
|
| `theme` | `YodlTheme` | No | Default custom hosted-UI palette; all fields are optional |
|
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("@yodlpay/sdk-core/theme/host"),r=require("react/jsx-runtime"),i=require("react-native-webview"),a=require("@yodlpay/sdk-core/qr");const o={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function s(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function c(e,t,r){if(e===void 0&&t===void 0)return{envelope:null,error:null};let i=e===void 0?null:(0,n.safeParseYodlTheme)(e),a=t===void 0||t===`system`||t===`light`||t===`dark`,o=a?t??`system`:`system`,c=[i&&!i.success?`Invalid Yodl theme — ${i.error}`:null,a?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:i?.success?i.data:null,preference:o,resolved:s(o,r)},error:c.length>0?c.join(`; `):null}}function l(e,t){let n=o[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function u(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function d(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function f(e,t){return JSON.stringify(d(e,t))}function p(e,t,n,r){let{envelope:i,error:a}=c(e,t,n);return a&&r?.(a),i}function m(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=c(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 g=(0,e.createContext)(null);function _({sdk:n,provider:i,address:a,chainId:o,theme:s,themeMode:c,children:l}){let u=(0,t.useColorScheme)(),d=(0,e.useMemo)(()=>p(s,c,u,h),[s,c,u]),f=(0,e.useMemo)(()=>({sdk:n,provider:i,address:a,chainId:o,supportedChainIds:n.config.supportedChainIds,hostTheme:d,systemScheme:u}),[n,i,a,o,d,u]);return(0,r.jsx)(g.Provider,{value:f,children:l})}function v(){let t=(0,e.useContext)(g);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function y(t,n){let r=v(),i=(0,e.useMemo)(()=>m(r.hostTheme,t,n,r.systemScheme,h),[r.hostTheme,r.systemScheme,t,n]);return{...r,hostTheme:i}}function b(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function x(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 S(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function C(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 w(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function T(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function E(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const D=/^0x[a-fA-F0-9]{40}$/;function O(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!D.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function k(e){return{"X-Yodl-Integration-Id":O(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.9.0`}}function A(e,t){let n=e.yodlUiBaseUrl?T(e.yodlUiBaseUrl):null;if(!(!n||!E(t,n)))return k(e)}let j=0;function M(){return j+=1,`yodl-${Date.now().toString(36)}-${j.toString(36)}`}function N(e,t=M){return{sessionId:t(),initialHostTheme:e}}function P(e,t){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}})}function F(e,t,n){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n})}function I(e){return`0x${e.toString(16)}`}function L(e,t=`unsupported`){let n={};for(let r of e)n[I(r)]={atomic:{status:t}};return n}function R(e){return e.toLowerCase()}function z(e,t){let n=R(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:I(t.chainId)}}:{}}}function B(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function V(e){return{state:e,decision:{kind:`ignore`}}}function H(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function ee(e,t,r){return!(0,n.isYodlEmailAttestationRequestMessage)(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?V(e):r.supported?R(t.address)===R(r.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=n.YODL_EMAIL_ATTESTATION_MAX_PER_SESSION?H(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}}:H(e,t.requestId,`address_mismatch`):H(e,t.requestId,`not_supported`)}function te(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const U=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function W(e){return U.some(t=>t===e)}function ne(e,t,n){if(!W(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=C((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=I(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function G(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>C(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function K(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function q(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function re(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!K(t))return;let n=t.receipts;if(n?.length&&!n.some(q))return n[n.length-1]?.transactionHash}function ie(e){let t=I(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");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.0`};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() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function J(e){return JSON.stringify(e)}function Y(e){return{state:e,message:null,readyAccepted:!1}}function ae(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 oe(e,t){let n=J(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function se(e,t){let n=J(t);if(n===e.currentFingerprint)return Y(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?ae(r,!1):Y(r)}function ce(e,t){return!(0,n.isYodlReadyMessage)(t)||t.sessionId!==e.sessionId?Y(e):ae({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function X(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 Z(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function le(t){let{provider:r,address:i,chainId:a,supportedChainIds:o,onTransactionSent:s,onPaymentDetails:c,onSignupStatusChange:l,onSignedUp:u,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)(R(i)),C=(0,e.useRef)(a),T=(0,e.useRef)(a),E=(0,e.useRef)(new Set),D=(0,e.useRef)(h),O=(0,e.useRef)(m?oe(m,g):null),k=(0,e.useRef)(m?B(m):null),A=(0,e.useRef)(_);(0,e.useLayoutEffect)(()=>{D.current=h},[h]),(0,e.useLayoutEffect)(()=>{A.current=_},[_]),(0,e.useLayoutEffect)(()=>{O.current=m?oe(m,g):null},[g,m]),(0,e.useLayoutEffect)(()=>{k.current=m?B(m):null},[m]);let j=(0,e.useCallback)(e=>{E.current.has(e)||(E.current.add(e),s?.(e))},[s]);(0,e.useEffect)(()=>{let e=z({address:y.current,propChainId:C.current,activeChainId:T.current},{address:i,chainId:a});e&&(y.current=e.nextAddress,C.current=e.nextPropChainId,T.current=e.nextActiveChainId,e.accountsChanged&&Z(v,`accountsChanged`,e.accountsChanged),e.chainChanged&&Z(v,`chainChanged`,e.chainChanged.chainIdHex))},[i,a]),(0,e.useEffect)(()=>{if(!O.current)return;let e=se(O.current,h);O.current=e.state,e.message&&v.current?.postMessage(e.message)},[h]);let M=(0,e.useMemo)(()=>ie({address:i,chainId:a}),[i,a]),N=(0,e.useCallback)(async(e,t,n)=>{try{let i=ne(t,n,o);if(`error`in i){X(v,e,void 0,i.error);return}await r.request({method:i.providerMethod,params:i.providerParams}),X(v,e,null),i.switchesActiveChain&&(T.current=i.requestedChainId,Z(v,`chainChanged`,i.chainIdHex))}catch(t){let n=x(t,`Chain request failed`);X(v,e,void 0,S(n)),f?.(n)}},[r,o,f]),V=(0,e.useCallback)(async(e,t)=>{try{let n=t.length>0?t:[i,o.map(e=>I(e))],a=await r.request({method:`wallet_getCapabilities`,params:n});X(v,e,a)}catch(n){let r=x(n,`Capabilities unavailable`);if(!w(r)){X(v,e,void 0,S(r));return}X(v,e,L(G(t,o),`unsupported`))}},[r,i,o]),H=(0,e.useCallback)(async(e,t)=>{try{let n=await r.request({method:`wallet_getCallsStatus`,params:t}),i=re(n);i&&j(i),X(v,e,n)}catch(t){let n=x(t,`Failed to get call status`);X(v,e,void 0,S(n))}},[r,j]),U=(0,e.useCallback)(async(e,t,n)=>{try{let i=await r.request({method:t,params:n});t===`eth_sendTransaction`&&typeof i==`string`&&j(i),X(v,e,i)}catch(t){let n=x(t,`Request failed`),r=b(n);X(v,e,void 0,r?{code:4001,message:n.message}:S(n)),r||f?.(n)}},[r,j,f]),K=(0,e.useCallback)((e,t)=>{let n=k.current;n&&(k.current=te(n,e),v.current?.postMessage(F(n.sessionId,e,t)))},[]),q=(0,e.useCallback)(async(e,t)=>{let r=A.current;if(!r){K(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let i=new AbortController,a=setTimeout(()=>i.abort(),n.YODL_EMAIL_ATTESTATION_NATIVE_TIMEOUT_MS),o;try{let e=await r({address:t.address,signal:i.signal});o=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{o={status:`unavailable`,reason:i.signal.aborted?`timeout`:`error`}}finally{clearTimeout(a)}k.current?.sessionId===e&&K(t.requestId,o)},[K]),J=(0,e.useCallback)(e=>{let t=k.current;if(!t)return;let n=ee(t,e,{walletAddress:y.current,supported:!!A.current});if(k.current=n.state,n.decision.kind===`reject`){K(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&q(t.sessionId,n.decision.request)},[q,K]);return{uiRef:v,injectedJavaScript:M,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!O.current){p?.();return}let e=se(O.current,D.current);O.current=e.state,e.message&&v.current?.postMessage(e.message);let n=ce(O.current,t);if(O.current=n.state,!n.readyAccepted)return;n.message&&v.current?.postMessage(n.message);let r=k.current;r&&v.current?.postMessage(P(r.sessionId,!!A.current)),p?.();return}if(t.type===`yodl_email_attestation_request`){J(t);return}if(t.type===`yodl_payment_details`){c?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),f?.(n);return}if(t.type===`yodl_signup_status`){l?.(t.status);return}if(t.type===`yodl_signup_complete`){u?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),f?.(n);return}if(t.type===`yodl_signup_dismissed`){d?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;W(r)?N(n,r,i):r===`wallet_getCapabilities`?V(n,i):r===`wallet_getCallsStatus`?H(n,i):U(n,r,i)},[N,V,H,U,J,c,l,u,d,f,p])}}function Q(e){return(0,r.jsx)(ue,{...e},e.uri)}function ue({uri:a,sdkConfig:o,provider:s,address:c,chainId:d,supportedChainIds:f,onTransactionSent:p,onPaymentDetails:m,onSignupStatusChange:h,onSignedUp:g,onSignupDismissed:_,onError:v,style:y,backgroundColor:b,hostTheme:x=null,fetchEmailAttestation:S,renderLoading:C,onReady:w,sharedCookiesEnabled:D=!0,thirdPartyCookiesEnabled:O=!0,onLoadStart:k,...j}){let[M]=(0,e.useState)(()=>N(x)),P=l(x,b),F=P.background,[I,L]=(0,e.useState)(null),R=I===M.sessionId,z=(0,e.useRef)(w);(0,e.useLayoutEffect)(()=>{z.current=w},[w]);let B=(0,e.useRef)(!1),V=(0,e.useCallback)(()=>{L(M.sessionId),!B.current&&(B.current=!0,z.current?.())},[M.sessionId]);(0,e.useEffect)(()=>{if(R)return;let e=setTimeout(V,n.YODL_REVEAL_CEILING_MS);return()=>clearTimeout(e)},[V,R]);let{uiRef:H,injectedJavaScript:ee,onMessage:te}=le({provider:s,address:c,chainId:d,supportedChainIds:f,onReady:V,sessionId:M.sessionId,hostTheme:x,initialHostTheme:M.initialHostTheme,...p!==void 0&&{onTransactionSent:p},...m!==void 0&&{onPaymentDetails:m},...h!==void 0&&{onSignupStatusChange:h},...g!==void 0&&{onSignedUp:g},..._!==void 0&&{onSignupDismissed:_},...v!==void 0&&{onError:v},...S!==void 0&&{fetchEmailAttestation:S}}),U=(0,e.useMemo)(()=>T(a),[a]),W=(0,e.useMemo)(()=>{let e=A(o,a);return e?{uri:a,headers:e}:{uri:a}},[o,a]),ne=(0,e.useMemo)(()=>e=>!U||!e?.url?!1:E(e.url,U)||e.url.startsWith(`about:`),[U]),G=R?null:C?C():(0,r.jsx)(t.ActivityIndicator,{color:P.spinner});return(0,r.jsxs)(t.View,{style:[$.container,{backgroundColor:F},y],children:[(0,r.jsx)(i.WebView,{ref:H,source:W,originWhitelist:U?[U]:[],onShouldStartLoadWithRequest:ne,javaScriptEnabled:!0,sharedCookiesEnabled:D,thirdPartyCookiesEnabled:O,injectedJavaScriptBeforeContentLoaded:ee,injectedJavaScriptObject:u(M.sessionId,M.initialHostTheme,o.integrationAddress),onMessage:te,...k!==void 0&&{onLoadStart:k},style:[$.ui,{backgroundColor:F}],...j}),G&&(0,r.jsx)(t.View,{style:[$.overlay,{backgroundColor:F}],children:G})]})}const $=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 de({onTransactionSent:t,onPaymentDetails:n,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:_}=y(u,d);return(0,r.jsx)(Q,{uri:(0,e.useMemo)(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]),sdkConfig:g.config,provider:f,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...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 fe(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 pe(e){return fe(e,`/sdk/signup`)}const me=`always`;function he(e,t,n=me){return!e||typeof e!=`string`||e.trim().length===0||!(0,a.detectProvider)(e).find(e=>e.action===`resolve`)?null:fe(t,`/resolve`,{data:e,navigateOnSubmit:n===me?void 0:n})}function ge({qrData:t,navigateOnSubmit:n,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:b}=y(f,p),x=(0,e.useMemo)(()=>he(t,v.config.yodlUiBaseUrl,n),[t,v.config.yodlUiBaseUrl,n]);return x?(0,r.jsx)(Q,{uri:x,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:b,...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 _e({onStatusChange:t,onSignedUp:n,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}=y(d,f);return(0,r.jsx)(Q,{uri:(0,e.useMemo)(()=>pe(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]),sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...t!==void 0&&{onSignupStatusChange:t},...n!==void 0&&{onSignedUp:n},...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 ve(e){return(Array.isArray(e)?e:[e]).some(e=>(0,a.detectProvider)(e).some(e=>e.action===`resolve`))}var ye=class{config;constructor(e){let t=O(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 be(e){return new ye(e)}exports.Yodl=ye,exports.YodlDashboard=de,exports.YodlPayment=ge,exports.YodlProvider=_,exports.YodlSignup=_e,exports.createSdk=be,exports.isPaymentQr=ve;
|
|
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,164 @@
|
|
|
1
|
-
import { YodlTheme, YodlTheme as YodlTheme$1, YodlThemeMode, YodlThemeMode as YodlThemeMode$1 } from "@yodlpay/sdk-core/theme/host";
|
|
2
|
-
import { JsonValue, YodlNavigateOnSubmit, YodlPaymentDetails, YodlPaymentDetails as YodlPaymentDetails$1, YodlPaymentDetailsSource, YodlPaymentLifecycleStatus, YodlSignupStatus } from "@yodlpay/sdk-core/webview";
|
|
3
1
|
import { ReactElement, ReactNode } from "react";
|
|
4
2
|
import { ViewStyle } from "react-native";
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
//#region ../sdk-core/dist/messages-BnJRdNU0.d.mts
|
|
4
|
+
/** submitted: on-chain, not yet indexed by Yodl. processing: indexed, not settled (incl. a failure whose refund is in flight). */
|
|
5
|
+
type PaymentStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
6
|
+
/**
|
|
7
|
+
* Where a payment payload's figures came from. `optimistic` means Yodl's backend
|
|
8
|
+
* has not indexed the transaction yet, so every figure is the paying device's
|
|
9
|
+
* own pre-submit data. Independent of `status`: a payload can be `indexed` while
|
|
10
|
+
* the payment is still processing.
|
|
11
|
+
*/
|
|
12
|
+
type YodlPaymentDetailsSource = 'optimistic' | 'indexed';
|
|
13
|
+
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
14
|
+
/** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
|
|
15
|
+
type YodlNavigateOnSubmit = 'always' | 'never';
|
|
7
16
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
17
|
+
* Nullability here follows what the hosted page actually emits, not what is
|
|
18
|
+
* convenient to consume: it forwards a receipt's own `null`s rather than
|
|
19
|
+
* normalising them, so a host that assumes `string` will crash on a real
|
|
20
|
+
* payment. Narrow at the call site.
|
|
21
|
+
*/
|
|
22
|
+
interface YodlPaymentDetails {
|
|
23
|
+
status: PaymentStatus;
|
|
24
|
+
/** Optional: hosted builds older than the one that introduced it omit it. */
|
|
25
|
+
source?: YodlPaymentDetailsSource;
|
|
26
|
+
transaction: {
|
|
27
|
+
hash: string;
|
|
28
|
+
chainId?: string | number;
|
|
29
|
+
submittedAt?: string;
|
|
30
|
+
confirmedAt?: string;
|
|
31
|
+
};
|
|
32
|
+
payment?: {
|
|
33
|
+
processor?: string;
|
|
34
|
+
memo?: string | null;
|
|
35
|
+
recipient?: {
|
|
36
|
+
type?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
subtitle?: string | null;
|
|
39
|
+
iconUrl?: string | null;
|
|
40
|
+
};
|
|
41
|
+
invoice?: {
|
|
42
|
+
amount: string;
|
|
43
|
+
currency: string;
|
|
44
|
+
settlementAmount?: string;
|
|
45
|
+
settlementCurrency?: string;
|
|
46
|
+
} | null;
|
|
47
|
+
token?: {
|
|
48
|
+
symbol?: string | null;
|
|
49
|
+
amountGross?: string;
|
|
50
|
+
amountNet?: string;
|
|
51
|
+
};
|
|
52
|
+
senderAddress?: string;
|
|
53
|
+
receiverAddress?: string;
|
|
54
|
+
};
|
|
55
|
+
recovery?: {
|
|
56
|
+
refundTxHash?: string | null;
|
|
57
|
+
status?: string;
|
|
58
|
+
} | null;
|
|
59
|
+
rewards?: {
|
|
60
|
+
points?: number;
|
|
61
|
+
streakCount?: number;
|
|
62
|
+
streakMultiplier?: string;
|
|
63
|
+
berserMultiplier?: number;
|
|
64
|
+
};
|
|
65
|
+
raw?: unknown;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../sdk-core/dist/index-CmnifaLY.d.mts
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/evm/wallet-provider.d.ts
|
|
71
|
+
/**
|
|
72
|
+
* An EIP-1193 provider, declared structurally so anything shaped like one
|
|
73
|
+
* satisfies it — a browser wallet, a host-injected WebView provider, or a
|
|
74
|
+
* decorator such as `withYodl7702`.
|
|
75
|
+
*
|
|
76
|
+
* Deliberately *not* viem's `EIP1193Provider`, which is
|
|
77
|
+
* `EIP1193Events & { request: EIP1193RequestFn<EIP1474Methods> }` and so makes
|
|
78
|
+
* `on`/`removeListener` mandatory. Two providers this package has to accept
|
|
79
|
+
* cannot promise them: `withYodl7702` re-exposes them only when the provider it
|
|
80
|
+
* wraps has them, and a host bridge injected into a WebView frequently
|
|
81
|
+
* implements `request` alone. Nothing here subscribes to provider events — the
|
|
82
|
+
* chain switch polls `eth_chainId` instead — so requiring them would be asking
|
|
83
|
+
* for a capability this package never uses. viem's `custom()` types its own
|
|
84
|
+
* argument just as loosely, so no cast is needed on the way in either.
|
|
85
|
+
*
|
|
86
|
+
* `request` is declared as a method rather than a property on purpose: method
|
|
87
|
+
* bivariance is what lets a provider typed `params?: JsonValue[] | object`
|
|
88
|
+
* satisfy this without a cast.
|
|
10
89
|
*/
|
|
11
90
|
interface EIP1193Provider {
|
|
12
|
-
request
|
|
91
|
+
request(args: {
|
|
13
92
|
method: string;
|
|
14
|
-
params?:
|
|
15
|
-
})
|
|
93
|
+
params?: readonly unknown[] | object;
|
|
94
|
+
}): Promise<unknown>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../sdk-core/dist/host-COukZkft.d.mts
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/theme/contract.d.ts
|
|
100
|
+
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
101
|
+
type YodlThemeMode = 'system' | 'light' | 'dark';
|
|
102
|
+
/**
|
|
103
|
+
* One per-mode palette. Every key is optional — missing keys fall back to the
|
|
104
|
+
* stock Yodl palette, and the fine-tune keys are derived from their core keys
|
|
105
|
+
* downstream. Colors are hex, `rgb()` or `rgba()`.
|
|
106
|
+
*/
|
|
107
|
+
interface YodlThemeModeTokens {
|
|
108
|
+
bg?: string | undefined;
|
|
109
|
+
surface?: string | undefined;
|
|
110
|
+
surfaceSecondary?: string | undefined;
|
|
111
|
+
text?: string | undefined;
|
|
112
|
+
textSecondary?: string | undefined;
|
|
113
|
+
textMuted?: string | undefined;
|
|
114
|
+
border?: string | undefined;
|
|
115
|
+
success?: string | undefined;
|
|
116
|
+
error?: string | undefined;
|
|
117
|
+
warning?: string | undefined;
|
|
118
|
+
accent?: string | undefined;
|
|
119
|
+
bgDeep?: string | undefined;
|
|
120
|
+
surfaceHover?: string | undefined;
|
|
121
|
+
skeleton?: string | undefined;
|
|
122
|
+
accentStrong?: string | undefined;
|
|
123
|
+
accentDeep?: string | undefined;
|
|
124
|
+
brandSurface?: string | undefined;
|
|
125
|
+
brandSheet?: string | undefined;
|
|
126
|
+
brandText?: string | undefined;
|
|
127
|
+
brandButton?: string | undefined;
|
|
128
|
+
brandButtonText?: string | undefined;
|
|
129
|
+
}
|
|
130
|
+
/** The faces the hosted UI ships; see `THEME_FONT_VALUES` for why it is closed. */
|
|
131
|
+
type YodlThemeFont = 'system' | 'inter' | 'geist' | 'mono';
|
|
132
|
+
/** The three media slots the hosted UI can theme, for a single mode. https URLs only. */
|
|
133
|
+
interface YodlThemeImages {
|
|
134
|
+
/** Full-bleed backdrop behind the payment (amount entry) screen. */
|
|
135
|
+
payBackground?: string | undefined;
|
|
136
|
+
/** Alias for `loading` (used when it is unset). */
|
|
137
|
+
processing?: string | undefined;
|
|
138
|
+
/** Full-screen splash on the in-app loading screens; video or any `<img>` format. */
|
|
139
|
+
loading?: string | undefined;
|
|
140
|
+
}
|
|
141
|
+
/** Media is per mode. */
|
|
142
|
+
interface YodlThemeImageSets {
|
|
143
|
+
light?: YodlThemeImages | undefined;
|
|
144
|
+
dark?: YodlThemeImages | undefined;
|
|
16
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* One customizable Yodl theme: a light/dark palette pair plus optional media.
|
|
148
|
+
* `font` and the radii sit at the top level because none of them is a color
|
|
149
|
+
* and none varies by mode. `radiusSurface` defaults to `radiusControl`.
|
|
150
|
+
*/
|
|
151
|
+
interface YodlTheme {
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
font?: YodlThemeFont | undefined;
|
|
154
|
+
radiusControl?: string | undefined;
|
|
155
|
+
radiusSurface?: string | undefined;
|
|
156
|
+
light?: YodlThemeModeTokens | undefined;
|
|
157
|
+
dark?: YodlThemeModeTokens | undefined;
|
|
158
|
+
images?: YodlThemeImageSets | undefined;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/types.d.ts
|
|
17
162
|
type SupportedChainIds = number[];
|
|
18
163
|
/** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
|
|
19
164
|
interface YodlWallet {
|
|
@@ -37,12 +182,12 @@ interface YodlHostThemeProps {
|
|
|
37
182
|
* Without `themeMode` it follows the device appearance. Keep the object stable
|
|
38
183
|
* across renders (module constant or memo) to avoid redundant theme updates.
|
|
39
184
|
*/
|
|
40
|
-
theme?: YodlTheme
|
|
185
|
+
theme?: YodlTheme;
|
|
41
186
|
/**
|
|
42
187
|
* Which mode the hosted UI paints: `'system'` follows the device appearance,
|
|
43
188
|
* `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
|
|
44
189
|
*/
|
|
45
|
-
themeMode?: YodlThemeMode
|
|
190
|
+
themeMode?: YodlThemeMode;
|
|
46
191
|
}
|
|
47
192
|
interface YodlEmailAttestationRequest {
|
|
48
193
|
/** The wallet the hosted flow proved with SIWE. Mint `sub` for exactly this address. */
|
|
@@ -73,7 +218,7 @@ interface YodlEventHandlers {
|
|
|
73
218
|
/** Called after a transaction is sent. */
|
|
74
219
|
onTransactionSent?: (txHash: string) => void;
|
|
75
220
|
/** Called when the WebView emits Yodl payment lifecycle details. */
|
|
76
|
-
onPaymentDetails?: (details: YodlPaymentDetails
|
|
221
|
+
onPaymentDetails?: (details: YodlPaymentDetails) => void;
|
|
77
222
|
/** Called on RPC / payment errors. */
|
|
78
223
|
onError?: (error: Error) => void;
|
|
79
224
|
}
|
|
@@ -113,18 +258,7 @@ type YodlDashboardProps = YodlComponentProps;
|
|
|
113
258
|
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
114
259
|
* The Yodl UI is origin-locked to that host.
|
|
115
260
|
*/
|
|
116
|
-
declare function YodlDashboard({
|
|
117
|
-
onTransactionSent,
|
|
118
|
-
onPaymentDetails,
|
|
119
|
-
onError,
|
|
120
|
-
fetchEmailAttestation,
|
|
121
|
-
renderLoading,
|
|
122
|
-
onReady,
|
|
123
|
-
style,
|
|
124
|
-
backgroundColor,
|
|
125
|
-
theme,
|
|
126
|
-
themeMode
|
|
127
|
-
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
261
|
+
declare function YodlDashboard({ onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlDashboardProps): import("react").JSX.Element;
|
|
128
262
|
//#endregion
|
|
129
263
|
//#region src/components/YodlPayment.d.ts
|
|
130
264
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
@@ -143,20 +277,7 @@ interface YodlPaymentProps extends YodlComponentProps {
|
|
|
143
277
|
* (e.g. the `/resolve` screen on the configured host). The Yodl UI is
|
|
144
278
|
* origin-locked to that host. Renders nothing for empty/unsupported QR data.
|
|
145
279
|
*/
|
|
146
|
-
declare function YodlPayment({
|
|
147
|
-
qrData,
|
|
148
|
-
navigateOnSubmit,
|
|
149
|
-
onTransactionSent,
|
|
150
|
-
onPaymentDetails,
|
|
151
|
-
onError,
|
|
152
|
-
fetchEmailAttestation,
|
|
153
|
-
renderLoading,
|
|
154
|
-
onReady,
|
|
155
|
-
style,
|
|
156
|
-
backgroundColor,
|
|
157
|
-
theme,
|
|
158
|
-
themeMode
|
|
159
|
-
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
280
|
+
declare function YodlPayment({ qrData, navigateOnSubmit, onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlPaymentProps): import("react").JSX.Element | null;
|
|
160
281
|
//#endregion
|
|
161
282
|
//#region src/components/YodlSignup.d.ts
|
|
162
283
|
interface YodlSignupProps extends YodlVisualProps {
|
|
@@ -180,30 +301,18 @@ interface YodlSignupProps extends YodlVisualProps {
|
|
|
180
301
|
* verification code entry, and the final signed-up screen, while callbacks let
|
|
181
302
|
* the native app observe status and completion.
|
|
182
303
|
*/
|
|
183
|
-
declare function YodlSignup({
|
|
184
|
-
onStatusChange,
|
|
185
|
-
onSignedUp,
|
|
186
|
-
onError,
|
|
187
|
-
onDismiss,
|
|
188
|
-
fetchEmailAttestation,
|
|
189
|
-
renderLoading,
|
|
190
|
-
onReady,
|
|
191
|
-
style,
|
|
192
|
-
backgroundColor,
|
|
193
|
-
theme,
|
|
194
|
-
themeMode
|
|
195
|
-
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
304
|
+
declare function YodlSignup({ onStatusChange, onSignedUp, onError, onDismiss, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlSignupProps): import("react").JSX.Element;
|
|
196
305
|
//#endregion
|
|
197
306
|
//#region src/sdk/yodl.d.ts
|
|
198
307
|
/**
|
|
199
308
|
* App-host configuration for the Yodl React Native SDK.
|
|
200
|
-
* Injected once via {@link
|
|
309
|
+
* Injected once via {@link createYodlSdk}.
|
|
201
310
|
*
|
|
202
311
|
* No RPC endpoint is needed: the embedded Yodl UI reads chain state through its
|
|
203
312
|
* own provider, and the injected wallet bridge only forwards signing/wallet
|
|
204
313
|
* methods to the host wallet.
|
|
205
314
|
*/
|
|
206
|
-
interface
|
|
315
|
+
interface YodlSdkConfig {
|
|
207
316
|
/** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
|
|
208
317
|
integrationAddress: `0x${string}`;
|
|
209
318
|
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
@@ -212,7 +321,7 @@ interface YodlConfig {
|
|
|
212
321
|
supportedChainIds: SupportedChainIds;
|
|
213
322
|
}
|
|
214
323
|
/** Config with defaults applied — what components read from the instance. */
|
|
215
|
-
type
|
|
324
|
+
type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
|
|
216
325
|
yodlUiBaseUrl: string;
|
|
217
326
|
};
|
|
218
327
|
/**
|
|
@@ -220,20 +329,20 @@ type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
|
|
|
220
329
|
* and the components read at runtime. Stateless QR helpers are exported as
|
|
221
330
|
* standalone functions (e.g. {@link isPaymentQr}) rather than instance methods.
|
|
222
331
|
*/
|
|
223
|
-
declare class
|
|
224
|
-
readonly config:
|
|
225
|
-
constructor(config:
|
|
332
|
+
declare class YodlSdk {
|
|
333
|
+
readonly config: ResolvedYodlSdkConfig;
|
|
334
|
+
constructor(config: YodlSdkConfig);
|
|
226
335
|
}
|
|
227
336
|
/**
|
|
228
337
|
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
229
|
-
* `@yodlpay/sdk-core`'s `
|
|
338
|
+
* `@yodlpay/sdk-core`'s `createYodlClient` / config-once convention.
|
|
230
339
|
*/
|
|
231
|
-
declare function
|
|
340
|
+
declare function createYodlSdk(config: YodlSdkConfig): YodlSdk;
|
|
232
341
|
//#endregion
|
|
233
342
|
//#region src/provider/context.d.ts
|
|
234
343
|
interface YodlProviderProps extends YodlHostThemeProps {
|
|
235
|
-
/** The SDK instance created via
|
|
236
|
-
sdk:
|
|
344
|
+
/** The SDK instance created via createYodlSdk(). */
|
|
345
|
+
sdk: YodlSdk;
|
|
237
346
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
238
347
|
provider: YodlWallet['provider'];
|
|
239
348
|
/** Connected wallet address. */
|
|
@@ -246,15 +355,7 @@ interface YodlProviderProps extends YodlHostThemeProps {
|
|
|
246
355
|
* Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
|
|
247
356
|
* the optional host theme state to the Yodl components via React context.
|
|
248
357
|
*/
|
|
249
|
-
declare function YodlProvider({
|
|
250
|
-
sdk,
|
|
251
|
-
provider,
|
|
252
|
-
address,
|
|
253
|
-
chainId,
|
|
254
|
-
theme,
|
|
255
|
-
themeMode,
|
|
256
|
-
children
|
|
257
|
-
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
358
|
+
declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMode, children }: YodlProviderProps): import("react").JSX.Element;
|
|
258
359
|
//#endregion
|
|
259
360
|
//#region src/sdk/qr.d.ts
|
|
260
361
|
/**
|
|
@@ -268,4 +369,4 @@ declare function YodlProvider({
|
|
|
268
369
|
*/
|
|
269
370
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
270
371
|
//#endregion
|
|
271
|
-
export { type EIP1193Provider, type
|
|
372
|
+
export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,164 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
//#region ../sdk-core/dist/messages-BnJRdNU0.d.mts
|
|
4
|
+
/** submitted: on-chain, not yet indexed by Yodl. processing: indexed, not settled (incl. a failure whose refund is in flight). */
|
|
5
|
+
type PaymentStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
6
|
+
/**
|
|
7
|
+
* Where a payment payload's figures came from. `optimistic` means Yodl's backend
|
|
8
|
+
* has not indexed the transaction yet, so every figure is the paying device's
|
|
9
|
+
* own pre-submit data. Independent of `status`: a payload can be `indexed` while
|
|
10
|
+
* the payment is still processing.
|
|
11
|
+
*/
|
|
12
|
+
type YodlPaymentDetailsSource = 'optimistic' | 'indexed';
|
|
13
|
+
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
14
|
+
/** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
|
|
15
|
+
type YodlNavigateOnSubmit = 'always' | 'never';
|
|
7
16
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
17
|
+
* Nullability here follows what the hosted page actually emits, not what is
|
|
18
|
+
* convenient to consume: it forwards a receipt's own `null`s rather than
|
|
19
|
+
* normalising them, so a host that assumes `string` will crash on a real
|
|
20
|
+
* payment. Narrow at the call site.
|
|
21
|
+
*/
|
|
22
|
+
interface YodlPaymentDetails {
|
|
23
|
+
status: PaymentStatus;
|
|
24
|
+
/** Optional: hosted builds older than the one that introduced it omit it. */
|
|
25
|
+
source?: YodlPaymentDetailsSource;
|
|
26
|
+
transaction: {
|
|
27
|
+
hash: string;
|
|
28
|
+
chainId?: string | number;
|
|
29
|
+
submittedAt?: string;
|
|
30
|
+
confirmedAt?: string;
|
|
31
|
+
};
|
|
32
|
+
payment?: {
|
|
33
|
+
processor?: string;
|
|
34
|
+
memo?: string | null;
|
|
35
|
+
recipient?: {
|
|
36
|
+
type?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
subtitle?: string | null;
|
|
39
|
+
iconUrl?: string | null;
|
|
40
|
+
};
|
|
41
|
+
invoice?: {
|
|
42
|
+
amount: string;
|
|
43
|
+
currency: string;
|
|
44
|
+
settlementAmount?: string;
|
|
45
|
+
settlementCurrency?: string;
|
|
46
|
+
} | null;
|
|
47
|
+
token?: {
|
|
48
|
+
symbol?: string | null;
|
|
49
|
+
amountGross?: string;
|
|
50
|
+
amountNet?: string;
|
|
51
|
+
};
|
|
52
|
+
senderAddress?: string;
|
|
53
|
+
receiverAddress?: string;
|
|
54
|
+
};
|
|
55
|
+
recovery?: {
|
|
56
|
+
refundTxHash?: string | null;
|
|
57
|
+
status?: string;
|
|
58
|
+
} | null;
|
|
59
|
+
rewards?: {
|
|
60
|
+
points?: number;
|
|
61
|
+
streakCount?: number;
|
|
62
|
+
streakMultiplier?: string;
|
|
63
|
+
berserMultiplier?: number;
|
|
64
|
+
};
|
|
65
|
+
raw?: unknown;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../sdk-core/dist/index-CmnifaLY.d.mts
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/evm/wallet-provider.d.ts
|
|
71
|
+
/**
|
|
72
|
+
* An EIP-1193 provider, declared structurally so anything shaped like one
|
|
73
|
+
* satisfies it — a browser wallet, a host-injected WebView provider, or a
|
|
74
|
+
* decorator such as `withYodl7702`.
|
|
75
|
+
*
|
|
76
|
+
* Deliberately *not* viem's `EIP1193Provider`, which is
|
|
77
|
+
* `EIP1193Events & { request: EIP1193RequestFn<EIP1474Methods> }` and so makes
|
|
78
|
+
* `on`/`removeListener` mandatory. Two providers this package has to accept
|
|
79
|
+
* cannot promise them: `withYodl7702` re-exposes them only when the provider it
|
|
80
|
+
* wraps has them, and a host bridge injected into a WebView frequently
|
|
81
|
+
* implements `request` alone. Nothing here subscribes to provider events — the
|
|
82
|
+
* chain switch polls `eth_chainId` instead — so requiring them would be asking
|
|
83
|
+
* for a capability this package never uses. viem's `custom()` types its own
|
|
84
|
+
* argument just as loosely, so no cast is needed on the way in either.
|
|
85
|
+
*
|
|
86
|
+
* `request` is declared as a method rather than a property on purpose: method
|
|
87
|
+
* bivariance is what lets a provider typed `params?: JsonValue[] | object`
|
|
88
|
+
* satisfy this without a cast.
|
|
10
89
|
*/
|
|
11
90
|
interface EIP1193Provider {
|
|
12
|
-
request
|
|
91
|
+
request(args: {
|
|
13
92
|
method: string;
|
|
14
|
-
params?:
|
|
15
|
-
})
|
|
93
|
+
params?: readonly unknown[] | object;
|
|
94
|
+
}): Promise<unknown>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../sdk-core/dist/host-COukZkft.d.mts
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/theme/contract.d.ts
|
|
100
|
+
/** What a host may ask for: an explicit mode, or "follow the host appearance". */
|
|
101
|
+
type YodlThemeMode = 'system' | 'light' | 'dark';
|
|
102
|
+
/**
|
|
103
|
+
* One per-mode palette. Every key is optional — missing keys fall back to the
|
|
104
|
+
* stock Yodl palette, and the fine-tune keys are derived from their core keys
|
|
105
|
+
* downstream. Colors are hex, `rgb()` or `rgba()`.
|
|
106
|
+
*/
|
|
107
|
+
interface YodlThemeModeTokens {
|
|
108
|
+
bg?: string | undefined;
|
|
109
|
+
surface?: string | undefined;
|
|
110
|
+
surfaceSecondary?: string | undefined;
|
|
111
|
+
text?: string | undefined;
|
|
112
|
+
textSecondary?: string | undefined;
|
|
113
|
+
textMuted?: string | undefined;
|
|
114
|
+
border?: string | undefined;
|
|
115
|
+
success?: string | undefined;
|
|
116
|
+
error?: string | undefined;
|
|
117
|
+
warning?: string | undefined;
|
|
118
|
+
accent?: string | undefined;
|
|
119
|
+
bgDeep?: string | undefined;
|
|
120
|
+
surfaceHover?: string | undefined;
|
|
121
|
+
skeleton?: string | undefined;
|
|
122
|
+
accentStrong?: string | undefined;
|
|
123
|
+
accentDeep?: string | undefined;
|
|
124
|
+
brandSurface?: string | undefined;
|
|
125
|
+
brandSheet?: string | undefined;
|
|
126
|
+
brandText?: string | undefined;
|
|
127
|
+
brandButton?: string | undefined;
|
|
128
|
+
brandButtonText?: string | undefined;
|
|
129
|
+
}
|
|
130
|
+
/** The faces the hosted UI ships; see `THEME_FONT_VALUES` for why it is closed. */
|
|
131
|
+
type YodlThemeFont = 'system' | 'inter' | 'geist' | 'mono';
|
|
132
|
+
/** The three media slots the hosted UI can theme, for a single mode. https URLs only. */
|
|
133
|
+
interface YodlThemeImages {
|
|
134
|
+
/** Full-bleed backdrop behind the payment (amount entry) screen. */
|
|
135
|
+
payBackground?: string | undefined;
|
|
136
|
+
/** Alias for `loading` (used when it is unset). */
|
|
137
|
+
processing?: string | undefined;
|
|
138
|
+
/** Full-screen splash on the in-app loading screens; video or any `<img>` format. */
|
|
139
|
+
loading?: string | undefined;
|
|
140
|
+
}
|
|
141
|
+
/** Media is per mode. */
|
|
142
|
+
interface YodlThemeImageSets {
|
|
143
|
+
light?: YodlThemeImages | undefined;
|
|
144
|
+
dark?: YodlThemeImages | undefined;
|
|
16
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* One customizable Yodl theme: a light/dark palette pair plus optional media.
|
|
148
|
+
* `font` and the radii sit at the top level because none of them is a color
|
|
149
|
+
* and none varies by mode. `radiusSurface` defaults to `radiusControl`.
|
|
150
|
+
*/
|
|
151
|
+
interface YodlTheme {
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
font?: YodlThemeFont | undefined;
|
|
154
|
+
radiusControl?: string | undefined;
|
|
155
|
+
radiusSurface?: string | undefined;
|
|
156
|
+
light?: YodlThemeModeTokens | undefined;
|
|
157
|
+
dark?: YodlThemeModeTokens | undefined;
|
|
158
|
+
images?: YodlThemeImageSets | undefined;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/types.d.ts
|
|
17
162
|
type SupportedChainIds = number[];
|
|
18
163
|
/** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
|
|
19
164
|
interface YodlWallet {
|
|
@@ -37,12 +182,12 @@ interface YodlHostThemeProps {
|
|
|
37
182
|
* Without `themeMode` it follows the device appearance. Keep the object stable
|
|
38
183
|
* across renders (module constant or memo) to avoid redundant theme updates.
|
|
39
184
|
*/
|
|
40
|
-
theme?: YodlTheme
|
|
185
|
+
theme?: YodlTheme;
|
|
41
186
|
/**
|
|
42
187
|
* Which mode the hosted UI paints: `'system'` follows the device appearance,
|
|
43
188
|
* `'light'`/`'dark'` pin it. Supplied without `theme`, it controls stock Yodl.
|
|
44
189
|
*/
|
|
45
|
-
themeMode?: YodlThemeMode
|
|
190
|
+
themeMode?: YodlThemeMode;
|
|
46
191
|
}
|
|
47
192
|
interface YodlEmailAttestationRequest {
|
|
48
193
|
/** The wallet the hosted flow proved with SIWE. Mint `sub` for exactly this address. */
|
|
@@ -73,7 +218,7 @@ interface YodlEventHandlers {
|
|
|
73
218
|
/** Called after a transaction is sent. */
|
|
74
219
|
onTransactionSent?: (txHash: string) => void;
|
|
75
220
|
/** Called when the WebView emits Yodl payment lifecycle details. */
|
|
76
|
-
onPaymentDetails?: (details: YodlPaymentDetails
|
|
221
|
+
onPaymentDetails?: (details: YodlPaymentDetails) => void;
|
|
77
222
|
/** Called on RPC / payment errors. */
|
|
78
223
|
onError?: (error: Error) => void;
|
|
79
224
|
}
|
|
@@ -113,18 +258,7 @@ type YodlDashboardProps = YodlComponentProps;
|
|
|
113
258
|
* <YodlProvider> and loads the dashboard route on the configured Yodl host.
|
|
114
259
|
* The Yodl UI is origin-locked to that host.
|
|
115
260
|
*/
|
|
116
|
-
declare function YodlDashboard({
|
|
117
|
-
onTransactionSent,
|
|
118
|
-
onPaymentDetails,
|
|
119
|
-
onError,
|
|
120
|
-
fetchEmailAttestation,
|
|
121
|
-
renderLoading,
|
|
122
|
-
onReady,
|
|
123
|
-
style,
|
|
124
|
-
backgroundColor,
|
|
125
|
-
theme,
|
|
126
|
-
themeMode
|
|
127
|
-
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
261
|
+
declare function YodlDashboard({ onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlDashboardProps): import("react").JSX.Element;
|
|
128
262
|
//#endregion
|
|
129
263
|
//#region src/components/YodlPayment.d.ts
|
|
130
264
|
interface YodlPaymentProps extends YodlComponentProps {
|
|
@@ -143,20 +277,7 @@ interface YodlPaymentProps extends YodlComponentProps {
|
|
|
143
277
|
* (e.g. the `/resolve` screen on the configured host). The Yodl UI is
|
|
144
278
|
* origin-locked to that host. Renders nothing for empty/unsupported QR data.
|
|
145
279
|
*/
|
|
146
|
-
declare function YodlPayment({
|
|
147
|
-
qrData,
|
|
148
|
-
navigateOnSubmit,
|
|
149
|
-
onTransactionSent,
|
|
150
|
-
onPaymentDetails,
|
|
151
|
-
onError,
|
|
152
|
-
fetchEmailAttestation,
|
|
153
|
-
renderLoading,
|
|
154
|
-
onReady,
|
|
155
|
-
style,
|
|
156
|
-
backgroundColor,
|
|
157
|
-
theme,
|
|
158
|
-
themeMode
|
|
159
|
-
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
280
|
+
declare function YodlPayment({ qrData, navigateOnSubmit, onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlPaymentProps): import("react").JSX.Element | null;
|
|
160
281
|
//#endregion
|
|
161
282
|
//#region src/components/YodlSignup.d.ts
|
|
162
283
|
interface YodlSignupProps extends YodlVisualProps {
|
|
@@ -180,30 +301,18 @@ interface YodlSignupProps extends YodlVisualProps {
|
|
|
180
301
|
* verification code entry, and the final signed-up screen, while callbacks let
|
|
181
302
|
* the native app observe status and completion.
|
|
182
303
|
*/
|
|
183
|
-
declare function YodlSignup({
|
|
184
|
-
onStatusChange,
|
|
185
|
-
onSignedUp,
|
|
186
|
-
onError,
|
|
187
|
-
onDismiss,
|
|
188
|
-
fetchEmailAttestation,
|
|
189
|
-
renderLoading,
|
|
190
|
-
onReady,
|
|
191
|
-
style,
|
|
192
|
-
backgroundColor,
|
|
193
|
-
theme,
|
|
194
|
-
themeMode
|
|
195
|
-
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
304
|
+
declare function YodlSignup({ onStatusChange, onSignedUp, onError, onDismiss, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlSignupProps): import("react").JSX.Element;
|
|
196
305
|
//#endregion
|
|
197
306
|
//#region src/sdk/yodl.d.ts
|
|
198
307
|
/**
|
|
199
308
|
* App-host configuration for the Yodl React Native SDK.
|
|
200
|
-
* Injected once via {@link
|
|
309
|
+
* Injected once via {@link createYodlSdk}.
|
|
201
310
|
*
|
|
202
311
|
* No RPC endpoint is needed: the embedded Yodl UI reads chain state through its
|
|
203
312
|
* own provider, and the injected wallet bridge only forwards signing/wallet
|
|
204
313
|
* methods to the host wallet.
|
|
205
314
|
*/
|
|
206
|
-
interface
|
|
315
|
+
interface YodlSdkConfig {
|
|
207
316
|
/** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
|
|
208
317
|
integrationAddress: `0x${string}`;
|
|
209
318
|
/** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
|
|
@@ -212,7 +321,7 @@ interface YodlConfig {
|
|
|
212
321
|
supportedChainIds: SupportedChainIds;
|
|
213
322
|
}
|
|
214
323
|
/** Config with defaults applied — what components read from the instance. */
|
|
215
|
-
type
|
|
324
|
+
type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
|
|
216
325
|
yodlUiBaseUrl: string;
|
|
217
326
|
};
|
|
218
327
|
/**
|
|
@@ -220,20 +329,20 @@ type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
|
|
|
220
329
|
* and the components read at runtime. Stateless QR helpers are exported as
|
|
221
330
|
* standalone functions (e.g. {@link isPaymentQr}) rather than instance methods.
|
|
222
331
|
*/
|
|
223
|
-
declare class
|
|
224
|
-
readonly config:
|
|
225
|
-
constructor(config:
|
|
332
|
+
declare class YodlSdk {
|
|
333
|
+
readonly config: ResolvedYodlSdkConfig;
|
|
334
|
+
constructor(config: YodlSdkConfig);
|
|
226
335
|
}
|
|
227
336
|
/**
|
|
228
337
|
* Create a Yodl SDK instance. Factory pattern, consistent with
|
|
229
|
-
* `@yodlpay/sdk-core`'s `
|
|
338
|
+
* `@yodlpay/sdk-core`'s `createYodlClient` / config-once convention.
|
|
230
339
|
*/
|
|
231
|
-
declare function
|
|
340
|
+
declare function createYodlSdk(config: YodlSdkConfig): YodlSdk;
|
|
232
341
|
//#endregion
|
|
233
342
|
//#region src/provider/context.d.ts
|
|
234
343
|
interface YodlProviderProps extends YodlHostThemeProps {
|
|
235
|
-
/** The SDK instance created via
|
|
236
|
-
sdk:
|
|
344
|
+
/** The SDK instance created via createYodlSdk(). */
|
|
345
|
+
sdk: YodlSdk;
|
|
237
346
|
/** EIP-1193 provider from the host wallet SDK. */
|
|
238
347
|
provider: YodlWallet['provider'];
|
|
239
348
|
/** Connected wallet address. */
|
|
@@ -246,15 +355,7 @@ interface YodlProviderProps extends YodlHostThemeProps {
|
|
|
246
355
|
* Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
|
|
247
356
|
* the optional host theme state to the Yodl components via React context.
|
|
248
357
|
*/
|
|
249
|
-
declare function YodlProvider({
|
|
250
|
-
sdk,
|
|
251
|
-
provider,
|
|
252
|
-
address,
|
|
253
|
-
chainId,
|
|
254
|
-
theme,
|
|
255
|
-
themeMode,
|
|
256
|
-
children
|
|
257
|
-
}: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
358
|
+
declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMode, children }: YodlProviderProps): import("react").JSX.Element;
|
|
258
359
|
//#endregion
|
|
259
360
|
//#region src/sdk/qr.d.ts
|
|
260
361
|
/**
|
|
@@ -268,4 +369,4 @@ declare function YodlProvider({
|
|
|
268
369
|
*/
|
|
269
370
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
270
371
|
//#endregion
|
|
271
|
-
export { type EIP1193Provider, type
|
|
372
|
+
export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{YODL_EMAIL_ATTESTATION_MAX_PER_SESSION as f,YODL_EMAIL_ATTESTATION_NATIVE_TIMEOUT_MS as p,YODL_REVEAL_CEILING_MS as m,isYodlEmailAttestationRequestMessage as h,isYodlReadyMessage as g,safeParseYodlTheme as _}from"@yodlpay/sdk-core/theme/host";import{jsx as v,jsxs as y}from"react/jsx-runtime";import{WebView as b}from"react-native-webview";import{detectProvider as x}from"@yodlpay/sdk-core/qr";const S={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function C(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function w(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:_(e),i=t===void 0||t===`system`||t===`light`||t===`dark`,a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:C(a,n)},error:o.length>0?o.join(`; `):null}}function T(e,t){let n=S[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function E(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function D(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function O(e,t){return JSON.stringify(D(e,t))}function k(e,t,n,r){let{envelope:i,error:a}=w(e,t,n);return a&&r?.(a),i}function A(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=w(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function j(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const M=e(null);function N({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>k(i,o,c,j),[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 v(M.Provider,{value:u,children:s})}function P(){let e=n(M);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function F(e,t){let n=P(),r=a(()=>A(n.hostTheme,e,t,n.systemScheme,j),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function I(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function L(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 R(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function z(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 ee(e){let t=e.code;if(t===4200||t===-32601)return!0;let n=e.message.toLowerCase();return n.includes(`method not found`)||n.includes(`method not supported`)||n.includes(`unsupported method`)||n.includes(`unsupported wc_ method`)||n.includes(`not supported`)||n.includes(`does not exist`)||n.includes(`not available`)}function B(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function V(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const H=/^0x[a-fA-F0-9]{40}$/;function U(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!H.test(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function W(e){return{"X-Yodl-Integration-Id":U(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.9.0`}}function te(e,t){let n=e.yodlUiBaseUrl?B(e.yodlUiBaseUrl):null;if(!(!n||!V(t,n)))return W(e)}let G=0;function ne(){return G+=1,`yodl-${Date.now().toString(36)}-${G.toString(36)}`}function re(e,t=ne){return{sessionId:t(),initialHostTheme:e}}function ie(e,t){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}})}function ae(e,t,n){return JSON.stringify({channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n})}function K(e){return`0x${e.toString(16)}`}function oe(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 J(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 se(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function ce(e){return{state:e,decision:{kind:`ignore`}}}function Y(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!h(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?ce(e):n.supported?q(t.address)===q(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=f?Y(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}}:Y(e,t.requestId,`address_mismatch`):Y(e,t.requestId,`not_supported`)}function ue(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const de=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function fe(e){return de.some(t=>t===e)}function pe(e,t,n){if(!fe(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=z((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 me(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>z(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function he(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function ge(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function _e(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!he(t))return;let n=t.receipts;if(n?.length&&!n.some(ge))return n[n.length-1]?.transactionHash}function ve(e){let t=K(e.chainId);return`(function() {
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLayoutEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{ActivityIndicator as c,StyleSheet as l,View as u,useColorScheme as d}from"react-native";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{WebView as m}from"react-native-webview";const h=/^0x[a-fA-F0-9]{40}$/;function g(e){return typeof e==`string`&&h.test(e)}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const v=new Set([`checking`,`signed_out`,`signing_up`,`signed_up`]);function y(e){if(e===void 0)return!0;if(!_(e))return!1;let{message:t,code:n}=e;return t!==void 0&&typeof t!=`string`?!1:n===void 0||typeof n==`string`||typeof n==`number`}function b(e){if(!_(e))return!1;switch(e.type){case`yodl_payment_details`:return _(e.details);case`yodl_payment_error`:case`yodl_signup_error`:return y(e.error);case`yodl_signup_status`:return typeof e.status==`string`&&v.has(e.status);case`yodl_signup_complete`:case`yodl_signup_dismissed`:return!0;case`ethereum_rpc_request`:return typeof e.id==`number`&&typeof e.method==`string`&&Array.isArray(e.params);default:return!1}}const x=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.%\s,/]+\))$/i,S=/^(?:0|(?:\d{1,4}(?:\.\d{1,3})?|\.\d{1,3})(?:px|rem|em|%))$/i,C=/^https:\/\/[^\s"\\]+$/,ee=[`system`,`inter`,`geist`,`mono`],w=[`bg`,`surface`,`surfaceSecondary`,`text`,`textSecondary`,`textMuted`,`border`,`success`,`error`,`warning`,`accent`,`bgDeep`,`surfaceHover`,`skeleton`,`accentStrong`,`accentDeep`,`brandSurface`,`brandSheet`,`brandText`,`brandButton`,`brandButtonText`],T=[`payBackground`,`processing`,`loading`];function E(e,t){return t?{channel:`yodl`,sessionId:e,type:`theme:update`,payload:t}:{channel:`yodl`,sessionId:e,type:`theme:release`}}function D(e,t){return{channel:`yodl`,sessionId:e,type:`auth:capabilities`,payload:{emailAttestation:t}}}function te(e,t,n){return{channel:`yodl`,sessionId:e,type:`auth:email-attestation`,requestId:t,payload:n}}const O=new Set([`system`,`light`,`dark`]);function k(e){return typeof e==`string`&&O.has(e)}const A=new Set(ee);function j(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of w){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>64||!x.test(i))return{success:!1,error:`${t}.${r}: colors must be hex, rgb() or rgba()`};n[r]=i}}return{success:!0,data:n}}function M(e,t){if(!_(e))return{success:!1,error:`${t}: expected an object`};let n={};for(let r of T){let i=e[r];if(i!==void 0){if(typeof i!=`string`||i.length>2048||!C.test(i))return{success:!1,error:`${t}.${r}: images must be https:// URLs`};n[r]=i}}return{success:!0,data:n}}function N(e){if(!_(e))return{success:!1,error:`images: expected an object`};let t=Object.keys(e).find(e=>e!==`light`&&e!==`dark`);if(t)return{success:!1,error:`images.${t}: unknown key`};let n={};for(let t of[`light`,`dark`]){if(e[t]===void 0)continue;let r=M(e[t],`images.${t}`);if(!r.success)return r;n[t]=r.data}return{success:!0,data:n}}function P(e){if(!_(e))return{success:!1,error:`(root): expected an object`};let t={};if(e.name!==void 0){if(typeof e.name!=`string`||e.name.length>64)return{success:!1,error:`name: must be a string of at most 64 characters`};t.name=e.name}if(e.font!==void 0){if(typeof e.font!=`string`||!A.has(e.font))return{success:!1,error:`font: must be one of ${[...A].join(`, `)}`};t.font=e.font}for(let n of[`radiusControl`,`radiusSurface`]){let r=e[n];if(r!==void 0){if(typeof r!=`string`||!S.test(r))return{success:!1,error:`${n}: radius must be a css length`};t[n]=r}}for(let n of[`light`,`dark`]){if(e[n]===void 0)continue;let r=j(e[n],n);if(!r.success)return r;t[n]=r.data}if(e.images!==void 0){let n=N(e.images);if(!n.success)return n;t.images=n.data}return{success:!0,data:t}}function F(e,t,n=1){return typeof e==`string`&&e.length>=n&&e.length<=t}function I(e,t){for(let n in e)if(!t.has(n))return!1;return!0}function L(e){if(!_(e)||Object.keys(e).length!==3)return!1;let{type:t,version:n,sessionId:r}=e;return!(t!==`yodl_ready`||n!==1||!F(r,128))}const R=new Set([`type`,`version`,`sessionId`,`requestId`,`address`]);function z(e){if(!_(e)||!I(e,R))return!1;let{type:t,version:n,sessionId:r,requestId:i,address:a}=e;return!(t!==`yodl_email_attestation_request`||n!==1||!F(r,128)||!F(i,64)||!g(a))}const B={light:{background:`#f8f8fc`,spinner:`#52525b`},dark:{background:`#18181b`,spinner:`#a1a1aa`}};function ne(e,t){return e===`system`?t===`light`?`light`:`dark`:e}function re(e,t,n){if(e===void 0&&t===void 0)return{envelope:null,error:null};let r=e===void 0?null:P(e),i=t===void 0||k(t),a=i?t??`system`:`system`,o=[r&&!r.success?`Invalid Yodl theme — ${r.error}`:null,i?null:`Invalid Yodl themeMode — themeMode must be system, light or dark`].filter(e=>e!==null);return{envelope:{version:1,authority:`host`,theme:r?.success?r.data:null,preference:a,resolved:ne(a,n)},error:o.length>0?o.join(`; `):null}}function ie(e,t){let n=B[e?e.resolved:`dark`],r=e?.theme?.[e.resolved];return{background:t??r?.bg??n.background,spinner:r?.textSecondary??n.spinner}}function ae(e,t,n){return{yodl:{version:1,sessionId:e,...t?{hostTheme:t}:{},...n?{integrationAddress:n}:{}}}}function V(e,t){return JSON.stringify(E(e,t))}function oe(e,t,n,r){let{envelope:i,error:a}=re(e,t,n);return a&&r?.(a),i}function se(e,t,n,r,i){if(t===void 0&&n===void 0)return e;let{envelope:a,error:o}=re(t??e?.theme??void 0,n??e?.preference,r);return o&&i?.(o),a}function H(e){typeof __DEV__<`u`&&__DEV__&&console.error(`[@yodlpay/react-native] ${e}`)}const ce=e(null);function le({sdk:e,provider:t,address:n,chainId:r,theme:i,themeMode:o,children:s}){let c=d(),l=a(()=>oe(i,o,c,H),[i,o,c]),u=a(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds,hostTheme:l,systemScheme:c}),[e,t,n,r,l,c]);return f(ce.Provider,{value:u,children:s})}function ue(){let e=n(ce);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function de(e,t){let n=ue(),r=a(()=>se(n.hostTheme,e,t,n.systemScheme,H),[n.hostTheme,n.systemScheme,e,t]);return{...n,hostTheme:r}}function fe(e){let t=e?.integrationAddress?.trim();if(!t)throw Error(`Yodl integrationAddress is required`);if(!g(t))throw Error(`Yodl integrationAddress is not a valid address: ${t}`);return t}function pe(e,t){return{"X-Yodl-Integration-Id":fe(e),"X-Yodl-SDK-Name":t.name,"X-Yodl-SDK-Version":t.version}}function U(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function me(e){return e.code===4001||/rejected|denied/i.test(e.message)}const he=[`method not found`,`method not supported`,`unsupported method`,`does not exist`],ge=[...he,`not supported`,`not available`];function _e(e,t){let n=[e.message,e.details].filter(e=>typeof e==`string`).join(` `).toLowerCase();return t.some(e=>n.includes(e))}function ve(e){let t=e.code;return typeof t==`number`?t===4200||t===-32601||_e(e,he):_e(e,ge)}function ye(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function be(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}const xe={name:`@yodlpay/react-native`,version:`0.10.0`};function Se(e){return pe(e,xe)}function Ce(e,t){let n=e.yodlUiBaseUrl?ye(e.yodlUiBaseUrl):null;if(!(!n||!be(t,n)))return Se(e)}let we=0;function Te(){return we+=1,`yodl-${Date.now().toString(36)}-${we.toString(36)}`}function Ee(e,t=Te){return{sessionId:t(),initialHostTheme:e}}function W(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function De(e){if(typeof e!=`string`||!/^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(e))return;let t=Number.parseInt(e,16);return Number.isSafeInteger(t)?t:void 0}function Oe(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>De(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function ke(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function Ae(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!ke(t))return;let n=t.receipts;if(n?.length&&!n.some(Ae))return n[n.length-1]?.transactionHash}function G(e){return`0x${e.toString(16)}`}function Me(e,t=`unsupported`){let n={};for(let r of e)n[G(r)]={atomic:{status:t}};return n}function K(e){return e.toLowerCase()}function Ne(e,t){let n=K(t.address),r=e.address!==n,i=e.propChainId!==t.chainId;if(!r&&!i)return null;let a=i&&e.activeChainId!==t.chainId;return{nextAddress:n,nextPropChainId:t.chainId,nextActiveChainId:a?t.chainId:e.activeChainId,...r?{accountsChanged:[n]}:{},...a?{chainChanged:{chainId:t.chainId,chainIdHex:G(t.chainId)}}:{}}}function Pe(e){return{sessionId:e,answeredRequestIds:new Set,inFlightRequestId:null,mintCount:0}}function Fe(e){return{state:e,decision:{kind:`ignore`}}}function Ie(e,t,n){return{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t)},decision:{kind:`reject`,requestId:t,reason:n}}}function Le(e,t,n){return!z(t)||t.sessionId!==e.sessionId||e.answeredRequestIds.has(t.requestId)?Fe(e):n.supported?K(t.address)===K(n.walletAddress)?e.inFlightRequestId!==null||e.mintCount>=3?Ie(e,t.requestId,`rate_limited`):{state:{...e,answeredRequestIds:new Set(e.answeredRequestIds).add(t.requestId),inFlightRequestId:t.requestId,mintCount:e.mintCount+1},decision:{kind:`mint`,request:t}}:Ie(e,t.requestId,`address_mismatch`):Ie(e,t.requestId,`not_supported`)}function Re(e,t){return e.inFlightRequestId===t?{...e,inFlightRequestId:null}:e}const ze=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function Be(e){return ze.some(t=>t===e)}function Ve(e,t,n){if(!Be(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=De((t[0]??{}).chainId);if(typeof r!=`number`)return{error:{code:-32602,message:`Missing or invalid chainId parameter`}};if(!n.includes(r))return{error:{code:4902,message:`Chain ${r} not supported`}};let i=G(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function He(e){let t=G(e.chainId);return`(function() {
|
|
2
2
|
if (window.ethereum) return;
|
|
3
3
|
|
|
4
4
|
var _address = ${JSON.stringify(e.address.toLowerCase())};
|
|
@@ -225,4 +225,4 @@ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useLay
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function ye(e){return JSON.stringify(e)}function X(e){return{state:e,message:null,readyAccepted:!1}}function be(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:O(e.sessionId,e.currentTheme),readyAccepted:t}}function xe(e,t){let n=ye(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function Se(e,t){let n=ye(t);if(n===e.currentFingerprint)return X(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?be(r,!1):X(r)}function Ce(e,t){return!g(t)||t.sessionId!==e.sessionId?X(e):be({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function Z(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function Q(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function we(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:m,onSignupDismissed:h,onError:g,onReady:_,sessionId:v,hostTheme:y=null,initialHostTheme:b=null,fetchEmailAttestation:x}=e,S=o(null),C=o(q(s)),w=o(c),T=o(c),E=o(new Set),D=o(y),O=o(v?xe(v,b):null),k=o(v?se(v):null),A=o(x);i(()=>{D.current=y},[y]),i(()=>{A.current=x},[x]),i(()=>{O.current=v?xe(v,b):null},[b,v]),i(()=>{k.current=v?se(v):null},[v]);let j=t(e=>{E.current.has(e)||(E.current.add(e),u?.(e))},[u]);r(()=>{let e=J({address:C.current,propChainId:w.current,activeChainId:T.current},{address:s,chainId:c});e&&(C.current=e.nextAddress,w.current=e.nextPropChainId,T.current=e.nextActiveChainId,e.accountsChanged&&Q(S,`accountsChanged`,e.accountsChanged),e.chainChanged&&Q(S,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!O.current)return;let e=Se(O.current,y);O.current=e.state,e.message&&S.current?.postMessage(e.message)},[y]);let M=a(()=>ve({address:s,chainId:c}),[s,c]),N=t(async(e,t,r)=>{try{let i=pe(t,r,l);if(`error`in i){Z(S,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),Z(S,e,null),i.switchesActiveChain&&(T.current=i.requestedChainId,Q(S,`chainChanged`,i.chainIdHex))}catch(t){let n=L(t,`Chain request failed`);Z(S,e,void 0,R(n)),g?.(n)}},[n,l,g]),P=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});Z(S,e,i)}catch(n){let r=L(n,`Capabilities unavailable`);if(!ee(r)){Z(S,e,void 0,R(r));return}Z(S,e,oe(me(t,l),`unsupported`))}},[n,s,l]),F=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=_e(r);i&&j(i),Z(S,e,r)}catch(t){let n=L(t,`Failed to get call status`);Z(S,e,void 0,R(n))}},[n,j]),z=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&j(i),Z(S,e,i)}catch(t){let n=L(t,`Request failed`),r=I(n);Z(S,e,void 0,r?{code:4001,message:n.message}:R(n)),r||g?.(n)}},[n,j,g]),B=t((e,t)=>{let n=k.current;n&&(k.current=ue(n,e),S.current?.postMessage(ae(n.sessionId,e,t)))},[]),V=t(async(e,t)=>{let n=A.current;if(!n){B(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),p),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&&B(t.requestId,a)},[B]),H=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`){B(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&V(t.sessionId,n.decision.request)},[V,B]);return{uiRef:S,injectedJavaScript:M,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(!t||typeof t!=`object`||!(`type`in t))return;if(t.type===`yodl_ready`){if(!O.current){_?.();return}let e=Se(O.current,D.current);O.current=e.state,e.message&&S.current?.postMessage(e.message);let n=Ce(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(ie(r.sessionId,!!A.current)),_?.();return}if(t.type===`yodl_email_attestation_request`){H(t);return}if(t.type===`yodl_payment_details`){d?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),g?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){m?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),g?.(n);return}if(t.type===`yodl_signup_dismissed`){h?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;fe(r)?N(n,r,i):r===`wallet_getCapabilities`?P(n,i):r===`wallet_getCallsStatus`?F(n,i):z(n,r,i)},[N,P,F,z,H,d,f,m,h,g,_])}}function $(e){return v(Te,{...e},e.uri)}function Te({uri:e,sdkConfig:n,provider:l,address:d,chainId:f,supportedChainIds:p,onTransactionSent:h,onPaymentDetails:g,onSignupStatusChange:_,onSignedUp:x,onSignupDismissed:S,onError:C,style:w,backgroundColor:D,hostTheme:O=null,fetchEmailAttestation:k,renderLoading:A,onReady:j,sharedCookiesEnabled:M=!0,thirdPartyCookiesEnabled:N=!0,onLoadStart:P,...F}){let[I]=s(()=>re(O)),L=T(O,D),R=L.background,[z,ee]=s(null),H=z===I.sessionId,U=o(j);i(()=>{U.current=j},[j]);let W=o(!1),G=t(()=>{ee(I.sessionId),!W.current&&(W.current=!0,U.current?.())},[I.sessionId]);r(()=>{if(H)return;let e=setTimeout(G,m);return()=>clearTimeout(e)},[G,H]);let{uiRef:ne,injectedJavaScript:ie,onMessage:ae}=we({provider:l,address:d,chainId:f,supportedChainIds:p,onReady:G,sessionId:I.sessionId,hostTheme:O,initialHostTheme:I.initialHostTheme,...h!==void 0&&{onTransactionSent:h},...g!==void 0&&{onPaymentDetails:g},..._!==void 0&&{onSignupStatusChange:_},...x!==void 0&&{onSignedUp:x},...S!==void 0&&{onSignupDismissed:S},...C!==void 0&&{onError:C},...k!==void 0&&{fetchEmailAttestation:k}}),K=a(()=>B(e),[e]),oe=a(()=>{let t=te(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),q=a(()=>e=>!K||!e?.url?!1:V(e.url,K)||e.url.startsWith(`about:`),[K]),J=H?null:A?A():v(c,{color:L.spinner});return y(u,{style:[Ee.container,{backgroundColor:R},w],children:[v(b,{ref:ne,source:oe,originWhitelist:K?[K]:[],onShouldStartLoadWithRequest:q,javaScriptEnabled:!0,sharedCookiesEnabled:M,thirdPartyCookiesEnabled:N,injectedJavaScriptBeforeContentLoaded:ie,injectedJavaScriptObject:E(I.sessionId,I.initialHostTheme,n.integrationAddress),onMessage:ae,...P!==void 0&&{onLoadStart:P},style:[Ee.ui,{backgroundColor:R}],...F}),J&&v(u,{style:[Ee.overlay,{backgroundColor:R}],children:J})]})}const Ee=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function De({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:f,chainId:p,supportedChainIds:m,sdk:h,hostTheme:g}=F(l,u);return v($,{uri:a(()=>h.config.yodlUiBaseUrl.replace(/\/$/,``),[h.config.yodlUiBaseUrl]),sdkConfig:h.config,provider:d,address:f,chainId:p,supportedChainIds:m,hostTheme:g,...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 Oe(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 ke(e){return Oe(e,`/sdk/signup`)}const Ae=`always`;function je(e,t,n=Ae){return!e||typeof e!=`string`||e.trim().length===0||!x(e).find(e=>e.action===`resolve`)?null:Oe(t,`/resolve`,{data:e,navigateOnSubmit:n===Ae?void 0:n})}function Me({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,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:y}=F(d,f),b=a(()=>je(e,_.config.yodlUiBaseUrl,t),[e,_.config.yodlUiBaseUrl,t]);return b?v($,{uri:b,sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,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 Ne({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:f,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=F(u,d);return v($,{uri:a(()=>ke(g.config.yodlUiBaseUrl),[g.config.yodlUiBaseUrl]),sdkConfig:g.config,provider:f,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...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 Pe(e){return(Array.isArray(e)?e:[e]).some(e=>x(e).some(e=>e.action===`resolve`))}var Fe=class{config;constructor(e){let t=U(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 Ie(e){return new Fe(e)}export{Fe as Yodl,De as YodlDashboard,Me as YodlPayment,N as YodlProvider,Ne as YodlSignup,Ie as createSdk,Pe as isPaymentQr};
|
|
228
|
+
true;`}function Ue(e){return JSON.stringify(e)}function We(e){return{state:e,message:null,readyAccepted:!1}}function Ge(e,t){return e.currentFingerprint===e.deliveredFingerprint?{state:e,message:null,readyAccepted:t}:{state:{...e,deliveredFingerprint:e.currentFingerprint},message:V(e.sessionId,e.currentTheme),readyAccepted:t}}function Ke(e,t){let n=Ue(t);return{sessionId:e,currentTheme:t,currentFingerprint:n,deliveredFingerprint:n,ready:!1}}function qe(e,t){let n=Ue(t);if(n===e.currentFingerprint)return We(e);let r={...e,currentTheme:t,currentFingerprint:n};return r.ready?Ge(r,!1):We(r)}function Je(e,t){return!L(t)||t.sessionId!==e.sessionId?We(e):Ge({...e,ready:!0,...e.ready&&{deliveredFingerprint:``}},!0)}function q(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function Ye(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function Xe(e){return _(e)&&`type`in e}function Ze(e,t){let n=Error(e?.message??t);return e?.code!==void 0&&(n.code=e.code),n}function Qe(e){let{provider:n,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g,sessionId:_,hostTheme:v=null,initialHostTheme:y=null,fetchEmailAttestation:x}=e,S=o(null),C=o(K(s)),ee=o(c),w=o(c),T=o(new Set),E=o(v),O=o(_?Ke(_,y):null),k=o(_?Pe(_):null),A=o(x);i(()=>{E.current=v},[v]),i(()=>{A.current=x},[x]),i(()=>{O.current=_?Ke(_,y):null},[y,_]),i(()=>{k.current=_?Pe(_):null},[_]);let j=t(e=>{T.current.has(e)||(T.current.add(e),u?.(e))},[u]);r(()=>{let e=Ne({address:C.current,propChainId:ee.current,activeChainId:w.current},{address:s,chainId:c});e&&(C.current=e.nextAddress,ee.current=e.nextPropChainId,w.current=e.nextActiveChainId,e.accountsChanged&&Ye(S,`accountsChanged`,e.accountsChanged),e.chainChanged&&Ye(S,`chainChanged`,e.chainChanged.chainIdHex))},[s,c]),r(()=>{if(!O.current)return;let e=qe(O.current,v);O.current=e.state,e.message&&S.current?.postMessage(e.message)},[v]);let M=a(()=>He({address:s,chainId:c}),[s,c]),N=t(async(e,t,r)=>{try{let i=Ve(t,r,l);if(`error`in i){q(S,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),q(S,e,null),i.switchesActiveChain&&(w.current=i.requestedChainId,Ye(S,`chainChanged`,i.chainIdHex))}catch(t){let n=U(t,`Chain request failed`);q(S,e,void 0,W(n)),h?.(n)}},[n,l,h]),P=t(async(e,t)=>{try{let r=t.length>0?t:[s,l.map(e=>G(e))],i=await n.request({method:`wallet_getCapabilities`,params:r});q(S,e,i)}catch(n){let r=U(n,`Capabilities unavailable`);if(!ve(r)){q(S,e,void 0,W(r));return}q(S,e,Me(Oe(t,l),`unsupported`))}},[n,s,l]),F=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=je(r);i&&j(i),q(S,e,r)}catch(t){let n=U(t,`Failed to get call status`);q(S,e,void 0,W(n))}},[n,j]),I=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&j(i),q(S,e,i)}catch(t){let n=U(t,`Request failed`),r=me(n);q(S,e,void 0,r?{code:4001,message:n.message}:W(n)),r||h?.(n)}},[n,j,h]),L=t((e,t)=>{let n=k.current;n&&(k.current=Re(n,e),S.current?.postMessage(JSON.stringify(te(n.sessionId,e,t))))},[]),R=t(async(e,t)=>{let n=A.current;if(!n){L(t.requestId,{status:`unavailable`,reason:`not_supported`});return}let r=new AbortController,i=setTimeout(()=>r.abort(),3e4),a;try{let e=await n({address:t.address,signal:r.signal});a=e?.token&&e.email?{status:`ok`,token:e.token,email:e.email}:{status:`unavailable`,reason:`declined`}}catch{a={status:`unavailable`,reason:r.signal.aborted?`timeout`:`error`}}finally{clearTimeout(i)}k.current?.sessionId===e&&L(t.requestId,a)},[L]),z=t(e=>{let t=k.current;if(!t)return;let n=Le(t,e,{walletAddress:C.current,supported:!!A.current});if(k.current=n.state,n.decision.kind===`reject`){L(n.decision.requestId,{status:`unavailable`,reason:n.decision.reason});return}n.decision.kind===`mint`&&R(t.sessionId,n.decision.request)},[R,L]),B=t(e=>{switch(e.type){case`yodl_payment_details`:d?.(e.details);return;case`yodl_payment_error`:h?.(Ze(e.error,`Payment details error`));return;case`yodl_signup_status`:f?.(e.status);return;case`yodl_signup_complete`:p?.();return;case`yodl_signup_error`:h?.(Ze(e.error,`Signup error`));return;case`yodl_signup_dismissed`:m?.();return;case`ethereum_rpc_request`:{let{id:t,method:n,params:r}=e;Be(n)?N(t,n,r):n===`wallet_getCapabilities`?P(t,r):n===`wallet_getCallsStatus`?F(t,r):I(t,n,r);return}}},[N,P,F,I,d,f,p,m,h]);return{uiRef:S,injectedJavaScript:M,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(Xe(t)){if(t.type===`yodl_ready`){if(!O.current){g?.();return}let e=qe(O.current,E.current);O.current=e.state,e.message&&S.current?.postMessage(e.message);let n=Je(O.current,t);if(O.current=n.state,!n.readyAccepted)return;n.message&&S.current?.postMessage(n.message);let r=k.current;r&&S.current?.postMessage(JSON.stringify(D(r.sessionId,!!A.current))),g?.();return}if(t.type===`yodl_email_attestation_request`){z(t);return}b(t)&&B(t)}},[B,z,g])}}function $e(e){return f(et,{...e},e.uri)}function et({uri:e,sdkConfig:n,provider:l,address:d,chainId:h,supportedChainIds:g,onTransactionSent:_,onPaymentDetails:v,onSignupStatusChange:y,onSignedUp:b,onSignupDismissed:x,onError:S,style:C,backgroundColor:ee,hostTheme:w=null,fetchEmailAttestation:T,renderLoading:E,onReady:D,sharedCookiesEnabled:te=!0,thirdPartyCookiesEnabled:O=!0,onLoadStart:k,...A}){let[j]=s(()=>Ee(w)),M=ie(w,ee),N=M.background,[P,F]=s(null),I=P===j.sessionId,L=o(D);i(()=>{L.current=D},[D]);let R=o(!1),z=t(()=>{F(j.sessionId),!R.current&&(R.current=!0,L.current?.())},[j.sessionId]);r(()=>{if(I)return;let e=setTimeout(z,8e3);return()=>clearTimeout(e)},[z,I]);let{uiRef:B,injectedJavaScript:ne,onMessage:re}=Qe({provider:l,address:d,chainId:h,supportedChainIds:g,onReady:z,sessionId:j.sessionId,hostTheme:w,initialHostTheme:j.initialHostTheme,..._!==void 0&&{onTransactionSent:_},...v!==void 0&&{onPaymentDetails:v},...y!==void 0&&{onSignupStatusChange:y},...b!==void 0&&{onSignedUp:b},...x!==void 0&&{onSignupDismissed:x},...S!==void 0&&{onError:S},...T!==void 0&&{fetchEmailAttestation:T}}),V=a(()=>ye(e),[e]),oe=a(()=>{let t=Ce(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),se=a(()=>e=>!V||!e?.url?!1:be(e.url,V)||e.url.startsWith(`about:`),[V]),H=I?null:E?E():f(c,{color:M.spinner});return p(u,{style:[tt.container,{backgroundColor:N},C],children:[f(m,{ref:B,source:oe,originWhitelist:V?[V]:[],onShouldStartLoadWithRequest:se,javaScriptEnabled:!0,sharedCookiesEnabled:te,thirdPartyCookiesEnabled:O,injectedJavaScriptBeforeContentLoaded:ne,injectedJavaScriptObject:ae(j.sessionId,j.initialHostTheme,n.integrationAddress),onMessage:re,...k!==void 0&&{onLoadStart:k},style:[tt.ui,{backgroundColor:N}],...A}),H&&f(u,{style:[tt.overlay,{backgroundColor:N}],children:H})]})}const tt=l.create({container:{flex:1},ui:{flex:1},overlay:{position:`absolute`,top:0,left:0,right:0,bottom:0,alignItems:`center`,justifyContent:`center`}});function nt({onTransactionSent:e,onPaymentDetails:t,onError:n,fetchEmailAttestation:r,renderLoading:i,onReady:o,style:s,backgroundColor:c,theme:l,themeMode:u}){let{provider:d,address:p,chainId:m,supportedChainIds:h,sdk:g,hostTheme:_}=de(l,u),v=a(()=>g.config.yodlUiBaseUrl.replace(/\/$/,``),[g.config.yodlUiBaseUrl]);return f($e,{uri:v,sdkConfig:g.config,provider:d,address:p,chainId:m,supportedChainIds:h,hostTheme:_,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{fetchEmailAttestation:r},...i!==void 0&&{renderLoading:i},...o!==void 0&&{onReady:o},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function rt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function it(e){if(Array.isArray(e))return e}function at(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t,n){return t&&ot(e.prototype,t),n&&ot(e,n),e}function ct(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function lt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ut(e,t){return it(e)||ct(e,t)||ft(e,t)||lt()}function dt(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ft(e,t){if(e){if(typeof e==`string`)return rt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rt(e,t)}}var pt=Object.defineProperty,mt=function(e,t,n){return t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},ht=function(e,t){for(var n in t)pt(e,n,{get:t[n],enumerable:!0})},J=function(e,t,n){return mt(e,(t===void 0?`undefined`:dt(t))===`symbol`?t:t+``,n)},gt=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];function _t(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0)t=gt[(o.value.charCodeAt(0)^t>>8)&255]^t<<8}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return(t^0)&65535}function vt(e){for(var t=[],n=0;n<e.length;){var r=e.substring(n),i=r.substring(0,2),a=parseInt(r.substring(2,4)),o=r.substring(4,4+a);t.push({id:i,length:a,value:o}),n+=a+4}return t}function Y(e){var t=``,n=!0,r=!1,i=void 0;try{for(var a=e[Symbol.iterator](),o;!(n=(o=a.next()).done);n=!0){var s=o.value;if(t+=s.id,t+=(`00`+s.length).slice(-2),s.subTags){t+=Y(s.subTags);continue}t+=s.value}}catch(e){r=!0,i=e}finally{try{!n&&a.return!=null&&a.return()}finally{if(r)throw i}}return t}function yt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=_t(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function X(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=yt(e,n),e}function bt(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function Z(e,t){return{id:e,length:t.length,value:t}}function xt(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[Z(`00`,`A000000677010112`),Z(`01`,t),Z(`02`,r)];i&&o.push(Z(`03`,i));var s=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`30`,Y(o)),Z(`53`,`764`),Z(`58`,`TH`)];return n&&s.push(Z(`54`,Number(n).toFixed(2))),a&&s.push(Z(`62`,Y([Z(`07`,a)]))),X(Y(s),`63`)}var St=function(){function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;at(this,e),J(this,`billerId`),J(this,`ref1`),J(this,`ref2`),J(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return st(e,[{key:`toString`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount,a=i?String(Number(i.toFixed(2))*100):`0`;return`|${t}\r${n}\r${r??``}\r${a}`}},{key:`toQrTag30`,value:function(){var e=this,t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return xt({billerId:t,ref1:n,ref2:r??void 0,amount:i??void 0})}}],[{key:`fromString`,value:function(t){if(!t.startsWith(`|`))return null;var n=t.slice(1).split(`\r`,4);if(n.length!=4)return null;var r=ut(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Q=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Q||{});function Ct(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=Y([Z(`00`,`A000000677010111`),Z(Q[t],n)]),a=[Z(`00`,`01`),Z(`01`,r?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return r&&a.push(Z(`54`,Number(r).toFixed(2))),X(Y(a),`63`)}ht({},{ProxyType:function(){return Q},anyId:function(){return Ct},billPayment:function(){return xt},botBarcode:function(){return wt},slipVerify:function(){return Tt},trueMoney:function(){return Dt},trueMoneySlipVerify:function(){return Ot}});function wt(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new St(t,n,r,i).toString()}function Tt(e){var t=e.sendingBank,n=e.transRef;return X(Y([Z(`00`,Y([Z(`00`,`000001`),Z(`01`,t),Z(`02`,n)])),Z(`51`,`TH`)]),`91`)}function Et(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Dt(e){var t=e.mobileNo,n=e.amount,r=e.message,i=Y([Z(`00`,`A000000677010111`),Z(`03`,`14000${t}`)]),a=[Z(`00`,`01`),Z(`01`,n?`12`:`11`),Z(`29`,i),Z(`53`,`764`),Z(`58`,`TH`)];return n&&a.push(Z(`54`,Number(n).toFixed(2))),r&&a.push(Z(`81`,Et(r))),X(Y(a),`63`)}function Ot(e){var t=e.eventType,n=e.transactionId,r=e.date;return X(Y([Z(`00`,Y([Z(`00`,`01`),Z(`01`,`01`),Z(`02`,t),Z(`03`,n),Z(`04`,r)]))]),`91`,!1)}function kt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function At(e){if(Array.isArray(e))return e}function jt(e){if(Array.isArray(e))return kt(e)}function Mt(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Nt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Pt(e,t,n){return t&&Nt(e.prototype,t),n&&Nt(e,n),e}function Ft(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Lt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Rt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zt(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Ft(e,t,n[t])})}return e}function Vt(e,t){return At(e)||Lt(e,t)||Ut(e,t)||Rt()}function Ht(e){return jt(e)||It(e)||Ut(e)||zt()}function Ut(e,t){if(e){if(typeof e==`string`)return kt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kt(e,t)}}ht({},{anyId:function(){return Kt},bcelOneProof:function(){return Gt},billPayment:function(){return qt},slipVerify:function(){return Jt},trueMoneySlipVerify:function(){return Yt}});var Wt=function(){function e(t,n){Mt(this,e),J(this,`payload`),J(this,`tags`),this.payload=t,this.tags=n}return Pt(e,[{key:`getTag`,value:function(e,t){return bt(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=X(Y(Ht(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=yt(e.slice(0,-4)))return null;var r=vt(e);if(r.length==0)return null;if(n){var i=!0,a=!1,o=void 0;try{for(var s=r[Symbol.iterator](),c;!(i=(c=s.next()).done);i=!0){var l=c.value;if(!(typeof l.value!=`string`||!l.value.match(/^\d{4}.+/))){var u=vt(l.value);u.every(function(e){return e.length>0&&e.length===e.value.length})&&(l.subTags=u)}}}catch(e){a=!0,o=e}finally{try{!i&&s.return!=null&&s.return()}finally{if(a)throw o}}}return new Wt(e,r)}function Gt(e){var t=$(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Kt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Q).find(function(e){var n=Vt(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Vt(i,2),o=a[0],s=a[1],c=t.getTagValue(`29`,s);o===`MSISDN`&&c.length==13&&c.startsWith(`0066`)&&(c=`0`+c.slice(-9));var l=t?.getTagValue(`54`),u=l===void 0?void 0:parseFloat(l);return Bt({type:o,target:c},u!==void 0&&{amount:u})}function qt(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Bt({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Jt(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=$(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Yt(e){var t=$(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Xt={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Zt(e){return e?e.getTagValue(`58`)??null:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(Xt))r.includes(e)&&t.push(n);return t}function $t(e){return e.toLowerCase().startsWith(`upi://`)}function en(e,t){if(!e||typeof e!=`string`||e.trim().length===0)return[];let n=e.trim(),r=[];try{let e=Zt($(n));if(e){let n=Qt(e);for(let e of n)(!t||t.includes(e))&&r.push({provider:e,action:`resolve`});if(r.length>0)return r}}catch{}return $t(n)&&(!t||t.includes(`aeon`))?[{provider:`aeon`,action:`resolve`}]:r}function tn(e,t){let n=e.filter(e=>e.action===`resolve`).map(e=>e.provider);return t?n.filter(e=>t.includes(e)):n}function nn(e,t,n={}){let r=Object.entries(n).filter(e=>e[1]!==void 0).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`),i=`${e.replace(/\/+$/,``)}${t?`/${t.replace(/^\/+/,``)}`:``}`;return r?`${i}?${r}`:i}function rn(e){return nn(e,`/sdk/signup`)}const an=`always`;function on(e,t,n=an){return!e||typeof e!=`string`||e.trim().length===0||tn(en(e)).length===0?null:nn(t,`/resolve`,{data:e,navigateOnSubmit:n===an?void 0:n})}function sn({qrData:e,navigateOnSubmit:t,onTransactionSent:n,onPaymentDetails:r,onError:i,fetchEmailAttestation:o,renderLoading:s,onReady:c,style:l,backgroundColor:u,theme:d,themeMode:p}){let{provider:m,address:h,chainId:g,supportedChainIds:_,sdk:v,hostTheme:y}=de(d,p),b=a(()=>on(e,v.config.yodlUiBaseUrl,t),[e,v.config.yodlUiBaseUrl,t]);return b?f($e,{uri:b,sdkConfig:v.config,provider:m,address:h,chainId:g,supportedChainIds:_,hostTheme:y,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...o!==void 0&&{fetchEmailAttestation:o},...s!==void 0&&{renderLoading:s},...c!==void 0&&{onReady:c},...l!==void 0&&{style:l},...u!==void 0&&{backgroundColor:u}}):null}function cn({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,fetchEmailAttestation:i,renderLoading:o,onReady:s,style:c,backgroundColor:l,theme:u,themeMode:d}){let{provider:p,address:m,chainId:h,supportedChainIds:g,sdk:_,hostTheme:v}=de(u,d),y=a(()=>rn(_.config.yodlUiBaseUrl),[_.config.yodlUiBaseUrl]);return f($e,{uri:y,sdkConfig:_.config,provider:p,address:m,chainId:h,supportedChainIds:g,hostTheme:v,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...i!==void 0&&{fetchEmailAttestation:i},...o!==void 0&&{renderLoading:o},...s!==void 0&&{onReady:s},...c!==void 0&&{style:c},...l!==void 0&&{backgroundColor:l}})}function ln(e){return(Array.isArray(e)?e:[e]).some(e=>tn(en(e)).length>0)}var un=class{config;constructor(e){let t=fe(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationAddress:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function dn(e){return new un(e)}export{nt as YodlDashboard,sn as YodlPayment,le as YodlProvider,un as YodlSdk,cn as YodlSignup,dn as createYodlSdk,ln as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"react-native": {
|
|
30
|
-
"types": "./dist/index.d.
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
31
|
"default": "./dist/index.cjs"
|
|
32
32
|
},
|
|
33
33
|
"import": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"types": "./dist/index.d.cts",
|
|
39
39
|
"default": "./dist/index.cjs"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
42
43
|
},
|
|
43
44
|
"repository": {
|
|
44
45
|
"type": "git",
|
|
@@ -61,30 +62,28 @@
|
|
|
61
62
|
"THIRD_PARTY_NOTICES.txt"
|
|
62
63
|
],
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"react": "
|
|
65
|
+
"react": "^19.2.8",
|
|
65
66
|
"react-native": ">=0.72.0",
|
|
66
67
|
"react-native-webview": ">=13.0.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
70
|
-
"@types/
|
|
71
|
-
"
|
|
70
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
71
|
+
"@types/node": "^22.19.19",
|
|
72
|
+
"@types/react": "^19.2.18",
|
|
73
|
+
"publint": "^0.3.24",
|
|
72
74
|
"react": "^19.0.0",
|
|
73
|
-
"react-native": "^0.
|
|
74
|
-
"react-native-webview": "
|
|
75
|
-
"tsdown": "^0.22.
|
|
76
|
-
"typescript": "^5.
|
|
77
|
-
"vitest": "^4.1.
|
|
78
|
-
"@yodlpay/sdk-core": "0.
|
|
79
|
-
},
|
|
80
|
-
"dependencies": {
|
|
81
|
-
"zod": "^4.4.3"
|
|
75
|
+
"react-native": "^0.87.0",
|
|
76
|
+
"react-native-webview": "13.16.1",
|
|
77
|
+
"tsdown": "^0.22.14",
|
|
78
|
+
"typescript": "^5.9.0",
|
|
79
|
+
"vitest": "^4.1.11",
|
|
80
|
+
"@yodlpay/sdk-core": "0.13.0"
|
|
82
81
|
},
|
|
83
82
|
"scripts": {
|
|
84
83
|
"build": "tsdown",
|
|
85
84
|
"typecheck": "tsc --noEmit",
|
|
86
85
|
"test": "vitest run",
|
|
87
86
|
"test:watch": "vitest",
|
|
88
|
-
"lint": "
|
|
87
|
+
"lint": "eslint . --max-warnings 0"
|
|
89
88
|
}
|
|
90
89
|
}
|