Socket
Socket
Sign inDemoInstall

@galoymoney/client

Package Overview
Dependencies
Maintainers
5
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@galoymoney/client - npm Package Compare versions

Comparing version 0.1.76 to 0.1.77

66

dist/parsing-v2/index.d.ts

@@ -7,36 +7,39 @@ import bolt11 from "bolt11";

export declare const getHashFromInvoice: (invoice: string, network: Network) => string | undefined;
export declare enum PaymentType {
Lightning = "lightning",
Intraledger = "intraledger",
Onchain = "onchain",
Lnurl = "lnurl",
Unified = "unified",
NullInput = "nullinput",
Unknown = "unknown"
}
export declare const PaymentType: {
readonly Lightning: "lightning";
readonly Intraledger: "intraledger";
readonly Onchain: "onchain";
readonly Lnurl: "lnurl";
readonly NullInput: "nullInput";
readonly Unified: "unified";
readonly Unknown: "unknown";
};
export type PaymentType = typeof PaymentType[keyof typeof PaymentType];
export type UnknownPaymentDestination = {
paymentType: PaymentType.Unknown;
paymentType: typeof PaymentType.Unknown;
};
export type NullInputPaymentDestination = {
paymentType: PaymentType.NullInput;
paymentType: typeof PaymentType.NullInput;
};
export declare enum InvalidLnurlPaymentDestinationReason {
Unknown = "Unknown"
}
export declare const InvalidLnurlPaymentDestinationReason: {
Unknown: string;
};
export type InvalidLnurlPaymentDestinationReason = typeof InvalidLnurlPaymentDestinationReason[keyof typeof InvalidLnurlPaymentDestinationReason];
export type LnurlPaymentDestination = {
paymentType: PaymentType.Lnurl;
paymentType: typeof PaymentType.Lnurl;
valid: true;
lnurl: string;
} | {
paymentType: PaymentType.Lnurl;
paymentType: typeof PaymentType.Lnurl;
valid: false;
invalidReason: InvalidLnurlPaymentDestinationReason;
};
export declare enum InvalidLightningDestinationReason {
InvoiceExpired = "InvoiceExpired",
WrongNetwork = "WrongNetwork",
Unknown = "Unknown"
}
export declare const InvalidLightningDestinationReason: {
readonly InvoiceExpired: "InvoiceExpired";
readonly WrongNetwork: "WrongNetwork";
readonly Unknown: "Unknown";
};
export type InvalidLightningDestinationReason = typeof InvalidLightningDestinationReason[keyof typeof InvalidLightningDestinationReason];
export type LightningPaymentDestination = {
paymentType: PaymentType.Lightning;
paymentType: typeof PaymentType.Lightning;
valid: true;

@@ -47,13 +50,14 @@ paymentRequest: string;

} | {
paymentType: PaymentType.Lightning;
paymentType: typeof PaymentType.Lightning;
valid: false;
invalidReason: InvalidLightningDestinationReason;
};
export declare enum InvalidOnchainDestinationReason {
WrongNetwork = "WrongNetwork",
Unknown = "Unknown",
InvalidAmount = "InvalidAmount"
}
export declare const InvalidOnchainDestinationReason: {
readonly WrongNetwork: "WrongNetwork";
readonly Unknown: "Unknown";
readonly InvalidAmount: "InvalidAmount";
};
export type InvalidOnchainDestinationReason = typeof InvalidOnchainDestinationReason[keyof typeof InvalidOnchainDestinationReason];
export type OnchainPaymentDestination = {
paymentType: PaymentType.Onchain;
paymentType: typeof PaymentType.Onchain;
valid: true;

@@ -64,3 +68,3 @@ address: string;

} | {
paymentType: PaymentType.Onchain;
paymentType: typeof PaymentType.Onchain;
valid: false;

@@ -70,3 +74,3 @@ invalidReason: InvalidOnchainDestinationReason;

export type IntraledgerPaymentDestination = {
paymentType: PaymentType.Intraledger;
paymentType: typeof PaymentType.Intraledger;
handle: string;

@@ -73,0 +77,0 @@ };

@@ -78,28 +78,24 @@ "use strict";

exports.getHashFromInvoice = getHashFromInvoice;
var PaymentType;
(function (PaymentType) {
PaymentType["Lightning"] = "lightning";
PaymentType["Intraledger"] = "intraledger";
PaymentType["Onchain"] = "onchain";
PaymentType["Lnurl"] = "lnurl";
PaymentType["Unified"] = "unified";
PaymentType["NullInput"] = "nullinput";
PaymentType["Unknown"] = "unknown";
})(PaymentType = exports.PaymentType || (exports.PaymentType = {}));
var InvalidLnurlPaymentDestinationReason;
(function (InvalidLnurlPaymentDestinationReason) {
InvalidLnurlPaymentDestinationReason["Unknown"] = "Unknown";
})(InvalidLnurlPaymentDestinationReason = exports.InvalidLnurlPaymentDestinationReason || (exports.InvalidLnurlPaymentDestinationReason = {}));
var InvalidLightningDestinationReason;
(function (InvalidLightningDestinationReason) {
InvalidLightningDestinationReason["InvoiceExpired"] = "InvoiceExpired";
InvalidLightningDestinationReason["WrongNetwork"] = "WrongNetwork";
InvalidLightningDestinationReason["Unknown"] = "Unknown";
})(InvalidLightningDestinationReason = exports.InvalidLightningDestinationReason || (exports.InvalidLightningDestinationReason = {}));
var InvalidOnchainDestinationReason;
(function (InvalidOnchainDestinationReason) {
InvalidOnchainDestinationReason["WrongNetwork"] = "WrongNetwork";
InvalidOnchainDestinationReason["Unknown"] = "Unknown";
InvalidOnchainDestinationReason["InvalidAmount"] = "InvalidAmount";
})(InvalidOnchainDestinationReason = exports.InvalidOnchainDestinationReason || (exports.InvalidOnchainDestinationReason = {}));
exports.PaymentType = {
Lightning: "lightning",
Intraledger: "intraledger",
Onchain: "onchain",
Lnurl: "lnurl",
NullInput: "nullInput",
Unified: "unified",
Unknown: "unknown",
};
exports.InvalidLnurlPaymentDestinationReason = {
Unknown: "unknown",
};
exports.InvalidLightningDestinationReason = {
InvoiceExpired: "InvoiceExpired",
WrongNetwork: "WrongNetwork",
Unknown: "Unknown",
};
exports.InvalidOnchainDestinationReason = {
WrongNetwork: "WrongNetwork",
Unknown: "Unknown",
InvalidAmount: "InvalidAmount",
};
var lightningInvoiceHasExpired = function (payReq) {

@@ -150,13 +146,13 @@ return Boolean((payReq === null || payReq === void 0 ? void 0 : payReq.timeExpireDate) && payReq.timeExpireDate < Date.now() / 1000);

lnurl_pay_1.utils.parseLightningAddress(protocol === "lightning" ? destinationWithoutProtocol : rawDestination)) {
return PaymentType.Lnurl;
return exports.PaymentType.Lnurl;
}
if (destinationWithoutProtocol.match(/^ln(bc|tb).{50,}/iu)) {
return PaymentType.Lightning;
return exports.PaymentType.Lightning;
}
if (destinationWithoutProtocol && getLNParam(destinationWithoutProtocol)) {
return PaymentType.Unified;
return exports.PaymentType.Unified;
}
if (protocol === "onchain" ||
destinationWithoutProtocol.match(/^(1|3|bc1|tb1|bcrt1)/iu)) {
return PaymentType.Onchain;
return exports.PaymentType.Onchain;
}

@@ -167,9 +163,9 @@ var handle = protocol.match(/^(http|\/\/)/iu)

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

@@ -185,3 +181,3 @@ ? destinationWithoutProtocol.split("/")[destinationWithoutProtocol.split("/").length - 1]

return {
paymentType: PaymentType.Unknown,
paymentType: exports.PaymentType.Unknown,
};

@@ -203,3 +199,3 @@ };

