@nuvei-connect/nc-websdk 1.0.5 → 1.0.6

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
@@ -143,5 +143,7 @@ const instance = await NuveiSDK.mount({
143
143
  | `fetchClientSession` | No | Custom authentication/session callback |
144
144
  | `refreshClientSession` | No | Custom session refresh callback |
145
145
  | `destroySession` | No | Custom session destroy/logout callback |
146
+ | `config.requestId` | No | Merchant request ID; falls back to the host URL |
147
+ | `config.documentRequestId` | No | Document Utility request ID; falls back to the host URL |
146
148
 
147
149
  > **Note:** Authentication callbacks are optional. If they are not provided, the SDK uses its built-in authentication flow.
package/dist/cdn-index.js CHANGED
@@ -324,6 +324,7 @@
324
324
  ["DOC_UTILITY" /* DOC_UTILITY */]: "/_document-upload"
325
325
  };
326
326
  var DOCUMENT_REQUEST_ID_PARAM = "documentRequestId";
327
+ var REQUEST_ID_PARAM = "requestId";
327
328
  var getEnvironmentBaseUrl = (environment = "prod") => {
328
329
  var _a;
329
330
  return (_a = ENVIRONMENT_BASE_URLS[environment]) != null ? _a : ENVIRONMENT_BASE_URLS.prod;
@@ -343,6 +344,13 @@
343
344
  const params = new URLSearchParams(window.location.search);
344
345
  return params.get(DOCUMENT_REQUEST_ID_PARAM);
345
346
  };
347
+ var getRequestIdFromUrl = () => {
348
+ if (typeof window === "undefined") {
349
+ return null;
350
+ }
351
+ const params = new URLSearchParams(window.location.search);
352
+ return params.get(REQUEST_ID_PARAM);
353
+ };
346
354
  var getBaseUrl = (componentName, environment, config) => {
347
355
  if (config.iframeBaseUrl) {
348
356
  return config.iframeBaseUrl;
@@ -353,7 +361,7 @@
353
361
  return getEnvironmentBaseUrl(environment);
354
362
  };
355
363
  var resolveIframeUrl = (componentName, config) => {
356
- var _a, _b;
364
+ var _a, _b, _c;
357
365
  const environment = (_a = config.environment) != null ? _a : "prod";
358
366
  const baseUrl = getBaseUrl(
359
367
  componentName,
@@ -367,6 +375,11 @@
367
375
  queryParams = {
368
376
  [DOCUMENT_REQUEST_ID_PARAM]: documentRequestId
369
377
  };
378
+ } else if (componentName === "ONBOARDING_MERCHANT" /* ONBOARDING_MERCHANT */ || componentName === "ONBOARDING_PARTNER" /* ONBOARDING_PARTNER */) {
379
+ const requestId = (_c = config.requestId) != null ? _c : getRequestIdFromUrl();
380
+ queryParams = {
381
+ [REQUEST_ID_PARAM]: requestId
382
+ };
370
383
  }
371
384
  const query = buildQuery(queryParams);
372
385
  return `${baseUrl}${path}${query}`;
@@ -1,3 +1,3 @@
1
- "use strict";(()=>{var O=Object.defineProperty,P=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var C=(r,e,s)=>e in r?O(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,f=(r,e)=>{for(var s in e||(e={}))_.call(e,s)&&C(r,s,e[s]);if(w)for(var s of w(e))L.call(e,s)&&C(r,s,e[s]);return r},S=(r,e)=>P(r,U(e));var u=(r,e,s)=>new Promise((t,n)=>{var i=c=>{try{o(s.next(c))}catch(l){n(l)}},a=c=>{try{o(s.throw(c))}catch(l){n(l)}},o=c=>c.done?t(c.value):Promise.resolve(c.value).then(i,a);o((s=s.apply(r,e)).next())});var m=(t=>(t.ONBOARDING_PARTNER="ONBOARDING_PARTNER",t.ONBOARDING_MERCHANT="ONBOARDING_MERCHANT",t.DOC_UTILITY="DOC_UTILITY",t))(m||{});var D=r=>{if(r&&typeof r=="object"){let e=Object.keys(r),s=e.length,t=e.length?"?":"";return e.forEach((n,i)=>{let a=i+1,o=r[n],c=r[e[a]];if(a<s&&g(o)){let l=t+n+"="+o;g(c)?t=l+"&":t=l}else g(o)&&(t=t+n+"="+o)}),t}return""},g=r=>!(r==null||r===""||typeof r=="number"&&Number.isNaN(r)||typeof r=="string"&&r.trim()===""),p=r=>{let e=t=>t!=null&&!(Array.isArray(t)&&t.length===0)&&!(typeof t=="object"&&Object.keys(t).length===0)&&!(typeof t=="string"&&t.trim()==="");if(!r||typeof r!="object")return;let s={};for(let t in r)if(r.hasOwnProperty(t)){let n=r[t];if(e(n))if(Array.isArray(n)){let i=n.filter(a=>e(a)).map(p).filter(a=>e(a));i.length&&(s[t]=i)}else if(typeof n=="object"){let i=p(n);e(i)&&(s[t]=i)}else s[t]=n}return Object.keys(s).length?s:void 0};var F={isSuccess:!1,accessToken:"",accessTokenExpiry:"",refreshToken:"",refreshTokenExpiry:""},K={isSuccess:!1,accessToken:"",accessTokenExpiry:""},y=class{constructor(e,s){this.currentAccessToken="";this.fetchClientSession=()=>u(this,null,function*(){let e=this.getAuthUrl("/auth/micro-frontend/tokens"),s=p({modules:[{name:this.getAuthModuleName()}],referenceId:this.authConfig.referenceId});try{let t=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(s)}),n=yield this.parseJsonResponse(t,e,"Frontend AccessToken");return this.currentAccessToken=n.accessToken||"",S(f(f({},F),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken",e,t)}});this.refreshClientSession=e=>u(this,null,function*(){let s=this.getAuthUrl("/auth/micro-frontend/tokens/refresh");try{let t=yield fetch(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(p(e))}),n=yield this.parseJsonResponse(t,s,"Frontend AccessToken Refresh");return this.currentAccessToken=n.accessToken||this.currentAccessToken,S(f(f({},K),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken Refresh",s,t)}});this.destroySession=()=>u(this,null,function*(){if(!this.currentAccessToken)return!0;let e=this.getAuthUrl("/auth/access-token/revoke");try{let s=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({accessToken:this.currentAccessToken})});if(!s.ok){let t=yield s.text();throw new Error(`Session revoke failed(Web SDK): ${s.status} ${s.statusText}. URL: ${e}. Response: ${t.slice(0,200)}`)}return this.currentAccessToken="",!0}catch(s){return console.error(this.createAuthError("Session revoke",e,s).message),!1}});this.getAuthModuleName=()=>{switch(this.moduleName){case"ONBOARDING_PARTNER":case"ONBOARDING_MERCHANT":return"ONBOARDING";default:return this.moduleName||""}};this.getHeaders=()=>({Authorization:this.authConfig.authToken||"","Content-Type":"application/json"});this.getAuthUrl=e=>{var t;let s=(t=this.authConfig.authApiUrl)==null?void 0:t.trim();if(!s)throw new Error("authConfig.authApiUrl is required(Web SDK)");return`${s.replace(/\/$/,"")}${e}`};this.parseJsonResponse=(e,s,t)=>u(null,null,function*(){let n=yield e.text();if(!e.ok)throw new Error(`${t} Error Response(Web SDK): ${e.status} ${e.statusText}. URL: ${s}. Response: ${n.slice(0,200)}`);let i=e.headers.get("content-type")||"";if(!i.includes("application/json"))throw new Error(`${t} expected JSON response(Web SDK). URL: ${s}. Content-Type: ${i||"unknown"}. Response: ${n.slice(0,200)}`);try{return JSON.parse(n)}catch(a){throw new Error(`${t} JSON parse failed(Web SDK). URL: ${s}. Response: ${n.slice(0,200)}`)}});this.createAuthError=(e,s,t)=>{if(t instanceof Error&&t.message.includes("(Web SDK)"))return t;let i=(t instanceof Error?t.message:String(t)).includes("Failed to fetch")?" This usually means the browser blocked the request because of CORS, the URL is unreachable, or the request was blocked before a response was returned.":"";return new Error(`${e} Request Failed(Web SDK). URL: ${s}.${i}`)};this.authConfig=e,this.moduleName=s}};function T(r,e){let s=f({},r);for(let t of Object.keys(e))r[t]&&typeof r[t]=="object"&&typeof e[t]=="object"&&!Array.isArray(r[t])&&!Array.isArray(e[t])?s[t]=T(r[t],e[t]):s[t]=e[t];return s}var E={iframeId:"nc-web-sdk-iframe",containerId:"websdk-container",iframeStyle:{width:"100%",height:"100vh",border:"none",display:"block"},sessionValidation:(r,e)=>!r||!e?!1:new Date(e)>new Date,sessionCheckInterval:10*60*1e3,environment:"uat"};var N=r=>{if(!r)return!0;let e;if(r instanceof Date)e=r;else if(typeof r=="number")e=new Date(r);else if(typeof r=="string"){let s=r.trim().replace(" ","T");e=new Date(s)}else return!0;return isNaN(e.getTime())?!0:Date.now()>e.getTime()};var v={local:"http://localhost:4000",dev:"https://dev3-non-pci.eastus.cloudapp.azure.com",preprod:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},b={local:"http://localhost:5000",dev:"https://dev3-non-pci.eastus.cloudapp.azure.com",preprod:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},W={ONBOARDING_PARTNER:"/_onboarding/partner/application",ONBOARDING_MERCHANT:"/_onboarding/merchant/application",DOC_UTILITY:"/_document-upload"},M="documentRequestId",$=(r="prod")=>{var e;return(e=v[r])!=null?e:v.prod},B=(r="prod")=>{var e;return(e=b[r])!=null?e:b.prod},V=r=>{var e;return(e=W[r])!=null?e:""},H=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(M),q=(r,e,s)=>s.iframeBaseUrl?s.iframeBaseUrl:r==="DOC_UTILITY"?B(e):$(e),x=(r,e)=>{var o,c;let s=(o=e.environment)!=null?o:"prod",t=q(r,s,e),n=V(r),i={};if(r==="DOC_UTILITY"){let l=(c=e.documentRequestId)!=null?c:H();i={[M]:l}}let a=D(i);return`${t}${n}${a}`};var h=class h{constructor(e){this.sdkConfig=f({},E);this.currentIframe=null;this.iframeUrl="";this.isIframeReady=!1;this.messageQueue=[];this.cachedSession=null;this.sessionCheckInterval=null;this.expiryTimeout=null;this.retryAttempts=0;this.MAX_RETRIES=3;this.REFRESH_BUFFER_MS=60*1e3;this.isListeningToIframeEvents=!1;this.isDestroyed=!1;this.initialize=()=>u(this,null,function*(){var e,s;if(this.isDestroyed=!1,!this.componentName)throw new Error("componentName is required to initialize the SDK(Web SDK)");try{let t=yield this.loadComponent(this.componentName);return this.isDestroyed||(yield(e=this.onReady)==null?void 0:e.call(this,this)),t}catch(t){throw(s=this.onError)==null||s.call(this,t),t}});this.loadComponent=e=>u(this,null,function*(){console.log("Component Requested to Load(Web SDK): ",e);try{let s=yield this.getClientSession();if(!this.sdkConfig.sessionValidation(s==null?void 0:s.accessToken,s==null?void 0:s.accessTokenExpiry))throw new Error("Token Validation FailedLoad(Web SDK)");this.iframeUrl=x(e,this.sdkConfig),console.log(`
1
+ "use strict";(()=>{var P=Object.defineProperty,U=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var C=(r,e,s)=>e in r?P(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,f=(r,e)=>{for(var s in e||(e={}))L.call(e,s)&&C(r,s,e[s]);if(w)for(var s of w(e))F.call(e,s)&&C(r,s,e[s]);return r},T=(r,e)=>U(r,_(e));var u=(r,e,s)=>new Promise((t,n)=>{var i=c=>{try{o(s.next(c))}catch(l){n(l)}},a=c=>{try{o(s.throw(c))}catch(l){n(l)}},o=c=>c.done?t(c.value):Promise.resolve(c.value).then(i,a);o((s=s.apply(r,e)).next())});var p=(t=>(t.ONBOARDING_PARTNER="ONBOARDING_PARTNER",t.ONBOARDING_MERCHANT="ONBOARDING_MERCHANT",t.DOC_UTILITY="DOC_UTILITY",t))(p||{});var D=r=>{if(r&&typeof r=="object"){let e=Object.keys(r),s=e.length,t=e.length?"?":"";return e.forEach((n,i)=>{let a=i+1,o=r[n],c=r[e[a]];if(a<s&&I(o)){let l=t+n+"="+o;I(c)?t=l+"&":t=l}else I(o)&&(t=t+n+"="+o)}),t}return""},I=r=>!(r==null||r===""||typeof r=="number"&&Number.isNaN(r)||typeof r=="string"&&r.trim()===""),y=r=>{let e=t=>t!=null&&!(Array.isArray(t)&&t.length===0)&&!(typeof t=="object"&&Object.keys(t).length===0)&&!(typeof t=="string"&&t.trim()==="");if(!r||typeof r!="object")return;let s={};for(let t in r)if(r.hasOwnProperty(t)){let n=r[t];if(e(n))if(Array.isArray(n)){let i=n.filter(a=>e(a)).map(y).filter(a=>e(a));i.length&&(s[t]=i)}else if(typeof n=="object"){let i=y(n);e(i)&&(s[t]=i)}else s[t]=n}return Object.keys(s).length?s:void 0};var K={isSuccess:!1,accessToken:"",accessTokenExpiry:"",refreshToken:"",refreshTokenExpiry:""},W={isSuccess:!1,accessToken:"",accessTokenExpiry:""},g=class{constructor(e,s){this.currentAccessToken="";this.fetchClientSession=()=>u(this,null,function*(){let e=this.getAuthUrl("/auth/micro-frontend/tokens"),s=y({modules:[{name:this.getAuthModuleName()}],referenceId:this.authConfig.referenceId});try{let t=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(s)}),n=yield this.parseJsonResponse(t,e,"Frontend AccessToken");return this.currentAccessToken=n.accessToken||"",T(f(f({},K),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken",e,t)}});this.refreshClientSession=e=>u(this,null,function*(){let s=this.getAuthUrl("/auth/micro-frontend/tokens/refresh");try{let t=yield fetch(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(y(e))}),n=yield this.parseJsonResponse(t,s,"Frontend AccessToken Refresh");return this.currentAccessToken=n.accessToken||this.currentAccessToken,T(f(f({},W),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken Refresh",s,t)}});this.destroySession=()=>u(this,null,function*(){if(!this.currentAccessToken)return!0;let e=this.getAuthUrl("/auth/access-token/revoke");try{let s=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({accessToken:this.currentAccessToken})});if(!s.ok){let t=yield s.text();throw new Error(`Session revoke failed(Web SDK): ${s.status} ${s.statusText}. URL: ${e}. Response: ${t.slice(0,200)}`)}return this.currentAccessToken="",!0}catch(s){return console.error(this.createAuthError("Session revoke",e,s).message),!1}});this.getAuthModuleName=()=>{switch(this.moduleName){case"ONBOARDING_PARTNER":case"ONBOARDING_MERCHANT":return"ONBOARDING";default:return this.moduleName||""}};this.getHeaders=()=>({Authorization:this.authConfig.authToken||"","Content-Type":"application/json"});this.getAuthUrl=e=>{var t;let s=(t=this.authConfig.authApiUrl)==null?void 0:t.trim();if(!s)throw new Error("authConfig.authApiUrl is required(Web SDK)");return`${s.replace(/\/$/,"")}${e}`};this.parseJsonResponse=(e,s,t)=>u(null,null,function*(){let n=yield e.text();if(!e.ok)throw new Error(`${t} Error Response(Web SDK): ${e.status} ${e.statusText}. URL: ${s}. Response: ${n.slice(0,200)}`);let i=e.headers.get("content-type")||"";if(!i.includes("application/json"))throw new Error(`${t} expected JSON response(Web SDK). URL: ${s}. Content-Type: ${i||"unknown"}. Response: ${n.slice(0,200)}`);try{return JSON.parse(n)}catch(a){throw new Error(`${t} JSON parse failed(Web SDK). URL: ${s}. Response: ${n.slice(0,200)}`)}});this.createAuthError=(e,s,t)=>{if(t instanceof Error&&t.message.includes("(Web SDK)"))return t;let i=(t instanceof Error?t.message:String(t)).includes("Failed to fetch")?" This usually means the browser blocked the request because of CORS, the URL is unreachable, or the request was blocked before a response was returned.":"";return new Error(`${e} Request Failed(Web SDK). URL: ${s}.${i}`)};this.authConfig=e,this.moduleName=s}};function E(r,e){let s=f({},r);for(let t of Object.keys(e))r[t]&&typeof r[t]=="object"&&typeof e[t]=="object"&&!Array.isArray(r[t])&&!Array.isArray(e[t])?s[t]=E(r[t],e[t]):s[t]=e[t];return s}var A={iframeId:"nc-web-sdk-iframe",containerId:"websdk-container",iframeStyle:{width:"100%",height:"100vh",border:"none",display:"block"},sessionValidation:(r,e)=>!r||!e?!1:new Date(e)>new Date,sessionCheckInterval:10*60*1e3,environment:"uat"};var N=r=>{if(!r)return!0;let e;if(r instanceof Date)e=r;else if(typeof r=="number")e=new Date(r);else if(typeof r=="string"){let s=r.trim().replace(" ","T");e=new Date(s)}else return!0;return isNaN(e.getTime())?!0:Date.now()>e.getTime()};var v={local:"http://localhost:4000",dev:"https://dev3-non-pci.eastus.cloudapp.azure.com",preprod:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},b={local:"http://localhost:5000",dev:"https://dev3-non-pci.eastus.cloudapp.azure.com",preprod:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},$={ONBOARDING_PARTNER:"/_onboarding/partner/application",ONBOARDING_MERCHANT:"/_onboarding/merchant/application",DOC_UTILITY:"/_document-upload"},M="documentRequestId",O="requestId",B=(r="prod")=>{var e;return(e=v[r])!=null?e:v.prod},V=(r="prod")=>{var e;return(e=b[r])!=null?e:b.prod},H=r=>{var e;return(e=$[r])!=null?e:""},q=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(M),G=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(O),Q=(r,e,s)=>s.iframeBaseUrl?s.iframeBaseUrl:r==="DOC_UTILITY"?V(e):B(e),x=(r,e)=>{var o,c,l;let s=(o=e.environment)!=null?o:"prod",t=Q(r,s,e),n=H(r),i={};if(r==="DOC_UTILITY"){let d=(c=e.documentRequestId)!=null?c:q();i={[M]:d}}else if(r==="ONBOARDING_MERCHANT"||r==="ONBOARDING_PARTNER"){let d=(l=e.requestId)!=null?l:G();i={[O]:d}}let a=D(i);return`${t}${n}${a}`};var h=class h{constructor(e){this.sdkConfig=f({},A);this.currentIframe=null;this.iframeUrl="";this.isIframeReady=!1;this.messageQueue=[];this.cachedSession=null;this.sessionCheckInterval=null;this.expiryTimeout=null;this.retryAttempts=0;this.MAX_RETRIES=3;this.REFRESH_BUFFER_MS=60*1e3;this.isListeningToIframeEvents=!1;this.isDestroyed=!1;this.initialize=()=>u(this,null,function*(){var e,s;if(this.isDestroyed=!1,!this.componentName)throw new Error("componentName is required to initialize the SDK(Web SDK)");try{let t=yield this.loadComponent(this.componentName);return this.isDestroyed||(yield(e=this.onReady)==null?void 0:e.call(this,this)),t}catch(t){throw(s=this.onError)==null||s.call(this,t),t}});this.loadComponent=e=>u(this,null,function*(){console.log("Component Requested to Load(Web SDK): ",e);try{let s=yield this.getClientSession();if(!this.sdkConfig.sessionValidation(s==null?void 0:s.accessToken,s==null?void 0:s.accessTokenExpiry))throw new Error("Token Validation FailedLoad(Web SDK)");this.iframeUrl=x(e,this.sdkConfig),console.log(`
2
2
  Iframe URL(Web SDK): `,this.iframeUrl,`
3
- `);let t=yield this.createIframeWithSource(this.iframeUrl,e);return this.currentIframe=t,this.updateIframeToken(s.accessToken),t}catch(s){throw this.destroyIframe(),s}});this.destroyIframe=()=>{this.currentIframe&&(this.currentIframe.remove(),this.currentIframe=null),this.stopSessionExpiryCheck()};this.destroy=()=>{this.isDestroyed=!0,this.destroyIframe(),this.messageQueue=[],this.isIframeReady=!1,window.removeEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!1};this.logout=()=>u(this,null,function*(){(yield this.authProvider.destroySession())?(this.stopSessionExpiryCheck(),this.destroyIframe()):console.error("Logout failed(Web SDK)")});this.updateIframeNavigation=e=>{this.enqueueMessage("NAVIGATE",e)};this.sendCustomDataToIframe=e=>{this.enqueueMessage("CUSTOM_DATA",e)};this.getClientSession=()=>u(this,null,function*(){var e,s,t,n;try{if(this.cachedSession&&((t=this.sdkConfig)!=null&&t.sessionValidation((e=this.cachedSession)==null?void 0:e.accessToken,(s=this.cachedSession)==null?void 0:s.accessTokenExpiry)))return this.cachedSession;{let i=yield this.authProvider.fetchClientSession();if(!i.isSuccess)throw new Error("Client Session Fetch Failed(Web SDK)");if(!((n=this.sdkConfig)!=null&&n.sessionValidation(i.accessToken,i.accessTokenExpiry)))throw new Error("Client Session Validation Failed(Web SDK)");return this.cachedSession=i,this.retryAttempts=0,i}}catch(i){throw i}});this.refreshedClientSession=()=>u(this,null,function*(){var e,s;if(!((e=this.cachedSession)!=null&&e.refreshToken)||!this.cachedSession.accessToken)throw console.error("Invalid or missing refreshToken or accessToken in cashed session. Destroying iframe(Web SDK)."),this.destroyIframe(),new Error("No session found(Web SDK)");try{let t=yield this.authProvider.refreshClientSession({accessToken:this.cachedSession.accessToken,refreshToken:this.cachedSession.refreshToken});if(!t.isSuccess)throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Failed");if(!((s=this.sdkConfig)!=null&&s.sessionValidation(t.accessToken,t.accessTokenExpiry)))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Validation Failed");let n=f({},this.cachedSession);return n.accessToken=t.accessToken,n.accessTokenExpiry=t.accessTokenExpiry,this.cachedSession=n,this.retryAttempts=0,t}catch(t){throw console.error("Session Refresh Failed(Web SDK):",t),t}});this.createIframeWithSource=(e,s)=>new Promise((t,n)=>{let i=this.getContainerElement();if(!i)return n(new Error("SDK container not found(Web SDK)"));let a=this.getIframeId(s),o=document.getElementById(a);if(o){console.log(`Iframe with Id: ${a} already exists, reusing it(Web SDK)`),t(o);return}o=document.createElement("iframe"),o.src=e,o.id=a;let c=f({},this.sdkConfig.iframeStyle);c&&Object.assign(o.style,c),o.setAttribute("allow","clipboard-write *"),o.onload=()=>{console.log("Iframe loaded successfully(Web SDK)"),this.startSessionExpiryCheck(),t(o)},o.onerror=()=>{n(new Error("Iframe failed to load(Web SDK)"))},i.appendChild(o)});this.getContainerElement=()=>this.container instanceof HTMLElement?this.container:typeof this.container=="string"?document.querySelector(this.container)||document.getElementById(this.container):document.getElementById(this.sdkConfig.containerId);this.getIframeId=e=>{let s=String(e).toLowerCase().replace(/_/g,"-");return`${this.sdkConfig.iframeId}-${s}`};this.startSessionExpiryCheck=()=>u(this,null,function*(){var o,c;if(N((o=this.cachedSession)==null?void 0:o.refreshTokenExpiry)){console.error("Refresh token is expired. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let s=new Date,t=(c=this.cachedSession)==null?void 0:c.accessTokenExpiry,n=t?new Date(t):null;if(!n||isNaN(n.getTime())){console.error("Invalid or missing accessTokenExpiry in session. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let i=n.getTime()-s.getTime()-this.REFRESH_BUFFER_MS,a=()=>u(this,null,function*(){try{if(this.retryAttempts>=this.MAX_RETRIES){console.warn(`Max retry attempts (${this.MAX_RETRIES}) reached. Stopping session check(Web SDK).`),this.stopSessionExpiryCheck(),this.destroyIframe();return}let l=yield this.refreshedClientSession();this.updateIframeToken(l.accessToken),this.retryAttempts=0,this.startSessionExpiryCheck()}catch(l){console.error("Failed to perform session refresh(Web SDK):",l),this.retryAttempts++,this.stopSessionExpiryCheck(),this.expiryTimeout=setTimeout(a,5e3)}});this.stopSessionExpiryCheck(),i<=0?a():this.expiryTimeout=setTimeout(a,i)});this.stopSessionExpiryCheck=()=>{this.expiryTimeout&&(clearTimeout(this.expiryTimeout),this.expiryTimeout=null),this.sessionCheckInterval&&(clearInterval(this.sessionCheckInterval),this.sessionCheckInterval=null)};this.updateIframeToken=e=>{this.enqueueMessage("UPDATE_TOKEN",e)};this.enqueueMessage=(e,s)=>{let t={action:e,source:"NUVEI_WEB_SDK",data:s};if(!this.isIframeReady){console.log("Iframe not ready, queueing message(Web SDK):",t),this.messageQueue.push(t);return}this.postMessageToIframe(t)};this.flushMessageQueue=()=>{for(console.log("Flushing message queue(Web SDK):",this.messageQueue);this.messageQueue.length>0;){let e=this.messageQueue.shift();e&&this.postMessageToIframe(e)}};this.listenToIframeEvents=()=>{this.isListeningToIframeEvents||(window.addEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!0)};this.handleIframeMessage=e=>{if(!this.iframeUrl)return;let s=new URL(this.iframeUrl).origin;if(e.origin!==s)return;let t=e.data;if((t==null?void 0:t.source)==="NUVEI_IFRAME"&&!this.isDestroyed)switch(console.log("Received from iframe:(Web SDK)",t),this.onMessage&&this.onMessage(t),t.action){case"IFRAME_READY":this.handleIframeReady();break;default:break}};this.handleIframeReady=()=>{console.log("Iframe is READY(Web SDK)"),this.isIframeReady=!0,this.flushMessageQueue()};this.postMessageToIframe=e=>{var t;if(!((t=this==null?void 0:this.currentIframe)!=null&&t.contentWindow)){console.warn("Iframe not available(Web SDK)");return}let s=new URL(this.iframeUrl).origin;console.log("Sending message to microfrontend(Web SDK):",e),this.currentIframe.contentWindow.postMessage(e,s)};let{fetchClientSession:s,refreshClientSession:t,destroySession:n,componentName:i,container:a,authConfig:o,config:c,onReady:l,onError:k,onMessage:R}=e;if(o){let I=new y(o,i);this.authProvider={fetchClientSession:s!=null?s:I.fetchClientSession,refreshClientSession:t!=null?t:I.refreshClientSession,destroySession:n!=null?n:I.destroySession}}else if(s&&t&&n)this.authProvider={fetchClientSession:s,refreshClientSession:t,destroySession:n};else throw new Error("authConfig is required when auth callbacks are not fully provided(Web SDK)");this.componentName=i,this.container=a,c&&(this.sdkConfig=T(E,c)),l&&(this.onReady=l),k&&(this.onError=k),R&&(this.onMessage=R),this.listenToIframeEvents()}};h.mount=e=>u(null,null,function*(){let s=new h(e);return yield s.initialize(),s}),h.create=h.mount;var d=h;var A=window;A.NCWebSDK=d;A.NuveiSDK=d;A.ModulesNameEnum=m;})();
3
+ `);let t=yield this.createIframeWithSource(this.iframeUrl,e);return this.currentIframe=t,this.updateIframeToken(s.accessToken),t}catch(s){throw this.destroyIframe(),s}});this.destroyIframe=()=>{this.currentIframe&&(this.currentIframe.remove(),this.currentIframe=null),this.stopSessionExpiryCheck()};this.destroy=()=>{this.isDestroyed=!0,this.destroyIframe(),this.messageQueue=[],this.isIframeReady=!1,window.removeEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!1};this.logout=()=>u(this,null,function*(){(yield this.authProvider.destroySession())?(this.stopSessionExpiryCheck(),this.destroyIframe()):console.error("Logout failed(Web SDK)")});this.updateIframeNavigation=e=>{this.enqueueMessage("NAVIGATE",e)};this.sendCustomDataToIframe=e=>{this.enqueueMessage("CUSTOM_DATA",e)};this.getClientSession=()=>u(this,null,function*(){var e,s,t,n;try{if(this.cachedSession&&((t=this.sdkConfig)!=null&&t.sessionValidation((e=this.cachedSession)==null?void 0:e.accessToken,(s=this.cachedSession)==null?void 0:s.accessTokenExpiry)))return this.cachedSession;{let i=yield this.authProvider.fetchClientSession();if(!i.isSuccess)throw new Error("Client Session Fetch Failed(Web SDK)");if(!((n=this.sdkConfig)!=null&&n.sessionValidation(i.accessToken,i.accessTokenExpiry)))throw new Error("Client Session Validation Failed(Web SDK)");return this.cachedSession=i,this.retryAttempts=0,i}}catch(i){throw i}});this.refreshedClientSession=()=>u(this,null,function*(){var e,s;if(!((e=this.cachedSession)!=null&&e.refreshToken)||!this.cachedSession.accessToken)throw console.error("Invalid or missing refreshToken or accessToken in cashed session. Destroying iframe(Web SDK)."),this.destroyIframe(),new Error("No session found(Web SDK)");try{let t=yield this.authProvider.refreshClientSession({accessToken:this.cachedSession.accessToken,refreshToken:this.cachedSession.refreshToken});if(!t.isSuccess)throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Failed");if(!((s=this.sdkConfig)!=null&&s.sessionValidation(t.accessToken,t.accessTokenExpiry)))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Validation Failed");let n=f({},this.cachedSession);return n.accessToken=t.accessToken,n.accessTokenExpiry=t.accessTokenExpiry,this.cachedSession=n,this.retryAttempts=0,t}catch(t){throw console.error("Session Refresh Failed(Web SDK):",t),t}});this.createIframeWithSource=(e,s)=>new Promise((t,n)=>{let i=this.getContainerElement();if(!i)return n(new Error("SDK container not found(Web SDK)"));let a=this.getIframeId(s),o=document.getElementById(a);if(o){console.log(`Iframe with Id: ${a} already exists, reusing it(Web SDK)`),t(o);return}o=document.createElement("iframe"),o.src=e,o.id=a;let c=f({},this.sdkConfig.iframeStyle);c&&Object.assign(o.style,c),o.setAttribute("allow","clipboard-write *"),o.onload=()=>{console.log("Iframe loaded successfully(Web SDK)"),this.startSessionExpiryCheck(),t(o)},o.onerror=()=>{n(new Error("Iframe failed to load(Web SDK)"))},i.appendChild(o)});this.getContainerElement=()=>this.container instanceof HTMLElement?this.container:typeof this.container=="string"?document.querySelector(this.container)||document.getElementById(this.container):document.getElementById(this.sdkConfig.containerId);this.getIframeId=e=>{let s=String(e).toLowerCase().replace(/_/g,"-");return`${this.sdkConfig.iframeId}-${s}`};this.startSessionExpiryCheck=()=>u(this,null,function*(){var o,c;if(N((o=this.cachedSession)==null?void 0:o.refreshTokenExpiry)){console.error("Refresh token is expired. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let s=new Date,t=(c=this.cachedSession)==null?void 0:c.accessTokenExpiry,n=t?new Date(t):null;if(!n||isNaN(n.getTime())){console.error("Invalid or missing accessTokenExpiry in session. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let i=n.getTime()-s.getTime()-this.REFRESH_BUFFER_MS,a=()=>u(this,null,function*(){try{if(this.retryAttempts>=this.MAX_RETRIES){console.warn(`Max retry attempts (${this.MAX_RETRIES}) reached. Stopping session check(Web SDK).`),this.stopSessionExpiryCheck(),this.destroyIframe();return}let l=yield this.refreshedClientSession();this.updateIframeToken(l.accessToken),this.retryAttempts=0,this.startSessionExpiryCheck()}catch(l){console.error("Failed to perform session refresh(Web SDK):",l),this.retryAttempts++,this.stopSessionExpiryCheck(),this.expiryTimeout=setTimeout(a,5e3)}});this.stopSessionExpiryCheck(),i<=0?a():this.expiryTimeout=setTimeout(a,i)});this.stopSessionExpiryCheck=()=>{this.expiryTimeout&&(clearTimeout(this.expiryTimeout),this.expiryTimeout=null),this.sessionCheckInterval&&(clearInterval(this.sessionCheckInterval),this.sessionCheckInterval=null)};this.updateIframeToken=e=>{this.enqueueMessage("UPDATE_TOKEN",e)};this.enqueueMessage=(e,s)=>{let t={action:e,source:"NUVEI_WEB_SDK",data:s};if(!this.isIframeReady){console.log("Iframe not ready, queueing message(Web SDK):",t),this.messageQueue.push(t);return}this.postMessageToIframe(t)};this.flushMessageQueue=()=>{for(console.log("Flushing message queue(Web SDK):",this.messageQueue);this.messageQueue.length>0;){let e=this.messageQueue.shift();e&&this.postMessageToIframe(e)}};this.listenToIframeEvents=()=>{this.isListeningToIframeEvents||(window.addEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!0)};this.handleIframeMessage=e=>{if(!this.iframeUrl)return;let s=new URL(this.iframeUrl).origin;if(e.origin!==s)return;let t=e.data;if((t==null?void 0:t.source)==="NUVEI_IFRAME"&&!this.isDestroyed)switch(console.log("Received from iframe:(Web SDK)",t),this.onMessage&&this.onMessage(t),t.action){case"IFRAME_READY":this.handleIframeReady();break;default:break}};this.handleIframeReady=()=>{console.log("Iframe is READY(Web SDK)"),this.isIframeReady=!0,this.flushMessageQueue()};this.postMessageToIframe=e=>{var t;if(!((t=this==null?void 0:this.currentIframe)!=null&&t.contentWindow)){console.warn("Iframe not available(Web SDK)");return}let s=new URL(this.iframeUrl).origin;console.log("Sending message to microfrontend(Web SDK):",e),this.currentIframe.contentWindow.postMessage(e,s)};let{fetchClientSession:s,refreshClientSession:t,destroySession:n,componentName:i,container:a,authConfig:o,config:c,onReady:l,onError:d,onMessage:k}=e;if(o){let S=new g(o,i);this.authProvider={fetchClientSession:s!=null?s:S.fetchClientSession,refreshClientSession:t!=null?t:S.refreshClientSession,destroySession:n!=null?n:S.destroySession}}else if(s&&t&&n)this.authProvider={fetchClientSession:s,refreshClientSession:t,destroySession:n};else throw new Error("authConfig is required when auth callbacks are not fully provided(Web SDK)");this.componentName=i,this.container=a,c&&(this.sdkConfig=E(A,c)),l&&(this.onReady=l),d&&(this.onError=d),k&&(this.onMessage=k),this.listenToIframeEvents()}};h.mount=e=>u(null,null,function*(){let s=new h(e);return yield s.initialize(),s}),h.create=h.mount;var m=h;var R=window;R.NCWebSDK=m;R.NuveiSDK=m;R.ModulesNameEnum=p;})();
@@ -48,6 +48,7 @@ export interface INuveiSdkConfig {
48
48
  sessionCheckInterval: number;
49
49
  environment: EnvironmentEnum;
50
50
  iframeBaseUrl?: string;
51
+ requestId?: string;
51
52
  documentRequestId?: string;
52
53
  }
53
54
  export interface HTMLIFrameElement extends HTMLElement {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAE;IACpD,oBAAoB,CAAC,EAA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AM,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IAEd,cAAc,IAAI,QAAQ,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACpD,aAAa,EAAE,CAAC,aAAa,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACrF,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;CAGpB"}
@@ -4,8 +4,9 @@ export declare const getModulePath: (componentName: ModulesNameEnum) => string;
4
4
  /**
5
5
  * Resolves the complete iframe URL for a module.
6
6
  *
7
- * For Document Utility, documentRequestId is automatically
8
- * extracted from the host application's URL.
7
+ * Request IDs are passed to the corresponding microfrontend as query
8
+ * parameters. Merchant onboarding uses requestId; Document Utility uses
9
+ * documentRequestId.
9
10
  */
10
11
  export declare const resolveIframeUrl: (componentName: ModulesNameEnum, config: INuveiSdkConfig) => string;
11
12
  //# sourceMappingURL=iframe-url.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iframe-url.utils.d.ts","sourceRoot":"","sources":["../../src/utils/iframe-url.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAgDpD,eAAO,MAAM,aAAa,GACxB,eAAe,eAAe,KAC7B,MAEF,CAAC;AA2CF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,eAAe,EAC9B,QAAQ,eAAe,KACtB,MAwBF,CAAC"}
1
+ {"version":3,"file":"iframe-url.utils.d.ts","sourceRoot":"","sources":["../../src/utils/iframe-url.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAiDpD,eAAO,MAAM,aAAa,GACxB,eAAe,eAAe,KAC7B,MAEF,CAAC;AAqDF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,eAAe,EAC9B,QAAQ,eAAe,KACtB,MAiCF,CAAC"}
@@ -22,6 +22,7 @@ var MODULE_PATHS = (_a = {},
22
22
  _a[enums_1.ModulesNameEnum.DOC_UTILITY] = '/_document-upload',
23
23
  _a);
24
24
  var DOCUMENT_REQUEST_ID_PARAM = 'documentRequestId';
25
+ var REQUEST_ID_PARAM = 'requestId';
25
26
  var getEnvironmentBaseUrl = function (environment) {
26
27
  var _a;
27
28
  if (environment === void 0) { environment = 'prod'; }
@@ -53,6 +54,13 @@ var getDocumentRequestIdFromUrl = function () {
53
54
  var params = new URLSearchParams(window.location.search);
54
55
  return params.get(DOCUMENT_REQUEST_ID_PARAM);
55
56
  };
57
+ var getRequestIdFromUrl = function () {
58
+ if (typeof window === 'undefined') {
59
+ return null;
60
+ }
61
+ var params = new URLSearchParams(window.location.search);
62
+ return params.get(REQUEST_ID_PARAM);
63
+ };
56
64
  /**
57
65
  * Resolves the base URL for the requested module.
58
66
  *
@@ -71,22 +79,30 @@ var getBaseUrl = function (componentName, environment, config) {
71
79
  /**
72
80
  * Resolves the complete iframe URL for a module.
73
81
  *
74
- * For Document Utility, documentRequestId is automatically
75
- * extracted from the host application's URL.
82
+ * Request IDs are passed to the corresponding microfrontend as query
83
+ * parameters. Merchant onboarding uses requestId; Document Utility uses
84
+ * documentRequestId.
76
85
  */
77
86
  var resolveIframeUrl = function (componentName, config) {
78
- var _a;
79
- var _b, _c;
80
- var environment = (_b = config.environment) !== null && _b !== void 0 ? _b : 'prod';
87
+ var _a, _b;
88
+ var _c, _d, _e;
89
+ var environment = (_c = config.environment) !== null && _c !== void 0 ? _c : 'prod';
81
90
  var baseUrl = getBaseUrl(componentName, environment, config);
82
91
  var path = (0, exports.getModulePath)(componentName);
83
92
  var queryParams = {};
84
93
  if (componentName === enums_1.ModulesNameEnum.DOC_UTILITY) {
85
- var documentRequestId = (_c = config.documentRequestId) !== null && _c !== void 0 ? _c : getDocumentRequestIdFromUrl();
94
+ var documentRequestId = (_d = config.documentRequestId) !== null && _d !== void 0 ? _d : getDocumentRequestIdFromUrl();
86
95
  queryParams = (_a = {},
87
96
  _a[DOCUMENT_REQUEST_ID_PARAM] = documentRequestId,
88
97
  _a);
89
98
  }
99
+ else if (componentName === enums_1.ModulesNameEnum.ONBOARDING_MERCHANT ||
100
+ componentName === enums_1.ModulesNameEnum.ONBOARDING_PARTNER) {
101
+ var requestId = (_e = config.requestId) !== null && _e !== void 0 ? _e : getRequestIdFromUrl();
102
+ queryParams = (_b = {},
103
+ _b[REQUEST_ID_PARAM] = requestId,
104
+ _b);
105
+ }
90
106
  var query = (0, common_utils_1.buildQuery)(queryParams);
91
107
  return "".concat(baseUrl).concat(path).concat(query);
92
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvei-connect/nc-websdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",