diff --git a/README.md b/README.md index d81de82..f7874c1 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,12 @@ yarn add lnurl-pay ```js import { requestInvoice } from 'lnurl-pay' -const { invoice, params, successAction } = await requestInvoice({ - lnUrlOrAddress: - 'lnurl1dp68gurn8ghj7urp0yh8xarpva5kueewvaskcmme9e5k7tewwajkcmpdddhx7amw9akxuatjd3cz7atnv4erqgfuvv5', - tokens: 333, // satoshis -}) +const { invoice, params, successAction, validatePreimage } = + await requestInvoice({ + lnUrlOrAddress: + 'lnurl1dp68gurn8ghj7urp0yh8xarpva5kueewvaskcmme9e5k7tewwajkcmpdddhx7amw9akxuatjd3cz7atnv4erqgfuvv5', + tokens: 333, // satoshis + }) ``` ### Lightning Address @@ -31,10 +32,11 @@ const { invoice, params, successAction } = await requestInvoice({ ```js import { requestInvoice } from 'lnurl-pay' -const { invoice, params, successAction } = await requestInvoice({ - lnUrlOrAddress: 'user@domain.com', - tokens: 333, // satoshis -}) +const { invoice, params, successAction, validatePreimage } = + await requestInvoice({ + lnUrlOrAddress: 'user@domain.com', + tokens: 333, // satoshis + }) ``` ## Methods @@ -74,6 +76,7 @@ Request an invoice for lnurl o lightning address image: commentAllowed: // Default to 0 - not allowed } + validatePreimage: // (preimage: string) => boolean } ``` @@ -166,6 +169,7 @@ Request an invoice for lnurl o lightning address with the given service params ( image: commentAllowed: // Default to 0 - not allowed } + validatePreimage: // (preimage: string) => boolean } ``` @@ -186,6 +190,9 @@ const params = await requestInvoiceWithServiceParams({ - [isLightningAddress](#isLightningAddress) - Verify if a string is a lightning adress - [parseLightningAddress](#parseLightningAddress) - Parse an address and return username and domain - [isOnionUrl](#isOnionUrl) - Verify if a string is an onion url +- [getHashFromInvoice](#getHashFromInvoice) - Decodes an invoice(string) and get the hash +- [isValidPreimage](#isValidPreimage) - Returns true if the given preimage is valid for invoice +- [decipherAES](#decipherAES) - Decipher ciphertext with a preimage ## Test diff --git a/config/webpack.config.js b/config/webpack.config.js index afcd84a..fa9b8f9 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -26,6 +26,6 @@ module.exports = { }, resolve: { extensions: ['.ts', '.js', '.tsx', '.jsx'], - fallback: { url: false }, + fallback: { url: false, buffer: false, crypto: false, stream: false }, }, } diff --git a/package.json b/package.json index 1b7613d..1436748 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lnurl-pay", - "version": "0.1.0", + "version": "0.1.1", "description": "Client library for lnurl-pay and lightning address", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", @@ -47,12 +47,16 @@ "url": "https://github.com/dolcalmi/lnurl-pay/issues" }, "dependencies": { + "aes-js": "^3.1.2", "axios": "^0.24.0", - "bech32": "^2.0.0" + "base64-js": "^1.5.1", + "bech32": "^2.0.0", + "bolt11": "^1.3.4" }, "devDependencies": { "@commitlint/cli": "^15.0.0", "@commitlint/config-conventional": "^15.0.0", + "@types/aes-js": "^3.1.1", "@types/jest": "^27.0.1", "@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/parser": "^5.6.0", diff --git a/src/request-invoice.ts b/src/request-invoice.ts index 3de3b84..3f1765d 100644 --- a/src/request-invoice.ts +++ b/src/request-invoice.ts @@ -1,5 +1,13 @@ -import { getJson, isOnionUrl, isUrl, isValidAmount } from './utils' +import { + decipherAES, + getJson, + isOnionUrl, + isUrl, + isValidAmount, + isValidPreimage, +} from './utils' import type { + LNURLPaySuccessAction, LnUrlRequestInvoiceArgs, LnUrlRequestInvoiceResponse, LnUrlrequestInvoiceWithServiceParamsArgs, @@ -35,10 +43,19 @@ export const requestInvoiceWithServiceParams = async ({ const invoice = data && data.pr && data.pr.toString() if (!invoice) throw new Error('Invalid pay service invoice') + let successAction: LNURLPaySuccessAction | undefined = undefined + if (data.successAction) { + const decipher = (preimage: string): string | null => + decipherAES({ preimage, successAction: data.successAction }) + successAction = Object.assign({ decipher }, data.successAction) + } + return { params, invoice, - successAction: data.successAction, + successAction, + validatePreimage: (preimage: string): boolean => + isValidPreimage({ invoice, preimage }), } } diff --git a/src/types.ts b/src/types.ts index ded0952..f609d80 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,6 +9,16 @@ export type LightningAddress = { domain: string } +export type LNURLPaySuccessAction = { + tag: string + description: string | null + url: string | null + message: string | null + ciphertext: string | null + iv: string | null + decipher: (preimage: string) => string | null +} + export type FetcGetArgs = { url: string params?: Json @@ -52,5 +62,6 @@ export type LnUrlRequestInvoiceArgs = LnUrlRequestInvoiceBaseArgs & { export type LnUrlRequestInvoiceResponse = { params: LnUrlPayServiceResponse invoice: string - successAction?: Json + successAction?: LNURLPaySuccessAction + validatePreimage: (preimage: string) => boolean } diff --git a/src/utils.ts b/src/utils.ts index a349ab2..5ee35a8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,12 @@ import { URL } from 'url' import { bech32 } from 'bech32' -import type { LightningAddress, Satoshis } from './types' import axios from 'axios' +import aesjs from 'aes-js' +import Base64 from 'base64-js' +import * as bolt11 from 'bolt11' +import * as crypto from 'crypto' + +import type { LightningAddress, LNURLPaySuccessAction, Satoshis } from './types' const LNURL_REGEX = /^(?:http.*[&?]lightning=|lightning:)?(lnurl[0-9]{1,}[02-9ac-hj-np-z]+)/ @@ -155,3 +160,74 @@ export const getJson = async ({ return response.data }) } + +export const sha256 = (data: string) => + crypto.createHash('sha256').update(data, 'hex').digest('hex') + +export const getHashFromInvoice = (invoice: string): string | null => { + if (!invoice) return null + + try { + const decoded = bolt11.decode(invoice) + if (!decoded.tags) return null + + const hashTag = decoded.tags.find( + (value) => value.tagName === 'payment_hash' + ) + if (!hashTag || !hashTag.data) return null + + return hashTag.data.toString() + } catch { + return null + } +} + +export const isValidPreimage = ({ + invoice, + preimage, +}: { + invoice: string + preimage: string +}): boolean => { + if (!invoice || !preimage) return false + + const invoiceHash = getHashFromInvoice(invoice) + if (!invoiceHash) return false + + try { + const preimageHash = sha256(preimage) + return invoiceHash === preimageHash + } catch { + return false + } +} + +export const decipherAES = ({ + successAction, + preimage, +}: { + successAction: LNURLPaySuccessAction + preimage: string +}): string | null => { + if ( + successAction.tag !== 'aes' || + !successAction.iv || + !successAction.ciphertext || + !preimage + ) + return null + + const key = aesjs.utils.hex.toBytes(preimage) + const iv = Base64.toByteArray(successAction.iv) + const ciphertext = Base64.toByteArray(successAction.ciphertext) + + const cbc = new aesjs.ModeOfOperation.cbc(key, iv) + let plaintext = cbc.decrypt(ciphertext) + + // remove padding + const size = plaintext.length + const pad = plaintext[size - 1] + plaintext = plaintext.slice(0, size - pad) + + return aesjs.utils.utf8.fromBytes(plaintext) +} diff --git a/test/helper.ts b/test/helper.ts index ad157da..c60f903 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -12,10 +12,12 @@ export const validPayServiceParams = [ tag: 'payRequest', }, serviceInvoice: { - pr: 'lntb5m1psu9df3pp59ukuqcahss6uyngxq907j0v2njy56m9qsf9s3t5dknjxt2r5nraqhp545kpgr2glw2ch3tadkf9xmhd72ep7m339ry93np8z9a53fkn82lqcqzpuxqyz5vqsp5rhn6p6cfpmeqxcn8h62lngz8ezvxgh9hqqn2ka4utst4gmg4z79s9qyyssq3f9xgq7amzl6nlh3h9ctfmj2z99zplmwkh0re9ucc0dqrm0rjz0pjz32rgkw8pcqvdjrc4s3rsa57gkhwd8jgde6nyn2ee4exy7rxqcpqt6xz4', + pr: 'lntb13130n1psl9la5pp57pd5fud26tpk5a893yp4snl90mda5sns6uj8589422rw0fndz03qsp5umjxesrm440437ykfjykt2rst8wfdlegg32f0xq5k4val9zvz38sdqqcqzynxqyz5vq9qxpq9qsqrzjqwfn3p9278ttzzpe0e00uhyxhned3j5d9acqak5emwfpflp8z2cnggqd7qqqq3qqqgqqqqlgqqqqqeqqjqtz9qwfn3p9278ttzzpe0e00uhyxhned3j5d9acqak5emwfpflp8z2cngqqqq05qqqqqvsqfqvu7u2ke04028p35n2xr9k23m53ggg6rjx045k2kpvysj0q6zhq74cxnh27xa3vdkqq0dypsfeyqys5mtcn0hz3hrdqvyl3n8tndhlpgpzchyh7', routes: [], successAction: undefined, }, + preimage: + '4cad8d163234461cb4de6c5ad35e5938f190df261065ef51b9708433466d0c3b', serviceParamsExpected: { callback: 'https://pay.staging.galoy.io:443/.well-known/lnurlp/user0', commentAllowed: 0, @@ -44,10 +46,12 @@ export const validPayServiceParams = [ tag: 'payRequest', }, serviceInvoice: { - pr: 'lntb100n1psu9dd9pp5vkrhqjq60fd49wheygkrx7rw5rafvy6xs5ask5lk6g89udmalzrqhp58qsep20d72qyr7jrjv0e7pruqsjjh6qddtnysdq8lgm3rhmdg9fqcqzpuxqyz5vqsp57f2tcn3qj73st880v2ezmz6e75nv58khttawjkkrtymk623whses9qyyssqkqqk509zydy5p2f9jgr9wgzy7ky5zvqrj8spqdxdqcz6f4p8xej9ku2mq07wvx2kyddsjsgca9vepy3nfln78hmpcaq72entrl0vwggpnuuhht', + pr: 'lnbc10m1ps79mp5pp5eat0y56jcfym7eruu049280n9yssw5flmzvnp99up995zq4p2r4qdqqcqzpuxqyz5vqsp5r88jwj2er6nlj40748slw3zy3rwaydtu2x4s84yqmgq0w63fxjdq9qyyssqyc58k4lmayagad3upndzny07w777axtcfv4w9dj4q3tjvj877y99t2r7vgtxc3pw0xtk9j7mftvx72fg5m8rjnphcrkf3mnzzg8l6lcprw8apg', routes: [], successAction: undefined, }, + preimage: + 'b956cb683997640065bad032aa177e7609c6a6c6289b73c2bf6237cea32fa6c6', serviceParamsExpected: { callback: 'https://pay.staging.galoy.io:443/.well-known/lnurlp/user11', commentAllowed: 0, diff --git a/test/request-invoice.test.ts b/test/request-invoice.test.ts index e1c8de9..6b7354d 100644 --- a/test/request-invoice.test.ts +++ b/test/request-invoice.test.ts @@ -14,6 +14,7 @@ describe('requestInvoice', () => { serviceParams, serviceParamsExpected, serviceInvoice, + preimage, }) => { axios.get = jest .fn() @@ -28,16 +29,13 @@ describe('requestInvoice', () => { successAction: serviceInvoice.successAction, params: { ...serviceParamsExpected }, }) + expect(result.validatePreimage(preimage)).toBeTruthy() } ) test.each(validPayServiceParams)( '$lnUrlOrAddress throws with invalid amount', - async ({ - lnUrlOrAddress, - serviceParams, - serviceInvoice, - }) => { + async ({ lnUrlOrAddress, serviceParams, serviceInvoice }) => { axios.get = jest .fn() .mockResolvedValueOnce({ data: serviceParams }) diff --git a/test/utils/get-hash-from-invoice.test.ts b/test/utils/get-hash-from-invoice.test.ts new file mode 100644 index 0000000..1fc5cab --- /dev/null +++ b/test/utils/get-hash-from-invoice.test.ts @@ -0,0 +1,15 @@ +import { getHashFromInvoice } from '../../src/utils' +import { validInvoices, invalidInvoices } from './helper' + +describe('getHashFromInvoice', () => { + test.each(validInvoices)( + 'decodes $invoice and get a valid hash', + ({ invoice, hash }) => { + expect(getHashFromInvoice(invoice)).toBe(hash) + } + ) + + test.each(invalidInvoices)('%s return null', (invoice) => { + expect(getHashFromInvoice(invoice)).toBeFalsy() + }) +}) diff --git a/test/utils/helper.ts b/test/utils/helper.ts index 949ff85..07bf348 100644 --- a/test/utils/helper.ts +++ b/test/utils/helper.ts @@ -50,3 +50,34 @@ export const invalidLnUrls = [ `http://www.domain.com/pagina.html?lightning=abcd`, `http://www.domain.com/pagina.html?lightning=lnurl`, ] + +export const validInvoices = [ + { + invoice: + 'lnbcrt10u1pslcly8pp55ytcf99kf6t75vkfnewzgtgxav8dv8fyd0nxw3hfkfp8xtnhckgsdqqcqzpuxqyz5vqsp5zukyzq2lcflnz8es0djh2jyza087nkn8jvx0qdcqrlt4rfrcxlcq9qyyssqmvr8937qug6au92nz97p4z8tdggkhksq6yvclsfy6ts732l9kz28ctt9qhw8gwygfq8a3t73f5689lwff6ul2xfl7m77p7ks4gmzjtgqvnvqyv', + hash: 'a1178494b64e97ea32c99e5c242d06eb0ed61d246be66746e9b242732e77c591', + preimage: + 'fbc30fd92d7829ed871f29fdeef71c652e1f697e22800b88e5297bdb57bdace0', + }, + { + invoice: + 'lntb13130n1psl9la5pp57pd5fud26tpk5a893yp4snl90mda5sns6uj8589422rw0fndz03qsp5umjxesrm440437ykfjykt2rst8wfdlegg32f0xq5k4val9zvz38sdqqcqzynxqyz5vq9qxpq9qsqrzjqwfn3p9278ttzzpe0e00uhyxhned3j5d9acqak5emwfpflp8z2cnggqd7qqqq3qqqgqqqqlgqqqqqeqqjqtz9qwfn3p9278ttzzpe0e00uhyxhned3j5d9acqak5emwfpflp8z2cngqqqq05qqqqqvsqfqvu7u2ke04028p35n2xr9k23m53ggg6rjx045k2kpvysj0q6zhq74cxnh27xa3vdkqq0dypsfeyqys5mtcn0hz3hrdqvyl3n8tndhlpgpzchyh7', + hash: 'f05b44f1aad2c36a74e58903584fe57edbda4270d7247a1cb55286e7a66d13e2', + preimage: + '4cad8d163234461cb4de6c5ad35e5938f190df261065ef51b9708433466d0c3b', + }, + { + invoice: + 'lnbc10m1ps79mp5pp5eat0y56jcfym7eruu049280n9yssw5flmzvnp99up995zq4p2r4qdqqcqzpuxqyz5vqsp5r88jwj2er6nlj40748slw3zy3rwaydtu2x4s84yqmgq0w63fxjdq9qyyssqyc58k4lmayagad3upndzny07w777axtcfv4w9dj4q3tjvj877y99t2r7vgtxc3pw0xtk9j7mftvx72fg5m8rjnphcrkf3mnzzg8l6lcprw8apg', + hash: 'cf56f25352c249bf647ce3ea551df3292107513fd8993094bc094b4102a150ea', + preimage: + 'b956cb683997640065bad032aa177e7609c6a6c6289b73c2bf6237cea32fa6c6', + }, +] + +export const invalidInvoices = [ + 'lnbcrt1pslcav8pp5y8lae09uqd69fv6mccgp7lp42j6nefmzlgfpxzm7289ddvvj43jsdqqcqzpuxqr23ssp50jylhv3wzfnfk2lsgrga0v2px742pnml9tcajfwdulqppeyg5hdq9qyyssq7hmj9wkzen6nnpv9040wxgpcx6dy0zdmkj7k539ll32ecjc6s9r4cj08cj05nszcmc3zkhnu52yhdsmajzmg2ueww7m7z5790vy3cugqn2zsd', + 'lntb349820n1pslcagupp53qzw32u7s70s2uaejhtmpq76fr0lv80c28f7gtv3tw2vgv59n8wsdqqcqzpuxqyz5vqsp560xz2teaz74cltfmvpw6wmcqkrc5a6a0njy8n90w7ptfe42q2h4s9qyyssqdzu9da88zs6qdre3pqxdppls4xj2mnghv3facn2vztjvc2x6p3h9lann5hwx7a972ffna6zhzqrke7mz4cq7xt2d487g2x48pyjvlhsp9cuhy', + 'lnbc1pslca2wpp5zrwrnh2unz02e2qve8ue26dd4l862vumxx0ry0j64tjljucw9jhqdqqcqzpuxqyz5vqsp58mdlrld5wnwhg06skyk4tcwdfyx6t9qk4apc4qka5ah0usduptrq9qyyssqj0rwcgeuz46l3q0jtyazjr9j9lhgq7mgf2xydpdf6cqjenpgaxur43f35c6g9nz634q7r2ze7s5ujqxlvq84wfvxesc78y7khhdy6wspkuesj', + 'abc', +] diff --git a/test/utils/is-valid-preimage.test.ts b/test/utils/is-valid-preimage.test.ts new file mode 100644 index 0000000..b09cc0b --- /dev/null +++ b/test/utils/is-valid-preimage.test.ts @@ -0,0 +1,19 @@ +import { isValidPreimage } from '../../src/utils' +import { validInvoices, invalidInvoices } from './helper' + +describe('isValidPreimage', () => { + test.each(validInvoices)( + '$preimage is valid for $invoice', + ({ invoice, preimage }) => { + expect(isValidPreimage({ invoice, preimage })).toBeTruthy() + } + ) + + test.each(validInvoices)('%s return false', ({ invoice }) => { + expect(isValidPreimage({ invoice, preimage: 'some preimage' })).toBeFalsy() + }) + + test.each(invalidInvoices)('%s return false', (invoice) => { + expect(isValidPreimage({ invoice, preimage: 'some preimage' })).toBeFalsy() + }) +}) diff --git a/yarn.lock b/yarn.lock index b471e6d..9b4e5a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -711,6 +711,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@types/aes-js@^3.1.1": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@types/aes-js/-/aes-js-3.1.1.tgz#34b3978122310c135de4b377270d1d65676fae28" + integrity sha512-SDSGgXT3LRCH6qMWk8OHT1vLSVNuHNvCpKCx2/TYtQMbMGGgxJC9fspwSkQjqzRagrWnCrxuLL3jMNXLXHHvSw== + "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": version "7.1.17" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.17.tgz#f50ac9d20d64153b510578d84f9643f9a3afbe64" @@ -744,6 +749,13 @@ dependencies: "@babel/types" "^7.3.0" +"@types/bn.js@^4.11.3": + version "4.11.6" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" + integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg== + dependencies: + "@types/node" "*" + "@types/eslint-scope@^3.7.0": version "3.7.1" resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.1.tgz#8dc390a7b4f9dd9f1284629efce982e41612116e" @@ -1110,6 +1122,11 @@ acorn@^8.2.4, acorn@^8.4.1, acorn@^8.6.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.6.0.tgz#e3692ba0eb1a0c83eaa4f37f5fa7368dd7142895" integrity sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw== +aes-js@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.2.tgz#db9aabde85d5caabbfc0d4f2a4446960f627146a" + integrity sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ== + agent-base@6: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" @@ -1286,11 +1303,65 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base-x@^3.0.2: + version "3.0.9" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" + integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bech32@^1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + bech32@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== +bip174@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.0.1.tgz#39cf8ca99e50ce538fb762589832f4481d07c254" + integrity sha512-i3X26uKJOkDTAalYAp0Er+qGMDhrbbh2o93/xiPyAN2s25KrClSpe3VXo/7mNJoqA5qfko8rLS2l3RWZgYmjKQ== + +bitcoinjs-lib@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.1.tgz#4fa9438bb86a0449451ac58607e83d9b5a7732e6" + integrity sha512-x/7D4jDj/MMkmO6t3p2CSDXTqpwZ/jRsRiJDmaiXabrR9XRo7jwby8HRn7EyK1h24rKFFI7vI0ay4czl6bDOZQ== + dependencies: + bech32 "^2.0.0" + bip174 "^2.0.1" + bs58check "^2.1.2" + create-hash "^1.1.0" + typeforce "^1.11.3" + varuint-bitcoin "^1.1.2" + wif "^2.0.1" + +bn.js@^4.11.8, bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + +bolt11@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/bolt11/-/bolt11-1.3.4.tgz#4f2c2fa529f2dc1d60ee7c932aa47d90a0c17ed9" + integrity sha512-x4lHDv0oid13lGlZU7cl/5gx9nRwjB2vgK/uB3c50802Wh+9WjWQMwzD2PCETHylUijx2iBAqUQYbx3ZgwF06Q== + dependencies: + "@types/bn.js" "^4.11.3" + bech32 "^1.1.2" + bitcoinjs-lib "^6.0.0" + bn.js "^4.11.8" + create-hash "^1.2.0" + lodash "^4.17.11" + safe-buffer "^5.1.1" + secp256k1 "^4.0.2" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1306,6 +1377,11 @@ braces@^3.0.1: dependencies: fill-range "^7.0.1" +brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= + browser-process-hrtime@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" @@ -1329,6 +1405,22 @@ bs-logger@0.x: dependencies: fast-json-stable-stringify "2.x" +bs58@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha1-vhYedsNU9veIrkBx9j806MTwpCo= + dependencies: + base-x "^3.0.2" + +bs58check@<3.0.0, bs58check@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" + integrity sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA== + dependencies: + bs58 "^4.0.0" + create-hash "^1.1.0" + safe-buffer "^5.1.2" + bser@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -1402,6 +1494,14 @@ ci-info@^3.2.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.0.tgz#b4ed1fb6818dea4803a55c623041f9165d2066b2" integrity sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw== +cipher-base@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" + integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + cjs-module-lexer@^1.0.0: version "1.2.2" resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40" @@ -1541,6 +1641,17 @@ cosmiconfig@^7.0.0: path-type "^4.0.0" yaml "^1.10.0" +create-hash@^1.1.0, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + create-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" @@ -1679,6 +1790,19 @@ electron-to-chromium@^1.3.896: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.16.tgz#38ddecc616385e6f101359d1b978c802664157d2" integrity sha512-BQb7FgYwnu6haWLU63/CdVW+9xhmHls3RCQUFiV4lvw3wimEHTVcUk2hkuZo76QhR8nnDdfZE7evJIZqijwPdA== +elliptic@^6.5.4: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + emittery@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.8.1.tgz#bb23cc86d03b30aa75a7f734819dee2e1ba70860" @@ -2183,6 +2307,32 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hash-base@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" + integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== + dependencies: + inherits "^2.0.4" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -2285,7 +2435,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -3020,7 +3170,7 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.15, lodash@^4.17.19, lodash@^4.7.0: +lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -3061,6 +3211,15 @@ map-obj@^4.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.3.0.tgz#9304f906e93faae70880da102a9f1df0ea8bb05a" integrity sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ== +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + meow@^8.0.0: version "8.1.2" resolved "https://registry.yarnpkg.com/meow/-/meow-8.1.2.tgz#bcbe45bda0ee1729d350c03cffc8395a36c4e897" @@ -3118,6 +3277,16 @@ min-indent@^1.0.0: resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= + minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -3154,6 +3323,16 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +node-addon-api@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" + integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== + +node-gyp-build@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" + integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -3449,7 +3628,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@3, readable-stream@^3.0.0: +readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -3532,6 +3711,14 @@ rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" +ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" + integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" @@ -3539,7 +3726,7 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -safe-buffer@^5.1.0, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -3570,6 +3757,15 @@ schema-utils@^3.1.0, schema-utils@^3.1.1: ajv "^6.12.5" ajv-keywords "^3.5.2" +secp256k1@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303" + integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA== + dependencies: + elliptic "^6.5.4" + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + "semver@2 || 3 || 4 || 5": version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -3594,6 +3790,14 @@ serialize-javascript@^6.0.0: dependencies: randombytes "^2.1.0" +sha.js@^2.4.0: + version "2.4.11" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + shallow-clone@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" @@ -3994,6 +4198,11 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typeforce@^1.11.3: + version "1.18.0" + resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" + integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== + typescript@^4.4.3: version "4.5.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c" @@ -4043,6 +4252,13 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" +varuint-bitcoin@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/varuint-bitcoin/-/varuint-bitcoin-1.1.2.tgz#e76c138249d06138b480d4c5b40ef53693e24e92" + integrity sha512-4EVb+w4rx+YfVM32HQX42AbbT7/1f5zwAYhIujKXKk8NQK+JfRVl3pqT3hjNn/L+RstigmGGKVwHA/P0wgITZw== + dependencies: + safe-buffer "^5.1.1" + w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" @@ -4171,6 +4387,13 @@ which@^2.0.1: dependencies: isexe "^2.0.0" +wif@^2.0.1: + version "2.0.6" + resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" + integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= + dependencies: + bs58check "<3.0.0" + wildcard@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec"