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

@moneybutton/paymail-client

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moneybutton/paymail-client - npm Package Compare versions

Comparing version 0.31.3 to 0.32.0

96

dist/paymail-client.cjs.js

@@ -7,9 +7,10 @@ 'use strict';

var AbortController = _interopDefault(require('abort-controller'));
var moment = _interopDefault(require('moment'));
var fetch = _interopDefault(require('isomorphic-fetch'));
const Capabilities = {
const CapabilityCodes = {
pki: 'pki',
paymentDestination: 'paymentDestination',
senderValidation: '6745385c3fc0',
requestSenderValidation: '6745385c3fc0',
verifyPublicKeyOwner: 'a9f510c16bde',

@@ -150,2 +151,35 @@ publicProfile: 'f12f968c92d6',

class Http {
constructor(fetch$$1) {
this.fetch = fetch$$1;
}
async get(url) {
return this._basicRequest(url);
}
async postJson(url, body) {
return this._basicRequest(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
}
async _basicRequest(url, options = {}) {
var controller = new AbortController();
const timer = setTimeout(() => controller.abort(), 30000);
return this.fetch(url, { ...options,
credentials: 'omit',
signal: controller.signal
}).then(result => {
clearTimeout(timer);
return result;
});
}
}
class EndpointResolver {

@@ -156,3 +190,3 @@ constructor(dns = null, fetch$$1) {

}));
this.fetch = fetch$$1;
this.http = new Http(fetch$$1);
this._cache = {};

@@ -169,3 +203,3 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.pki);
await this.ensureCapabilityFor(domain, CapabilityCodes.pki);
const apiDescriptor = await this.getApiDescriptionFor(domain);

@@ -178,3 +212,3 @@ const identityUrl = apiDescriptor.capabilities.pki.replace('{alias}', alias).replace('{domain.tld}', domain);

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.paymentDestination);
await this.ensureCapabilityFor(domain, CapabilityCodes.paymentDestination);
const apiDescriptor = await this.getApiDescriptionFor(domain);

@@ -187,5 +221,5 @@ const addressUrl = apiDescriptor.capabilities.paymentDestination.replace('{alias}', alias).replace('{domain.tld}', domain);

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.verifyPublicKeyOwner);
await this.ensureCapabilityFor(domain, CapabilityCodes.verifyPublicKeyOwner);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.verifyPublicKeyOwner].replace('{alias}', alias).replace('{domain.tld}', domain).replace('{pubkey}', aPubkey);
const url = apiDescriptor.capabilities[CapabilityCodes.verifyPublicKeyOwner].replace('{alias}', alias).replace('{domain.tld}', domain).replace('{pubkey}', aPubkey);
return url;

@@ -196,5 +230,5 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.publicProfile);
await this.ensureCapabilityFor(domain, CapabilityCodes.publicProfile);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.publicProfile].replace('{alias}', alias).replace('{domain.tld}', domain);
const url = apiDescriptor.capabilities[CapabilityCodes.publicProfile].replace('{alias}', alias).replace('{domain.tld}', domain);
return url;

@@ -205,5 +239,5 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.receiveTransaction);
await this.ensureCapabilityFor(domain, CapabilityCodes.receiveTransaction);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.receiveTransaction].replace('{alias}', alias).replace('{domain.tld}', domain);
const url = apiDescriptor.capabilities[CapabilityCodes.receiveTransaction].replace('{alias}', alias).replace('{domain.tld}', domain);
return url;

@@ -233,5 +267,3 @@ }

const protocol = domain === 'localhost' || domain === 'localhost.' ? 'http' : 'https';
const wellKnown = await this.fetch(`${protocol}://${domain}:${port}/.well-known/bsvalias`, {
credentials: 'omit'
});
const wellKnown = await this.http.get(`${protocol}://${domain}:${port}/.well-known/bsvalias`);
const apiDescriptor = await wellKnown.json();

@@ -412,3 +444,3 @@ return apiDescriptor;

this.resolver = new EndpointResolver(dns, fetch2);
this.fetch = fetch2;
this.http = new Http(fetch2);
this.requestBodyFactory = new RequestBodyFactory(clock !== null ? clock : new Clock());

@@ -425,5 +457,3 @@ }

const identityUrl = await this.resolver.getIdentityUrlFor(paymail);
const response = await this.fetch(identityUrl, {
credentials: 'omit'
});
const response = await this.http.get(identityUrl);
const {

@@ -452,10 +482,3 @@ pubkey

const addressUrl = await this.resolver.getAddressUrlFor(aPaymail);
const response = await this.fetch(addressUrl, {
method: 'POST',
credentials: 'omit',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.requestBodyFactory.buildBodyToRequestAddress(senderInfo, privateKey))
});
const response = await this.http.postJson(addressUrl, this.requestBodyFactory.buildBodyToRequestAddress(senderInfo, privateKey));

