@tap-payments/connect-v2 1.0.4-development → 1.0.5-development

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 CHANGED
@@ -43,6 +43,10 @@ const App = () => {
43
43
  theme={ConnectTheme.DARK}
44
44
  scope={ConnectScope.MERCHANT}
45
45
  onClose={() => setOpen(false)}
46
+ onSuccess={(res) => console.log('success', res)}
47
+ onError={(err) => console.log('error', err)}
48
+ onCreated={(res) => console.log('created', res)}
49
+ onBoardCompleted={() => console.log('board completed')}
46
50
  features={{ poweredBy: true, closeButton: true }}
47
51
  mode={ConnectMode.POPUP}
48
52
  />
@@ -73,7 +77,7 @@ You can also use the SDK without a React build setup by including the UMD bundle
73
77
  <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
74
78
 
75
79
  <!-- Tap Connect SDK UMD bundle -->
76
- <script src="https://cdn.tap.company/tap-sdks/connect-v2/build-1.0.4-development/index.js"></script>
80
+ <script src="https://cdn.tap.company/tap-sdks/connect-v2/build-1.0.5-development/index.js"></script>
77
81
 
78
82
  <script>
79
83
  function openConnect() {
@@ -98,35 +102,37 @@ You can also use the SDK without a React build setup by including the UMD bundle
98
102
 
99
103
  ## 🧠 Props
100
104
 
101
- | Prop | Type | Required | Description |
102
- | ----------------------- | ------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------- |
103
- | **open** | `boolean` | ✅ | Controls whether the Connect element is open or closed. |
104
- | **publicKey** | `string` | ✅ | Your public API key provided by Tap Payments. |
105
- | **merchantDomain** | `string` | ✅ | Merchant's domain (e.g. `https://example.com`). |
106
- | **scope** | `ConnectScope` | ✅ | Defines the integration scope. |
107
- | **onReady** | `() => void` | ❌ | Called when the app configurations are loaded successfully. |
108
- | **onClose** | `() => void` | ❌ | Triggered when the Connect element is closed. |
109
- | **onError** | `(error: CustomError) => void` | ❌ | Triggered when an error occurs. |
110
- | **onSuccess** | `(response: Record<string, string \| number>) => void` | ❌ | Triggered when the flow completes successfully. |
111
- | **theme** | `ConnectTheme` | ❌ | UI theme configuration. |
112
- | **language** | `ConnectLanguage` | ❌ | Localization language. |
113
- | **businessCountryCode** | `string` | ❌ | ISO2 country code of the merchant. |
114
- | **leadId** | `string` | ❌ | ID to Load an existing lead. |
115
- | **showBoard** | `boolean` | ❌ | Show merchant board UI. |
116
- | **boardEditable** | `boolean` | ❌ | Allow merchant board editing. |
117
- | **platforms** | `string[]` | ❌ | List of merchant platforms. |
118
- | **features** | `ConnectAppFeatures` | ❌ | UI and behavior customization options. |
119
- | **paymentProvider** | `ConnectPaymentProvider` | ❌ | Payment provider configuration. |
120
- | **postUrl** | `string` | ❌ | Endpoint to post collected data to your backend. |
121
- | **redirectUrl** | `string` | ❌ | Redirect URL after success. |
122
- | **data** | `string[]` | ❌ | Data modules to collect (e.g. `brand`, `entity`). |
123
- | **mode** | `ConnectMode` | ❌ | Controls display behavior (page, popup, content). |
124
- | **notification** | `ConnectNotification` | ❌ | Notification configuration. |
125
- | **flow** | `ConnectFlows` | ❌ | Specifies a predefined flow to open directly (e.g., `brand`, `entity`, `kyc`, etc.). |
126
- | **token** | `string` | ❌ | Connect session token. Required when `flow` is provided and the flow is not `board` or `auth`. |
127
- | **boardId** | `string` | ❌ | Identifier of the board to load. Required when `flow` is set to `board`. |
128
- | **configToken** | `string` | ❌ | Pre-generated configuration token from backend. |
129
- | **region** | `ConnectRegions` | ❌ | Region code determining middleware domain. |
105
+ | Prop | Type | Required | Description |
106
+ | ----------------------- | ---------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------- |
107
+ | **open** | `boolean` | ✅ | Controls whether the Connect element is open or closed. |
108
+ | **publicKey** | `string` | ✅ | Your public API key provided by Tap Payments. |
109
+ | **merchantDomain** | `string` | ✅ | Merchant's domain (e.g. `https://example.com`). |
110
+ | **scope** | `ConnectScope` | ✅ | Defines the integration scope. |
111
+ | **onReady** | `() => void` | ❌ | Called when the app configurations are loaded successfully. |
112
+ | **onClose** | `() => void` | ❌ | Triggered when the Connect element is closed. |
113
+ | **onError** | `(error: CustomError) => void` | ❌ | Triggered when an error occurs. |
114
+ | **onSuccess** | `(response: Record<string, string \| number \| object>) => void` | ❌ | Triggered when the flow completes successfully. |
115
+ | **onCreated** | `(response: Record<string, string \| number \| object>) => void` | ❌ | Triggered after creating an account. |
116
+ | **onBoardCompleted** | `() => void` | ❌ | Triggered when all board flows are completed. |
117
+ | **theme** | `ConnectTheme` | ❌ | UI theme configuration. |
118
+ | **language** | `ConnectLanguage` | ❌ | Localization language. |
119
+ | **businessCountryCode** | `string` | ❌ | ISO2 country code of the merchant. |
120
+ | **leadId** | `string` | ❌ | ID to Load an existing lead. |
121
+ | **showBoard** | `boolean` | ❌ | Show merchant board UI. |
122
+ | **boardEditable** | `boolean` | ❌ | Allow merchant board editing. |
123
+ | **platforms** | `string[]` | ❌ | List of merchant platforms. |
124
+ | **features** | `ConnectAppFeatures` | ❌ | UI and behavior customization options. |
125
+ | **paymentProvider** | `ConnectPaymentProvider` | ❌ | Payment provider configuration. |
126
+ | **postUrl** | `string` | ❌ | Endpoint to post collected data to your backend. |
127
+ | **redirectUrl** | `string` | ❌ | Redirect URL after success. |
128
+ | **data** | `string[]` | ❌ | Data modules to collect (e.g. `brand`, `entity`). |
129
+ | **mode** | `ConnectMode` | ❌ | Controls display behavior (page, popup, content). |
130
+ | **notification** | `ConnectNotification` | ❌ | Notification configuration. |
131
+ | **flow** | `ConnectFlows` | ❌ | Specifies a predefined flow to open directly (e.g., `brand`, `entity`, `kyc`, etc.). |
132
+ | **token** | `string` | ❌ | Connect session token. Required when `flow` is provided and the flow is not `board` or `auth`. |
133
+ | **boardId** | `string` | ❌ | Identifier of the board to load. Required when `flow` is set to `board`. |
134
+ | **configToken** | `string` | ❌ | Pre-generated configuration token from backend. |
135
+ | **region** | `ConnectRegions` | ❌ | Region code determining middleware domain. |
130
136
 
131
137
  ##### `ConnectAppFeatures`
132
138
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),f=require("react"),G=require("react-dom");function P(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const m=P(f);var y=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(y||{}),I=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(I||{}),h=(e=>(e.AUTH="auth",e.BANK="bank",e.BOARD="board",e.BRAND="brand",e.ENTITY="entity",e.INDIVIDUAL="individual",e.KYC="kyc",e.TAX="tax",e.TERMINAL="terminal",e))(h||{}),T=(e=>(e.SA="sa",e.SA_DR="sa-dr",e))(T||{}),v=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(v||{}),N=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(N||{}),C=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(C||{}),x=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(x||{}),l=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(l||{}),p=(e=>(e.AUTH_TOKEN="token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(p||{});const B=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:a=3,toggleAnimation:s=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),M=f.memo(B),S=f.createContext({}),g=()=>f.useContext(S);function H({children:e,props:n}){const[t,o]=f.useState(!1),a=i=>{o(i)},s=()=>{o(!1)};return r.jsx(S.Provider,{value:{...n,onLoadingHandler:a,loading:t,onLoaded:s},children:e})}const $="https://connect-mw.dev.tap.company/middleware/v3/connect",K="https://connect-mw.dev.tap.company/middleware/v3/connect",W="https://connect-mw.dev.tap.company/middleware/v3/connect",F="tap-connect-sdk-iframe",_="https://sdk-connect.dev.tap.company",Y="https://sdk-connect.dev.tap.company",q="https://sdk-connect.dev.tap.company",z=({src:e})=>{const{loading:n}=g();return r.jsxs(r.Fragment,{children:[n&&r.jsx(M,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:F,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var V=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},J=function(e){return e instanceof Error},X=function(e){return typeof e=="string"},Q=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,a=t.code;return{message:o,code:a}}catch(s){return{message:s.message,code:"UNKNOWN"}}},Z=function(e){try{var n=e.message,t=n.split("::"),o=t[0],a=t[1];return{message:a,code:o}}catch(s){return{message:s.message,code:"UNKNOWN"}}},ee=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},te=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),V(n)){var t=Q(n);this.code=t.code,this.message=t.message}else if(J(n)){var t=Z(n);this.code=t.code,this.message=t.message}else if(X(n)){var t=ee(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const re=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},R=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,U=e=>e==="dr",ne=(e="")=>{const[n,t]=e.split("-");return R(n)?U(t)?W:K:$},oe=(e="")=>{const[n,t]=e.split("-");return R(n)?U(t)?q:Y:_},ae=e=>{var n,t,o,a,s,i,c,d,u,b,j,O,E,A,k;return{operator:{public_key:e.publicKey},scope:e.scope,mode:e.mode||y.PAGE,domain:e.merchantDomain,...e.businessCountryCode&&{country:e.businessCountryCode},...e.data&&{data:e.data},board:{...e.boardId&&{id:e.boardId},display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||v.DYNAMIC,locale:e.language||N.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||C.CURVED,parnter_logo:((t=e.features)==null?void 0:t.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||x.UP,end:((a=e.features)==null?void 0:a.dialogEndTransition)||x.DOWN}},notification:{email:((s=e.notification)==null?void 0:s.email)??!1,sms:((i=e.notification)==null?void 0:i.sms)??!1},features:{poweredby:((c=e.features)==null?void 0:c.poweredBy)??!0,close_button:((d=e.features)==null?void 0:d.closeButton)??!1,embedded:((u=e.features)==null?void 0:u.embedded)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((b=e.paymentProvider)==null?void 0:b.institutionId)||((j=e.paymentProvider)==null?void 0:j.technologyId))&&{payment_provider:{...((O=e.paymentProvider)==null?void 0:O.institutionId)&&{institution:{id:(E=e.paymentProvider)==null?void 0:E.institutionId}},...((A=e.paymentProvider)==null?void 0:A.technologyId)&&{technology:{id:(k=e.paymentProvider)==null?void 0:k.technologyId}}}},app_info:{name:"connect-sdk-v2",version:"1.0.4-development",identifier:window.location.hostname||window.location.origin}}},se=({theme:e,language:n,configToken:t,flow:o,token:a,region:s})=>{const i=new URLSearchParams;let c="";return o&&(c=o,o!==h.AUTH&&o!==h.BOARD&&a&&i.append(p.AUTH_TOKEN,a)),e&&i.append(p.THEME,e),n&&i.append(p.LANGUAGE,n),i.append(p.CONFIG_TOKEN,t),`${oe(s)}/${c}?${i.toString()}`},ie=async e=>{const n=await fetch(ne(e.region),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.publicKey}`,mdn:e.merchantDomain||_},body:JSON.stringify(ae(e))});if(!n.ok)throw new Error(`${n.status}::${n.statusText}`);return n.json()},de=()=>{const[e,n]=m.useState(""),t=g(),o=async()=>{var a,s,i;t.onLoadingHandler(!0);try{let c=t.configToken,d;if(!c){if(d=await ie(t),!d.token)throw new Error("500::Config token is missing");c=d.token}const u=se({theme:(a=d==null?void 0:d.interface)==null?void 0:a.theme,language:(s=d==null?void 0:d.interface)==null?void 0:s.locale,configToken:c,flow:t.flow,token:t.token,region:t.region});if(t.mode!==y.PAGE)return n(u);window.location.href=u}catch(c){const d=new te(c);(i=t.onError)==null||i.call(t,d.getClientError()),t.onLoadingHandler(!1)}};return m.useEffect(()=>{o()},[]),{connectLink:e}},ce=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:a}=g(),s=m.useCallback(async i=>{if(i.origin!==_)return;const{data:c,event:d}=i.data;switch(d){case l.ON_CLOSE:n==null||n();break;case l.ON_ERROR:t==null||t(c);break;case l.ON_SUCCESS:e==null||e(c);break;case l.ON_LOADED:a();break;case l.ON_READY:o==null||o();break}},[n,t,a,o,e]);m.useEffect(()=>(window.addEventListener("message",s,!1),()=>{window.removeEventListener("message",s)}),[s])},le=()=>{const{connectLink:e}=de();return ce(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:"9999"},children:r.jsx(z,{src:e})})},ue=e=>r.jsx(H,{props:e,children:e.open&&r.jsx(le,{})}),D=m.memo(ue);var L,w=G;L=w.createRoot,w.hydrateRoot;const pe=(e,n)=>{const t=re(e),o=L(t);return o.render(r.jsx(D,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=C;exports.ConnectDialogTransition=x;exports.ConnectElement=D;exports.ConnectFlows=h;exports.ConnectLanguage=N;exports.ConnectMode=y;exports.ConnectRegions=T;exports.ConnectScope=I;exports.ConnectTheme=v;exports.renderConnectElement=pe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),f=require("react"),G=require("react-dom");function P(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const m=P(f);var v=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(v||{}),I=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(I||{}),x=(e=>(e.AUTH="auth",e.BANK="bank",e.BOARD="board",e.BRAND="brand",e.ENTITY="entity",e.INDIVIDUAL="individual",e.KYC="kyc",e.TAX="tax",e.TERMINAL="terminal",e))(x||{}),T=(e=>(e.SA="sa",e.SA_DR="sa-dr",e))(T||{}),N=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(N||{}),_=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(_||{}),O=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(O||{}),y=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(y||{}),u=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e.ON_CREATED="connect:onCreated",e.ON_BOARD_COMPLETED="connect:onBoardCompleted",e))(u||{}),p=(e=>(e.AUTH_TOKEN="token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(p||{});const B=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:t="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:a=3,toggleAnimation:s=!1})=>r.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:r.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:r.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{children:[r.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})}),r.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${a/3}s`,repeatCount:"indefinite"}),r.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${a}s`,repeatCount:"indefinite"})]})})]}),r.jsxs("defs",{children:[r.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[r.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.68224"}),r.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),r.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),r.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),r.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),r.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),r.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),r.jsx("feOffset",{dy:"1.50838"}),r.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),r.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),r.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),r.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:e}),r.jsx("stop",{offset:"1",stopColor:n})]}),r.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:t}),r.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),M=f.memo(B),R=f.createContext({}),C=()=>f.useContext(R);function H({children:e,props:n}){const[t,o]=f.useState(!1),a=i=>{o(i)},s=()=>{o(!1)};return r.jsx(R.Provider,{value:{...n,onLoadingHandler:a,loading:t,onLoaded:s},children:e})}const $="https://connect-mw.dev.tap.company/middleware/v3/connect",K="https://connect-mw.dev.tap.company/middleware/v3/connect",W="https://connect-mw.dev.tap.company/middleware/v3/connect",F="tap-connect-sdk-iframe",E="https://sdk-connect.dev.tap.company",Y="https://sdk-connect.dev.tap.company",q="https://sdk-connect.dev.tap.company",z=({src:e})=>{const{loading:n}=C();return r.jsxs(r.Fragment,{children:[n&&r.jsx(M,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:F,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var V=function(e){var n,t;return((t=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.errors)!==void 0},J=function(e){return e instanceof Error},X=function(e){return typeof e=="string"},Q=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,a=t.code;return{message:o,code:a}}catch(s){return{message:s.message,code:"UNKNOWN"}}},Z=function(e){try{var n=e.message,t=n.split("::"),o=t[0],a=t[1];return{message:a,code:o}}catch(s){return{message:s.message,code:"UNKNOWN"}}},ee=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},te=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),V(n)){var t=Q(n);this.code=t.code,this.message=t.message}else if(J(n)){var t=Z(n);this.code=t.code,this.message=t.message}else if(X(n)){var t=ee(n);this.code=t.code,this.message=t.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const re=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},S=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,D=e=>e==="dr",ne=(e="")=>{const[n,t]=e.split("-");return S(n)?D(t)?W:K:$},oe=(e="")=>{const[n,t]=e.split("-");return S(n)?D(t)?q:Y:E},ae=e=>{var n,t,o,a,s,i,c,d,l,h,b,g,j,A,k;return{operator:{public_key:e.publicKey},scope:e.scope,mode:e.mode||v.PAGE,domain:e.merchantDomain,...e.businessCountryCode&&{country:e.businessCountryCode},...e.data&&{data:e.data},board:{...e.boardId&&{id:e.boardId},display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||N.DYNAMIC,locale:e.language||_.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||O.CURVED,parnter_logo:((t=e.features)==null?void 0:t.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||y.UP,end:((a=e.features)==null?void 0:a.dialogEndTransition)||y.DOWN}},notification:{email:((s=e.notification)==null?void 0:s.email)??!1,sms:((i=e.notification)==null?void 0:i.sms)??!1},features:{poweredby:((c=e.features)==null?void 0:c.poweredBy)??!0,close_button:((d=e.features)==null?void 0:d.closeButton)??!1,embedded:((l=e.features)==null?void 0:l.embedded)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((h=e.paymentProvider)==null?void 0:h.institutionId)||((b=e.paymentProvider)==null?void 0:b.technologyId))&&{payment_provider:{...((g=e.paymentProvider)==null?void 0:g.institutionId)&&{institution:{id:(j=e.paymentProvider)==null?void 0:j.institutionId}},...((A=e.paymentProvider)==null?void 0:A.technologyId)&&{technology:{id:(k=e.paymentProvider)==null?void 0:k.technologyId}}}},app_info:{name:"connect-sdk-v2",version:"1.0.5-development",identifier:window.location.hostname||window.location.origin}}},se=({theme:e,language:n,configToken:t,flow:o,token:a,region:s})=>{const i=new URLSearchParams;let c="";return o&&(c=o,o!==x.AUTH&&o!==x.BOARD&&a&&i.append(p.AUTH_TOKEN,a)),e&&i.append(p.THEME,e),n&&i.append(p.LANGUAGE,n),i.append(p.CONFIG_TOKEN,t),`${oe(s)}/${c}?${i.toString()}`},ie=async e=>{const n=await fetch(ne(e.region),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.publicKey}`,mdn:e.merchantDomain||E},body:JSON.stringify(ae(e))});if(!n.ok)throw new Error(`${n.status}::${n.statusText}`);return n.json()},de=()=>{const[e,n]=m.useState(""),t=C(),o=async()=>{var a,s,i;t.onLoadingHandler(!0);try{let c=t.configToken,d;if(!c){if(d=await ie(t),!d.token)throw new Error("500::Config token is missing");c=d.token}const l=se({theme:(a=d==null?void 0:d.interface)==null?void 0:a.theme,language:(s=d==null?void 0:d.interface)==null?void 0:s.locale,configToken:c,flow:t.flow,token:t.token,region:t.region});if(t.mode!==v.PAGE)return n(l);window.location.href=l}catch(c){const d=new te(c);(i=t.onError)==null||i.call(t,d.getClientError()),t.onLoadingHandler(!1)}};return m.useEffect(()=>{o()},[]),{connectLink:e}},ce=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:a,onCreated:s,onBoardCompleted:i}=C(),c=m.useCallback(async d=>{if(d.origin!==E)return;const{data:l,event:h}=d.data;switch(h){case u.ON_CLOSE:n==null||n();break;case u.ON_ERROR:t==null||t(l);break;case u.ON_SUCCESS:e==null||e(l);break;case u.ON_LOADED:a();break;case u.ON_READY:o==null||o();break;case u.ON_CREATED:s==null||s(l);break;case u.ON_BOARD_COMPLETED:i==null||i();break}},[n,t,a,o,e,s,i]);m.useEffect(()=>(window.addEventListener("message",c,!1),()=>{window.removeEventListener("message",c)}),[c])},le=()=>{const{connectLink:e}=de();return ce(),r.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:"9999"},children:r.jsx(z,{src:e})})},ue=e=>r.jsx(H,{props:e,children:e.open&&r.jsx(le,{})}),U=m.memo(ue);var L,w=G;L=w.createRoot,w.hydrateRoot;const pe=(e,n)=>{const t=re(e),o=L(t);return o.render(r.jsx(U,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=O;exports.ConnectDialogTransition=y;exports.ConnectElement=U;exports.ConnectFlows=x;exports.ConnectLanguage=_;exports.ConnectMode=v;exports.ConnectRegions=T;exports.ConnectScope=I;exports.ConnectTheme=N;exports.renderConnectElement=pe;
package/build/index.d.ts CHANGED
@@ -61,9 +61,11 @@ export declare type ConnectPaymentProvider = {
61
61
 
62
62
  export declare type ConnectProps = {
63
63
  onClose?: () => void;
64
- onSuccess?: (res: Record<string, string | number>) => void;
64
+ onSuccess?: (res: Record<string, string | number | object>) => void;
65
65
  onError?: (error: CustomError) => void;
66
66
  onReady?: () => void;
67
+ onCreated?: (res: Record<string, string | number | object>) => void;
68
+ onBoardCompleted?: () => void;
67
69
  open: boolean;
68
70
  publicKey: string;
69
71
  scope: ConnectScope;
@@ -1,9 +1,9 @@
1
- import { jsx as n, jsxs as c, Fragment as v } from "react/jsx-runtime";
1
+ import { jsx as n, jsxs as u, Fragment as v } from "react/jsx-runtime";
2
2
  import * as f from "react";
3
- import h from "react";
4
- import D from "react-dom";
5
- var _ = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(_ || {}), B = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(B || {}), y = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.BANK = "bank", e.BOARD = "board", e.BRAND = "brand", e.ENTITY = "entity", e.INDIVIDUAL = "individual", e.KYC = "kyc", e.TAX = "tax", e.TERMINAL = "terminal", e))(y || {}), P = /* @__PURE__ */ ((e) => (e.SA = "sa", e.SA_DR = "sa-dr", e))(P || {}), I = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e.DYNAMIC = "dynamic", e))(I || {}), T = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e.DYNAMIC = "dynamic", e))(T || {}), U = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(U || {}), N = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(N || {}), u = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e))(u || {}), m = /* @__PURE__ */ ((e) => (e.AUTH_TOKEN = "token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(m || {});
6
- const H = ({
3
+ import y from "react";
4
+ import G from "react-dom";
5
+ var E = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(E || {}), B = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(B || {}), N = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.BANK = "bank", e.BOARD = "board", e.BRAND = "brand", e.ENTITY = "entity", e.INDIVIDUAL = "individual", e.KYC = "kyc", e.TAX = "tax", e.TERMINAL = "terminal", e))(N || {}), P = /* @__PURE__ */ ((e) => (e.SA = "sa", e.SA_DR = "sa-dr", e))(P || {}), I = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e.DYNAMIC = "dynamic", e))(I || {}), T = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e.DYNAMIC = "dynamic", e))(T || {}), R = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(R || {}), _ = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(_ || {}), p = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e.ON_CREATED = "connect:onCreated", e.ON_BOARD_COMPLETED = "connect:onBoardCompleted", e))(p || {}), m = /* @__PURE__ */ ((e) => (e.AUTH_TOKEN = "token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(m || {});
6
+ const M = ({
7
7
  outerStartColor: e = "rgba(244, 244, 244, 1)",
8
8
  outerEndColor: r = "rgba(238, 238, 238, 1)",
9
9
  innerStartColor: t = "rgba(244, 244, 244, 1)",
@@ -30,8 +30,8 @@ const H = ({
30
30
  height: "100%",
31
31
  opacity: 0.9
32
32
  },
33
- children: /* @__PURE__ */ c("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
- /* @__PURE__ */ c("g", { children: [
33
+ children: /* @__PURE__ */ u("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
+ /* @__PURE__ */ u("g", { children: [
35
35
  /* @__PURE__ */ n(
36
36
  "circle",
37
37
  {
@@ -43,7 +43,7 @@ const H = ({
43
43
  strokeWidth: "9.6",
44
44
  strokeLinecap: "round",
45
45
  strokeDasharray: "425 125",
46
- children: s && /* @__PURE__ */ c(v, { children: [
46
+ children: s && /* @__PURE__ */ u(v, { children: [
47
47
  /* @__PURE__ */ n(
48
48
  "animateTransform",
49
49
  {
@@ -79,7 +79,7 @@ const H = ({
79
79
  strokeWidth: "9.6",
80
80
  strokeLinecap: "round",
81
81
  strokeDasharray: "300 100",
82
- children: s && /* @__PURE__ */ c(v, { children: [
82
+ children: s && /* @__PURE__ */ u(v, { children: [
83
83
  /* @__PURE__ */ n(
84
84
  "animateTransform",
85
85
  {
@@ -105,8 +105,8 @@ const H = ({
105
105
  }
106
106
  )
107
107
  ] }),
108
- /* @__PURE__ */ c("defs", { children: [
109
- /* @__PURE__ */ c(
108
+ /* @__PURE__ */ u("defs", { children: [
109
+ /* @__PURE__ */ u(
110
110
  "filter",
111
111
  {
112
112
  id: "filter0_dddi_1427_22275",
@@ -177,7 +177,7 @@ const H = ({
177
177
  ]
178
178
  }
179
179
  ),
180
- /* @__PURE__ */ c(
180
+ /* @__PURE__ */ u(
181
181
  "linearGradient",
182
182
  {
183
183
  id: "strokeGradientOuter_1427_22275",
@@ -192,7 +192,7 @@ const H = ({
192
192
  ]
193
193
  }
194
194
  ),
195
- /* @__PURE__ */ c(
195
+ /* @__PURE__ */ u(
196
196
  "linearGradient",
197
197
  {
198
198
  id: "strokeGradientInner_1427_22275",
@@ -212,19 +212,19 @@ const H = ({
212
212
  }
213
213
  )
214
214
  }
215
- ), M = h.memo(H), R = h.createContext({}), E = () => h.useContext(R);
215
+ ), H = y.memo(M), U = y.createContext({}), O = () => y.useContext(U);
216
216
  function $({ children: e, props: r }) {
217
- const [t, o] = h.useState(!1), a = (i) => {
217
+ const [t, o] = y.useState(!1), a = (i) => {
218
218
  o(i);
219
219
  }, s = () => {
220
220
  o(!1);
221
221
  };
222
- return /* @__PURE__ */ n(R.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: s }, children: e });
222
+ return /* @__PURE__ */ n(U.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: s }, children: e });
223
223
  }
224
224
  const K = "https://connect-mw.dev.tap.company/middleware/v3/connect", j = "https://connect-mw.dev.tap.company/middleware/v3/connect", W = "https://connect-mw.dev.tap.company/middleware/v3/connect", Y = "tap-connect-sdk-iframe", C = "https://sdk-connect.dev.tap.company", F = "https://sdk-connect.dev.tap.company", V = "https://sdk-connect.dev.tap.company", z = ({ src: e }) => {
225
- const { loading: r } = E();
226
- return /* @__PURE__ */ c(v, { children: [
227
- r && /* @__PURE__ */ n(M, { toggleAnimation: !0 }),
225
+ const { loading: r } = O();
226
+ return /* @__PURE__ */ u(v, { children: [
227
+ r && /* @__PURE__ */ n(H, { toggleAnimation: !0 }),
228
228
  e && /* @__PURE__ */ n(
229
229
  "iframe",
230
230
  {
@@ -344,18 +344,18 @@ const re = (e = "tap-connect-sdk-element") => {
344
344
  if (r) return r;
345
345
  const t = document.createElement("div");
346
346
  return t.setAttribute("id", e), document.body.prepend(t), t;
347
- }, S = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, L = (e) => e === "dr", ne = (e = "") => {
347
+ }, S = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, D = (e) => e === "dr", ne = (e = "") => {
348
348
  const [r, t] = e.split("-");
349
- return S(r) ? L(t) ? W : j : K;
349
+ return S(r) ? D(t) ? W : j : K;
350
350
  }, oe = (e = "") => {
351
351
  const [r, t] = e.split("-");
352
- return S(r) ? L(t) ? V : F : C;
352
+ return S(r) ? D(t) ? V : F : C;
353
353
  }, ae = (e) => {
354
- var r, t, o, a, s, i, l, d, p, O, b, g, A, k, w;
354
+ var r, t, o, a, s, i, l, d, c, h, b, g, A, k, w;
355
355
  return {
356
356
  operator: { public_key: e.publicKey },
357
357
  scope: e.scope,
358
- mode: e.mode || _.PAGE,
358
+ mode: e.mode || E.PAGE,
359
359
  domain: e.merchantDomain,
360
360
  ...e.businessCountryCode && { country: e.businessCountryCode },
361
361
  ...e.data && { data: e.data },
@@ -367,11 +367,11 @@ const re = (e = "tap-connect-sdk-element") => {
367
367
  interface: {
368
368
  theme: e.theme || I.DYNAMIC,
369
369
  locale: e.language || T.DYNAMIC,
370
- edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) || U.CURVED,
370
+ edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) || R.CURVED,
371
371
  parnter_logo: ((t = e.features) == null ? void 0 : t.merchantLogo) ?? !1,
372
372
  dialog_transition: {
373
- start: ((o = e.features) == null ? void 0 : o.dialogStartTransition) || N.UP,
374
- end: ((a = e.features) == null ? void 0 : a.dialogEndTransition) || N.DOWN
373
+ start: ((o = e.features) == null ? void 0 : o.dialogStartTransition) || _.UP,
374
+ end: ((a = e.features) == null ? void 0 : a.dialogEndTransition) || _.DOWN
375
375
  }
376
376
  },
377
377
  notification: {
@@ -381,13 +381,13 @@ const re = (e = "tap-connect-sdk-element") => {
381
381
  features: {
382
382
  poweredby: ((l = e.features) == null ? void 0 : l.poweredBy) ?? !0,
383
383
  close_button: ((d = e.features) == null ? void 0 : d.closeButton) ?? !1,
384
- embedded: ((p = e.features) == null ? void 0 : p.embedded) ?? !1
384
+ embedded: ((c = e.features) == null ? void 0 : c.embedded) ?? !1
385
385
  },
386
386
  ...e.leadId && { lead: { id: e.leadId } },
387
387
  ...e.postUrl && { post: { url: e.postUrl } },
388
388
  ...e.redirectUrl && { redirect: { url: e.redirectUrl } },
389
389
  ...e.platforms && { platforms: e.platforms },
390
- ...(((O = e.paymentProvider) == null ? void 0 : O.institutionId) || ((b = e.paymentProvider) == null ? void 0 : b.technologyId)) && {
390
+ ...(((h = e.paymentProvider) == null ? void 0 : h.institutionId) || ((b = e.paymentProvider) == null ? void 0 : b.technologyId)) && {
391
391
  payment_provider: {
392
392
  ...((g = e.paymentProvider) == null ? void 0 : g.institutionId) && { institution: { id: (A = e.paymentProvider) == null ? void 0 : A.institutionId } },
393
393
  ...((k = e.paymentProvider) == null ? void 0 : k.technologyId) && { technology: { id: (w = e.paymentProvider) == null ? void 0 : w.technologyId } }
@@ -395,14 +395,14 @@ const re = (e = "tap-connect-sdk-element") => {
395
395
  },
396
396
  app_info: {
397
397
  name: "connect-sdk-v2",
398
- version: "1.0.4-development",
398
+ version: "1.0.5-development",
399
399
  identifier: window.location.hostname || window.location.origin
400
400
  }
401
401
  };
402
402
  }, se = ({ theme: e, language: r, configToken: t, flow: o, token: a, region: s }) => {
403
403
  const i = new URLSearchParams();
404
404
  let l = "";
405
- return o && (l = o, o !== y.AUTH && o !== y.BOARD && a && i.append(m.AUTH_TOKEN, a)), e && i.append(m.THEME, e), r && i.append(m.LANGUAGE, r), i.append(m.CONFIG_TOKEN, t), `${oe(s)}/${l}?${i.toString()}`;
405
+ return o && (l = o, o !== N.AUTH && o !== N.BOARD && a && i.append(m.AUTH_TOKEN, a)), e && i.append(m.THEME, e), r && i.append(m.LANGUAGE, r), i.append(m.CONFIG_TOKEN, t), `${oe(s)}/${l}?${i.toString()}`;
406
406
  }, ie = async (e) => {
407
407
  const r = await fetch(ne(e.region), {
408
408
  method: "POST",
@@ -417,7 +417,7 @@ const re = (e = "tap-connect-sdk-element") => {
417
417
  throw new Error(`${r.status}::${r.statusText}`);
418
418
  return r.json();
419
419
  }, de = () => {
420
- const [e, r] = f.useState(""), t = E(), o = async () => {
420
+ const [e, r] = f.useState(""), t = O(), o = async () => {
421
421
  var a, s, i;
422
422
  t.onLoadingHandler(!0);
423
423
  try {
@@ -426,7 +426,7 @@ const re = (e = "tap-connect-sdk-element") => {
426
426
  if (d = await ie(t), !d.token) throw new Error("500::Config token is missing");
427
427
  l = d.token;
428
428
  }
429
- const p = se({
429
+ const c = se({
430
430
  theme: (a = d == null ? void 0 : d.interface) == null ? void 0 : a.theme,
431
431
  language: (s = d == null ? void 0 : d.interface) == null ? void 0 : s.locale,
432
432
  configToken: l,
@@ -434,8 +434,8 @@ const re = (e = "tap-connect-sdk-element") => {
434
434
  token: t.token,
435
435
  region: t.region
436
436
  });
437
- if (t.mode !== _.PAGE) return r(p);
438
- window.location.href = p;
437
+ if (t.mode !== E.PAGE) return r(c);
438
+ window.location.href = c;
439
439
  } catch (l) {
440
440
  const d = new te(l);
441
441
  (i = t.onError) == null || i.call(t, d.getClientError()), t.onLoadingHandler(!1);
@@ -445,33 +445,39 @@ const re = (e = "tap-connect-sdk-element") => {
445
445
  o();
446
446
  }, []), { connectLink: e };
447
447
  }, le = () => {
448
- const { onSuccess: e, onClose: r, onError: t, onReady: o, onLoaded: a } = E(), s = f.useCallback(
449
- async (i) => {
450
- if (i.origin !== C) return;
451
- const { data: l, event: d } = i.data;
452
- switch (d) {
453
- case u.ON_CLOSE:
448
+ const { onSuccess: e, onClose: r, onError: t, onReady: o, onLoaded: a, onCreated: s, onBoardCompleted: i } = O(), l = f.useCallback(
449
+ async (d) => {
450
+ if (d.origin !== C) return;
451
+ const { data: c, event: h } = d.data;
452
+ switch (h) {
453
+ case p.ON_CLOSE:
454
454
  r == null || r();
455
455
  break;
456
- case u.ON_ERROR:
457
- t == null || t(l);
456
+ case p.ON_ERROR:
457
+ t == null || t(c);
458
458
  break;
459
- case u.ON_SUCCESS:
460
- e == null || e(l);
459
+ case p.ON_SUCCESS:
460
+ e == null || e(c);
461
461
  break;
462
- case u.ON_LOADED:
462
+ case p.ON_LOADED:
463
463
  a();
464
464
  break;
465
- case u.ON_READY:
465
+ case p.ON_READY:
466
466
  o == null || o();
467
467
  break;
468
+ case p.ON_CREATED:
469
+ s == null || s(c);
470
+ break;
471
+ case p.ON_BOARD_COMPLETED:
472
+ i == null || i();
473
+ break;
468
474
  }
469
475
  },
470
- [r, t, a, o, e]
476
+ [r, t, a, o, e, s, i]
471
477
  );
472
- f.useEffect(() => (window.addEventListener("message", s, !1), () => {
473
- window.removeEventListener("message", s);
474
- }), [s]);
478
+ f.useEffect(() => (window.addEventListener("message", l, !1), () => {
479
+ window.removeEventListener("message", l);
480
+ }), [l]);
475
481
  }, ce = () => {
476
482
  const { connectLink: e } = de();
477
483
  return le(), /* @__PURE__ */ n(
@@ -494,21 +500,21 @@ const re = (e = "tap-connect-sdk-element") => {
494
500
  }
495
501
  );
496
502
  }, ue = (e) => /* @__PURE__ */ n($, { props: e, children: e.open && /* @__PURE__ */ n(ce, {}) }), pe = f.memo(ue);
497
- var G, x = D;
498
- G = x.createRoot, x.hydrateRoot;
499
- const ve = (e, r) => {
500
- const t = re(e), o = G(t);
503
+ var L, x = G;
504
+ L = x.createRoot, x.hydrateRoot;
505
+ const ye = (e, r) => {
506
+ const t = re(e), o = L(t);
501
507
  return o.render(/* @__PURE__ */ n(pe, { ...r })), { unmount: () => o.unmount() };
502
508
  };
503
509
  export {
504
- U as ConnectDialogEdgeFormat,
505
- N as ConnectDialogTransition,
510
+ R as ConnectDialogEdgeFormat,
511
+ _ as ConnectDialogTransition,
506
512
  pe as ConnectElement,
507
- y as ConnectFlows,
513
+ N as ConnectFlows,
508
514
  T as ConnectLanguage,
509
- _ as ConnectMode,
515
+ E as ConnectMode,
510
516
  P as ConnectRegions,
511
517
  B as ConnectScope,
512
518
  I as ConnectTheme,
513
- ve as renderConnectElement
519
+ ye as renderConnectElement
514
520
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/connect-v2",
3
3
  "private": false,
4
- "version": "1.0.4-development",
4
+ "version": "1.0.5-development",
5
5
  "type": "module",
6
6
  "main": "build/index.cjs.js",
7
7
  "module": "build/index.esm.js",