valid: true,
paymentType: PaymentType.Lnurl,
paymentType: exports.PaymentType.Lnurl,
lnurl: "".concat(username, "@").concat(domain_1),

@@ -212,3 +208,3 @@ };

valid: true,
paymentType: PaymentType.Lnurl,
paymentType: exports.PaymentType.Lnurl,
lnurl: lnurl,

@@ -219,3 +215,3 @@ };

valid: false,
paymentType: PaymentType.Unknown,
paymentType: exports.PaymentType.Unknown,
};

@@ -226,3 +222,3 @@ };

var destination = _a.destination, network = _a.network;
var paymentType = PaymentType.Lightning;
var paymentType = exports.PaymentType.Lightning;
var destinationWithoutProtocol = getProtocolAndData(destination).destinationWithoutProtocol;

@@ -237,3 +233,3 @@ var lnProtocol = ((_b = getLNParam(destination)) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || destinationWithoutProtocol.toLowerCase();

paymentType: paymentType,
invalidReason: InvalidLightningDestinationReason.WrongNetwork,
invalidReason: exports.InvalidLightningDestinationReason.WrongNetwork,
};

@@ -249,3 +245,3 @@ }

paymentType: paymentType,
invalidReason: InvalidLightningDestinationReason.Unknown,
invalidReason: exports.InvalidLightningDestinationReason.Unknown,
};

@@ -260,3 +256,3 @@ }

paymentType: paymentType,
invalidReason: InvalidLightningDestinationReason.InvoiceExpired,
invalidReason: exports.InvalidLightningDestinationReason.InvoiceExpired,
};

