@nuvei-connect/nc-websdk 1.0.4 → 1.0.5
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/dist/cdn-index.js +2 -20
- package/dist/cdn-index.min.js +2 -2
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -28
- package/package.json +1 -1
package/dist/cdn-index.js
CHANGED
|
@@ -474,10 +474,6 @@
|
|
|
474
474
|
this.destroy = () => {
|
|
475
475
|
this.isDestroyed = true;
|
|
476
476
|
this.destroyIframe();
|
|
477
|
-
if (this.mountKey) {
|
|
478
|
-
_NuveiSDK.mountPromises.delete(this.mountKey);
|
|
479
|
-
this.mountKey = void 0;
|
|
480
|
-
}
|
|
481
477
|
this.messageQueue = [];
|
|
482
478
|
this.isIframeReady = false;
|
|
483
479
|
window.removeEventListener("message", this.handleIframeMessage);
|
|
@@ -854,28 +850,14 @@
|
|
|
854
850
|
this.listenToIframeEvents();
|
|
855
851
|
}
|
|
856
852
|
};
|
|
857
|
-
_NuveiSDK.mountPromises = /* @__PURE__ */ new Map();
|
|
858
|
-
_NuveiSDK.getMountKey = (params) => {
|
|
859
|
-
var _a;
|
|
860
|
-
const componentKey = String((_a = params.componentName) != null ? _a : "");
|
|
861
|
-
return componentKey;
|
|
862
|
-
};
|
|
863
853
|
// =============================|| PUBLIC METHODS ||============================== //
|
|
864
854
|
/**
|
|
865
855
|
* Creates and initializes an SDK instance in one call.
|
|
866
856
|
*/
|
|
867
857
|
_NuveiSDK.mount = (params) => __async(null, null, function* () {
|
|
868
|
-
const mountKey = _NuveiSDK.getMountKey(params);
|
|
869
|
-
const existingMount = _NuveiSDK.mountPromises.get(mountKey);
|
|
870
|
-
if (existingMount) return existingMount;
|
|
871
858
|
const instance = new _NuveiSDK(params);
|
|
872
|
-
instance.
|
|
873
|
-
|
|
874
|
-
_NuveiSDK.mountPromises.delete(mountKey);
|
|
875
|
-
throw error;
|
|
876
|
-
});
|
|
877
|
-
_NuveiSDK.mountPromises.set(mountKey, mountPromise);
|
|
878
|
-
return mountPromise;
|
|
859
|
+
yield instance.initialize();
|
|
860
|
+
return instance;
|
|
879
861
|
});
|
|
880
862
|
/**
|
|
881
863
|
* Alias for mount, useful for integrations that prefer create-style naming.
|
package/dist/cdn-index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
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(`
|
|
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.
|
|
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;})();
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ModulesNameEnum } from '../common/enums';
|
|
2
2
|
import { HTMLIFrameElement, INuveiInitParams } from '../interfaces';
|
|
3
3
|
export default class NuveiSDK {
|
|
4
|
-
private static readonly mountPromises;
|
|
5
|
-
private static getMountKey;
|
|
6
4
|
private sdkConfig;
|
|
7
5
|
private currentIframe;
|
|
8
6
|
private iframeUrl;
|
|
@@ -19,7 +17,6 @@ export default class NuveiSDK {
|
|
|
19
17
|
private container?;
|
|
20
18
|
private isListeningToIframeEvents;
|
|
21
19
|
private isDestroyed;
|
|
22
|
-
private mountKey?;
|
|
23
20
|
/**
|
|
24
21
|
* Initializes the Nuvei SDK instance
|
|
25
22
|
* @param {INuveiInitParams} params - Initialization parameters
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,eAAe,CAAC;AAQvB,OAAO,EACL,iBAAiB,EAKjB,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAIvB,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,eAAe,CAAC;AAQvB,OAAO,EACL,iBAAiB,EAKjB,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAIvB,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,SAAS,CAA0C;IAE3D,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAgC;IAEpD,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,oBAAoB,CAA+C;IAC3E,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAK;IACjC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,aAAa,CAAC,CAAkB;IACxC,OAAO,CAAC,SAAS,CAAC,CAAuB;IACzC,OAAO,CAAC,yBAAyB,CAAS;IAC1C,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;;OAOG;gBACS,MAAM,EAAE,gBAAgB;IAwDpC,OAAO,CAAC,OAAO,CAAC,CAAqD;IACrE,OAAO,CAAC,OAAO,CAAC,CAA2B;IAC3C,OAAO,CAAC,SAAS,CAAC,CAAyB;IAI3C;;OAEG;IACH,gBAAuB,KAAK,GAAU,QAAQ,gBAAgB,KAAG,OAAO,CAAC,QAAQ,CAAC,CAIhF;IAEF;;OAEG;IACH,gBAAuB,MAAM,WATiB,gBAAgB,KAAG,OAAO,CAAC,QAAQ,CAAC,CASnC;IAE/C;;;;;OAKG;IACI,UAAU,QAAa,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAgB7D;IAEF;;;;;;;;;;;;;;;OAeG;IACI,aAAa,GAClB,eAAe,eAAe,KAC7B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA2BlC;IAEF;;;OAGG;IACI,aAAa,aAOlB;IAEF;;OAEG;IACI,OAAO,aAOZ;IAEF;;;;;;;OAOG;IACI,MAAM,sBASX;IAEF;;;OAGG;IACI,sBAAsB,GAAI,MAAM,MAAM,UAE3C;IAEF;;;;OAIG;IACI,sBAAsB,GAAI,MAAM,GAAG,UAExC;IAIF;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB,CA4BtB;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB,CAoC5B;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB,CAgD5B;IAEF,OAAO,CAAC,mBAAmB,CAUzB;IAEF,OAAO,CAAC,WAAW,CAGjB;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB,CA2D7B;IAEF;;;;OAIG;IACH,OAAO,CAAC,sBAAsB,CAW5B;IAEF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAEvB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,cAAc,CAcpB;IAEF;;;;OAIG;IACH,OAAO,CAAC,iBAAiB,CAOvB;IAEF;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAK1B;IAEF,OAAO,CAAC,mBAAmB,CAwBzB;IAEF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAIvB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CASzB;CACH"}
|
package/dist/core/index.js
CHANGED
|
@@ -183,10 +183,6 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
183
183
|
this.destroy = function () {
|
|
184
184
|
_this.isDestroyed = true;
|
|
185
185
|
_this.destroyIframe();
|
|
186
|
-
if (_this.mountKey) {
|
|
187
|
-
_a.mountPromises.delete(_this.mountKey);
|
|
188
|
-
_this.mountKey = undefined;
|
|
189
|
-
}
|
|
190
186
|
_this.messageQueue = [];
|
|
191
187
|
_this.isIframeReady = false;
|
|
192
188
|
window.removeEventListener('message', _this.handleIframeMessage);
|
|
@@ -607,36 +603,21 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
607
603
|
}
|
|
608
604
|
var _a;
|
|
609
605
|
_a = NuveiSDK;
|
|
610
|
-
NuveiSDK.mountPromises = new Map();
|
|
611
|
-
NuveiSDK.getMountKey = function (params) {
|
|
612
|
-
var _b;
|
|
613
|
-
var componentKey = String((_b = params.componentName) !== null && _b !== void 0 ? _b : '');
|
|
614
|
-
// The SDK uses one deterministic iframe ID per component. Deduplicate by
|
|
615
|
-
// component so a host remount with a new container object cannot start a
|
|
616
|
-
// second SDK instance for the same microfrontend.
|
|
617
|
-
return componentKey;
|
|
618
|
-
};
|
|
619
606
|
// =============================|| PUBLIC METHODS ||============================== //
|
|
620
607
|
/**
|
|
621
608
|
* Creates and initializes an SDK instance in one call.
|
|
622
609
|
*/
|
|
623
610
|
NuveiSDK.mount = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
624
|
-
var
|
|
611
|
+
var instance;
|
|
625
612
|
return __generator(_a, function (_b) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
.catch(function (error) {
|
|
635
|
-
_a.mountPromises.delete(mountKey);
|
|
636
|
-
throw error;
|
|
637
|
-
});
|
|
638
|
-
_a.mountPromises.set(mountKey, mountPromise);
|
|
639
|
-
return [2 /*return*/, mountPromise];
|
|
613
|
+
switch (_b.label) {
|
|
614
|
+
case 0:
|
|
615
|
+
instance = new _a(params);
|
|
616
|
+
return [4 /*yield*/, instance.initialize()];
|
|
617
|
+
case 1:
|
|
618
|
+
_b.sent();
|
|
619
|
+
return [2 /*return*/, instance];
|
|
620
|
+
}
|
|
640
621
|
});
|
|
641
622
|
}); };
|
|
642
623
|
/**
|