@cometh/connect-hosted-sdk
Advanced tools
Comparing version 0.1.0-dev.15 to 0.1.0-dev.16
@@ -108,2 +108,4 @@ import { Bytes } from '@ethersproject/bytes'; | ||
initialized: boolean; | ||
private _modalID; | ||
private _modal; | ||
private _iframeID; | ||
@@ -115,2 +117,5 @@ private _iframe; | ||
constructor(_apiKey: string, _configuration: WalletConfiguration); | ||
private _createModal; | ||
private _hideModal; | ||
private _showModal; | ||
private _initializeIframe; | ||
@@ -117,0 +122,0 @@ private _sendMessage; |
@@ -57,3 +57,3 @@ var __defProp = Object.defineProperty; | ||
// src/iframe/design.ts | ||
var prepareModal = (modalId, onClose) => { | ||
var prepareModal = (modalId) => { | ||
const modal = document.createElement("div"); | ||
@@ -70,9 +70,2 @@ modal.id = modalId; | ||
modal.style.zIndex = "1000"; | ||
const closeBtn = document.createElement("button"); | ||
closeBtn.innerText = "Close"; | ||
closeBtn.style.position = "absolute"; | ||
closeBtn.style.top = "10px"; | ||
closeBtn.style.right = "10px"; | ||
closeBtn.onclick = onClose; | ||
modal.appendChild(closeBtn); | ||
return modal; | ||
@@ -225,3 +218,3 @@ }; | ||
} | ||
const modal = prepareModal(this._modalID, this._hideModal); | ||
const modal = prepareModal(this._modalID); | ||
document.body.appendChild(modal); | ||
@@ -325,3 +318,3 @@ this._modal = modal; | ||
try { | ||
const response = await this.api.post(`/wallets/${address}/is-valid-signature`, { | ||
const response = await this.api.post(`/wallet/is-valid-signature/${address}`, { | ||
message, | ||
@@ -358,2 +351,4 @@ signature | ||
__publicField(this, "initialized", false); | ||
__publicField(this, "_modalID", "modal-cometh-web-wallet"); | ||
__publicField(this, "_modal", null); | ||
__publicField(this, "_iframeID", "cometh-web-wallet"); | ||
@@ -368,2 +363,22 @@ __publicField(this, "_iframe", null); | ||
} | ||
_createModal() { | ||
const existingModal = document.getElementById(this._modalID); | ||
if (existingModal) { | ||
this._modal = existingModal; | ||
return; | ||
} | ||
const modal = prepareModal(this._modalID); | ||
document.body.appendChild(modal); | ||
this._modal = modal; | ||
} | ||
_hideModal() { | ||
if (this._modal) { | ||
this._modal.style.display = "none"; | ||
} | ||
} | ||
_showModal() { | ||
if (this._modal) { | ||
this._modal.style.display = "block"; | ||
} | ||
} | ||
_initializeIframe() { | ||
@@ -385,15 +400,23 @@ if (this._iframe) { | ||
); | ||
iframe.style.display = "none"; | ||
iframe.id = this._iframeID; | ||
iframe.allow = "publickey-credentials-get"; | ||
document.body.appendChild(iframe); | ||
iframe.style.width = "100%"; | ||
iframe.style.height = "100%"; | ||
this._iframe = iframe; | ||
this._modal?.appendChild(iframe); | ||
} | ||
_sendMessage(message) { | ||
communicator_default.sendMessage(this._iframe, message); | ||
this._showModal(); | ||
} | ||
async _waitMessage(type) { | ||
return communicator_default.waitMessage(type, this._oidcUrl); | ||
try { | ||
return await communicator_default.waitMessage(type, this._oidcUrl); | ||
} catch (e) { | ||
this._hideModal(); | ||
throw e; | ||
} | ||
} | ||
async connect() { | ||
this._createModal(); | ||
this._initializeIframe(); | ||
@@ -400,0 +423,0 @@ const result = await this._waitMessage("WALLET_READY" /* WALLET_READY */); |
{ | ||
"name": "@cometh/connect-hosted-sdk", | ||
"version": "0.1.0-dev.15", | ||
"version": "0.1.0-dev.16", | ||
"author": "Cometh", | ||
@@ -5,0 +5,0 @@ "description": "SDK Cometh Hosted-Connect", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72074
2041