Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crypttp

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypttp - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

4

env.js

@@ -1,2 +0,2 @@

const env = 'production'
const env = 'development'
const port = 8080

@@ -12,2 +12,2 @@

qrCodeRedirect: `${host}/crypttp`,
}
}

@@ -220,52 +220,62 @@ const axios = require('axios')

}) {
try {
this.cleanDeeplinkParams()
this.tx_params.type = (typeof type != "undefined") ? type.toString().replace("#/", "") : ""
this.tx_params.merchant_id = (typeof merchant_id != "undefined") ? merchant_id.toString().replace("#/", "") : ""
this.tx_params.to = (typeof to != "undefined") ? to : {}
this.tx_params.country_currency = (typeof country_currency != "undefined") ? country_currency.toString().replace("#/", "") : ""
this.tx_params.currency = (typeof currency != "undefined") ? currency.toString().replace("#/", "") : ""
this.tx_params.amount = (typeof amount != "undefined") ? Number(amount) : 0
this.tx_params.payload = (typeof payload != "undefined") ? payload.toString().replace("#/", "") : ""
this.tx_params.memo = (typeof memo != "undefined") ? memo.toString().replace("#/", "") : ""
this.tx_params.onsuccess = (typeof onsuccess != "undefined") ? onsuccess.toString().replace("#/", "") : ""
this.tx_params.onerror = (typeof onerror != "undefined") ? onerror.toString().replace("#/", "") : ""
await this.updateRates()
this.chains.map(el => {
this.amount[el] = (this.tx_params.amount / this.rates[this.nativeCurrency[el]]).toString().slice(0,8)
})
switch (this.tx_params.type) {
case "0" :
await this.navigation()
break
case "1" :
await this.invoice()
break
case "2" :
await this.transferToSpecifiedAddress()
break
return new Promise(async (resolve, reject) => {
try {
this.cleanDeeplinkParams()
default:
throw "Unknown transaction type"
this.tx_params.type = (typeof type != "undefined") ? type.toString().replace("#/", "") : ""
this.tx_params.merchant_id = (typeof merchant_id != "undefined") ? merchant_id.toString().replace("#/", "") : ""
this.tx_params.to = (typeof to != "undefined") ? to : {}
this.tx_params.country_currency = (typeof country_currency != "undefined") ? country_currency.toString().replace("#/", "") : ""
this.tx_params.currency = (typeof currency != "undefined") ? currency.toString().replace("#/", "") : ""
this.tx_params.amount = (typeof amount != "undefined") ? Number(amount) : 0
this.tx_params.payload = (typeof payload != "undefined") ? payload.toString().replace("#/", "") : ""
this.tx_params.memo = (typeof memo != "undefined") ? memo.toString().replace("#/", "") : ""
this.tx_params.onsuccess = (typeof onsuccess != "undefined") ? onsuccess.toString().replace("#/", "") : ""
this.tx_params.onerror = (typeof onerror != "undefined") ? onerror.toString().replace("#/", "") : ""
await this.updateRates()
this.chains.map(el => {
this.amount[el] = (this.tx_params.amount / this.rates[this.nativeCurrency[el]]).toString().slice(0,8)
})
switch (this.tx_params.type) {
case "0" :
await this.navigation()
break
case "1" :
await this.invoice()
break
case "2" :
await this.transferToSpecifiedAddress()
break
default:
throw "Unknown transaction type"
}
this.data_deep_links = await axios({
method: "get",
url: `${env.getLink}${JSON.stringify({
id: this.tx_params.merchant_id,
params: this.deeplink_params
})}`
})
resolve(this.defineDeviceAndNav())
}
this.data_deep_links = await axios({
method: "get",
url: `${env.getLink}${JSON.stringify(this.deeplink_params)}`
})
this.defineDeviceAndNav()
catch (e) {
console.log(e)
this.alertOrLog('Oops, seems like there was an error. Please try again later.')
}
})
}
}
catch (e) {
console.log(e)
window.alert('Oops, seems like there was an error. Please try again later.')
}
alertOrLog (msg) {
if (typeof window != 'undefined')
window.alert(msg)
else
console.log('[Crypttp-nodejs] ' + msg)
}

@@ -279,66 +289,96 @@

defineDeviceAndNav () {
let focusMissedByUs = false
const nav = {
default: () => {
focusMissedByUs = true
window.location = this.data_deep_links.data.link
},
share: () => {
focusMissedByUs = true
navigator.share({
title: 'Pay with Crypttp',
text: btoa(JSON.stringify({
id: this.tx_params.merchant_id,
params: this.deeplink_params
}))
})
}
}
window.onfocus = function () {
if (focusMissedByUs) {
window.onfocus = function () {}
focusMissedByUs = false
if (window.confirm(`Oops, seems you do not have crypto-wallet! Would you like to get one or open on mobile?`)) {
window.location = `${env.qrCodeRedirect}?params=${JSON.stringify({
id: this.tx_params.merchant_id,
params: this.deeplink_params
})}`
}
}
}
if (this.data_deep_links.data.link.split(":")[0] == "bitcoin")
nav.default()
else {
if (!this.isMobile.any()) {
if (navigator.appVersion.indexOf("Mac") != -1)
return new Promise(async (resolve, reject) => {
let focusMissedByUs = false
const nav = {
default: () => {
focusMissedByUs = true
window.location = this.data_deep_links.data.link
},
share: () => {
focusMissedByUs = true
navigator.share({
title: 'Pay with Crypttp',
text: btoa(JSON.stringify({
id: this.tx_params.merchant_id,
params: this.deeplink_params
}))
})
},
nodeReturn: async () => {
try {
nav.share()
const response = await axios({
url: `${env.api}/link/create_nav`,
method: "post",
data: {
deeplink: this.data_deep_links.data.link,
id: this.tx_params.merchant_id,
default_params: this.deeplink_params
},
headers: {
"Content-Type": "application/json"
},
})
return `${env.api}/link/nav?id=${response.data.id}`
}
catch (e) {
nav.default()
this.alertOrLog('Error saving navigation details')
}
}
}
else
/**
* start listening on leaving page and then back if user denied
*/
if (typeof window != 'undefined') {
window.onfocus = function () {
if (focusMissedByUs) {
window.onfocus = function () {}
focusMissedByUs = false
if (window.confirm(`Oops, seems you do not have crypto-wallet! Would you like to get one or open on mobile?`)) {
window.location = `${env.qrCodeRedirect}?params=${JSON.stringify({
id: this.tx_params.merchant_id,
params: this.deeplink_params
})}`
}
}
}
if (this.data_deep_links.data.link.split(":")[0] == "bitcoin")
nav.default()
else {
if (!this.isMobile.any()) {
if (navigator.appVersion.indexOf("Mac") != -1)
try {
nav.share()
}
catch (e) {
nav.default()
}
else
nav.default()
}
else {
if (this.isMobile.Android())
nav.default()
else if (this.isMobile.iOS())
try {
nav.share()
}
catch (e) {
nav.default()
}
}
}
}
else {
if (this.isMobile.Android())
nav.default()
else if (this.isMobile.iOS())
try {
nav.share()
}
catch (e) {
nav.default()
}
resolve(nav.nodeReturn())
}
}
})
}

@@ -437,3 +477,3 @@

if (typeof this.tx_params.to == "undefined") {
window.alert('Oops, seems like receival wallets not specified.')
this.alertOrLog('Oops, seems like receival wallets not specified.')
resolve(true)

@@ -456,6 +496,6 @@ }

else
window.alert(`Oops, seems like you specified currency, but did not specify a wallet address where to accept it`)
this.alertOrLog(`Oops, seems like you specified currency, but did not specify a wallet address where to accept it`)
}
else
window.alert(`Sorry but '${this.tx_params.currency}' payments is currently not supported`)
this.alertOrLog(`Sorry but '${this.tx_params.currency}' payments is currently not supported`)
}

@@ -479,3 +519,3 @@ else {

else
window.alert(`Sorry but '${this.tx_params.currency}' payments is currently not supported`)
this.alertOrLog(`Sorry but '${this.tx_params.currency}' payments is currently not supported`)
})

@@ -482,0 +522,0 @@ }

{
"name": "crypttp",
"version": "0.3.2",
"version": "0.3.3",
"description": "Module to call APIs of crypttp powered by alemey",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc