@yodlpay/react-native 0.1.3 → 0.3.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 +52 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +41 -5
- package/dist/index.d.mts +41 -5
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ const sdk = createSdk({
|
|
|
37
37
|
- [Features](#features)
|
|
38
38
|
- [Platform Notes](#platform-notes)
|
|
39
39
|
- [Usage](#usage)
|
|
40
|
+
- [Signup flow](#signup-flow)
|
|
40
41
|
- [Full example](#full-example)
|
|
41
42
|
- [Optional EIP-7702 fallback](#optional-eip-7702-fallback)
|
|
42
43
|
- [API Reference](#api-reference)
|
|
@@ -121,7 +122,7 @@ export function PaymentScreen({ qrData, provider, address, chainId }) {
|
|
|
121
122
|
## Features
|
|
122
123
|
|
|
123
124
|
- **Wallet-agnostic** — any EIP-1193 provider (Privy, MetaMask, Coinbase Wallet, Rainbow, WalletConnect).
|
|
124
|
-
- **
|
|
125
|
+
- **Three drop-in components** — `<YodlSignup>` for onboarding, `<YodlPayment>` for QR payments, `<YodlDashboard>` for the account view.
|
|
125
126
|
- **Hardened by default** — UI locked to the Yodl origin, off-origin navigation blocked. No config.
|
|
126
127
|
- **Batching & paymasters** — bridges [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) (`wallet_sendCalls`); native support passes through, or add the [EIP-7702 provider](#optional-eip-7702-fallback) for atomic batching + gas sponsorship.
|
|
127
128
|
- **Multi-chain** — Ethereum, Arbitrum, Base, Polygon, Optimism, BNB Chain, Gnosis.
|
|
@@ -138,6 +139,43 @@ Most apps just need the install above and a native rebuild. Edge cases:
|
|
|
138
139
|
|
|
139
140
|
Create the SDK once with `createSdk(config)` and supply wallet state at runtime via `<YodlProvider>`. Stateless helpers like `isPaymentQr(qrData)` are standalone exports — no SDK instance required to call them.
|
|
140
141
|
|
|
142
|
+
### Signup flow
|
|
143
|
+
|
|
144
|
+
Render `<YodlSignup />` when you need the hosted onboarding flow. The hosted Yodl UI owns the status check, SIWE, email capture, verification code entry, and the final signed-up screen.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { useState } from 'react';
|
|
148
|
+
import { Text } from 'react-native';
|
|
149
|
+
import { YodlProvider, YodlSignup } from '@yodlpay/react-native';
|
|
150
|
+
import { sdk } from './sdk';
|
|
151
|
+
import { useWallet } from './wallet';
|
|
152
|
+
|
|
153
|
+
export function SignupScreen() {
|
|
154
|
+
const { provider, address, chainId, isConnected } = useWallet();
|
|
155
|
+
const [showSignup, setShowSignup] = useState(true);
|
|
156
|
+
|
|
157
|
+
if (!isConnected) return <Text>Connect a wallet first.</Text>;
|
|
158
|
+
if (!showSignup) return null;
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<YodlProvider sdk={sdk} provider={provider} address={address} chainId={chainId}>
|
|
162
|
+
<YodlSignup
|
|
163
|
+
onStatusChange={(status) => console.log('signup status:', status)}
|
|
164
|
+
onSignedUp={() => {
|
|
165
|
+
// Store completion however your app tracks user state.
|
|
166
|
+
console.log('signed up');
|
|
167
|
+
setShowSignup(false);
|
|
168
|
+
}}
|
|
169
|
+
onDismiss={() => setShowSignup(false)}
|
|
170
|
+
onError={console.error}
|
|
171
|
+
/>
|
|
172
|
+
</YodlProvider>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`<YodlSignup />` shows the Yodl signup flow and calls `onSignedUp` when the user is finished. The SDK does not expose account details from the hosted flow. If you need to remember that the user signed up, save completion in your own app state, storage, or backend.
|
|
178
|
+
|
|
141
179
|
### Full example
|
|
142
180
|
|
|
143
181
|
**`sdk.ts`** — create the instance once, app-wide:
|
|
@@ -296,6 +334,18 @@ Supplies the SDK instance and wallet state to the components. Render it once, hi
|
|
|
296
334
|
|
|
297
335
|
`address` and `chainId` are the wallet's **live** account and chain — pass them straight from your wallet SDK's hooks (e.g. `useWallets()`, `useAccount()`), not as fixed values. They tell the embedded Yodl UI who is connected and on which chain, and the SDK pushes `accountsChanged` / `chainChanged` into the UI whenever they change — so keep them updated when the user switches account or network. (The `provider` is used only as the RPC/signing transport.)
|
|
298
336
|
|
|
337
|
+
### `<YodlSignup />`
|
|
338
|
+
|
|
339
|
+
Renders the hosted signup flow. Use this as a full-screen component inside `<YodlProvider>`.
|
|
340
|
+
|
|
341
|
+
| Prop | Type | Required | Description |
|
|
342
|
+
| ---------------- | ---------------------------------------------------------------------------- | -------- | ----------------------------------------------------- |
|
|
343
|
+
| `onStatusChange` | `(status: 'checking' \| 'signed_out' \| 'signing_up' \| 'signed_up') => void` | No | Called when the hosted flow reports signup status |
|
|
344
|
+
| `onSignedUp` | `() => void` | No | Called when signup completes |
|
|
345
|
+
| `onDismiss` | `() => void` | No | Called when the hosted success screen is dismissed |
|
|
346
|
+
| `onError` | `(error: Error) => void` | No | Called on SIWE, registration, verification, or RPC errors |
|
|
347
|
+
| `style` | `ViewStyle` | No | Container style |
|
|
348
|
+
|
|
299
349
|
### `<YodlPayment />`
|
|
300
350
|
|
|
301
351
|
Renders the payment flow for a scanned QR code. Renders nothing if `qrData` is empty or unsupported.
|
|
@@ -327,7 +377,7 @@ The Yodl UI emits generalized payment lifecycle details once it has payment stat
|
|
|
327
377
|
|
|
328
378
|
## Security
|
|
329
379
|
|
|
330
|
-
`<YodlPayment
|
|
380
|
+
`<YodlSignup>`, `<YodlPayment>`, and `<YodlDashboard>` inject an EIP-1193 provider bound to the user's wallet, so the underlying Yodl UI is **locked to the configured Yodl origin** and off-origin navigation is blocked (`onShouldStartLoadWithRequest`). This prevents origin spoofing and mid-request navigation that could intercept signed responses. The injected provider also enforces a 30 s pending-request timeout.
|
|
331
381
|
|
|
332
382
|
The bridge forwards EIP-5792 (`wallet_sendCalls`, `wallet_getCallsStatus`, `wallet_showCallsStatus`, `wallet_getCapabilities`) and all signing methods straight to the supplied wallet provider — it owns no smart-account stack and makes no RPC calls of its own (the embedded UI reads chain state through its own provider). For wallets without native EIP-5792, add `@yodlpay/react-native-eip-7702-provider` for atomic batching.
|
|
333
383
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("react-native"),r=require("react-native-webview");const i=(0,e.createContext)(null);function a({sdk:n,provider:r,address:a,chainId:o,children:s}){let c=(0,e.useMemo)(()=>({sdk:n,provider:r,address:a,chainId:o,supportedChainIds:n.config.supportedChainIds}),[n,r,a,o]);return(0,t.jsx)(i.Provider,{value:c,children:s})}function o(){let t=(0,e.useContext)(i);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function s(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function c(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function l(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function u(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 d(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 f(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function p(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}function m(e){let t=e?.integrationId?.trim();if(!t)throw Error(`Yodl integrationId is required`);return t}function h(e){return{"X-Yodl-Integration-Id":m(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime"),n=require("react-native"),r=require("react-native-webview");const i=(0,e.createContext)(null);function a({sdk:n,provider:r,address:a,chainId:o,children:s}){let c=(0,e.useMemo)(()=>({sdk:n,provider:r,address:a,chainId:o,supportedChainIds:n.config.supportedChainIds}),[n,r,a,o]);return(0,t.jsx)(i.Provider,{value:c,children:s})}function o(){let t=(0,e.useContext)(i);if(!t)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return t}function s(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function c(e,t){if(e instanceof Error)return e;if(typeof e==`object`&&e){let t=e;if(typeof t.message==`string`){let e=Error(t.message);return typeof t.code==`number`&&(e.code=t.code),e}}return Error(t)}function l(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function u(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 d(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 f(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function p(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}function m(e){let t=e?.integrationId?.trim();if(!t)throw Error(`Yodl integrationId is required`);return t}function h(e){return{"X-Yodl-Integration-Id":m(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.3.0`}}function g(e,t){let n=e.yodlUiBaseUrl?f(e.yodlUiBaseUrl):null;if(!(!n||!p(t,n)))return h(e)}function _(e){return`0x${e.toString(16)}`}function v(e,t=`unsupported`){let n={};for(let r of e)n[_(r)]={atomic:{status:t}};return n}const y=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function b(e){return y.some(t=>t===e)}function x(e,t,n){if(!b(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=u((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=_(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function S(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>u(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function C(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function w(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!C(t))return;let n=t.receipts;if(n?.length&&!n.some(w))return n[n.length-1]?.transactionHash}function E(e){let t=_(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 E(e){return e.toLowerCase()}function te(e,t){let n=E(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:_(t.chainId)}}:{}}}function D(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 O(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function k(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:u,onError:f}=t,p=(0,e.useRef)(null),m=(0,e.useRef)(E(r)),h=(0,e.useRef)(i),g=(0,e.useRef)(i),y=(0,e.useRef)(new Set),C=(0,e.useCallback)(e=>{y.current.has(e)||(y.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=te({address:m.current,propChainId:h.current,activeChainId:g.current},{address:r,chainId:i});e&&(m.current=e.nextAddress,h.current=e.nextPropChainId,g.current=e.nextActiveChainId,e.accountsChanged&&O(p,`accountsChanged`,e.accountsChanged),e.chainChanged&&O(p,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]);let w=(0,e.useMemo)(()=>ee({address:r,chainId:i}),[r,i]),k=(0,e.useCallback)(async(e,t,r)=>{try{let i=x(t,r,a);if(`error`in i){D(p,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),D(p,e,null),i.switchesActiveChain&&(g.current=i.requestedChainId,O(p,`chainChanged`,i.chainIdHex))}catch(t){let n=c(t,`Chain request failed`);D(p,e,void 0,l(n)),f?.(n)}},[n,a,f]),A=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>_(e))];D(p,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=c(n,`Capabilities unavailable`);if(!d(r)){D(p,e,void 0,l(r));return}D(p,e,v(S(t,a),`unsupported`))}},[n,r,a]),j=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=T(r);i&&C(i),D(p,e,r)}catch(t){D(p,e,void 0,l(c(t,`Failed to get call status`)))}},[n,C]),M=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&C(i),D(p,e,i)}catch(t){let n=c(t,`Request failed`),r=s(n);D(p,e,void 0,r?{code:4001,message:n.message}:l(n)),r||f?.(n)}},[n,C,f]);return{uiRef:p,injectedJavaScript:w,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_payment_details`){u?.(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!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;b(r)?k(n,r,i):r===`wallet_getCapabilities`?A(n,i):r===`wallet_getCallsStatus`?j(n,i):M(n,r,i)},[k,A,j,M,u,f])}}function A({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onError:m,style:h,sharedCookiesEnabled:_=!0,thirdPartyCookiesEnabled:v=!0,...y}){let{uiRef:b,injectedJavaScript:x,onMessage:S}=k({provider:o,address:s,chainId:c,supportedChainIds:l,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...m!==void 0&&{onError:m}}),C=(0,e.useMemo)(()=>f(i),[i]),w=(0,e.useMemo)(()=>{let e=g(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),T=(0,e.useMemo)(()=>e=>C?p(e.url,C)||e.url.startsWith(`about:`):!1,[C]);return(0,t.jsx)(n.View,{style:[j.container,h],children:(0,t.jsx)(r.WebView,{ref:b,source:w,originWhitelist:C?[C]:[],onShouldStartLoadWithRequest:T,javaScriptEnabled:!0,sharedCookiesEnabled:_,thirdPartyCookiesEnabled:v,injectedJavaScriptBeforeContentLoaded:x,onMessage:S,style:j.ui,...y})})}const j=n.StyleSheet.create({container:{flex:1},ui:{flex:1}});function M({onTransactionSent:n,onPaymentDetails:r,onError:i,style:a}){let{provider:s,address:c,chainId:l,supportedChainIds:u,sdk:d}=o();return(0,t.jsx)(A,{uri:(0,e.useMemo)(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]),sdkConfig:d.config,provider:s,address:c,chainId:l,supportedChainIds:u,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a}})}function N(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 ne(e){if(Array.isArray(e))return e}function re(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function P(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 ie(e,t,n){return t&&P(e.prototype,t),n&&P(e,n),e}function ae(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 oe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function se(e,t){return ne(e)||ae(e,t)||le(e,t)||oe()}function ce(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function le(e,t){if(e){if(typeof e==`string`)return N(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 N(e,t)}}var F=Object.defineProperty,ue=function(e,t,n){return t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},I=function(e,t){for(var n in t)F(e,n,{get:t[n],enumerable:!0})},L=function(e,t,n){return ue(e,(t===void 0?`undefined`:ce(t))===`symbol`?t:t+``,n)},de=[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 fe(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=de[(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 R(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 z(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+=z(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 B(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=fe(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function V(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=B(e,n),e}function pe(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 H(e,t){return{id:e,length:t.length,value:t}}function U(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[H(`00`,`A000000677010112`),H(`01`,t),H(`02`,r)];i&&o.push(H(`03`,i));var s=[H(`00`,`01`),H(`01`,n?`12`:`11`),H(`30`,z(o)),H(`53`,`764`),H(`58`,`TH`)];return n&&s.push(H(`54`,Number(n).toFixed(2))),a&&s.push(H(`62`,z([H(`07`,a)]))),V(z(s),`63`)}var me=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;re(this,e),L(this,`billerId`),L(this,`ref1`),L(this,`ref2`),L(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ie(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 U({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=se(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}(),W=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(W||{});function he(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=z([H(`00`,`A000000677010111`),H(W[t],n)]),a=[H(`00`,`01`),H(`01`,r?`12`:`11`),H(`29`,i),H(`53`,`764`),H(`58`,`TH`)];return r&&a.push(H(`54`,Number(r).toFixed(2))),V(z(a),`63`)}I({},{ProxyType:function(){return W},anyId:function(){return he},billPayment:function(){return U},botBarcode:function(){return ge},slipVerify:function(){return _e},trueMoney:function(){return ye},trueMoneySlipVerify:function(){return be}});function ge(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new me(t,n,r,i).toString()}function _e(e){var t=e.sendingBank,n=e.transRef;return V(z([H(`00`,z([H(`00`,`000001`),H(`01`,t),H(`02`,n)])),H(`51`,`TH`)]),`91`)}function ve(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function ye(e){var t=e.mobileNo,n=e.amount,r=e.message,i=z([H(`00`,`A000000677010111`),H(`03`,`14000${t}`)]),a=[H(`00`,`01`),H(`01`,n?`12`:`11`),H(`29`,i),H(`53`,`764`),H(`58`,`TH`)];return n&&a.push(H(`54`,Number(n).toFixed(2))),r&&a.push(H(`81`,ve(r))),V(z(a),`63`)}function be(e){var t=e.eventType,n=e.transactionId,r=e.date;return V(z([H(`00`,z([H(`00`,`01`),H(`01`,`01`),H(`02`,t),H(`03`,n),H(`04`,r)]))]),`91`,!1)}function G(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 xe(e){if(Array.isArray(e))return e}function Se(e){if(Array.isArray(e))return G(e)}function Ce(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function K(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 we(e,t,n){return t&&K(e.prototype,t),n&&K(e,n),e}function Te(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ee(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function De(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 Oe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ke(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function q(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){Te(e,t,n[t])})}return e}function J(e,t){return xe(e)||De(e,t)||Y(e,t)||Oe()}function Ae(e){return Se(e)||Ee(e)||Y(e)||ke()}function Y(e,t){if(e){if(typeof e==`string`)return G(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 G(e,t)}}I({},{anyId:function(){return Ne},bcelOneProof:function(){return Me},billPayment:function(){return Pe},slipVerify:function(){return Fe},trueMoneySlipVerify:function(){return Ie}});var je=function(){"use strict";function e(t,n){Ce(this,e),L(this,`payload`),L(this,`tags`),this.payload=t,this.tags=n}return we(e,[{key:`getTag`,value:function(e,t){return pe(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=V(z(Ae(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function X(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=B(e.slice(0,-4)))return null;var r=R(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=R(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 je(e,r)}function Me(e){var t=X(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 Ne(e){var t=X(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(W).find(function(e){var n=J(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=J(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 q({type:o,target:c},u!==void 0&&{amount:u})}function Pe(e){var t=X(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 q({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Fe(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=X(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 Ie(e){var t=X(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 Le={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Z(e){return e?e.getTagValue(`58`)??null:null}function Re(e){let t=[];for(let[n,r]of Object.entries(Le))r.includes(e)&&t.push(n);return t}function Q(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Z(X(r));if(e){let n=Re(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function ze(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Q(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Be({qrData:n,onTransactionSent:r,onPaymentDetails:i,onError:a,style:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=o(),p=(0,e.useMemo)(()=>ze(n,f.config.yodlUiBaseUrl),[n,f.config.yodlUiBaseUrl]);return p?(0,t.jsx)(A,{uri:p,sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...s!==void 0&&{style:s}}):null}function Ve(e){return(Array.isArray(e)?e:[e]).some(e=>Q(e).some(e=>e.action===`resolve`))}var $=class{config;constructor(e){let t=m(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={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function He(e){return new $(e)}exports.Yodl=$,exports.YodlDashboard=M,exports.YodlPayment=Be,exports.YodlProvider=a,exports.createSdk=He,exports.isPaymentQr=Ve;
|
|
228
|
+
true;`}function D(e){return e.toLowerCase()}function O(e,t){let n=D(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:_(t.chainId)}}:{}}}function k(e,t,n,r){let i=r?{id:t,error:r}:{id:t,result:n};e.current?.injectJavaScript(`window.ethereum._handleResponse(${JSON.stringify(i)});true;`)}function A(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function j(t){let{provider:n,address:r,chainId:i,supportedChainIds:a,onTransactionSent:o,onPaymentDetails:u,onSignupStatusChange:f,onSignedUp:p,onSignupDismissed:m,onError:h,onReady:g}=t,y=(0,e.useRef)(null),C=(0,e.useRef)(D(r)),w=(0,e.useRef)(i),j=(0,e.useRef)(i),M=(0,e.useRef)(new Set),N=(0,e.useCallback)(e=>{M.current.has(e)||(M.current.add(e),o?.(e))},[o]);(0,e.useEffect)(()=>{let e=O({address:C.current,propChainId:w.current,activeChainId:j.current},{address:r,chainId:i});e&&(C.current=e.nextAddress,w.current=e.nextPropChainId,j.current=e.nextActiveChainId,e.accountsChanged&&A(y,`accountsChanged`,e.accountsChanged),e.chainChanged&&A(y,`chainChanged`,e.chainChanged.chainIdHex))},[r,i]);let P=(0,e.useMemo)(()=>E({address:r,chainId:i}),[r,i]),F=(0,e.useCallback)(async(e,t,r)=>{try{let i=x(t,r,a);if(`error`in i){k(y,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),k(y,e,null),i.switchesActiveChain&&(j.current=i.requestedChainId,A(y,`chainChanged`,i.chainIdHex))}catch(t){let n=c(t,`Chain request failed`);k(y,e,void 0,l(n)),h?.(n)}},[n,a,h]),I=(0,e.useCallback)(async(e,t)=>{try{let i=t.length>0?t:[r,a.map(e=>_(e))];k(y,e,await n.request({method:`wallet_getCapabilities`,params:i}))}catch(n){let r=c(n,`Capabilities unavailable`);if(!d(r)){k(y,e,void 0,l(r));return}k(y,e,v(S(t,a),`unsupported`))}},[n,r,a]),L=(0,e.useCallback)(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=T(r);i&&N(i),k(y,e,r)}catch(t){k(y,e,void 0,l(c(t,`Failed to get call status`)))}},[n,N]),R=(0,e.useCallback)(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&N(i),k(y,e,i)}catch(t){let n=c(t,`Request failed`),r=s(n);k(y,e,void 0,r?{code:4001,message:n.message}:l(n)),r||h?.(n)}},[n,N,h]);return{uiRef:y,injectedJavaScript:P,onMessage:(0,e.useCallback)(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){g?.();return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_status`){f?.(t.status);return}if(t.type===`yodl_signup_complete`){p?.();return}if(t.type===`yodl_signup_error`){let e=t.error?.message??`Signup error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),h?.(n);return}if(t.type===`yodl_signup_dismissed`){m?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;b(r)?F(n,r,i):r===`wallet_getCapabilities`?I(n,i):r===`wallet_getCallsStatus`?L(n,i):R(n,r,i)},[F,I,L,R,u,f,p,m,h,g])}}function M({uri:i,sdkConfig:a,provider:o,address:s,chainId:c,supportedChainIds:l,onTransactionSent:u,onPaymentDetails:d,onSignupStatusChange:m,onSignedUp:h,onSignupDismissed:_,onError:v,style:y,backgroundColor:b=`#18181b`,sharedCookiesEnabled:x=!0,thirdPartyCookiesEnabled:S=!0,...C}){let[w,T]=(0,e.useState)(!1),E=(0,e.useCallback)(()=>T(!0),[]),{uiRef:D,injectedJavaScript:O,onMessage:k}=j({provider:o,address:s,chainId:c,supportedChainIds:l,onReady:E,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...m!==void 0&&{onSignupStatusChange:m},...h!==void 0&&{onSignedUp:h},..._!==void 0&&{onSignupDismissed:_},...v!==void 0&&{onError:v}});(0,e.useEffect)(()=>{if(w)return;let e=setTimeout(E,8e3);return()=>clearTimeout(e)},[w,E]);let A=(0,e.useMemo)(()=>f(i),[i]),M=(0,e.useMemo)(()=>{let e=g(a,i);return e?{uri:i,headers:e}:{uri:i}},[a,i]),P=(0,e.useMemo)(()=>e=>A?p(e.url,A)||e.url.startsWith(`about:`):!1,[A]);return(0,t.jsxs)(n.View,{style:[N.container,{backgroundColor:b},y],children:[(0,t.jsx)(r.WebView,{ref:D,source:M,originWhitelist:A?[A]:[],onShouldStartLoadWithRequest:P,javaScriptEnabled:!0,sharedCookiesEnabled:x,thirdPartyCookiesEnabled:S,injectedJavaScriptBeforeContentLoaded:O,onMessage:k,onLoadEnd:E,style:[N.ui,{backgroundColor:b}],...C}),w?null:(0,t.jsx)(n.View,{style:[N.overlay,{backgroundColor:b}],children:(0,t.jsx)(n.ActivityIndicator,{color:`#a1a1aa`})})]})}const N=n.StyleSheet.create({container:{flex:1},ui:{flex:1},overlay:{...n.StyleSheet.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function P({onTransactionSent:n,onPaymentDetails:r,onError:i,style:a,backgroundColor:s}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=o();return(0,t.jsx)(M,{uri:(0,e.useMemo)(()=>f.config.yodlUiBaseUrl.replace(/\/$/,``),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...n!==void 0&&{onTransactionSent:n},...r!==void 0&&{onPaymentDetails:r},...i!==void 0&&{onError:i},...a!==void 0&&{style:a},...s!==void 0&&{backgroundColor:s}})}function F(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 I(e){if(Array.isArray(e))return e}function L(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function R(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 ee(e,t,n){return t&&R(e.prototype,t),n&&R(e,n),e}function te(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 ne(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function re(e,t){return I(e)||te(e,t)||ae(e,t)||ne()}function ie(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ae(e,t){if(e){if(typeof e==`string`)return F(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 F(e,t)}}var z=Object.defineProperty,oe=function(e,t,n){return t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},B=function(e,t){for(var n in t)z(e,n,{get:t[n],enumerable:!0})},V=function(e,t,n){return oe(e,(t===void 0?`undefined`:ie(t))===`symbol`?t:t+``,n)},se=[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 ce(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=se[(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 H(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 U(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+=U(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 W(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ce(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function G(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=W(e,n),e}function le(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 K(e,t){return{id:e,length:t.length,value:t}}function q(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[K(`00`,`A000000677010112`),K(`01`,t),K(`02`,r)];i&&o.push(K(`03`,i));var s=[K(`00`,`01`),K(`01`,n?`12`:`11`),K(`30`,U(o)),K(`53`,`764`),K(`58`,`TH`)];return n&&s.push(K(`54`,Number(n).toFixed(2))),a&&s.push(K(`62`,U([K(`07`,a)]))),G(U(s),`63`)}var ue=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;L(this,e),V(this,`billerId`),V(this,`ref1`),V(this,`ref2`),V(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ee(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 q({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=re(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}(),J=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(J||{});function de(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=U([K(`00`,`A000000677010111`),K(J[t],n)]),a=[K(`00`,`01`),K(`01`,r?`12`:`11`),K(`29`,i),K(`53`,`764`),K(`58`,`TH`)];return r&&a.push(K(`54`,Number(r).toFixed(2))),G(U(a),`63`)}B({},{ProxyType:function(){return J},anyId:function(){return de},billPayment:function(){return q},botBarcode:function(){return fe},slipVerify:function(){return pe},trueMoney:function(){return he},trueMoneySlipVerify:function(){return ge}});function fe(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ue(t,n,r,i).toString()}function pe(e){var t=e.sendingBank,n=e.transRef;return G(U([K(`00`,U([K(`00`,`000001`),K(`01`,t),K(`02`,n)])),K(`51`,`TH`)]),`91`)}function me(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function he(e){var t=e.mobileNo,n=e.amount,r=e.message,i=U([K(`00`,`A000000677010111`),K(`03`,`14000${t}`)]),a=[K(`00`,`01`),K(`01`,n?`12`:`11`),K(`29`,i),K(`53`,`764`),K(`58`,`TH`)];return n&&a.push(K(`54`,Number(n).toFixed(2))),r&&a.push(K(`81`,me(r))),G(U(a),`63`)}function ge(e){var t=e.eventType,n=e.transactionId,r=e.date;return G(U([K(`00`,U([K(`00`,`01`),K(`01`,`01`),K(`02`,t),K(`03`,n),K(`04`,r)]))]),`91`,!1)}function Y(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 _e(e){if(Array.isArray(e))return e}function ve(e){if(Array.isArray(e))return Y(e)}function ye(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function X(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 be(e,t,n){return t&&X(e.prototype,t),n&&X(e,n),e}function xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Se(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Ce(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 we(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Te(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z(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){xe(e,t,n[t])})}return e}function Q(e,t){return _e(e)||Ce(e,t)||De(e,t)||we()}function Ee(e){return ve(e)||Se(e)||De(e)||Te()}function De(e,t){if(e){if(typeof e==`string`)return Y(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 Y(e,t)}}B({},{anyId:function(){return Ae},bcelOneProof:function(){return ke},billPayment:function(){return je},slipVerify:function(){return Me},trueMoneySlipVerify:function(){return Ne}});var Oe=function(){"use strict";function e(t,n){ye(this,e),V(this,`payload`),V(this,`tags`),this.payload=t,this.tags=n}return be(e,[{key:`getTag`,value:function(e,t){return le(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=G(U(Ee(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=W(e.slice(0,-4)))return null;var r=H(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=H(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 Oe(e,r)}function ke(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 Ae(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(J).find(function(e){var n=Q(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Q(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 Z({type:o,target:c},u!==void 0&&{amount:u})}function je(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 Z({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Me(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 Ne(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 Pe={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function Fe(e){return e?e.getTagValue(`58`)??null:null}function Ie(e){let t=[];for(let[n,r]of Object.entries(Pe))r.includes(e)&&t.push(n);return t}function Le(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=Fe($(r));if(e){let n=Ie(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Re(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Le(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function ze({qrData:n,onTransactionSent:r,onPaymentDetails:i,onError:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o(),m=(0,e.useMemo)(()=>Re(n,p.config.yodlUiBaseUrl),[n,p.config.yodlUiBaseUrl]);return m?(0,t.jsx)(M,{uri:m,sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...r!==void 0&&{onTransactionSent:r},...i!==void 0&&{onPaymentDetails:i},...a!==void 0&&{onError:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}}):null}function Be(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Ve({onStatusChange:n,onSignedUp:r,onError:i,onDismiss:a,style:s,backgroundColor:c}){let{provider:l,address:u,chainId:d,supportedChainIds:f,sdk:p}=o();return(0,t.jsx)(M,{uri:(0,e.useMemo)(()=>Be(p.config.yodlUiBaseUrl),[p.config.yodlUiBaseUrl]),sdkConfig:p.config,provider:l,address:u,chainId:d,supportedChainIds:f,...n!==void 0&&{onSignupStatusChange:n},...r!==void 0&&{onSignedUp:r},...i!==void 0&&{onError:i},...a!==void 0&&{onSignupDismissed:a},...s!==void 0&&{style:s},...c!==void 0&&{backgroundColor:c}})}function He(e){return(Array.isArray(e)?e:[e]).some(e=>Le(e).some(e=>e.action===`resolve`))}var Ue=class{config;constructor(e){let t=m(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={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function We(e){return new Ue(e)}exports.Yodl=Ue,exports.YodlDashboard=P,exports.YodlPayment=ze,exports.YodlProvider=a,exports.YodlSignup=Ve,exports.createSdk=We,exports.isPaymentQr=He;
|
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,7 @@ interface EIP1193Provider {
|
|
|
18
18
|
}
|
|
19
19
|
type SupportedChainIds = number[];
|
|
20
20
|
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
21
|
+
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
21
22
|
interface YodlPaymentDetails {
|
|
22
23
|
status: YodlPaymentLifecycleStatus;
|
|
23
24
|
transaction: {
|
|
@@ -81,10 +82,18 @@ interface YodlEventHandlers {
|
|
|
81
82
|
/** Called on RPC / payment errors. */
|
|
82
83
|
onError?: (error: Error) => void;
|
|
83
84
|
}
|
|
84
|
-
/**
|
|
85
|
-
interface
|
|
85
|
+
/** Visual props shared by all Yodl UI components. */
|
|
86
|
+
interface YodlVisualProps {
|
|
86
87
|
style?: ViewStyle;
|
|
88
|
+
/**
|
|
89
|
+
* Color painted behind the WebView and in the loading overlay while the Yodl
|
|
90
|
+
* UI loads, preventing a white flash before the page's first paint. Defaults
|
|
91
|
+
* to the Yodl UI's dark theme (#18181b).
|
|
92
|
+
*/
|
|
93
|
+
backgroundColor?: string;
|
|
87
94
|
}
|
|
95
|
+
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
96
|
+
interface YodlComponentProps extends YodlVisualProps, YodlEventHandlers {}
|
|
88
97
|
//#endregion
|
|
89
98
|
//#region src/components/YodlDashboard.d.ts
|
|
90
99
|
type YodlDashboardProps = YodlComponentProps;
|
|
@@ -97,7 +106,8 @@ declare function YodlDashboard({
|
|
|
97
106
|
onTransactionSent,
|
|
98
107
|
onPaymentDetails,
|
|
99
108
|
onError,
|
|
100
|
-
style
|
|
109
|
+
style,
|
|
110
|
+
backgroundColor
|
|
101
111
|
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
102
112
|
//#endregion
|
|
103
113
|
//#region src/components/YodlPayment.d.ts
|
|
@@ -116,9 +126,35 @@ declare function YodlPayment({
|
|
|
116
126
|
onTransactionSent,
|
|
117
127
|
onPaymentDetails,
|
|
118
128
|
onError,
|
|
119
|
-
style
|
|
129
|
+
style,
|
|
130
|
+
backgroundColor
|
|
120
131
|
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
121
132
|
//#endregion
|
|
133
|
+
//#region src/components/YodlSignup.d.ts
|
|
134
|
+
interface YodlSignupProps extends YodlVisualProps {
|
|
135
|
+
/** Called when the hosted signup flow reports checking/signing/signed status. */
|
|
136
|
+
onStatusChange?: (status: YodlSignupStatus) => void;
|
|
137
|
+
/** Called when the hosted signup flow completes successfully. */
|
|
138
|
+
onSignedUp?: () => void;
|
|
139
|
+
/** Called when the hosted signup flow reports an error. */
|
|
140
|
+
onError?: (error: Error) => void;
|
|
141
|
+
/** Called when the hosted signup flow is dismissed. */
|
|
142
|
+
onDismiss?: () => void;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Renders the hosted Yodl signup flow. The WebView owns SIWE, email capture,
|
|
146
|
+
* verification code entry, and the final signed-up screen, while callbacks let
|
|
147
|
+
* the native app observe status and completion.
|
|
148
|
+
*/
|
|
149
|
+
declare function YodlSignup({
|
|
150
|
+
onStatusChange,
|
|
151
|
+
onSignedUp,
|
|
152
|
+
onError,
|
|
153
|
+
onDismiss,
|
|
154
|
+
style,
|
|
155
|
+
backgroundColor
|
|
156
|
+
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
157
|
+
//#endregion
|
|
122
158
|
//#region src/sdk/yodl.d.ts
|
|
123
159
|
/**
|
|
124
160
|
* App-host configuration for the Yodl React Native SDK.
|
|
@@ -191,4 +227,4 @@ declare function YodlProvider({
|
|
|
191
227
|
*/
|
|
192
228
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
193
229
|
//#endregion
|
|
194
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, createSdk, isPaymentQr };
|
|
230
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
|
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ interface EIP1193Provider {
|
|
|
18
18
|
}
|
|
19
19
|
type SupportedChainIds = number[];
|
|
20
20
|
type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
|
|
21
|
+
type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
|
|
21
22
|
interface YodlPaymentDetails {
|
|
22
23
|
status: YodlPaymentLifecycleStatus;
|
|
23
24
|
transaction: {
|
|
@@ -81,10 +82,18 @@ interface YodlEventHandlers {
|
|
|
81
82
|
/** Called on RPC / payment errors. */
|
|
82
83
|
onError?: (error: Error) => void;
|
|
83
84
|
}
|
|
84
|
-
/**
|
|
85
|
-
interface
|
|
85
|
+
/** Visual props shared by all Yodl UI components. */
|
|
86
|
+
interface YodlVisualProps {
|
|
86
87
|
style?: ViewStyle;
|
|
88
|
+
/**
|
|
89
|
+
* Color painted behind the WebView and in the loading overlay while the Yodl
|
|
90
|
+
* UI loads, preventing a white flash before the page's first paint. Defaults
|
|
91
|
+
* to the Yodl UI's dark theme (#18181b).
|
|
92
|
+
*/
|
|
93
|
+
backgroundColor?: string;
|
|
87
94
|
}
|
|
95
|
+
/** Props shared by the Yodl UI components (YodlPayment, YodlDashboard). */
|
|
96
|
+
interface YodlComponentProps extends YodlVisualProps, YodlEventHandlers {}
|
|
88
97
|
//#endregion
|
|
89
98
|
//#region src/components/YodlDashboard.d.ts
|
|
90
99
|
type YodlDashboardProps = YodlComponentProps;
|
|
@@ -97,7 +106,8 @@ declare function YodlDashboard({
|
|
|
97
106
|
onTransactionSent,
|
|
98
107
|
onPaymentDetails,
|
|
99
108
|
onError,
|
|
100
|
-
style
|
|
109
|
+
style,
|
|
110
|
+
backgroundColor
|
|
101
111
|
}: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
102
112
|
//#endregion
|
|
103
113
|
//#region src/components/YodlPayment.d.ts
|
|
@@ -116,9 +126,35 @@ declare function YodlPayment({
|
|
|
116
126
|
onTransactionSent,
|
|
117
127
|
onPaymentDetails,
|
|
118
128
|
onError,
|
|
119
|
-
style
|
|
129
|
+
style,
|
|
130
|
+
backgroundColor
|
|
120
131
|
}: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
|
|
121
132
|
//#endregion
|
|
133
|
+
//#region src/components/YodlSignup.d.ts
|
|
134
|
+
interface YodlSignupProps extends YodlVisualProps {
|
|
135
|
+
/** Called when the hosted signup flow reports checking/signing/signed status. */
|
|
136
|
+
onStatusChange?: (status: YodlSignupStatus) => void;
|
|
137
|
+
/** Called when the hosted signup flow completes successfully. */
|
|
138
|
+
onSignedUp?: () => void;
|
|
139
|
+
/** Called when the hosted signup flow reports an error. */
|
|
140
|
+
onError?: (error: Error) => void;
|
|
141
|
+
/** Called when the hosted signup flow is dismissed. */
|
|
142
|
+
onDismiss?: () => void;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Renders the hosted Yodl signup flow. The WebView owns SIWE, email capture,
|
|
146
|
+
* verification code entry, and the final signed-up screen, while callbacks let
|
|
147
|
+
* the native app observe status and completion.
|
|
148
|
+
*/
|
|
149
|
+
declare function YodlSignup({
|
|
150
|
+
onStatusChange,
|
|
151
|
+
onSignedUp,
|
|
152
|
+
onError,
|
|
153
|
+
onDismiss,
|
|
154
|
+
style,
|
|
155
|
+
backgroundColor
|
|
156
|
+
}: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
|
|
157
|
+
//#endregion
|
|
122
158
|
//#region src/sdk/yodl.d.ts
|
|
123
159
|
/**
|
|
124
160
|
* App-host configuration for the Yodl React Native SDK.
|
|
@@ -191,4 +227,4 @@ declare function YodlProvider({
|
|
|
191
227
|
*/
|
|
192
228
|
declare function isPaymentQr(qrData: string | string[]): boolean;
|
|
193
229
|
//#endregion
|
|
194
|
-
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, createSdk, isPaymentQr };
|
|
230
|
+
export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, createSdk, isPaymentQr };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMemo as i,useRef as a}from"react";import{jsx as
|
|
1
|
+
import{createContext as e,useCallback as t,useContext as n,useEffect as r,useMemo as i,useRef as a,useState as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{ActivityIndicator as l,StyleSheet as u,View as d}from"react-native";import{WebView as f}from"react-native-webview";const p=e(null);function m({sdk:e,provider:t,address:n,chainId:r,children:a}){let o=i(()=>({sdk:e,provider:t,address:n,chainId:r,supportedChainIds:e.config.supportedChainIds}),[e,t,n,r]);return s(p.Provider,{value:o,children:a})}function h(){let e=n(p);if(!e)throw Error(`Yodl components must be rendered inside <YodlProvider>.`);return e}function g(e){if(e.code===4001)return!0;let t=e.message.toLowerCase();return t.includes(`rejected`)||t.includes(`denied`)}function _(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 v(e,t=-32603){let n=e.code;return{code:typeof n==`number`?n:t,message:e.message}}function y(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 b(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 x(e){return e.match(/^(https?:\/\/[^/?#]+)/i)?.[1]??null}function S(e,t){if(!e.startsWith(t))return!1;let n=e.charAt(t.length);return n===``||n===`/`||n===`?`||n===`#`}function C(e){let t=e?.integrationId?.trim();if(!t)throw Error(`Yodl integrationId is required`);return t}function w(e){return{"X-Yodl-Integration-Id":C(e),"X-Yodl-SDK-Name":`@yodlpay/react-native`,"X-Yodl-SDK-Version":`0.3.0`}}function T(e,t){let n=e.yodlUiBaseUrl?x(e.yodlUiBaseUrl):null;if(!(!n||!S(t,n)))return w(e)}function E(e){return`0x${e.toString(16)}`}function ee(e,t=`unsupported`){let n={};for(let r of e)n[E(r)]={atomic:{status:t}};return n}const D=[`wallet_addEthereumChain`,`wallet_switchEthereumChain`];function O(e){return D.some(t=>t===e)}function te(e,t,n){if(!O(e))return{error:{code:4200,message:`Unsupported chain method: ${e}`}};let r=y((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=E(r);return{providerMethod:e,providerParams:e===`wallet_switchEthereumChain`?[{chainId:i}]:t,requestedChainId:r,chainIdHex:i,switchesActiveChain:e===`wallet_switchEthereumChain`}}function k(e,t){let n=e[1];return Array.isArray(n)?n.map(e=>y(e)).filter(e=>typeof e==`number`&&t.includes(e)):t}function A(e){return e.status===200||e.statusCode===200||e.status===`success`||e.status===`CONFIRMED`}function j(e){return e.status===`0x0`||e.status===`reverted`||e.status===`failure`||e.status===0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!A(t))return;let n=t.receipts;if(n?.length&&!n.some(j))return n[n.length-1]?.transactionHash}function N(e){let t=E(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,useMem
|
|
|
225
225
|
announceProvider();
|
|
226
226
|
window.addEventListener("eip6963:requestProvider", announceProvider);
|
|
227
227
|
})();
|
|
228
|
-
true;`}function k(e){return e.toLowerCase()}function ie(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:C(t.chainId)}}:{}}}function A(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 j(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function M(e){let{provider:n,address:o,chainId:s,supportedChainIds:c,onTransactionSent:l,onPaymentDetails:u,onError:d}=e,f=a(null),g=a(k(o)),v=a(s),y=a(s),b=a(new Set),x=t(e=>{b.current.has(e)||(b.current.add(e),l?.(e))},[l]);r(()=>{let e=ie({address:g.current,propChainId:v.current,activeChainId:y.current},{address:o,chainId:s});e&&(g.current=e.nextAddress,v.current=e.nextPropChainId,y.current=e.nextActiveChainId,e.accountsChanged&&j(f,`accountsChanged`,e.accountsChanged),e.chainChanged&&j(f,`chainChanged`,e.chainChanged.chainIdHex))},[o,s]);let S=i(()=>re({address:o,chainId:s}),[o,s]),T=t(async(e,t,r)=>{try{let i=ee(t,r,c);if(`error`in i){A(f,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),A(f,e,null),i.switchesActiveChain&&(y.current=i.requestedChainId,j(f,`chainChanged`,i.chainIdHex))}catch(t){let n=m(t,`Chain request failed`);A(f,e,void 0,h(n)),d?.(n)}},[n,c,d]),D=t(async(e,t)=>{try{let r=t.length>0?t:[o,c.map(e=>C(e))];A(f,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=m(n,`Capabilities unavailable`);if(!_(r)){A(f,e,void 0,h(r));return}A(f,e,w(te(t,c),`unsupported`))}},[n,o,c]),O=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=ne(r);i&&x(i),A(f,e,r)}catch(t){A(f,e,void 0,h(m(t,`Failed to get call status`)))}},[n,x]),M=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&x(i),A(f,e,i)}catch(t){let n=m(t,`Request failed`),r=p(n);A(f,e,void 0,r?{code:4001,message:n.message}:h(n)),r||d?.(n)}},[n,x,d]);return{uiRef:f,injectedJavaScript:S,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_payment_details`){u?.(t.details);return}if(t.type===`yodl_payment_error`){let e=t.error?.message??`Payment details error`,n=Error(e);t.error?.code!==void 0&&(n.code=t.error.code),d?.(n);return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;E(r)?T(n,r,i):r===`wallet_getCapabilities`?D(n,i):r===`wallet_getCallsStatus`?O(n,i):M(n,r,i)},[T,D,O,M,u,d])}}function N({uri:e,sdkConfig:t,provider:n,address:r,chainId:a,supportedChainIds:s,onTransactionSent:u,onPaymentDetails:d,onError:f,style:p,sharedCookiesEnabled:m=!0,thirdPartyCookiesEnabled:h=!0,...g}){let{uiRef:_,injectedJavaScript:b,onMessage:x}=M({provider:n,address:r,chainId:a,supportedChainIds:s,...u!==void 0&&{onTransactionSent:u},...d!==void 0&&{onPaymentDetails:d},...f!==void 0&&{onError:f}}),C=i(()=>v(e),[e]),w=i(()=>{let n=S(t,e);return n?{uri:e,headers:n}:{uri:e}},[t,e]),T=i(()=>e=>C?y(e.url,C)||e.url.startsWith(`about:`):!1,[C]);return o(c,{style:[P.container,p],children:o(l,{ref:_,source:w,originWhitelist:C?[C]:[],onShouldStartLoadWithRequest:T,javaScriptEnabled:!0,sharedCookiesEnabled:m,thirdPartyCookiesEnabled:h,injectedJavaScriptBeforeContentLoaded:b,onMessage:x,style:P.ui,...g})})}const P=s.create({container:{flex:1},ui:{flex:1}});function ae({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r}){let{provider:a,address:s,chainId:c,supportedChainIds:l,sdk:u}=f();return o(N,{uri:i(()=>u.config.yodlUiBaseUrl.replace(/\/$/,``),[u.config.yodlUiBaseUrl]),sdkConfig:u.config,provider:a,address:s,chainId:c,supportedChainIds:l,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r}})}function F(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 oe(e){if(Array.isArray(e))return e}function se(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function I(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 ce(e,t,n){return t&&I(e.prototype,t),n&&I(e,n),e}function le(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 ue(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function de(e,t){return oe(e)||le(e,t)||pe(e,t)||ue()}function fe(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function pe(e,t){if(e){if(typeof e==`string`)return F(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 F(e,t)}}var L=Object.defineProperty,me=function(e,t,n){return t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},R=function(e,t){for(var n in t)L(e,n,{get:t[n],enumerable:!0})},z=function(e,t,n){return me(e,(t===void 0?`undefined`:fe(t))===`symbol`?t:t+``,n)},he=[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 ge(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=he[(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 B(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 V(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+=V(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 H(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=ge(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function U(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=H(e,n),e}function _e(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 W(e,t){return{id:e,length:t.length,value:t}}function G(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[W(`00`,`A000000677010112`),W(`01`,t),W(`02`,r)];i&&o.push(W(`03`,i));var s=[W(`00`,`01`),W(`01`,n?`12`:`11`),W(`30`,V(o)),W(`53`,`764`),W(`58`,`TH`)];return n&&s.push(W(`54`,Number(n).toFixed(2))),a&&s.push(W(`62`,V([W(`07`,a)]))),U(V(s),`63`)}var ve=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;se(this,e),z(this,`billerId`),z(this,`ref1`),z(this,`ref2`),z(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ce(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 G({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=de(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}(),K=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(K||{});function ye(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=V([W(`00`,`A000000677010111`),W(K[t],n)]),a=[W(`00`,`01`),W(`01`,r?`12`:`11`),W(`29`,i),W(`53`,`764`),W(`58`,`TH`)];return r&&a.push(W(`54`,Number(r).toFixed(2))),U(V(a),`63`)}R({},{ProxyType:function(){return K},anyId:function(){return ye},billPayment:function(){return G},botBarcode:function(){return be},slipVerify:function(){return xe},trueMoney:function(){return Ce},trueMoneySlipVerify:function(){return we}});function be(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ve(t,n,r,i).toString()}function xe(e){var t=e.sendingBank,n=e.transRef;return U(V([W(`00`,V([W(`00`,`000001`),W(`01`,t),W(`02`,n)])),W(`51`,`TH`)]),`91`)}function Se(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function Ce(e){var t=e.mobileNo,n=e.amount,r=e.message,i=V([W(`00`,`A000000677010111`),W(`03`,`14000${t}`)]),a=[W(`00`,`01`),W(`01`,n?`12`:`11`),W(`29`,i),W(`53`,`764`),W(`58`,`TH`)];return n&&a.push(W(`54`,Number(n).toFixed(2))),r&&a.push(W(`81`,Se(r))),U(V(a),`63`)}function we(e){var t=e.eventType,n=e.transactionId,r=e.date;return U(V([W(`00`,V([W(`00`,`01`),W(`01`,`01`),W(`02`,t),W(`03`,n),W(`04`,r)]))]),`91`,!1)}function q(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Te(e){if(Array.isArray(e))return e}function Ee(e){if(Array.isArray(e))return q(e)}function De(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function J(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 Oe(e,t,n){return t&&J(e.prototype,t),n&&J(e,n),e}function ke(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ae(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function je(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Me(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Y(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){ke(e,t,n[t])})}return e}function X(e,t){return Te(e)||je(e,t)||Z(e,t)||Me()}function Pe(e){return Ee(e)||Ae(e)||Z(e)||Ne()}function Z(e,t){if(e){if(typeof e==`string`)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return q(e,t)}}R({},{anyId:function(){return Le},bcelOneProof:function(){return Ie},billPayment:function(){return Re},slipVerify:function(){return ze},trueMoneySlipVerify:function(){return Be}});var Fe=function(){function e(t,n){De(this,e),z(this,`payload`),z(this,`tags`),this.payload=t,this.tags=n}return Oe(e,[{key:`getTag`,value:function(e,t){return _e(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=U(V(Pe(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function Q(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=H(e.slice(0,-4)))return null;var r=B(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=B(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 Fe(e,r)}function Ie(e){var t=Q(e,!0),n=t?.getTagValue(`33`,`02`),r=t?.getTagValue(`33`,`03`),i=t?.getTagValue(`33`,`04`);return t?.getTagValue(`00`)!==`01`&&t?.getTagValue(`01`)!==`11`&&t?.getTagValue(`33`,`00`)!==`BCEL`&&t?.getTagValue(`33`,`00`)!==`ONEPROOF`?null:{type:n,ticket:r,fccref:i}}function Le(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(K).find(function(e){var n=X(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=X(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 Y({type:o,target:c},u!==void 0&&{amount:u})}function Re(e){var t=Q(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`30`,`00`),i=t?.getTagValue(`30`,`01`),a=t?.getTagValue(`30`,`02`);if(n!==`01`||r!==`A000000677010112`||!i||!a)return null;var o=t?.getTagValue(`30`,`03`),s=t?.getTagValue(`62`,`07`),c=t?.getTagValue(`54`),l=c===void 0?void 0:parseFloat(c);return Y({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function ze(e){if(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]){var t=e.lastIndexOf(`9104`);if(t!=-1){var n=e.substring(t+4);n.length>0&&n.length<4&&(e=e.substring(0,t+4)+n.padStart(4,`0`))}}var r=Q(e,!0),i=r?.getTagValue(`00`,`00`),a=r?.getTagValue(`00`,`01`),o=r?.getTagValue(`00`,`02`);return i!==`000001`||!a||!o?null:{sendingBank:a,transRef:o}}function Be(e){var t=Q(e,!0),n=t?.getTagValue(`00`,`02`),r=t?.getTagValue(`00`,`03`),i=t?.getTagValue(`00`,`04`);return t?.getTagValue(`00`,`00`)!==`01`&&t?.getTagValue(`00`,`01`)!==`01`?null:{eventType:n,transactionId:r,date:i}}const Ve={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function He(e){return e?e.getTagValue(`58`)??null:null}function Ue(e){let t=[];for(let[n,r]of Object.entries(Ve))r.includes(e)&&t.push(n);return t}function We(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=He(Q(r));if(e){let n=Ue(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function Ge(e,t){return!e||typeof e!=`string`||e.trim().length===0||!We(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Ke({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:a}){let{provider:s,address:c,chainId:l,supportedChainIds:u,sdk:d}=f(),p=i(()=>Ge(e,d.config.yodlUiBaseUrl),[e,d.config.yodlUiBaseUrl]);return p?o(N,{uri:p,sdkConfig:d.config,provider:s,address:c,chainId:l,supportedChainIds:u,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...a!==void 0&&{style:a}}):null}function qe(e){return(Array.isArray(e)?e:[e]).some(e=>We(e).some(e=>e.action===`resolve`))}var $=class{config;constructor(e){let t=b(e),n=e.supportedChainIds;if(!Array.isArray(n)||n.length===0)throw Error(`Yodl supportedChainIds is required — provide at least one chain id`);this.config={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function Je(e){return new $(e)}export{$ as Yodl,ae as YodlDashboard,Ke as YodlPayment,d as YodlProvider,Je as createSdk,qe as isPaymentQr};
|
|
228
|
+
true;`}function P(e){return e.toLowerCase()}function F(e,t){let n=P(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:E(t.chainId)}}:{}}}function I(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 L(e,t,n){e.current?.injectJavaScript(`window.ethereum._emitEvent(${JSON.stringify(t)},${JSON.stringify(n)});true;`)}function R(e){let{provider:n,address:o,chainId:s,supportedChainIds:c,onTransactionSent:l,onPaymentDetails:u,onSignupStatusChange:d,onSignedUp:f,onSignupDismissed:p,onError:m,onReady:h}=e,y=a(null),x=a(P(o)),S=a(s),C=a(s),w=a(new Set),T=t(e=>{w.current.has(e)||(w.current.add(e),l?.(e))},[l]);r(()=>{let e=F({address:x.current,propChainId:S.current,activeChainId:C.current},{address:o,chainId:s});e&&(x.current=e.nextAddress,S.current=e.nextPropChainId,C.current=e.nextActiveChainId,e.accountsChanged&&L(y,`accountsChanged`,e.accountsChanged),e.chainChanged&&L(y,`chainChanged`,e.chainChanged.chainIdHex))},[o,s]);let D=i(()=>N({address:o,chainId:s}),[o,s]),A=t(async(e,t,r)=>{try{let i=te(t,r,c);if(`error`in i){I(y,e,void 0,i.error);return}await n.request({method:i.providerMethod,params:i.providerParams}),I(y,e,null),i.switchesActiveChain&&(C.current=i.requestedChainId,L(y,`chainChanged`,i.chainIdHex))}catch(t){let n=_(t,`Chain request failed`);I(y,e,void 0,v(n)),m?.(n)}},[n,c,m]),j=t(async(e,t)=>{try{let r=t.length>0?t:[o,c.map(e=>E(e))];I(y,e,await n.request({method:`wallet_getCapabilities`,params:r}))}catch(n){let r=_(n,`Capabilities unavailable`);if(!b(r)){I(y,e,void 0,v(r));return}I(y,e,ee(k(t,c),`unsupported`))}},[n,o,c]),R=t(async(e,t)=>{try{let r=await n.request({method:`wallet_getCallsStatus`,params:t}),i=M(r);i&&T(i),I(y,e,r)}catch(t){I(y,e,void 0,v(_(t,`Failed to get call status`)))}},[n,T]),z=t(async(e,t,r)=>{try{let i=await n.request({method:t,params:r});t===`eth_sendTransaction`&&typeof i==`string`&&T(i),I(y,e,i)}catch(t){let n=_(t,`Request failed`),r=g(n);I(y,e,void 0,r?{code:4001,message:n.message}:v(n)),r||m?.(n)}},[n,T,m]);return{uiRef:y,injectedJavaScript:D,onMessage:t(e=>{let t;try{t=JSON.parse(e.nativeEvent.data)}catch{return}if(t.type===`yodl_ready`){h?.();return}if(t.type===`yodl_payment_details`){u?.(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),m?.(n);return}if(t.type===`yodl_signup_status`){d?.(t.status);return}if(t.type===`yodl_signup_complete`){f?.();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),m?.(n);return}if(t.type===`yodl_signup_dismissed`){p?.();return}if(t.type!==`ethereum_rpc_request`)return;let{id:n,method:r,params:i}=t;O(r)?A(n,r,i):r===`wallet_getCapabilities`?j(n,i):r===`wallet_getCallsStatus`?R(n,i):z(n,r,i)},[A,j,R,z,u,d,f,p,m,h])}}function z({uri:e,sdkConfig:n,provider:a,address:u,chainId:p,supportedChainIds:m,onTransactionSent:h,onPaymentDetails:g,onSignupStatusChange:_,onSignedUp:v,onSignupDismissed:y,onError:b,style:C,backgroundColor:w=`#18181b`,sharedCookiesEnabled:E=!0,thirdPartyCookiesEnabled:ee=!0,...D}){let[O,te]=o(!1),k=t(()=>te(!0),[]),{uiRef:A,injectedJavaScript:j,onMessage:M}=R({provider:a,address:u,chainId:p,supportedChainIds:m,onReady:k,...h!==void 0&&{onTransactionSent:h},...g!==void 0&&{onPaymentDetails:g},..._!==void 0&&{onSignupStatusChange:_},...v!==void 0&&{onSignedUp:v},...y!==void 0&&{onSignupDismissed:y},...b!==void 0&&{onError:b}});r(()=>{if(O)return;let e=setTimeout(k,8e3);return()=>clearTimeout(e)},[O,k]);let N=i(()=>x(e),[e]),P=i(()=>{let t=T(n,e);return t?{uri:e,headers:t}:{uri:e}},[n,e]),F=i(()=>e=>N?S(e.url,N)||e.url.startsWith(`about:`):!1,[N]);return c(d,{style:[B.container,{backgroundColor:w},C],children:[s(f,{ref:A,source:P,originWhitelist:N?[N]:[],onShouldStartLoadWithRequest:F,javaScriptEnabled:!0,sharedCookiesEnabled:E,thirdPartyCookiesEnabled:ee,injectedJavaScriptBeforeContentLoaded:j,onMessage:M,onLoadEnd:k,style:[B.ui,{backgroundColor:w}],...D}),O?null:s(d,{style:[B.overlay,{backgroundColor:w}],children:s(l,{color:`#a1a1aa`})})]})}const B=u.create({container:{flex:1},ui:{flex:1},overlay:{...u.absoluteFillObject,alignItems:`center`,justifyContent:`center`}});function ne({onTransactionSent:e,onPaymentDetails:t,onError:n,style:r,backgroundColor:a}){let{provider:o,address:c,chainId:l,supportedChainIds:u,sdk:d}=h();return s(z,{uri:i(()=>d.config.yodlUiBaseUrl.replace(/\/$/,``),[d.config.yodlUiBaseUrl]),sdkConfig:d.config,provider:o,address:c,chainId:l,supportedChainIds:u,...e!==void 0&&{onTransactionSent:e},...t!==void 0&&{onPaymentDetails:t},...n!==void 0&&{onError:n},...r!==void 0&&{style:r},...a!==void 0&&{backgroundColor:a}})}function V(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 re(e){if(Array.isArray(e))return e}function ie(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function H(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 ae(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),e}function oe(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 se(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ce(e,t){return re(e)||oe(e,t)||ue(e,t)||se()}function le(e){"@swc/helpers - typeof";return e&&typeof Symbol<`u`&&e.constructor===Symbol?`symbol`:typeof e}function ue(e,t){if(e){if(typeof e==`string`)return V(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 V(e,t)}}var U=Object.defineProperty,de=function(e,t,n){return t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},W=function(e,t){for(var n in t)U(e,n,{get:t[n],enumerable:!0})},G=function(e,t,n){return de(e,(t===void 0?`undefined`:le(t))===`symbol`?t:t+``,n)},fe=[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 pe(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=fe[(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 K(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 q(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+=q(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 J(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=pe(e,65535).toString(16);return n=t?n.toUpperCase():n.toLowerCase(),n=(`0000`+n).slice(-4),n}function Y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e+=(`00`+t).slice(-2),e+=`04`,e+=J(e,n),e}function me(e,t,n){var r=e.find(function(e){return e.id==t});return n?r?.subTags?.find(function(e){return e.id==n}):r}function X(e,t){return{id:e,length:t.length,value:t}}function he(e){var t=e.billerId,n=e.amount,r=e.ref1,i=e.ref2,a=e.ref3,o=[X(`00`,`A000000677010112`),X(`01`,t),X(`02`,r)];i&&o.push(X(`03`,i));var s=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`30`,q(o)),X(`53`,`764`),X(`58`,`TH`)];return n&&s.push(X(`54`,Number(n).toFixed(2))),a&&s.push(X(`62`,q([X(`07`,a)]))),Y(q(s),`63`)}var ge=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;ie(this,e),G(this,`billerId`),G(this,`ref1`),G(this,`ref2`),G(this,`amount`),this.billerId=t,this.ref1=n,this.ref2=r,this.amount=i}return ae(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 he({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=ce(n,4),i=r[0],a=r[1],o=r[2],s=r[3];return new e(i,a,o.length>0?o:null,s==`0`?null:Number((parseInt(s)/100).toFixed(2)))}}]),e}(),Z=function(e){return e.MSISDN=`01`,e.NATID=`02`,e.EWALLETID=`03`,e.BANKACC=`04`,e}(Z||{});function _e(e){var t=e.type,n=e.target,r=e.amount;t==`MSISDN`&&(n=(`0000000000000`+n.replace(/^0/,`66`)).slice(-13));var i=q([X(`00`,`A000000677010111`),X(Z[t],n)]),a=[X(`00`,`01`),X(`01`,r?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return r&&a.push(X(`54`,Number(r).toFixed(2))),Y(q(a),`63`)}W({},{ProxyType:function(){return Z},anyId:function(){return _e},billPayment:function(){return he},botBarcode:function(){return ve},slipVerify:function(){return ye},trueMoney:function(){return xe},trueMoneySlipVerify:function(){return Se}});function ve(e){var t=e.billerId,n=e.ref1,r=e.ref2,i=e.amount;return new ge(t,n,r,i).toString()}function ye(e){var t=e.sendingBank,n=e.transRef;return Y(q([X(`00`,q([X(`00`,`000001`),X(`01`,t),X(`02`,n)])),X(`51`,`TH`)]),`91`)}function be(e){return e.split(``).map(function(e){return e.charCodeAt(0).toString(16).padStart(4,`0`)}).join(``).toUpperCase()}function xe(e){var t=e.mobileNo,n=e.amount,r=e.message,i=q([X(`00`,`A000000677010111`),X(`03`,`14000${t}`)]),a=[X(`00`,`01`),X(`01`,n?`12`:`11`),X(`29`,i),X(`53`,`764`),X(`58`,`TH`)];return n&&a.push(X(`54`,Number(n).toFixed(2))),r&&a.push(X(`81`,be(r))),Y(q(a),`63`)}function Se(e){var t=e.eventType,n=e.transactionId,r=e.date;return Y(q([X(`00`,q([X(`00`,`01`),X(`01`,`01`),X(`02`,t),X(`03`,n),X(`04`,r)]))]),`91`,!1)}function Q(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ce(e){if(Array.isArray(e))return e}function we(e){if(Array.isArray(e))return Q(e)}function Te(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ee(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 De(e,t,n){return t&&Ee(e.prototype,t),n&&Ee(e,n),e}function Oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ke(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Ae(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 je(){throw TypeError(`Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Me(){throw TypeError(`Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(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){Oe(e,t,n[t])})}return e}function Pe(e,t){return Ce(e)||Ae(e,t)||Ie(e,t)||je()}function Fe(e){return we(e)||ke(e)||Ie(e)||Me()}function Ie(e,t){if(e){if(typeof e==`string`)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(n);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}W({},{anyId:function(){return ze},bcelOneProof:function(){return Re},billPayment:function(){return Be},slipVerify:function(){return Ve},trueMoneySlipVerify:function(){return He}});var Le=function(){function e(t,n){Te(this,e),G(this,`payload`),G(this,`tags`),this.payload=t,this.tags=n}return De(e,[{key:`getTag`,value:function(e,t){return me(this.tags,e,t)}},{key:`getTagValue`,value:function(e,t){return this.getTag(e,t)?.value}},{key:`getTags`,value:function(){return this.tags}},{key:`getPayload`,value:function(){return this.payload}},{key:`validate`,value:function(e){var t=Y(q(Fe(this.tags).filter(function(t){return t.id!=e})),e);return this.payload===t}}]),e}();function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e.match(/^\d{4}.+/)||t&&e.slice(-4).toUpperCase()!=J(e.slice(0,-4)))return null;var r=K(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=K(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 Le(e,r)}function Re(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 ze(e){var t=$(e,!0),n=t?.getTagValue(`00`),r=t?.getTagValue(`29`,`00`);if(n!==`01`||r!==`A000000677010111`)return null;var i=Object.entries(Z).find(function(e){var n=Pe(e,2)[1];return t?.getTagValue(`29`,n)!==void 0});if(!i)return null;var a=Pe(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 Ne({type:o,target:c},u!==void 0&&{amount:u})}function Be(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 Ne({billerId:i,ref1:a},o!==void 0&&{ref2:o},s!==void 0&&{ref3:s},l!==void 0&&{amount:l})}function Ve(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 He(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 Ue={aeon:[`PH`,`VN`,`BR`,`AR`],manteca:[`AR`,`BR`],bcpilot:[],holdstation:[`VN`]};function We(e){return e?e.getTagValue(`58`)??null:null}function Ge(e){let t=[];for(let[n,r]of Object.entries(Ue))r.includes(e)&&t.push(n);return t}function Ke(e,t,n){if(!e||typeof e!=`string`||e.trim().length===0)return[];let r=e.trim(),i=[];try{let e=We($(r));if(e){let n=Ge(e);for(let e of n)(!t||t.includes(e))&&i.push({provider:e,action:`resolve`});if(i.length>0)return i}}catch{}if(n){let e=n(r);e&&(!t||t.includes(`bcpilot`))&&i.push(e)}return i}function qe(e,t){return!e||typeof e!=`string`||e.trim().length===0||!Ke(e).find(e=>e.action===`resolve`)?null:`${t.replace(/\/$/,``)}/resolve?data=${encodeURIComponent(e)}`}function Je({qrData:e,onTransactionSent:t,onPaymentDetails:n,onError:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h(),p=i(()=>qe(e,f.config.yodlUiBaseUrl),[e,f.config.yodlUiBaseUrl]);return p?s(z,{uri:p,sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...t!==void 0&&{onTransactionSent:t},...n!==void 0&&{onPaymentDetails:n},...r!==void 0&&{onError:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}}):null}function Ye(e){return`${e.replace(/\/$/,``)}/sdk/signup`}function Xe({onStatusChange:e,onSignedUp:t,onError:n,onDismiss:r,style:a,backgroundColor:o}){let{provider:c,address:l,chainId:u,supportedChainIds:d,sdk:f}=h();return s(z,{uri:i(()=>Ye(f.config.yodlUiBaseUrl),[f.config.yodlUiBaseUrl]),sdkConfig:f.config,provider:c,address:l,chainId:u,supportedChainIds:d,...e!==void 0&&{onSignupStatusChange:e},...t!==void 0&&{onSignedUp:t},...n!==void 0&&{onError:n},...r!==void 0&&{onSignupDismissed:r},...a!==void 0&&{style:a},...o!==void 0&&{backgroundColor:o}})}function Ze(e){return(Array.isArray(e)?e:[e]).some(e=>Ke(e).some(e=>e.action===`resolve`))}var Qe=class{config;constructor(e){let t=C(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={integrationId:t,yodlUiBaseUrl:e.yodlUiBaseUrl??`https://sdk-webview.yodl.me`,supportedChainIds:[...n]}}};function $e(e){return new Qe(e)}export{Qe as Yodl,ne as YodlDashboard,Je as YodlPayment,m as YodlProvider,Xe as YodlSignup,$e as createSdk,Ze as isPaymentQr};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yodlpay/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yodl React Native SDK — drop-in components for EIP-1193 wallets",
|
|
6
6
|
"keywords": [
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"tsdown": "^0.22.0",
|
|
76
76
|
"typescript": "^5.7.2",
|
|
77
77
|
"vitest": "^4.1.7",
|
|
78
|
-
"@yodlpay/sdk-core": "0.1
|
|
78
|
+
"@yodlpay/sdk-core": "0.2.1"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsdown",
|