@bloks/browser-transport
Advanced tools
Comparing version 3.2.1-4 to 3.2.1-5
/** | ||
* Proton Browser Transport v3.2.1-4 | ||
* Proton Browser Transport v3.2.1-5 | ||
* https://github.com/protonprotocol/proton-browser-transport | ||
@@ -4,0 +4,0 @@ * |
{ | ||
"name": "@bloks/browser-transport", | ||
"version": "3.2.1-4", | ||
"version": "3.2.1-5", | ||
"description": "Vanilla JS browser transport for Proton Link", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/protonprotocol/proton-browser-transport", |
@@ -83,3 +83,3 @@ import type {LinkSession} from '@bloks/link' | ||
{transaction: {...result.data.request[1]}}, | ||
{abiProvider: (request as any).abiProvider} | ||
{abiProvider: (request as any).abiProvider, scheme: request.getScheme()} | ||
) | ||
@@ -86,0 +86,0 @@ ).data.req |
@@ -85,3 +85,4 @@ import { | ||
action?: {text: string; callback: () => void} | ||
footnote?: string | HTMLElement | ||
footnote?: string | HTMLElement, | ||
hideLogo?: boolean | ||
} | ||
@@ -270,9 +271,12 @@ | ||
const logoEl = this.createEl({class: 'logo'}) | ||
if (args.type) { | ||
logoEl.classList.add(args.type) | ||
emptyElement(this.requestEl) | ||
if (!args.hideLogo) { | ||
const logoEl = this.createEl({class: 'logo'}) | ||
if (args.type) { | ||
logoEl.classList.add(args.type) | ||
} | ||
this.requestEl.appendChild(logoEl) | ||
} | ||
emptyElement(this.requestEl) | ||
this.requestEl.appendChild(logoEl) | ||
if (args.content) { | ||
@@ -289,2 +293,13 @@ this.requestEl.appendChild(args.content) | ||
} | ||
if (args.subtitle) { | ||
let subtitleEl | ||
if (typeof args.subtitle === 'string') { | ||
subtitleEl = this.createEl({class: 'subtitle', tag: 'span', text: args.subtitle}) | ||
} else { | ||
subtitleEl = args.subtitle | ||
} | ||
this.requestEl.appendChild(subtitleEl) | ||
} | ||
if (args.footnote) { | ||
@@ -364,2 +379,3 @@ const footnoteEl = this.createEl({class: 'footnote', content: args.footnote}) | ||
actionEl.appendChild(backgroundEl) | ||
if (isMobile() || this.walletType == 'anchor') { | ||
@@ -370,4 +386,2 @@ actionEl.appendChild(divider) | ||
backgroundEl.appendChild(qrEl) | ||
let footnote: HTMLElement = this.createEl({class: 'footnote'}) | ||
@@ -393,5 +407,4 @@ const isIdentity = request.isIdentity() | ||
title: 'Scan the QR-Code', | ||
subtitle: this.createEl({class: 'subtitle'}), | ||
footnote, | ||
content: backgroundEl, | ||
content: actionEl, | ||
}) | ||
@@ -401,10 +414,9 @@ } | ||
public async showLoading() { | ||
const status = this.createEl({ | ||
this.prepareStatusEl = this.createEl({ | ||
tag: 'span', | ||
text: 'Preparing request...', | ||
}) | ||
this.prepareStatusEl = status | ||
this.showDialog({ | ||
title: 'Loading', | ||
subtitle: status, | ||
title: 'Pending...', | ||
subtitle: this.prepareStatusEl.textContent!, | ||
type: 'loading', | ||
@@ -444,5 +456,28 @@ }) | ||
// Create content | ||
const content = this.createEl({class: 'info'}) | ||
// Content timer | ||
const start = Date.now() | ||
const countdown = this.createEl({class: 'countdown', tag: 'span', text: ''}) | ||
const updateCountdown = () => { | ||
const timeLeft = timeout + start - Date.now() | ||
const timeFormatted = | ||
timeLeft > 0 ? new Date(timeLeft).toISOString().substr(14, 5) : '00:00' | ||
countdown.textContent = `${timeFormatted}` | ||
} | ||
this.countdownTimer = setInterval(updateCountdown, 500) | ||
updateCountdown() | ||
content.appendChild(countdown) | ||
// Content title | ||
const infoEl = this.createEl({class: 'info'}) | ||
const infoTitle = this.createEl({class: 'title', tag: 'span', text: 'Confirm request'}) | ||
infoEl.appendChild(infoTitle) | ||
content.appendChild(infoEl) | ||
// Content subtitle | ||
let subtitle: string | ||
if (deviceName && deviceName.length > 0) { | ||
subtitle = `Please open wallet on “${deviceName}” to review and sign the transaction.` | ||
subtitle = `Please open on "${deviceName}" to review and sign the transaction.` | ||
} else { | ||
@@ -452,30 +487,8 @@ subtitle = 'Please review and sign the transaction in the linked wallet.' | ||
const title = this.createEl({tag: 'span', text: 'Sign'}) | ||
const expires = new Date(Date.now() + timeout) | ||
const updateCountdown = () => { | ||
title.textContent = `Sign - ${countdownFormat(expires)}` | ||
} | ||
this.countdownTimer = setInterval(updateCountdown, 200) | ||
updateCountdown() | ||
const content = this.createEl({class: 'info'}) | ||
const manualHr = this.createEl({tag: 'hr'}) | ||
const manualA = this.createEl({ | ||
tag: 'a', | ||
text: 'Sign manually or with another device', | ||
class: 'manual', | ||
}) | ||
manualA.addEventListener('click', (event) => { | ||
event.preventDefault() | ||
const error = new SessionError('Manual', 'E_TIMEOUT', session) | ||
error[SkipToManual] = true | ||
cancel(error) | ||
}) | ||
content.appendChild(manualHr) | ||
content.appendChild(manualA) | ||
this.showDialog({ | ||
title, | ||
title: 'Pending...', | ||
subtitle, | ||
content, | ||
hideLogo: true, | ||
}) | ||
@@ -487,3 +500,4 @@ | ||
} else if (isAppleHandheld()) { | ||
window.location.href = 'anchor://link' | ||
const scheme = request.getScheme() | ||
window.location.href = `${scheme}://link` | ||
} | ||
@@ -612,3 +626,3 @@ } | ||
this.showLoading() | ||
if (!this.fuelEnabled || !session || request.isIdentity()) { | ||
if (!this.fuelEnabled || !session || request.isIdentity() || this.walletType === 'proton') { | ||
// don't attempt to cosign id request or if we don't have a session attached | ||
@@ -615,0 +629,0 @@ return request |
@@ -180,2 +180,3 @@ interface stylesInterface { | ||
margin-top: 10px; | ||
text-align: center; | ||
} | ||
@@ -182,0 +183,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
887225
6838