@tap-payments/connect-v2 0.0.31-test → 0.0.33-test

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
@@ -42,10 +42,6 @@ const App = () => {
42
42
  merchantDomain="https://example.com"
43
43
  theme={ConnectTheme.DARK}
44
44
  scope={ConnectScope.MERCHANT}
45
- appInfo={{
46
- name: 'My App',
47
- version: '1.0.0',
48
- }}
49
45
  onClose={() => setOpen(false)}
50
46
  features={{ poweredBy: true, closeButton: true }}
51
47
  mode={ConnectMode.POPUP}
@@ -86,9 +82,6 @@ You can also use the SDK without a React build setup by including the UMD bundle
86
82
  publicKey: 'pk_test_lat64TEDSvHrUOYAxVRe28PQ',
87
83
  merchantDomain: 'https://connect.dev.tap.company',
88
84
  language: TapConnectSDK.ConnectLanguage.EN,
89
- appInfo: {
90
- name: 'My App',
91
- },
92
85
  theme: TapConnectSDK.ConnectTheme.DARK,
93
86
  scope: TapConnectSDK.ConnectScope.MERCHANT,
94
87
  data: ['brand', 'entity'],
@@ -111,10 +104,6 @@ You can also use the SDK without a React build setup by including the UMD bundle
111
104
  | **publicKey** | `string` | ✅ | Your public API key provided by Tap Payments. |
112
105
  | **merchantDomain** | `string` | ✅ | Merchant's domain (e.g. `https://expamle.com`). |
113
106
  | **scope** | `ConnectScope` | ✅ | Defines the integration scope [**auth**, **merchant**]. |
114
- | **appInfo** | `ConnectAppInfo` | ✅ | Information about the merchant’s host application. |
115
- | — name | `string` | ✅ | The display name of your application. |
116
- | — identifier | `string` | ❌ | A unique identifier for your application (e.g., bundle ID or package name). |
117
- | — version | `string` | ❌ | The current version of your application (e.g., `1.0.0`). |
118
107
  | **onReady** | `() => void` | ❌ | Called when the app configurations are loaded successfully initializing. |
119
108
  | **onClose** | `() => void` | ❌ | Triggered when the Connect element is closed by the user. |
120
109
  | **onError** | `(eror: CustomError) => void` | ❌ | Triggered on any error. |
@@ -127,7 +116,7 @@ You can also use the SDK without a React build setup by including the UMD bundle
127
116
  | **platforms** | `string` | ❌ | - |
128
117
  | **paymentProvider** | `ConnectPaymentProvider` | ❌ | Information about the payment provider configuration. |
129
118
  | — technologyId | `string` | ✅ | - |
130
- | — settlementBy | `string` | ✅ | - |
119
+ | — institutionId | `string` | ✅ | - |
131
120
  | **features** | `ConnectAppFeatures` | ❌ | Additional configuration options for appearance and UI. |
132
121
  | — poweredBy | `boolean` | ❌ | Show or hide the “Powered by Tap” logo. |
133
122
  | — merchantLogo | `boolean` | ❌ | Show or hide the merchant’s logo in the widget. |
@@ -141,13 +130,8 @@ You can also use the SDK without a React build setup by including the UMD bundle
141
130
  | **mode** | `ConnectMode` | ❌ | Controls the display behavior of the Connect Element, using the ConnectMode enum to specify whether it appears as a full page, popup, or display content only. |
142
131
  | **notification** | `ConnectNotification` | ❌ | Notification configuration to notify the user after account creation. |
143
132
  | — email | `boolean` | ✅ | Enable or disable email notifications. |
144
- | — mobile | `boolean` | ❌ | Enable or disable mobile (SMS) notifications. |
133
+ | — sms | `boolean` | ❌ | Enable or disable mobile SMS notifications. |
145
134
  | **boardEditable** | `boolean` | ❌ | Allow merchant board to be editable. |
146
- | **boardId** | `string` | ❌ | Specify existing board ID. |
147
- | **boardInfoId** | `string` | ❌ | Specify board info ID for password kit. |
148
- | **userId** | `string` | ❌ | User ID for password kit. |
149
- | **userType** | `string` | ❌ | Type of the user for password kit. |
150
- | **operationType** | `ConnectPasswordOperationType` | ❌ | Operation type for password kit. |
151
135
  | **loginMode** | `boolean` | ❌ | Opens Connect in login/auth mode. |
152
136
  | **region** | `string` | ❌ | Region code that changes the target middlware (e.g., **sa** for Saudi). |
153
137
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),A=require("react-dom");function R(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 u=R(p);var g=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(g||{}),_=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(_||{}),j=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(j||{}),C=(e=>(e.DARK="dark",e.LIGHT="light",e))(C||{}),b=(e=>(e.AR="ar",e.EN="en",e))(b||{}),E=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(E||{}),O=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(O||{}),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||{}),f=(e=>(e.PROFILE_TOKEN="profile_token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(f||{});const T=({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:s=3,toggleAnimation:i=!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:i&&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:`${s/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:`${s}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:i&&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:`${s/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:`${s}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})]})]})]})})}),L=p.memo(T),N=p.createContext({}),v=()=>p.useContext(N);function U({children:e,props:n}){const[t,o]=p.useState(!1),s=a=>{o(a)},i=()=>{o(!1)};return r.jsx(N.Provider,{value:{...n,onLoadingHandler:s,loading:t,onLoaded:i},children:e})}const G="https://connect-mw.dev.tap.company/middleware/v3/connect",I="https://connect-mw.dev.tap.company/middleware/v3/connect",D="https://connect-mw.dev.tap.company/middleware/v3/connect",P="tap-connect-sdk-iframe",x="https://connect.alpha.tap.company",B=({src:e})=>{const{loading:n}=v();return r.jsxs(r.Fragment,{children:[n&&r.jsx(L,{toggleAnimation:!0}),e&&r.jsx("iframe",{id:P,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var F=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},M=function(e){return e instanceof Error},$=function(e){return typeof e=="string"},H=function(e){try{var n=e.response.data.errors,t=n[0],o=t.description,s=t.code;return{message:o,code:s}}catch(i){return{message:i.message,code:"UNKNOWN"}}},W=function(e){try{var n=e.message,t=n.split("::"),o=t[0],s=t[1];return{message:s,code:o}}catch(i){return{message:i.message,code:"UNKNOWN"}}},K=function(e){try{var n=e.split("::"),t=n[0],o=n[1];return{message:o,code:t}}catch(s){return{message:s,code:"UNKNOWN"}}},q=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}),F(n)){var t=H(n);this.code=t.code,this.message=t.message}else if(M(n)){var t=W(n);this.code=t.code,this.message=t.message}else if($(n)){var t=K(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 z=(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},Y=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,J=e=>e==="dr",V=(e="")=>{const[n,t]=e.split("-");return Y(n)?J(t)?D:I:G},Q=({features:e,notification:n,...t})=>({open:t.open,operator:{public_key:t.publicKey},domain:t.merchantDomain,app_info:t.appInfo,country:t.businessCountryCode,scope:t.scope,board:{display:t.showBoard,editable:t.boardEditable},...t.leadId&&{lead:{id:t.leadId}},platforms:t.platforms,payment_provider:t.paymentProvider,features:e&&{poweredby:e.poweredBy,close_button:e.closeButton},...t.postUrl&&{post:{url:t.postUrl}},...t.redirectUrl&&{redirect:{url:t.redirectUrl}},data:t.data,mode:t.mode,notification:n&&{sms:n.mobile,email:n.email},interface:{...(e==null?void 0:e.dialogEdgeFormat)&&{edges:e.dialogEdgeFormat},locale:t.language,theme:t.theme,partner_logo:e==null?void 0:e.merchantLogo,...(e==null?void 0:e.dialogEndTransition)&&(e==null?void 0:e.dialogStartTransition)&&{dialog_transition:{start:e.dialogStartTransition,end:e.dialogEndTransition}}}}),X=()=>{const[e,n]=u.useState(""),{onError:t,onLoadingHandler:o,loginMode:s,region:i,...a}=v(),m=async()=>{o(!0);try{const d=await fetch(V(i),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.publicKey}`,mdn:a.merchantDomain||x},body:JSON.stringify(Q(a))});if(!d.ok)throw new Error(`${d.status}::${d.statusText}`);const c=await d.json(),h=new URLSearchParams;a!=null&&a.theme&&h.append(f.THEME,a.theme),a!=null&&a.language&&h.append(f.LANGUAGE,a.language);const k=s?`${x}/auth`:x;if(h.append(f.CONFIG_TOKEN,c.token),c.connect.url=`${k}?${h.toString()}`,a.mode!==g.PAGE)return n(c.connect.url);window.location.href=c.connect.url}catch(d){const c=new q(d);t==null||t(c.getClientError()),o(!1)}};return u.useEffect(()=>{m()},[]),{connectLink:e}},Z=()=>{const{onSuccess:e,onClose:n,onError:t,onReady:o,onLoaded:s}=v(),i=u.useCallback(async a=>{if(a.origin!==x)return;const{data:m,event:d}=a.data;switch(d){case l.ON_CLOSE:n==null||n();break;case l.ON_ERROR:t==null||t(m);break;case l.ON_SUCCESS:e(m);break;case l.ON_LOADED:s();break;case l.ON_READY:o==null||o();break}},[n,t,s,o,e]);u.useEffect(()=>(window.addEventListener("message",i,!1),()=>{window.removeEventListener("message",i)}),[i])},ee=()=>{const{connectLink:e}=X();return Z(),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%"},children:r.jsx(B,{src:e})})},te=e=>r.jsx(U,{props:e,children:e.open&&r.jsx(ee,{})}),w=u.memo(te);var S,y=A;S=y.createRoot,y.hydrateRoot;const re=(e,n)=>{const t=z(e),o=S(t);return o.render(r.jsx(w,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=E;exports.ConnectDialogTransition=O;exports.ConnectElement=w;exports.ConnectLanguage=b;exports.ConnectMode=g;exports.ConnectPasswordOperationType=j;exports.ConnectScope=_;exports.ConnectTheme=C;exports.renderConnectElement=re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),U=require("react-dom");function L(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const m=L(f);var v=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(v||{}),S=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(S||{}),k=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(k||{}),C=(e=>(e.DARK="dark",e.LIGHT="light",e.DYNAMIC="dynamic",e))(C||{}),j=(e=>(e.AR="ar",e.EN="en",e.DYNAMIC="dynamic",e))(j||{}),_=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(_||{}),x=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(x||{}),p=(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))(p||{}),h=(e=>(e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(h||{});const T=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:r="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:s=3,toggleAnimation:a=!1})=>t.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:t.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:t.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsxs("g",{children:[t.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:a&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})}),t.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:a&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})})]}),t.jsxs("defs",{children:[t.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t.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"}),t.jsx("feOffset",{dy:"1.68224"}),t.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.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"}),t.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),t.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"}),t.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),t.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.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"}),t.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),t.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"}),t.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),t.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.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"}),t.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),t.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),t.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"}),t.jsx("feOffset",{dy:"1.50838"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),t.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"}),t.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),t.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:e}),t.jsx("stop",{offset:"1",stopColor:n})]}),t.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:r}),t.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),D=f.memo(T),A=f.createContext({}),g=()=>f.useContext(A);function G({children:e,props:n}){const[r,o]=f.useState(!1),s=i=>{o(i)},a=()=>{o(!1)};return t.jsx(A.Provider,{value:{...n,onLoadingHandler:s,loading:r,onLoaded:a},children:e})}const P="https://connect-mw.dev.tap.company/middleware/v3/connect",M="https://connect-mw.dev.tap.company/middleware/v3/connect",B="https://connect-mw.dev.tap.company/middleware/v3/connect",F="tap-connect-sdk-iframe",y="https://connect.alpha.tap.company",$=({src:e})=>{const{loading:n}=g();return t.jsxs(t.Fragment,{children:[n&&t.jsx(D,{toggleAnimation:!0}),e&&t.jsx("iframe",{id:F,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var W=function(e){var n,r;return((r=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||r===void 0?void 0:r.errors)!==void 0},H=function(e){return e instanceof Error},K=function(e){return typeof e=="string"},Y=function(e){try{var n=e.response.data.errors,r=n[0],o=r.description,s=r.code;return{message:o,code:s}}catch(a){return{message:a.message,code:"UNKNOWN"}}},q=function(e){try{var n=e.message,r=n.split("::"),o=r[0],s=r[1];return{message:s,code:o}}catch(a){return{message:a.message,code:"UNKNOWN"}}},z=function(e){try{var n=e.split("::"),r=n[0],o=n[1];return{message:o,code:r}}catch(s){return{message:s,code:"UNKNOWN"}}},V=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}),W(n)){var r=Y(n);this.code=r.code,this.message=r.message}else if(H(n)){var r=q(n);this.code=r.code,this.message=r.message}else if(K(n)){var r=z(n);this.code=r.code,this.message=r.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 J=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const r=document.createElement("div");return r.setAttribute("id",e),document.body.prepend(r),r},Q=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,X=e=>e==="dr",Z=(e="")=>{const[n,r]=e.split("-");return Q(n)?X(r)?B:M:P},ee=e=>{var n,r,o,s,a,i,d,l,c,u,b,E,O,N;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:{display:e.showBoard??!0,editable:e.boardEditable??!0},interface:{theme:e.theme||C.DYNAMIC,locale:e.language||j.DYNAMIC,edges:((n=e.features)==null?void 0:n.dialogEdgeFormat)||_.CURVED,parnter_logo:((r=e.features)==null?void 0:r.merchantLogo)??!1,dialog_transition:{start:((o=e.features)==null?void 0:o.dialogStartTransition)||x.UP,end:((s=e.features)==null?void 0:s.dialogEndTransition)||x.DOWN}},notification:{email:((a=e.notification)==null?void 0:a.email)??!1,sms:((i=e.notification)==null?void 0:i.sms)??!1},features:{poweredby:((d=e.features)==null?void 0:d.poweredBy)??!0,close_button:((l=e.features)==null?void 0:l.closeButton)??!1},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},...e.platforms&&{platforms:e.platforms},...(((c=e.paymentProvider)==null?void 0:c.institutionId)||((u=e.paymentProvider)==null?void 0:u.technologyId))&&{payment_provider:{...((b=e.paymentProvider)==null?void 0:b.institutionId)&&{institution:{id:(E=e.paymentProvider)==null?void 0:E.institutionId}},...((O=e.paymentProvider)==null?void 0:O.technologyId)&&{technology:{id:(N=e.paymentProvider)==null?void 0:N.technologyId}}}},app_info:{name:window.location.hostname||window.location.origin,version:"0.0.33-test"}}},te=(e,n,r,o)=>{const s=new URLSearchParams;e&&s.append(h.THEME,e),n&&s.append(h.LANGUAGE,n);const a=o?`${y}/auth`:y;return s.append(h.CONFIG_TOKEN,r),`${a}?${s.toString()}`},re=async({region:e,...n})=>{const r=await fetch(Z(e),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.publicKey}`,mdn:n.merchantDomain||y},body:JSON.stringify(ee(n))});if(!r.ok)throw new Error(`${r.status}::${r.statusText}`);return r.json()},ne=()=>{const[e,n]=m.useState(""),{onError:r,onLoadingHandler:o,loginMode:s,...a}=g(),i=async()=>{var d,l;o(!0);try{const c=await re(a),u=te((d=c.interface)==null?void 0:d.theme,(l=c.interface)==null?void 0:l.locale,c.token,s);if(a.mode!==v.PAGE)return n(u);window.location.href=u}catch(c){const u=new V(c);r==null||r(u.getClientError()),o(!1)}};return m.useEffect(()=>{i()},[]),{connectLink:e}},oe=()=>{const{onSuccess:e,onClose:n,onError:r,onReady:o,onLoaded:s}=g(),a=m.useCallback(async i=>{if(i.origin!==y)return;const{data:d,event:l}=i.data;switch(l){case p.ON_CLOSE:n==null||n();break;case p.ON_ERROR:r==null||r(d);break;case p.ON_SUCCESS:e(d);break;case p.ON_LOADED:s();break;case p.ON_READY:o==null||o();break}},[n,r,s,o,e]);m.useEffect(()=>(window.addEventListener("message",a,!1),()=>{window.removeEventListener("message",a)}),[a])},se=()=>{const{connectLink:e}=ne();return oe(),t.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%"},children:t.jsx($,{src:e})})},ae=e=>t.jsx(G,{props:e,children:e.open&&t.jsx(se,{})}),I=m.memo(ae);var R,w=U;R=w.createRoot,w.hydrateRoot;const ie=(e,n)=>{const r=J(e),o=R(r);return o.render(t.jsx(I,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=_;exports.ConnectDialogTransition=x;exports.ConnectElement=I;exports.ConnectLanguage=j;exports.ConnectMode=v;exports.ConnectPasswordOperationType=k;exports.ConnectScope=S;exports.ConnectTheme=C;exports.renderConnectElement=ie;
package/build/index.d.ts CHANGED
@@ -10,12 +10,6 @@ declare type ConnectAppFeatures = {
10
10
  dialogEdgeFormat?: ConnectDialogEdgeFormat;
11
11
  };
12
12
 
13
- export declare type ConnectAppInfo = {
14
- name: string;
15
- identifier?: string;
16
- version?: string;
17
- };
18
-
19
13
  export declare enum ConnectDialogEdgeFormat {
20
14
  STRAIGHT = "straight",
21
15
  CURVED = "curved"
@@ -32,7 +26,8 @@ export declare const ConnectElement: React_2.MemoExoticComponent<(props: Connect
32
26
 
33
27
  export declare enum ConnectLanguage {
34
28
  AR = "ar",
35
- EN = "en"
29
+ EN = "en",
30
+ DYNAMIC = "dynamic"
36
31
  }
37
32
 
38
33
  export declare enum ConnectMode {
@@ -43,7 +38,7 @@ export declare enum ConnectMode {
43
38
 
44
39
  export declare type ConnectNotification = {
45
40
  email: boolean;
46
- mobile?: boolean;
41
+ sms?: boolean;
47
42
  };
48
43
 
49
44
  export declare enum ConnectPasswordOperationType {
@@ -53,7 +48,7 @@ export declare enum ConnectPasswordOperationType {
53
48
 
54
49
  export declare type ConnectPaymentProvider = {
55
50
  technologyId: string;
56
- settlementBy: string;
51
+ institutionId: string;
57
52
  };
58
53
 
59
54
  export declare type ConnectProps = {
@@ -62,29 +57,23 @@ export declare type ConnectProps = {
62
57
  onError?: (error: CustomError) => void;
63
58
  onReady?: () => void;
64
59
  open: boolean;
65
- theme?: ConnectTheme;
66
- language?: ConnectLanguage;
67
60
  publicKey: string;
61
+ scope: ConnectScope;
68
62
  merchantDomain: string;
69
- appInfo: ConnectAppInfo;
63
+ theme?: ConnectTheme;
64
+ language?: ConnectLanguage;
70
65
  businessCountryCode?: string;
71
- scope: ConnectScope;
72
- showBoard?: boolean;
73
66
  leadId?: string;
67
+ showBoard?: boolean;
68
+ boardEditable?: boolean;
74
69
  platforms?: Array<string>;
75
- paymentProvider?: ConnectPaymentProvider;
76
70
  features?: ConnectAppFeatures;
71
+ paymentProvider?: ConnectPaymentProvider;
77
72
  postUrl?: string;
78
73
  redirectUrl?: string;
79
74
  data?: Array<string>;
80
75
  mode?: ConnectMode;
81
76
  notification?: ConnectNotification;
82
- boardEditable?: boolean;
83
- boardId?: string;
84
- boardInfoId?: string;
85
- userId?: string;
86
- userType?: string;
87
- operationType?: ConnectPasswordOperationType;
88
77
  loginMode?: boolean;
89
78
  region?: string;
90
79
  };
@@ -96,7 +85,8 @@ export declare enum ConnectScope {
96
85
 
97
86
  export declare enum ConnectTheme {
98
87
  DARK = "dark",
99
- LIGHT = "light"
88
+ LIGHT = "light",
89
+ DYNAMIC = "dynamic"
100
90
  }
101
91
 
102
92
  declare type CustomError = {
@@ -1,16 +1,16 @@
1
- import { jsx as r, jsxs as d, Fragment as y } from "react/jsx-runtime";
2
- import * as p from "react";
3
- import g from "react";
4
- import w from "react-dom";
5
- var C = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(C || {}), x = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(x || {}), k = /* @__PURE__ */ ((e) => (e.SET_PASSWORD = "set_password", e.RESET_PASSWORD = "reset_password", e))(k || {}), S = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e))(S || {}), A = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e))(A || {}), R = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(R || {}), L = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(L || {}), 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 || {}), f = /* @__PURE__ */ ((e) => (e.PROFILE_TOKEN = "profile_token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(f || {});
6
- const U = ({
1
+ import { jsx as n, jsxs as d, Fragment as _ } from "react/jsx-runtime";
2
+ import * as f from "react";
3
+ import v from "react";
4
+ import R from "react-dom";
5
+ var E = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(E || {}), L = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(L || {}), G = /* @__PURE__ */ ((e) => (e.SET_PASSWORD = "set_password", e.RESET_PASSWORD = "reset_password", e))(G || {}), A = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e.DYNAMIC = "dynamic", e))(A || {}), S = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e.DYNAMIC = "dynamic", e))(S || {}), k = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(k || {}), C = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(C || {}), m = /* @__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))(m || {}), h = /* @__PURE__ */ ((e) => (e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(h || {});
6
+ const T = ({
7
7
  outerStartColor: e = "rgba(244, 244, 244, 1)",
8
- outerEndColor: n = "rgba(238, 238, 238, 1)",
8
+ outerEndColor: r = "rgba(238, 238, 238, 1)",
9
9
  innerStartColor: t = "rgba(244, 244, 244, 1)",
10
10
  innerEndColor: o = "rgba(238, 238, 238, 1)",
11
11
  duration: a = 3,
12
- toggleAnimation: i = !1
13
- }) => /* @__PURE__ */ r(
12
+ toggleAnimation: s = !1
13
+ }) => /* @__PURE__ */ n(
14
14
  "div",
15
15
  {
16
16
  style: {
@@ -18,7 +18,7 @@ const U = ({
18
18
  width: "135px",
19
19
  height: "135px"
20
20
  },
21
- children: /* @__PURE__ */ r(
21
+ children: /* @__PURE__ */ n(
22
22
  "div",
23
23
  {
24
24
  style: {
@@ -32,7 +32,7 @@ const U = ({
32
32
  },
33
33
  children: /* @__PURE__ */ d("svg", { width: "199", height: "197", viewBox: "0 0 199 197", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
34
  /* @__PURE__ */ d("g", { children: [
35
- /* @__PURE__ */ r(
35
+ /* @__PURE__ */ n(
36
36
  "circle",
37
37
  {
38
38
  cx: "89.5",
@@ -43,8 +43,8 @@ const U = ({
43
43
  strokeWidth: "9.6",
44
44
  strokeLinecap: "round",
45
45
  strokeDasharray: "425 125",
46
- children: i && /* @__PURE__ */ d(y, { children: [
47
- /* @__PURE__ */ r(
46
+ children: s && /* @__PURE__ */ d(_, { children: [
47
+ /* @__PURE__ */ n(
48
48
  "animateTransform",
49
49
  {
50
50
  attributeName: "transform",
@@ -55,7 +55,7 @@ const U = ({
55
55
  repeatCount: "indefinite"
56
56
  }
57
57
  ),
58
- /* @__PURE__ */ r(
58
+ /* @__PURE__ */ n(
59
59
  "animate",
60
60
  {
61
61
  attributeName: "stroke-dashoffset",
@@ -68,7 +68,7 @@ const U = ({
68
68
  ] })
69
69
  }
70
70
  ),
71
- /* @__PURE__ */ r(
71
+ /* @__PURE__ */ n(
72
72
  "circle",
73
73
  {
74
74
  cx: "89.5",
@@ -79,8 +79,8 @@ const U = ({
79
79
  strokeWidth: "9.6",
80
80
  strokeLinecap: "round",
81
81
  strokeDasharray: "300 100",
82
- children: i && /* @__PURE__ */ d(y, { children: [
83
- /* @__PURE__ */ r(
82
+ children: s && /* @__PURE__ */ d(_, { children: [
83
+ /* @__PURE__ */ n(
84
84
  "animateTransform",
85
85
  {
86
86
  attributeName: "transform",
@@ -91,7 +91,7 @@ const U = ({
91
91
  repeatCount: "indefinite"
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ r(
94
+ /* @__PURE__ */ n(
95
95
  "animate",
96
96
  {
97
97
  attributeName: "stroke-dashoffset",
@@ -117,8 +117,8 @@ const U = ({
117
117
  filterUnits: "userSpaceOnUse",
118
118
  colorInterpolationFilters: "sRGB",
119
119
  children: [
120
- /* @__PURE__ */ r("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
121
- /* @__PURE__ */ r(
120
+ /* @__PURE__ */ n("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
121
+ /* @__PURE__ */ n(
122
122
  "feColorMatrix",
123
123
  {
124
124
  in: "SourceAlpha",
@@ -127,12 +127,12 @@ const U = ({
127
127
  result: "hardAlpha"
128
128
  }
129
129
  ),
130
- /* @__PURE__ */ r("feOffset", { dy: "1.68224" }),
131
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "4.20656" }),
132
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
133
- /* @__PURE__ */ r("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" }),
134
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_1427_22275" }),
135
- /* @__PURE__ */ r(
130
+ /* @__PURE__ */ n("feOffset", { dy: "1.68224" }),
131
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "4.20656" }),
132
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
133
+ /* @__PURE__ */ n("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" }),
134
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow_1427_22275" }),
135
+ /* @__PURE__ */ n(
136
136
  "feColorMatrix",
137
137
  {
138
138
  in: "SourceAlpha",
@@ -141,12 +141,12 @@ const U = ({
141
141
  result: "hardAlpha"
142
142
  }
143
143
  ),
144
- /* @__PURE__ */ r("feOffset", { dx: "22.3542", dy: "22.6047" }),
145
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "9.80447" }),
146
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
147
- /* @__PURE__ */ r("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" }),
148
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "effect1_dropShadow_1427_22275", result: "effect2_dropShadow_1427_22275" }),
149
- /* @__PURE__ */ r(
144
+ /* @__PURE__ */ n("feOffset", { dx: "22.3542", dy: "22.6047" }),
145
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "9.80447" }),
146
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
147
+ /* @__PURE__ */ n("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" }),
148
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "effect1_dropShadow_1427_22275", result: "effect2_dropShadow_1427_22275" }),
149
+ /* @__PURE__ */ n(
150
150
  "feColorMatrix",
151
151
  {
152
152
  in: "SourceAlpha",
@@ -155,13 +155,13 @@ const U = ({
155
155
  result: "hardAlpha"
156
156
  }
157
157
  ),
158
- /* @__PURE__ */ r("feOffset", { dx: "-6.03352", dy: "-3.01676" }),
159
- /* @__PURE__ */ r("feGaussianBlur", { stdDeviation: "7.5419" }),
160
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "out" }),
161
- /* @__PURE__ */ r("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" }),
162
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "effect2_dropShadow_1427_22275", result: "effect3_dropShadow_1427_22275" }),
163
- /* @__PURE__ */ r("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect3_dropShadow_1427_22275", result: "shape" }),
164
- /* @__PURE__ */ r(
158
+ /* @__PURE__ */ n("feOffset", { dx: "-6.03352", dy: "-3.01676" }),
159
+ /* @__PURE__ */ n("feGaussianBlur", { stdDeviation: "7.5419" }),
160
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "out" }),
161
+ /* @__PURE__ */ n("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" }),
162
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "effect2_dropShadow_1427_22275", result: "effect3_dropShadow_1427_22275" }),
163
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect3_dropShadow_1427_22275", result: "shape" }),
164
+ /* @__PURE__ */ n(
165
165
  "feColorMatrix",
166
166
  {
167
167
  in: "SourceAlpha",
@@ -170,10 +170,10 @@ const U = ({
170
170
  result: "hardAlpha"
171
171
  }
172
172
  ),
173
- /* @__PURE__ */ r("feOffset", { dy: "1.50838" }),
174
- /* @__PURE__ */ r("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
175
- /* @__PURE__ */ r("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" }),
176
- /* @__PURE__ */ r("feBlend", { mode: "normal", in2: "shape", result: "effect4_innerShadow_1427_22275" })
173
+ /* @__PURE__ */ n("feOffset", { dy: "1.50838" }),
174
+ /* @__PURE__ */ n("feComposite", { in2: "hardAlpha", operator: "arithmetic", k2: "-1", k3: "1" }),
175
+ /* @__PURE__ */ n("feColorMatrix", { type: "matrix", values: "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0" }),
176
+ /* @__PURE__ */ n("feBlend", { mode: "normal", in2: "shape", result: "effect4_innerShadow_1427_22275" })
177
177
  ]
178
178
  }
179
179
  ),
@@ -187,8 +187,8 @@ const U = ({
187
187
  y2: "154",
188
188
  gradientUnits: "userSpaceOnUse",
189
189
  children: [
190
- /* @__PURE__ */ r("stop", { stopColor: e }),
191
- /* @__PURE__ */ r("stop", { offset: "1", stopColor: n })
190
+ /* @__PURE__ */ n("stop", { stopColor: e }),
191
+ /* @__PURE__ */ n("stop", { offset: "1", stopColor: r })
192
192
  ]
193
193
  }
194
194
  ),
@@ -202,8 +202,8 @@ const U = ({
202
202
  y2: "134.713",
203
203
  gradientUnits: "userSpaceOnUse",
204
204
  children: [
205
- /* @__PURE__ */ r("stop", { stopColor: t }),
206
- /* @__PURE__ */ r("stop", { offset: "1", stopColor: o })
205
+ /* @__PURE__ */ n("stop", { stopColor: t }),
206
+ /* @__PURE__ */ n("stop", { offset: "1", stopColor: o })
207
207
  ]
208
208
  }
209
209
  )
@@ -212,23 +212,23 @@ const U = ({
212
212
  }
213
213
  )
214
214
  }
215
- ), T = g.memo(U), b = g.createContext({}), _ = () => g.useContext(b);
216
- function G({ children: e, props: n }) {
217
- const [t, o] = g.useState(!1), a = (s) => {
218
- o(s);
219
- }, i = () => {
215
+ ), D = v.memo(T), I = v.createContext({}), N = () => v.useContext(I);
216
+ function P({ children: e, props: r }) {
217
+ const [t, o] = v.useState(!1), a = (i) => {
218
+ o(i);
219
+ }, s = () => {
220
220
  o(!1);
221
221
  };
222
- return /* @__PURE__ */ r(b.Provider, { value: { ...n, onLoadingHandler: a, loading: t, onLoaded: i }, children: e });
222
+ return /* @__PURE__ */ n(I.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: s }, children: e });
223
223
  }
224
- const I = "https://connect-mw.dev.tap.company/middleware/v3/connect", B = "https://connect-mw.dev.tap.company/middleware/v3/connect", D = "https://connect-mw.dev.tap.company/middleware/v3/connect", P = "tap-connect-sdk-iframe", v = "https://connect.alpha.tap.company", F = ({ src: e }) => {
225
- const { loading: n } = _();
226
- return /* @__PURE__ */ d(y, { children: [
227
- n && /* @__PURE__ */ r(T, { toggleAnimation: !0 }),
228
- e && /* @__PURE__ */ r(
224
+ const B = "https://connect-mw.dev.tap.company/middleware/v3/connect", M = "https://connect-mw.dev.tap.company/middleware/v3/connect", $ = "https://connect-mw.dev.tap.company/middleware/v3/connect", F = "tap-connect-sdk-iframe", y = "https://connect.alpha.tap.company", j = ({ src: e }) => {
225
+ const { loading: r } = N();
226
+ return /* @__PURE__ */ d(_, { children: [
227
+ r && /* @__PURE__ */ n(D, { toggleAnimation: !0 }),
228
+ e && /* @__PURE__ */ n(
229
229
  "iframe",
230
230
  {
231
- id: P,
231
+ id: F,
232
232
  title: "connect",
233
233
  src: e,
234
234
  style: {
@@ -243,42 +243,42 @@ const I = "https://connect-mw.dev.tap.company/middleware/v3/connect", B = "https
243
243
  )
244
244
  ] });
245
245
  };
246
- var $ = function(e) {
247
- var n, t;
248
- 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;
249
- }, j = function(e) {
246
+ var W = function(e) {
247
+ var r, t;
248
+ return ((t = (r = e == null ? void 0 : e.response) === null || r === void 0 ? void 0 : r.data) === null || t === void 0 ? void 0 : t.errors) !== void 0;
249
+ }, H = function(e) {
250
250
  return e instanceof Error;
251
- }, M = function(e) {
251
+ }, K = function(e) {
252
252
  return typeof e == "string";
253
- }, H = function(e) {
253
+ }, Y = function(e) {
254
254
  try {
255
- var n = e.response.data.errors, t = n[0], o = t.description, a = t.code;
255
+ var r = e.response.data.errors, t = r[0], o = t.description, a = t.code;
256
256
  return {
257
257
  message: o,
258
258
  code: a
259
259
  };
260
- } catch (i) {
260
+ } catch (s) {
261
261
  return {
262
- message: i.message,
262
+ message: s.message,
263
263
  code: "UNKNOWN"
264
264
  };
265
265
  }
266
- }, W = function(e) {
266
+ }, V = function(e) {
267
267
  try {
268
- var n = e.message, t = n.split("::"), o = t[0], a = t[1];
268
+ var r = e.message, t = r.split("::"), o = t[0], a = t[1];
269
269
  return {
270
270
  message: a,
271
271
  code: o
272
272
  };
273
- } catch (i) {
273
+ } catch (s) {
274
274
  return {
275
- message: i.message,
275
+ message: s.message,
276
276
  code: "UNKNOWN"
277
277
  };
278
278
  }
279
- }, K = function(e) {
279
+ }, q = function(e) {
280
280
  try {
281
- var n = e.split("::"), t = n[0], o = n[1];
281
+ var r = e.split("::"), t = r[0], o = r[1];
282
282
  return {
283
283
  message: o,
284
284
  code: t
@@ -289,8 +289,8 @@ var $ = function(e) {
289
289
  code: "UNKNOWN"
290
290
  };
291
291
  }
292
- }, Y = function() {
293
- function e(n) {
292
+ }, z = function() {
293
+ function e(r) {
294
294
  if (Object.defineProperty(this, "code", {
295
295
  enumerable: !0,
296
296
  configurable: !0,
@@ -301,14 +301,14 @@ var $ = function(e) {
301
301
  configurable: !0,
302
302
  writable: !0,
303
303
  value: void 0
304
- }), $(n)) {
305
- var t = H(n);
304
+ }), W(r)) {
305
+ var t = Y(r);
306
306
  this.code = t.code, this.message = t.message;
307
- } else if (j(n)) {
308
- var t = W(n);
307
+ } else if (H(r)) {
308
+ var t = V(r);
309
309
  this.code = t.code, this.message = t.message;
310
- } else if (M(n)) {
311
- var t = K(n);
310
+ } else if (K(r)) {
311
+ var t = q(r);
312
312
  this.code = t.code, this.message = t.message;
313
313
  } else
314
314
  this.code = "UNKNOWN", this.message = "Unknown error";
@@ -339,112 +339,125 @@ var $ = function(e) {
339
339
  }
340
340
  }), e;
341
341
  }();
342
- const q = (e = "tap-connect-sdk-element") => {
343
- const n = document.getElementById(e);
344
- if (n) return n;
342
+ const J = (e = "tap-connect-sdk-element") => {
343
+ const r = document.getElementById(e);
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
- }, z = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, J = (e) => e === "dr", V = (e = "") => {
348
- const [n, t] = e.split("-");
349
- return z(n) ? J(t) ? D : B : I;
350
- }, Q = ({
351
- features: e,
352
- notification: n,
353
- ...t
354
- }) => ({
355
- open: t.open,
356
- operator: { public_key: t.publicKey },
357
- domain: t.merchantDomain,
358
- app_info: t.appInfo,
359
- country: t.businessCountryCode,
360
- scope: t.scope,
361
- board: { display: t.showBoard, editable: t.boardEditable },
362
- ...t.leadId && { lead: { id: t.leadId } },
363
- platforms: t.platforms,
364
- // TODO: need to confirm with backend
365
- payment_provider: t.paymentProvider,
366
- // TODO: need to confirm with backend
367
- features: e && {
368
- poweredby: e.poweredBy,
369
- close_button: e.closeButton
370
- },
371
- ...t.postUrl && { post: { url: t.postUrl } },
372
- ...t.redirectUrl && { redirect: { url: t.redirectUrl } },
373
- data: t.data,
374
- mode: t.mode,
375
- notification: n && {
376
- // TODO: need to confirm with backend
377
- sms: n.mobile,
378
- email: n.email
379
- },
380
- interface: {
381
- ...(e == null ? void 0 : e.dialogEdgeFormat) && { edges: e.dialogEdgeFormat },
382
- locale: t.language,
383
- theme: t.theme,
384
- partner_logo: e == null ? void 0 : e.merchantLogo,
385
- ...(e == null ? void 0 : e.dialogEndTransition) && (e == null ? void 0 : e.dialogStartTransition) && {
386
- dialog_transition: { start: e.dialogStartTransition, end: e.dialogEndTransition }
347
+ }, Q = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, X = (e) => e === "dr", Z = (e = "") => {
348
+ const [r, t] = e.split("-");
349
+ return Q(r) ? X(t) ? $ : M : B;
350
+ }, ee = (e) => {
351
+ var r, t, o, a, s, i, l, u, c, p, b, w, O, g;
352
+ return {
353
+ operator: { public_key: e.publicKey },
354
+ scope: e.scope,
355
+ mode: e.mode || E.PAGE,
356
+ domain: e.merchantDomain,
357
+ ...e.businessCountryCode && { country: e.businessCountryCode },
358
+ ...e.data && { data: e.data },
359
+ board: {
360
+ display: e.showBoard ?? !0,
361
+ editable: e.boardEditable ?? !0
362
+ },
363
+ interface: {
364
+ theme: e.theme || A.DYNAMIC,
365
+ locale: e.language || S.DYNAMIC,
366
+ edges: ((r = e.features) == null ? void 0 : r.dialogEdgeFormat) || k.CURVED,
367
+ parnter_logo: ((t = e.features) == null ? void 0 : t.merchantLogo) ?? !1,
368
+ dialog_transition: {
369
+ start: ((o = e.features) == null ? void 0 : o.dialogStartTransition) || C.UP,
370
+ end: ((a = e.features) == null ? void 0 : a.dialogEndTransition) || C.DOWN
371
+ }
372
+ },
373
+ notification: {
374
+ email: ((s = e.notification) == null ? void 0 : s.email) ?? !1,
375
+ sms: ((i = e.notification) == null ? void 0 : i.sms) ?? !1
376
+ },
377
+ features: {
378
+ poweredby: ((l = e.features) == null ? void 0 : l.poweredBy) ?? !0,
379
+ close_button: ((u = e.features) == null ? void 0 : u.closeButton) ?? !1
380
+ },
381
+ ...e.leadId && { lead: { id: e.leadId } },
382
+ ...e.postUrl && { post: { url: e.postUrl } },
383
+ ...e.redirectUrl && { redirect: { url: e.redirectUrl } },
384
+ ...e.platforms && { platforms: e.platforms },
385
+ ...(((c = e.paymentProvider) == null ? void 0 : c.institutionId) || ((p = e.paymentProvider) == null ? void 0 : p.technologyId)) && {
386
+ payment_provider: {
387
+ ...((b = e.paymentProvider) == null ? void 0 : b.institutionId) && { institution: { id: (w = e.paymentProvider) == null ? void 0 : w.institutionId } },
388
+ ...((O = e.paymentProvider) == null ? void 0 : O.technologyId) && { technology: { id: (g = e.paymentProvider) == null ? void 0 : g.technologyId } }
389
+ }
390
+ },
391
+ app_info: {
392
+ name: window.location.hostname || window.location.origin,
393
+ version: "0.0.33-test"
387
394
  }
388
- }
389
- }), X = () => {
390
- const [e, n] = p.useState(""), { onError: t, onLoadingHandler: o, loginMode: a, region: i, ...s } = _(), m = async () => {
395
+ };
396
+ }, te = (e, r, t, o) => {
397
+ const a = new URLSearchParams();
398
+ e && a.append(h.THEME, e), r && a.append(h.LANGUAGE, r);
399
+ const s = o ? `${y}/auth` : y;
400
+ return a.append(h.CONFIG_TOKEN, t), `${s}?${a.toString()}`;
401
+ }, re = async ({ region: e, ...r }) => {
402
+ const t = await fetch(Z(e), {
403
+ method: "POST",
404
+ headers: {
405
+ "Content-Type": "application/json",
406
+ Authorization: `Bearer ${r.publicKey}`,
407
+ mdn: r.merchantDomain || y
408
+ },
409
+ body: JSON.stringify(ee(r))
410
+ });
411
+ if (!t.ok)
412
+ throw new Error(`${t.status}::${t.statusText}`);
413
+ return t.json();
414
+ }, ne = () => {
415
+ const [e, r] = f.useState(""), { onError: t, onLoadingHandler: o, loginMode: a, ...s } = N(), i = async () => {
416
+ var l, u;
391
417
  o(!0);
392
418
  try {
393
- const l = await fetch(V(i), {
394
- method: "POST",
395
- headers: {
396
- "Content-Type": "application/json",
397
- Authorization: `Bearer ${s.publicKey}`,
398
- mdn: s.merchantDomain || v
399
- },
400
- body: JSON.stringify(Q(s))
401
- });
402
- if (!l.ok)
403
- throw new Error(`${l.status}::${l.statusText}`);
404
- const c = await l.json(), h = new URLSearchParams();
405
- s != null && s.theme && h.append(f.THEME, s.theme), s != null && s.language && h.append(f.LANGUAGE, s.language);
406
- const O = a ? `${v}/auth` : v;
407
- if (h.append(f.CONFIG_TOKEN, c.token), c.connect.url = `${O}?${h.toString()}`, s.mode !== C.PAGE) return n(c.connect.url);
408
- window.location.href = c.connect.url;
409
- } catch (l) {
410
- const c = new Y(l);
411
- t == null || t(c.getClientError()), o(!1);
419
+ const c = await re(s), p = te((l = c.interface) == null ? void 0 : l.theme, (u = c.interface) == null ? void 0 : u.locale, c.token, a);
420
+ if (s.mode !== E.PAGE) return r(p);
421
+ window.location.href = p;
422
+ } catch (c) {
423
+ const p = new z(c);
424
+ t == null || t(p.getClientError()), o(!1);
412
425
  }
413
426
  };
414
- return p.useEffect(() => {
415
- m();
427
+ return f.useEffect(() => {
428
+ i();
416
429
  }, []), { connectLink: e };
417
- }, Z = () => {
418
- const { onSuccess: e, onClose: n, onError: t, onReady: o, onLoaded: a } = _(), i = p.useCallback(
419
- async (s) => {
420
- if (s.origin !== v) return;
421
- const { data: m, event: l } = s.data;
422
- switch (l) {
423
- case u.ON_CLOSE:
424
- n == null || n();
430
+ }, oe = () => {
431
+ const { onSuccess: e, onClose: r, onError: t, onReady: o, onLoaded: a } = N(), s = f.useCallback(
432
+ async (i) => {
433
+ if (i.origin !== y) return;
434
+ const { data: l, event: u } = i.data;
435
+ switch (u) {
436
+ case m.ON_CLOSE:
437
+ r == null || r();
425
438
  break;
426
- case u.ON_ERROR:
427
- t == null || t(m);
439
+ case m.ON_ERROR:
440
+ t == null || t(l);
428
441
  break;
429
- case u.ON_SUCCESS:
430
- e(m);
442
+ case m.ON_SUCCESS:
443
+ e(l);
431
444
  break;
432
- case u.ON_LOADED:
445
+ case m.ON_LOADED:
433
446
  a();
434
447
  break;
435
- case u.ON_READY:
448
+ case m.ON_READY:
436
449
  o == null || o();
437
450
  break;
438
451
  }
439
452
  },
440
- [n, t, a, o, e]
453
+ [r, t, a, o, e]
441
454
  );
442
- p.useEffect(() => (window.addEventListener("message", i, !1), () => {
443
- window.removeEventListener("message", i);
444
- }), [i]);
445
- }, ee = () => {
446
- const { connectLink: e } = X();
447
- return Z(), /* @__PURE__ */ r(
455
+ f.useEffect(() => (window.addEventListener("message", s, !1), () => {
456
+ window.removeEventListener("message", s);
457
+ }), [s]);
458
+ }, ae = () => {
459
+ const { connectLink: e } = ne();
460
+ return oe(), /* @__PURE__ */ n(
448
461
  "div",
449
462
  {
450
463
  id: "tap-connect-main-container",
@@ -459,24 +472,24 @@ const q = (e = "tap-connect-sdk-element") => {
459
472
  width: "100%",
460
473
  height: "100%"
461
474
  },
462
- children: /* @__PURE__ */ r(F, { src: e })
475
+ children: /* @__PURE__ */ n(j, { src: e })
463
476
  }
464
477
  );
465
- }, te = (e) => /* @__PURE__ */ r(G, { props: e, children: e.open && /* @__PURE__ */ r(ee, {}) }), re = p.memo(te);
466
- var N, E = w;
467
- N = E.createRoot, E.hydrateRoot;
468
- const se = (e, n) => {
469
- const t = q(e), o = N(t);
470
- return o.render(/* @__PURE__ */ r(re, { ...n })), { unmount: () => o.unmount() };
478
+ }, se = (e) => /* @__PURE__ */ n(P, { props: e, children: e.open && /* @__PURE__ */ n(ae, {}) }), ie = f.memo(se);
479
+ var U, x = R;
480
+ U = x.createRoot, x.hydrateRoot;
481
+ const ue = (e, r) => {
482
+ const t = J(e), o = U(t);
483
+ return o.render(/* @__PURE__ */ n(ie, { ...r })), { unmount: () => o.unmount() };
471
484
  };
472
485
  export {
473
- R as ConnectDialogEdgeFormat,
474
- L as ConnectDialogTransition,
475
- re as ConnectElement,
476
- A as ConnectLanguage,
477
- C as ConnectMode,
478
- k as ConnectPasswordOperationType,
479
- x as ConnectScope,
480
- S as ConnectTheme,
481
- se as renderConnectElement
486
+ k as ConnectDialogEdgeFormat,
487
+ C as ConnectDialogTransition,
488
+ ie as ConnectElement,
489
+ S as ConnectLanguage,
490
+ E as ConnectMode,
491
+ G as ConnectPasswordOperationType,
492
+ L as ConnectScope,
493
+ A as ConnectTheme,
494
+ ue as renderConnectElement
482
495
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/connect-v2",
3
3
  "private": false,
4
- "version": "0.0.31-test",
4
+ "version": "0.0.33-test",
5
5
  "type": "module",
6
6
  "main": "build/index.cjs.js",
7
7
  "module": "build/index.esm.js",
@@ -33,7 +33,7 @@
33
33
  "prettier": "prettier . --check",
34
34
  "prettier:fix": "prettier . --write",
35
35
  "prepare": "husky",
36
- "push": "npm publish --access public"
36
+ "push": "npm publish --access public --tag latest"
37
37
  },
38
38
  "dependencies": {
39
39
  "@tap-payments/web-error-handing": "^1.0.1"