@@ -276,3 +272,3 @@ }

var destinationWithoutProtocol = _a.destinationWithoutProtocol, network = _a.network;
var paymentType = PaymentType.Onchain;
var paymentType = exports.PaymentType.Onchain;
try {

@@ -299,3 +295,3 @@ var decodedData = inputDataToObject(destinationWithoutProtocol);

paymentType: paymentType,
invalidReason: InvalidOnchainDestinationReason.InvalidAmount,
invalidReason: exports.InvalidOnchainDestinationReason.InvalidAmount,
};

@@ -316,3 +312,3 @@ }

valid: false,
invalidReason: InvalidOnchainDestinationReason.Unknown,
invalidReason: exports.InvalidOnchainDestinationReason.Unknown,
paymentType: paymentType,

@@ -336,3 +332,3 @@ };

if (!destination) {
return { paymentType: PaymentType.NullInput };
return { paymentType: exports.PaymentType.NullInput };
}

@@ -346,3 +342,3 @@ var _b = getProtocolAndData(destination), protocol = _b.protocol, destinationWithoutProtocol = _b.destinationWithoutProtocol;

switch (paymentType) {
case PaymentType.Lnurl:
case exports.PaymentType.Lnurl:
return getLNURLPayResponse({

@@ -352,9 +348,9 @@ lnAddressDomains: lnAddressDomains,

});
case PaymentType.Lightning:
case exports.PaymentType.Lightning:
return getLightningPayResponse({ destination: destination, network: network });
case PaymentType.Onchain:
case exports.PaymentType.Onchain:
return getOnChainPayResponse({ destinationWithoutProtocol: destinationWithoutProtocol, network: network });
case PaymentType.Intraledger:
case exports.PaymentType.Intraledger:
return getIntraLedgerPayResponse({ protocol: protocol, destinationWithoutProtocol: destinationWithoutProtocol });
case PaymentType.Unified:
case exports.PaymentType.Unified:
return getUnifiedPayResponse({

@@ -365,7 +361,7 @@ destination: destination,

});
case PaymentType.Unknown:
return { paymentType: PaymentType.Unknown };
case exports.PaymentType.Unknown:
return { paymentType: exports.PaymentType.Unknown };
}
return { paymentType: PaymentType.Unknown };
return { paymentType: exports.PaymentType.Unknown };
};
exports.parsePaymentDestination = parsePaymentDestination;

@@ -25,5 +25,4 @@ import bolt11 from "bolt11";

network: Network;
pubKey: string;
};
export declare const parsePaymentDestination: ({ destination, network, pubKey, }: ParsePaymentDestinationArgs) => ValidPaymentResponse;
export declare const parsePaymentDestination: ({ destination, network, }: ParsePaymentDestinationArgs) => ValidPaymentResponse;
export {};

@@ -142,3 +142,3 @@ "use strict";

var _b, _c;
var destination = _a.destination, network = _a.network, pubKey = _a.pubKey;
var destination = _a.destination, network = _a.network;
var paymentType = "lightning";

@@ -170,3 +170,2 @@ var _d = getProtocolAndData(destination), protocol = _d.protocol, destinationText = _d.destinationText;

}
var sameNode = pubKey === (0, exports.getDestination)(payReq);
var amount = payReq.satoshis || payReq.millisatoshis

@@ -179,3 +178,2 @@ ? (_c = payReq.satoshis) !== null && _c !== void 0 ? _c : Number(payReq.millisatoshis) / 1000

paymentType: paymentType,
sameNode: sameNode,
amount: amount,

@@ -190,3 +188,2 @@ paymentRequest: destinationText,

paymentRequest: destinationText,
sameNode: sameNode,
amount: amount,

@@ -260,3 +257,3 @@ memo: memo,

var parsePaymentDestination = function (_a) {
var destination = _a.destination, network = _a.network, pubKey = _a.pubKey;
var destination = _a.destination, network = _a.network;
if (!destination) {

@@ -271,3 +268,3 @@ return { valid: false };

case "lightning":
return getLightningPayResponse({ destination: destination, network: network, pubKey: pubKey });
return getLightningPayResponse({ destination: destination, network: network });
case "onchain":

@@ -274,0 +271,0 @@ return getOnChainPayResponse({ destinationText: destinationText, network: network });

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

@@ -30,3 +30,3 @@ "repository": "https://github.com/galoymoney/galoy-client",

"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.0",

@@ -37,3 +37,3 @@ "bech32": "^2.0.0",

"eslint": "^8.32.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.27.4",
"jest": "^28.1.2",

@@ -40,0 +40,0 @@ "lnurl-pay": "^2.0.1",

@@ -23,3 +23,2 @@ # Galoy Client

network: "mainnet", // or signet or regtest
pubKey: "nodePubKey",
})

@@ -26,0 +25,0 @@ ```

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