@imtbl/passport 2.7.4-alpha.0 → 2.7.4-alpha.1

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.
@@ -371,7 +371,7 @@ function _e(n){throw new Error("Node.js process "+n+" is not supported by JSPM c
371
371
  height=${r},
372
372
  top=${a},
373
373
  left=${i}
374
- `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var xe="Confirm this transaction",ke=720,Me=480,wt=1e3;var B=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let i=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${i}`;}return r}requestConfirmation(e,t,r,i){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==Z))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:Z,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===He.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:i}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((i,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==Z))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:Z,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),i({confirmed:!0});break}case"message_rejected":{this.closeWindow(),i({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,i);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=ae({url:this.getHref("loading"),title:xe,width:e?.width||Me,height:e?.height||ke}),this.overlay=new b(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new b(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=ae({url:this.getHref("loading"),title:xe,width:this.popupOptions?.width||Me,height:this.popupOptions?.height||ke});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let i=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(i,wt),this.overlay.update(()=>this.recreateConfirmationWindow(e,i));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=ae({url:e,title:xe,width:this.popupOptions?.width||Me,height:this.popupOptions?.height||ke}),this.timer=setInterval(t,wt);}catch{}}};var w=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=it(),document.body.insertAdjacentElement("beforeend",r);let i=document.querySelector(`#${W}`);i&&i.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var mi=560,ui=440,gi="16px",It="passport-embedded-login-keyframes",St="passport-embedded-login-iframe",H=class n{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${getDetail(Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(It))return;let e=document.createElement("style");e.id=It,e.textContent=`
374
+ `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var xe="Confirm this transaction",ke=720,Me=480,wt=1e3;var B=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let i=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${i}`;}return r}requestConfirmation(e,t,r,i){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==Z))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:Z,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===He.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:i}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((i,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==Z))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:Z,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),i({confirmed:!0});break}case"message_rejected":{this.closeWindow(),i({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,i);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=ae({url:this.getHref("loading"),title:xe,width:e?.width||Me,height:e?.height||ke}),this.overlay=new b(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new b(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=ae({url:this.getHref("loading"),title:xe,width:this.popupOptions?.width||Me,height:this.popupOptions?.height||ke});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let i=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(i,wt),this.overlay.update(()=>this.recreateConfirmationWindow(e,i));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=ae({url:e,title:xe,width:this.popupOptions?.width||Me,height:this.popupOptions?.height||ke}),this.timer=setInterval(t,wt);}catch{}}};var w=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=it(),document.body.insertAdjacentElement("beforeend",r);let i=document.querySelector(`#${W}`);i&&i.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var mi=660,ui=440,gi="16px",It="passport-embedded-login-keyframes",St="passport-embedded-login-iframe",H=class n{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${getDetail(Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(It))return;let e=document.createElement("style");e.id=It,e.textContent=`
375
375
  @keyframes passportEmbeddedLoginPromptPopBounceIn {
376
376
  0% {
377
377
  opacity: 0.5;
@@ -397,7 +397,7 @@ function pe(i){return "code"in i&&"message"in i}var g=class extends Error{type;c
397
397
  height=${r},
398
398
  top=${a},
399
399
  left=${n}
400
- `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var Ee="Confirm this transaction",ye=720,Re=480,dt=1e3;var k=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let n=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${n}`;}return r}requestConfirmation(e,t,r,n){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==G))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===Ie__namespace.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:n}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((n,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==G))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),n({confirmed:!0});break}case"message_rejected":{this.closeWindow(),n({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,n);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:e?.width||Re,height:e?.height||ye}),this.overlay=new _(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);metrics.trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new _(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let n=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(n,dt),this.overlay.update(()=>this.recreateConfirmationWindow(e,n));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=z({url:e,title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye}),this.timer=setInterval(t,dt);}catch{}}};var T=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=Ve(),document.body.insertAdjacentElement("beforeend",r);let n=document.querySelector(`#${L}`);n&&n.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var Dr=560,Ur=440,Gr="16px",pt="passport-embedded-login-keyframes",mt="passport-embedded-login-iframe",M=class i{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${metrics.getDetail(metrics.Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(pt))return;let e=document.createElement("style");e.id=pt,e.textContent=`
400
+ `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var Ee="Confirm this transaction",ye=720,Re=480,dt=1e3;var k=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let n=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${n}`;}return r}requestConfirmation(e,t,r,n){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==G))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===Ie__namespace.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:n}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((n,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==G))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),n({confirmed:!0});break}case"message_rejected":{this.closeWindow(),n({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,n);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:e?.width||Re,height:e?.height||ye}),this.overlay=new _(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);metrics.trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new _(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let n=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(n,dt),this.overlay.update(()=>this.recreateConfirmationWindow(e,n));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=z({url:e,title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye}),this.timer=setInterval(t,dt);}catch{}}};var T=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=Ve(),document.body.insertAdjacentElement("beforeend",r);let n=document.querySelector(`#${L}`);n&&n.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var Dr=660,Ur=440,Gr="16px",pt="passport-embedded-login-keyframes",mt="passport-embedded-login-iframe",M=class i{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${metrics.getDetail(metrics.Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(pt))return;let e=document.createElement("style");e.id=pt,e.textContent=`
401
401
  @keyframes passportEmbeddedLoginPromptPopBounceIn {
402
402
  0% {
403
403
  opacity: 0.5;
@@ -371,7 +371,7 @@ function pe(i){return "code"in i&&"message"in i}var g=class extends Error{type;c
371
371
  height=${r},
372
372
  top=${a},
373
373
  left=${n}
374
- `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var Ee="Confirm this transaction",ye=720,Re=480,dt=1e3;var k=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let n=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${n}`;}return r}requestConfirmation(e,t,r,n){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==G))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===Ie.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:n}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((n,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==G))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),n({confirmed:!0});break}case"message_rejected":{this.closeWindow(),n({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,n);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:e?.width||Re,height:e?.height||ye}),this.overlay=new _(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new _(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let n=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(n,dt),this.overlay.update(()=>this.recreateConfirmationWindow(e,n));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=z({url:e,title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye}),this.timer=setInterval(t,dt);}catch{}}};var T=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=Ve(),document.body.insertAdjacentElement("beforeend",r);let n=document.querySelector(`#${L}`);n&&n.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var Dr=560,Ur=440,Gr="16px",pt="passport-embedded-login-keyframes",mt="passport-embedded-login-iframe",M=class i{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${getDetail(Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(pt))return;let e=document.createElement("style");e.id=pt,e.textContent=`
374
+ `);if(!s)throw new Error("Failed to open confirmation screen");return s.focus(),s};var Ee="Confirm this transaction",ye=720,Re=480,dt=1e3;var k=class{config;confirmationWindow;popupOptions;overlay;overlayClosed;timer;constructor(e){this.config=e,this.overlayClosed=!1;}getHref(e,t){let r=`${this.config.passportDomain}/transaction-confirmation/${e}`;if(t){let n=t?Object.keys(t).map(a=>`${a}=${t[a]}`).join("&"):"";r=`${r}?${n}`;}return r}requestConfirmation(e,t,r,n){return new Promise((a,s)=>{let o=({data:d,origin:l})=>{if(!(l!==this.config.passportDomain||d.eventType!==G))switch(d.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"transaction_confirmed":{this.closeWindow(),a({confirmed:!0});break}case"transaction_rejected":{this.closeWindow(),a({confirmed:!1});break}case"transaction_error":{this.closeWindow(),s(new Error("Error during transaction confirmation"));break}default:this.closeWindow(),s(new Error("Unsupported message type"));}},c="";r===Ie.mr.TransactionApprovalRequestChainTypeEnum.Starkex?c=this.getHref("transaction",{transactionId:e,etherAddress:t,chainType:r}):c=this.getHref("zkevm/transaction",{transactionID:e,etherAddress:t,chainType:r,chainID:n}),window.addEventListener("message",o),this.showConfirmationScreen(c,o,a);})}requestMessageConfirmation(e,t,r){return new Promise((n,a)=>{let s=({data:c,origin:d})=>{if(!(d!==this.config.passportDomain||c.eventType!==G))switch(c.messageType){case"confirmation_window_ready":{this.confirmationWindow?.postMessage({eventType:G,messageType:"confirmation_start"},this.config.passportDomain);break}case"message_confirmed":{this.closeWindow(),n({confirmed:!0});break}case"message_rejected":{this.closeWindow(),n({confirmed:!1});break}case"message_error":{this.closeWindow(),a(new Error("Error during message confirmation"));break}default:this.closeWindow(),a(new Error("Unsupported message type"));}};window.addEventListener("message",s);let o=this.getHref("zkevm/message",{messageID:e,etherAddress:t,...r?{messageType:r}:{}});this.showConfirmationScreen(o,s,n);})}showServiceUnavailable(){return new Promise((e,t)=>{this.showConfirmationScreen(this.getHref("unavailable"),()=>{},()=>{this.closeWindow(),t(new Error("Service unavailable"));});})}loading(e){if(!this.config.crossSdkBridgeEnabled){this.popupOptions=e;try{this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:e?.width||Re,height:e?.height||ye}),this.overlay=new _(this.config.popupOverlayOptions);}catch(t){let r=t instanceof Error?t.message:String(t);trackError("passport","confirmationPopupDenied",new Error(r)),this.overlay=new _(this.config.popupOverlayOptions,!0);}this.overlay.append(()=>{try{this.confirmationWindow?.close(),this.confirmationWindow=z({url:this.getHref("loading"),title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye});}catch{}},()=>{this.overlayClosed=!0,this.closeWindow();});}}closeWindow(){this.confirmationWindow?.close(),this.overlay?.remove(),this.overlay=void 0;}showConfirmationScreen(e,t,r){if(this.confirmationWindow&&(this.confirmationWindow.location.href=e),!this.overlay){this.overlayClosed=!1,r({confirmed:!1});return}let n=()=>{(this.confirmationWindow?.closed||this.overlayClosed)&&(clearInterval(this.timer),window.removeEventListener("message",t),r({confirmed:!1}),this.overlayClosed=!1,this.confirmationWindow=void 0);};this.timer=setInterval(n,dt),this.overlay.update(()=>this.recreateConfirmationWindow(e,n));}recreateConfirmationWindow(e,t){try{clearInterval(this.timer),this.confirmationWindow?.close(),this.confirmationWindow=z({url:e,title:Ee,width:this.popupOptions?.width||Re,height:this.popupOptions?.height||ye}),this.timer=setInterval(t,dt);}catch{}}};var T=class{static overlay;static onCloseListener;static closeButton;static remove(){this.onCloseListener&&this.closeButton?.removeEventListener?.("click",this.onCloseListener),this.overlay?.remove(),this.closeButton=void 0,this.onCloseListener=void 0,this.overlay=void 0;}static appendOverlay(e,t){if(!this.overlay){let r=document.createElement("div");r.innerHTML=Ve(),document.body.insertAdjacentElement("beforeend",r);let n=document.querySelector(`#${L}`);n&&n.appendChild(e),r.addEventListener("click",t),this.overlay=r;}}};var Dr=660,Ur=440,Gr="16px",pt="passport-embedded-login-keyframes",mt="passport-embedded-login-iframe",M=class i{config;constructor(e){this.config=e;}getHref=()=>`${this.config.authenticationDomain}/im-embedded-login-prompt?client_id=${this.config.oidcConfiguration.clientId}&rid=${getDetail(Detail.RUNTIME_ID)}`;static appendIFrameStylesIfNeeded=()=>{if(document.getElementById(pt))return;let e=document.createElement("style");e.id=pt,e.textContent=`
375
375
  @keyframes passportEmbeddedLoginPromptPopBounceIn {
376
376
  0% {
377
377
  opacity: 0.5;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@imtbl/passport",
3
3
  "description": "Passport module for Immutable SDK",
4
- "version": "2.7.4-alpha.0",
4
+ "version": "2.7.4-alpha.1",
5
5
  "author": "Immutable",
6
6
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
7
7
  "dependencies": {
8
8
  "@0xsequence/abi": "^2.0.25",
9
9
  "@0xsequence/core": "^2.0.25",
10
- "@imtbl/config": "2.7.4-alpha.0",
11
- "@imtbl/generated-clients": "2.7.4-alpha.0",
12
- "@imtbl/metrics": "2.7.4-alpha.0",
13
- "@imtbl/toolkit": "2.7.4-alpha.0",
14
- "@imtbl/x-client": "2.7.4-alpha.0",
15
- "@imtbl/x-provider": "2.7.4-alpha.0",
10
+ "@imtbl/config": "2.7.4-alpha.1",
11
+ "@imtbl/generated-clients": "2.7.4-alpha.1",
12
+ "@imtbl/metrics": "2.7.4-alpha.1",
13
+ "@imtbl/toolkit": "2.7.4-alpha.1",
14
+ "@imtbl/x-client": "2.7.4-alpha.1",
15
+ "@imtbl/x-provider": "2.7.4-alpha.1",
16
16
  "@magic-ext/oidc": "12.0.5",
17
17
  "@magic-sdk/provider": "^29.0.5",
18
18
  "@metamask/detect-provider": "^2.0.0",