@@ -482,5 +505,3 @@ if (!response.ok) {

const url = await this.resolver.getVerifyUrlFor(paymail, pubkey);
const response = await this.fetch(url, {
credentials: 'omit'
});
const response = await this.http.get(url);
const body = await response.json();

@@ -516,3 +537,3 @@ const {

if (paymail) {
if (pubkey && (await this.resolver.domainHasCapability(paymail.split('@')[1], Capabilities.verifyPublicKeyOwner))) {
if (pubkey && (await this.resolver.domainHasCapability(paymail.split('@')[1], CapabilityCodes.verifyPublicKeyOwner))) {
if (await this.verifyPubkeyOwner(pubkey, paymail)) {

@@ -524,3 +545,3 @@ senderPublicKey = this.bsv.PublicKey.fromString(pubkey);

} else {
const hasPki = await this.resolver.domainHasCapability(paymail.split('@')[1], Capabilities.pki);
const hasPki = await this.resolver.domainHasCapability(paymail.split('@')[1], CapabilityCodes.pki);

@@ -555,5 +576,3 @@ if (hasPki) {

let publicProfileUrl = await this.resolver.getPublicProfileUrlFor(paymail);
const response = await this.fetch(publicProfileUrl, {
credentials: 'omit'
});
const response = await this.http.get(publicProfileUrl);

@@ -585,9 +604,3 @@ if (!response.ok) {

let receiveTxUrl = await this.resolver.getSendTxUrlFor(targetPaymail);
const response = await this.fetch(receiveTxUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.requestBodyFactory.buildBodySendTx(transactions, metadata, reference))
});
const response = await this.http.postJson(receiveTxUrl, JSON.stringify(this.requestBodyFactory.buildBodySendTx(transactions, metadata, reference)));

@@ -610,2 +623,3 @@ if (!response.ok) {

exports.BrowserDns = BrowserDns;
exports.CapabilityCodes = CapabilityCodes;
//# sourceMappingURL=paymail-client.cjs.js.map

@@ -0,8 +1,9 @@

import AbortController from 'abort-controller';
import moment from 'moment';
import fetch from 'isomorphic-fetch';
const Capabilities = {
const CapabilityCodes = {
pki: 'pki',
paymentDestination: 'paymentDestination',
senderValidation: '6745385c3fc0',
requestSenderValidation: '6745385c3fc0',
verifyPublicKeyOwner: 'a9f510c16bde',

@@ -143,2 +144,35 @@ publicProfile: 'f12f968c92d6',

class Http {
constructor(fetch$$1) {
this.fetch = fetch$$1;
}
async get(url) {
return this._basicRequest(url);
}
async postJson(url, body) {
return this._basicRequest(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
}
async _basicRequest(url, options = {}) {
var controller = new AbortController();
const timer = setTimeout(() => controller.abort(), 30000);
return this.fetch(url, { ...options,
credentials: 'omit',
signal: controller.signal
}).then(result => {
clearTimeout(timer);
return result;
});
}
}
class EndpointResolver {

@@ -149,3 +183,3 @@ constructor(dns = null, fetch$$1) {

}));
this.fetch = fetch$$1;
this.http = new Http(fetch$$1);
this._cache = {};

@@ -162,3 +196,3 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.pki);
await this.ensureCapabilityFor(domain, CapabilityCodes.pki);
const apiDescriptor = await this.getApiDescriptionFor(domain);

@@ -171,3 +205,3 @@ const identityUrl = apiDescriptor.capabilities.pki.replace('{alias}', alias).replace('{domain.tld}', domain);

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.paymentDestination);
await this.ensureCapabilityFor(domain, CapabilityCodes.paymentDestination);
const apiDescriptor = await this.getApiDescriptionFor(domain);

@@ -180,5 +214,5 @@ const addressUrl = apiDescriptor.capabilities.paymentDestination.replace('{alias}', alias).replace('{domain.tld}', domain);

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.verifyPublicKeyOwner);
await this.ensureCapabilityFor(domain, CapabilityCodes.verifyPublicKeyOwner);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.verifyPublicKeyOwner].replace('{alias}', alias).replace('{domain.tld}', domain).replace('{pubkey}', aPubkey);
const url = apiDescriptor.capabilities[CapabilityCodes.verifyPublicKeyOwner].replace('{alias}', alias).replace('{domain.tld}', domain).replace('{pubkey}', aPubkey);
return url;

@@ -189,5 +223,5 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.publicProfile);
await this.ensureCapabilityFor(domain, CapabilityCodes.publicProfile);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.publicProfile].replace('{alias}', alias).replace('{domain.tld}', domain);
const url = apiDescriptor.capabilities[CapabilityCodes.publicProfile].replace('{alias}', alias).replace('{domain.tld}', domain);
return url;

@@ -198,5 +232,5 @@ }

const [alias, domain] = aPaymail.split('@');
await this.ensureCapabilityFor(domain, Capabilities.receiveTransaction);
await this.ensureCapabilityFor(domain, CapabilityCodes.receiveTransaction);
const apiDescriptor = await this.getApiDescriptionFor(domain);
const url = apiDescriptor.capabilities[Capabilities.receiveTransaction].replace('{alias}', alias).replace('{domain.tld}', domain);
const url = apiDescriptor.capabilities[CapabilityCodes.receiveTransaction].replace('{alias}', alias).replace('{domain.tld}', domain);
return url;

@@ -226,5 +260,3 @@ }

const protocol = domain === 'localhost' || domain === 'localhost.' ? 'http' : 'https';
const wellKnown = await this.fetch(`${protocol}://${domain}:${port}/.well-known/bsvalias`, {
credentials: 'omit'
});
const wellKnown = await this.http.get(`${protocol}://${domain}:${port}/.well-known/bsvalias`);
const apiDescriptor = await wellKnown.json();

@@ -405,3 +437,3 @@ return apiDescriptor;

this.resolver = new EndpointResolver(dns, fetch2);
this.fetch = fetch2;
this.http = new Http(fetch2);
this.requestBodyFactory = new RequestBodyFactory(clock !== null ? clock : new Clock());

@@ -418,5 +450,3 @@ }

const identityUrl = await this.resolver.getIdentityUrlFor(paymail);
const response = await this.fetch(identityUrl, {
credentials: 'omit'
});
const response = await this.http.get(identityUrl);
const {

@@ -445,10 +475,3 @@ pubkey

const addressUrl = await this.resolver.getAddressUrlFor(aPaymail);
const response = await this.fetch(addressUrl, {
method: 'POST',
credentials: 'omit',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.requestBodyFactory.buildBodyToRequestAddress(senderInfo, privateKey))
});
const response = await this.http.postJson(addressUrl, this.requestBodyFactory.buildBodyToRequestAddress(senderInfo, privateKey));

@@ -475,5 +498,3 @@ if (!response.ok) {

const url = await this.resolver.getVerifyUrlFor(paymail, pubkey);
const response = await this.fetch(url, {
credentials: 'omit'
});
const response = await this.http.get(url);
const body = await response.json();

@@ -509,3 +530,3 @@ const {

if (paymail) {
if (pubkey && (await this.resolver.domainHasCapability(paymail.split('@')[1], Capabilities.verifyPublicKeyOwner))) {
if (pubkey && (await this.resolver.domainHasCapability(paymail.split('@')[1], CapabilityCodes.verifyPublicKeyOwner))) {
if (await this.verifyPubkeyOwner(pubkey, paymail)) {

@@ -517,3 +538,3 @@ senderPublicKey = this.bsv.PublicKey.fromString(pubkey);

} else {
const hasPki = await this.resolver.domainHasCapability(paymail.split('@')[1], Capabilities.pki);
const hasPki = await this.resolver.domainHasCapability(paymail.split('@')[1], CapabilityCodes.pki);

@@ -548,5 +569,3 @@ if (hasPki) {

let publicProfileUrl = await this.resolver.getPublicProfileUrlFor(paymail);
const response = await this.fetch(publicProfileUrl, {
credentials: 'omit'
});
const response = await this.http.get(publicProfileUrl);

@@ -578,9 +597,3 @@ if (!response.ok) {

let receiveTxUrl = await this.resolver.getSendTxUrlFor(targetPaymail);
const response = await this.fetch(receiveTxUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.requestBodyFactory.buildBodySendTx(transactions, metadata, reference))
});
const response = await this.http.postJson(receiveTxUrl, JSON.stringify(this.requestBodyFactory.buildBodySendTx(transactions, metadata, reference)));

@@ -597,3 +610,3 @@ if (!response.ok) {

export { PaymailClient, VerifiableMessage, RequestBodyFactory, Clock, PaymailNotFound, BrowserDns };
export { PaymailClient, VerifiableMessage, RequestBodyFactory, Clock, PaymailNotFound, BrowserDns, CapabilityCodes };
//# sourceMappingURL=paymail-client.esm.js.map
{
"name": "@moneybutton/paymail-client",
"version": "0.31.3",
"version": "0.32.0",
"description": "Money Button isomorphic Paymail utilities.",

@@ -30,2 +30,3 @@ "main": "dist/paymail-client.cjs.js",

"@babel/runtime": "7.5.5",
"abort-controller": "3.0.0",
"bsv": "^0.30.1",

@@ -70,3 +71,3 @@ "isomorphic-fetch": "2.2.1",

},
"gitHead": "b3b43ed7627ee9a13806a6b20932f4cc7f747687"
"gitHead": "03babbb5ee0b8fdef965e6ddfb19cd393f8c2bbc"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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