Socket
Socket
Sign inDemoInstall

@galoymoney/client

Package Overview
Dependencies
139
Maintainers
5
Versions
109
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.52 to 0.1.53

80

dist/parsing-v2/index.js

@@ -91,22 +91,23 @@ "use strict";

var protocol = split[1] ? split[0].toLocaleLowerCase() : "";
var destinationText = (_a = split[1]) !== null && _a !== void 0 ? _a : split[0];
return { protocol: protocol, destinationText: destinationText };
var destinationWithoutProtocol = (_a = split[1]) !== null && _a !== void 0 ? _a : split[0];
return { protocol: protocol, destinationWithoutProtocol: destinationWithoutProtocol };
};
var getPaymentType = function (_a) {
var protocol = _a.protocol, destinationText = _a.destinationText;
var protocol = _a.protocol, destinationWithoutProtocol = _a.destinationWithoutProtocol, rawDestination = _a.rawDestination;
// As far as the client is concerned, lnurl is the same as lightning address
if (lnurl_pay_1.utils.isLnurl(destinationText) || lnurl_pay_1.utils.isLightningAddress(destinationText)) {
if (lnurl_pay_1.utils.parseLnUrl(rawDestination) || lnurl_pay_1.utils.parseLightningAddress(rawDestination)) {
return PaymentType.Lnurl;
}
if (protocol === "lightning" ||
destinationText.match(/^ln(bc|tb).{50,}/iu) ||
(destinationText && getLNParam(destinationText) !== undefined)) {
destinationWithoutProtocol.match(/^ln(bc|tb).{50,}/iu) ||
(destinationWithoutProtocol && getLNParam(destinationWithoutProtocol) !== undefined)) {
return PaymentType.Lightning;
}
if (protocol === "onchain" || destinationText.match(/^(1|3|bc1|tb1|bcrt1)/iu)) {
if (protocol === "onchain" ||
destinationWithoutProtocol.match(/^(1|3|bc1|tb1|bcrt1)/iu)) {
return PaymentType.Onchain;
}
var handle = protocol.match(/^(http|\/\/)/iu)
? destinationText.split("/")[destinationText.split("/").length - 1]
: destinationText;
? destinationWithoutProtocol.split("/")[destinationWithoutProtocol.split("/").length - 1]
: destinationWithoutProtocol;
if (handle === null || handle === void 0 ? void 0 : handle.match(/(?!^(1|3|bc1|lnbc1))^[0-9a-z_]{3,50}$/iu)) {

@@ -118,7 +119,7 @@ return PaymentType.Intraledger;

var getIntraLedgerPayResponse = function (_a) {
var protocol = _a.protocol, destinationText = _a.destinationText;
var protocol = _a.protocol, destinationWithoutProtocol = _a.destinationWithoutProtocol;
var paymentType = PaymentType.Intraledger;
var handle = protocol.match(/^(http|\/\/)/iu)
? destinationText.split("/")[destinationText.split("/").length - 1]
: destinationText;
? destinationWithoutProtocol.split("/")[destinationWithoutProtocol.split("/").length - 1]
: destinationWithoutProtocol;
if (handle === null || handle === void 0 ? void 0 : handle.match(/(?!^(1|3|bc1|lnbc1))^[0-9a-z_]{3,50}$/iu)) {

@@ -135,18 +136,30 @@ return {

var getLNURLPayResponse = function (_a) {
var destinationText = _a.destinationText, lnAddressDomains = _a.lnAddressDomains;
// handle internal lightning addresses
for (var _i = 0, lnAddressDomains_1 = lnAddressDomains; _i < lnAddressDomains_1.length; _i++) {
var domain = lnAddressDomains_1[_i];
if (destinationText.includes(domain)) {
var handle = destinationText.split("@")[0];
var lnAddressDomains = _a.lnAddressDomains, rawDestination = _a.rawDestination;
var lnAddress = lnurl_pay_1.utils.parseLightningAddress(rawDestination);
if (lnAddress) {
var username = lnAddress.username, domain_1 = lnAddress.domain;
if (lnAddressDomains.find(function (lnAddressDomain) { return lnAddressDomain === domain_1; })) {
return getIntraLedgerPayResponse({
protocol: "",
destinationText: handle,
destinationWithoutProtocol: username,
});
}
return {
valid: true,
paymentType: PaymentType.Lnurl,
lnurl: "".concat(username, "@").concat(domain_1),
};
}
var lnurl = lnurl_pay_1.utils.parseLnUrl(rawDestination);
if (lnurl) {
return {
valid: true,
paymentType: PaymentType.Lnurl,
lnurl: lnurl,
};
}
return {
valid: true,
paymentType: PaymentType.Lnurl,
lnurl: destinationText,
valid: false,
paymentType: PaymentType.Unknown,
};

@@ -158,4 +171,4 @@ };

var paymentType = PaymentType.Lightning;
var destinationText = getProtocolAndData(destination).destinationText;
var lnProtocol = ((_b = getLNParam(destination)) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || destinationText.toLowerCase();
var destinationWithoutProtocol = getProtocolAndData(destination).destinationWithoutProtocol;
var lnProtocol = ((_b = getLNParam(destination)) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || destinationWithoutProtocol.toLowerCase();
if ((network === "mainnet" &&

@@ -205,6 +218,6 @@ !(lnProtocol.match(/^lnbc/iu) && !lnProtocol.match(/^lnbcrt/iu))) ||

var _b;
var destinationText = _a.destinationText, network = _a.network;
var destinationWithoutProtocol = _a.destinationWithoutProtocol, network = _a.network;
var paymentType = PaymentType.Onchain;
try {
var decodedData = inputDataToObject(destinationText);
var decodedData = inputDataToObject(destinationWithoutProtocol);
// some apps encode addresses in UPPERCASE

@@ -252,13 +265,20 @@ var path = decodedData === null || decodedData === void 0 ? void 0 : decodedData.pathname;

}
var _b = getProtocolAndData(destination), protocol = _b.protocol, destinationText = _b.destinationText;
var paymentType = getPaymentType({ protocol: protocol, destinationText: destinationText });
var _b = getProtocolAndData(destination), protocol = _b.protocol, destinationWithoutProtocol = _b.destinationWithoutProtocol;
var paymentType = getPaymentType({
protocol: protocol,
destinationWithoutProtocol: destinationWithoutProtocol,
rawDestination: destination,
});
switch (paymentType) {
case PaymentType.Lnurl:
return getLNURLPayResponse({ destinationText: destinationText, lnAddressDomains: lnAddressDomains });
return getLNURLPayResponse({
lnAddressDomains: lnAddressDomains,
rawDestination: destination,
});
case PaymentType.Lightning:
return getLightningPayResponse({ destination: destination, network: network, pubKey: pubKey });
case PaymentType.Onchain:
return getOnChainPayResponse({ destinationText: destinationText, network: network });
return getOnChainPayResponse({ destinationWithoutProtocol: destinationWithoutProtocol, network: network });
case PaymentType.Intraledger:
return getIntraLedgerPayResponse({ protocol: protocol, destinationText: destinationText });
return getIntraLedgerPayResponse({ protocol: protocol, destinationWithoutProtocol: destinationWithoutProtocol });
case PaymentType.Unknown:

@@ -265,0 +285,0 @@ return { paymentType: PaymentType.Unknown };

{
"name": "@galoymoney/client",
"main": "dist/index.js",
"version": "0.1.52",
"version": "0.1.53",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "https://github.com/galoymoney/galoy-client",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc