diff --git a/package-lock.json b/package-lock.json index 7e72b135..dab9572e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@protobuf-ts/grpc-transport": "^2.5.0", "@protobuf-ts/plugin": "^2.5.0", "@protobuf-ts/runtime": "^2.5.0", + "@stablelib/xchacha20": "^1.0.1", "@types/express": "^4.17.13", "@types/node": "^17.0.31", "@types/secp256k1": "^4.0.3", @@ -39,7 +40,9 @@ "ts-proto": "^1.112.1", "typeorm": "0.3.15", "typescript": "^4.6.4", - "uuid": "^8.3.2" + "uuid": "^8.3.2", + "websocket": "^1.0.34", + "websocket-polyfill": "^0.0.3" }, "devDependencies": { "@types/chai": "^4.3.4", @@ -50,6 +53,7 @@ "@types/node": "^16.11.10", "@types/node-fetch": "^2.6.3", "@types/uuid": "^8.3.4", + "@types/websocket": "^1.0.6", "nodemon": "^2.0.20", "ts-node": "10.7.0", "typescript": "4.5.2" @@ -395,6 +399,43 @@ "resolved": "https://registry.npmjs.org/@sqltools/formatter/-/formatter-1.2.5.tgz", "integrity": "sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==" }, + "node_modules/@stablelib/binary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", + "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", + "dependencies": { + "@stablelib/int": "^1.0.1" + } + }, + "node_modules/@stablelib/chacha": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-1.0.1.tgz", + "integrity": "sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg==", + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/int": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", + "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==" + }, + "node_modules/@stablelib/wipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", + "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==" + }, + "node_modules/@stablelib/xchacha20": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/xchacha20/-/xchacha20-1.0.1.tgz", + "integrity": "sha512-1YkiZnFF4veUwBVhDnDYwo6EHeKzQK4FnLiO7ezCl/zu64uG0bCCAUROJaBkaLH+5BEsO3W7BTXTguMbSLlWSw==", + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/chacha": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -586,6 +627,15 @@ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", "dev": true }, + "node_modules/@types/websocket": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.6.tgz", + "integrity": "sha512-JXkliwz93B2cMWOI1ukElQBPN88vMg3CruvW4KVSKpflt3NyNCJImnhIuB/f97rG7kakqRJGFiwkA895Kn02Dg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -998,6 +1048,18 @@ "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", "optional": true }, + "node_modules/bufferutil": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1316,6 +1378,15 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "devOptional": true }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "node_modules/dataloader": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-1.4.0.tgz", @@ -1550,11 +1621,44 @@ "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", "optional": true }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, "node_modules/es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -1627,6 +1731,19 @@ "node": ">= 0.10.0" } }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, "node_modules/fast-glob": { "version": "3.2.12", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", @@ -2230,6 +2347,11 @@ "node": ">=0.12.0" } }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, "node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -2599,6 +2721,11 @@ "node": ">= 0.6" } }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, "node_modules/node-addon-api": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", @@ -3918,6 +4045,16 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, + "node_modules/tstl": { + "version": "2.5.13", + "resolved": "https://registry.npmjs.org/tstl/-/tstl-2.5.13.tgz", + "integrity": "sha512-h9wayHHFI5+yqt8iau0vqH96cTNhezhZ/Fk/hrIdpfkiMu3lg9nzyvMfs5bIdX51IVzZO6DudLqhkL/rVXpT6g==" + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -3938,6 +4075,14 @@ "node": ">= 0.6" } }, + "node_modules/typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dependencies": { + "is-typedarray": "^1.0.0" + } + }, "node_modules/typeorm": { "version": "0.3.15", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.15.tgz", @@ -4213,6 +4358,18 @@ "node": ">=8" } }, + "node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -4253,6 +4410,31 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "node_modules/websocket": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", + "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "dependencies": { + "bufferutil": "^4.0.1", + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "typedarray-to-buffer": "^3.1.5", + "utf-8-validate": "^5.0.2", + "yaeti": "^0.0.6" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/websocket-polyfill": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/websocket-polyfill/-/websocket-polyfill-0.0.3.tgz", + "integrity": "sha512-pF3kR8Uaoau78MpUmFfzbIRxXj9PeQrCuPepGE6JIsfsJ/o/iXr07Q2iQNzKSSblQJ0FiGWlS64N4pVSm+O3Dg==", + "dependencies": { + "tstl": "^2.0.7", + "websocket": "^1.0.28" + } + }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", @@ -4322,6 +4504,14 @@ "node": ">=10" } }, + "node_modules/yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==", + "engines": { + "node": ">=0.10.32" + } + }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -4622,6 +4812,43 @@ "resolved": "https://registry.npmjs.org/@sqltools/formatter/-/formatter-1.2.5.tgz", "integrity": "sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==" }, + "@stablelib/binary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", + "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", + "requires": { + "@stablelib/int": "^1.0.1" + } + }, + "@stablelib/chacha": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-1.0.1.tgz", + "integrity": "sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg==", + "requires": { + "@stablelib/binary": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "@stablelib/int": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", + "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==" + }, + "@stablelib/wipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", + "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==" + }, + "@stablelib/xchacha20": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/xchacha20/-/xchacha20-1.0.1.tgz", + "integrity": "sha512-1YkiZnFF4veUwBVhDnDYwo6EHeKzQK4FnLiO7ezCl/zu64uG0bCCAUROJaBkaLH+5BEsO3W7BTXTguMbSLlWSw==", + "requires": { + "@stablelib/binary": "^1.0.1", + "@stablelib/chacha": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, "@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -4809,6 +5036,15 @@ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", "dev": true }, + "@types/websocket": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.6.tgz", + "integrity": "sha512-JXkliwz93B2cMWOI1ukElQBPN88vMg3CruvW4KVSKpflt3NyNCJImnhIuB/f97rG7kakqRJGFiwkA895Kn02Dg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -5122,6 +5358,14 @@ "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", "optional": true }, + "bufferutil": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "requires": { + "node-gyp-build": "^4.3.0" + } + }, "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -5370,6 +5614,15 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "devOptional": true }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, "dataloader": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-1.4.0.tgz", @@ -5560,11 +5813,40 @@ "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", "optional": true }, + "es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, "es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -5628,6 +5910,21 @@ "vary": "~1.1.2" } }, + "ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "requires": { + "type": "^2.7.2" + }, + "dependencies": { + "type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + } + } + }, "fast-glob": { "version": "3.2.12", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", @@ -6073,6 +6370,11 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -6368,6 +6670,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, "node-addon-api": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", @@ -7357,6 +7664,16 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, + "tstl": { + "version": "2.5.13", + "resolved": "https://registry.npmjs.org/tstl/-/tstl-2.5.13.tgz", + "integrity": "sha512-h9wayHHFI5+yqt8iau0vqH96cTNhezhZ/Fk/hrIdpfkiMu3lg9nzyvMfs5bIdX51IVzZO6DudLqhkL/rVXpT6g==" + }, + "type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -7371,6 +7688,14 @@ "mime-types": "~2.1.24" } }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "requires": { + "is-typedarray": "^1.0.0" + } + }, "typeorm": { "version": "0.3.15", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.15.tgz", @@ -7514,6 +7839,14 @@ "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==" }, + "utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "requires": { + "node-gyp-build": "^4.3.0" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -7545,6 +7878,28 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "websocket": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", + "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "requires": { + "bufferutil": "^4.0.1", + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "typedarray-to-buffer": "^3.1.5", + "utf-8-validate": "^5.0.2", + "yaeti": "^0.0.6" + } + }, + "websocket-polyfill": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/websocket-polyfill/-/websocket-polyfill-0.0.3.tgz", + "integrity": "sha512-pF3kR8Uaoau78MpUmFfzbIRxXj9PeQrCuPepGE6JIsfsJ/o/iXr07Q2iQNzKSSblQJ0FiGWlS64N4pVSm+O3Dg==", + "requires": { + "tstl": "^2.0.7", + "websocket": "^1.0.28" + } + }, "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", @@ -7596,6 +7951,11 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" }, + "yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==" + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", diff --git a/package.json b/package.json index a6c17ed7..07d440a6 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@protobuf-ts/grpc-transport": "^2.5.0", "@protobuf-ts/plugin": "^2.5.0", "@protobuf-ts/runtime": "^2.5.0", + "@stablelib/xchacha20": "^1.0.1", "@types/express": "^4.17.13", "@types/node": "^17.0.31", "@types/secp256k1": "^4.0.3", @@ -54,7 +55,9 @@ "ts-proto": "^1.112.1", "typeorm": "0.3.15", "typescript": "^4.6.4", - "uuid": "^8.3.2" + "uuid": "^8.3.2", + "websocket": "^1.0.34", + "websocket-polyfill": "^0.0.3" }, "devDependencies": { "@types/chai": "^4.3.4", @@ -65,6 +68,7 @@ "@types/node": "^16.11.10", "@types/node-fetch": "^2.6.3", "@types/uuid": "^8.3.4", + "@types/websocket": "^1.0.6", "nodemon": "^2.0.20", "ts-node": "10.7.0", "typescript": "4.5.2" diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 116dd6d7..3ffb13e7 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -88,10 +88,13 @@ The nostr server will send back a message response, and inside the body there wi - __user_id__: _string_ - __Admin__: - - this auth type is __encrypted__ - expected context content - __admin_id__: _string_ +- __App__: + - expected context content + - __app_id__: _string_ + ## HTTP Methods ### These are the http methods the client implements to communicate with the API @@ -111,12 +114,109 @@ The nostr server will send back a message response, and inside the body there wi - LndGetInfo - auth type: __Admin__ - - this method is encrypted - http method: __post__ - - http route: __/api/lnd/getinfo__ + - http route: __/api/admin/lnd/getinfo__ - input: [LndGetInfoRequest](#LndGetInfoRequest) - output: [LndGetInfoResponse](#LndGetInfoResponse) +- SetMockInvoiceAsPaid + - auth type: __Guest__ + - http method: __post__ + - http route: __/api/lnd/mock/invoice/paid__ + - input: [SetMockInvoiceAsPaidRequest](#SetMockInvoiceAsPaidRequest) + - This methods has an __empty__ __response__ body + +- AddApp + - auth type: __Admin__ + - http method: __post__ + - http route: __/api/admin/app/add__ + - input: [AddAppRequest](#AddAppRequest) + - output: [AuthApp](#AuthApp) + +- AuthApp + - auth type: __Admin__ + - http method: __post__ + - http route: __/api/admin/app/auth__ + - input: [AuthAppRequest](#AuthAppRequest) + - output: [AuthApp](#AuthApp) + +- GetApp + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/get__ + - This methods has an __empty__ __request__ body + - output: [Application](#Application) + +- AddAppUser + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/user/add__ + - input: [AddAppUserRequest](#AddAppUserRequest) + - output: [AppUser](#AppUser) + +- AddAppInvoice + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/add/invoice__ + - input: [AddAppInvoiceRequest](#AddAppInvoiceRequest) + - output: [NewInvoiceResponse](#NewInvoiceResponse) + +- AddAppUserInvoice + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/user/add/invoice__ + - input: [AddAppUserInvoiceRequest](#AddAppUserInvoiceRequest) + - output: [NewInvoiceResponse](#NewInvoiceResponse) + +- GetAppUser + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/user/get__ + - input: [GetAppUserRequest](#GetAppUserRequest) + - output: [AppUser](#AppUser) + +- PayAppUserInvoice + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/invoice/pay__ + - input: [PayAppUserInvoiceRequest](#PayAppUserInvoiceRequest) + - output: [PayAppUserInvoiceResponse](#PayAppUserInvoiceResponse) + +- SendAppUserToAppUserPayment + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/user/internal/pay__ + - input: [SendAppUserToAppUserPaymentRequest](#SendAppUserToAppUserPaymentRequest) + - This methods has an __empty__ __response__ body + +- SendAppUserToAppPayment + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/internal/pay__ + - input: [SendAppUserToAppPaymentRequest](#SendAppUserToAppPaymentRequest) + - This methods has an __empty__ __response__ body + +- GetAppUserLNURLInfo + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/user/lnurl/pay/info__ + - input: [GetAppUserLNURLInfoRequest](#GetAppUserLNURLInfoRequest) + - output: [LnurlPayInfoResponse](#LnurlPayInfoResponse) + +- SetMockAppUserBalance + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/mock/user/blance/set__ + - input: [SetMockAppUserBalanceRequest](#SetMockAppUserBalanceRequest) + - This methods has an __empty__ __response__ body + +- SetMockAppBalance + - auth type: __App__ + - http method: __post__ + - http route: __/api/app/mock/blance/set__ + - input: [SetMockAppBalanceRequest](#SetMockAppBalanceRequest) + - This methods has an __empty__ __response__ body + - AddUser - auth type: __Guest__ - http method: __post__ @@ -260,56 +360,96 @@ The nostr server will send back a message response, and inside the body there wi ## Messages ### The content of requests and response from the methods -### OpenChannelResponse - - __channelId__: _string_ +### LnurlPayInfoResponse + - __tag__: _string_ + - __callback__: _string_ + - __maxSendable__: _number_ + - __minSendable__: _number_ + - __metadata__: _string_ -### UserInfo - - __userId__: _string_ - - __balance__: _number_ +### AddUserRequest + - __callbackUrl__: _string_ + - __name__: _string_ + - __secret__: _string_ ### GetUserOperationsRequest - __latestIncomingInvoice__: _number_ - __latestOutgoingInvoice__: _number_ - __latestIncomingTx__: _number_ - __latestOutgoingTx__: _number_ + - __latestIncomingUserToUserPayment__: _number_ + - __latestOutgoingUserToUserPayment__: _number_ + +### Empty + +### AddAppUserRequest + - __identifier__: _string_ + - __fail_if_exists__: _boolean_ + - __balance__: _number_ + +### SetMockAppBalanceRequest + - __amount__: _number_ + +### NewAddressRequest + - __addressType__: _[AddressType](#AddressType)_ + +### NewInvoiceRequest + - __amountSats__: _number_ + - __memo__: _string_ + +### GetUserOperationsResponse + - __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_ + - __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_ + - __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_ + - __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ + - __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_ + +### Application + - __name__: _string_ + - __id__: _string_ + - __balance__: _number_ + - __npub__: _string_ + +### AddAppInvoiceRequest + - __payer_identifier__: _string_ + - __http_callback_url__: _string_ + - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ + +### GetAppUserLNURLInfoRequest + - __user_identifier__: _string_ + - __base_url_override__: _string_ + +### AuthUserResponse + - __userId__: _string_ + - __authToken__: _string_ ### AddProductRequest - __name__: _string_ - __price_sats__: _number_ -### Product - - __id__: _string_ - - __name__: _string_ - - __price_sats__: _number_ - ### EncryptionExchangeRequest - __publicKey__: _string_ - __deviceId__: _string_ -### NewInvoiceRequest - - __amountSats__: _number_ - - __memo__: _string_ +### AppUser + - __identifier__: _string_ + - __info__: _[UserInfo](#UserInfo)_ + - __max_withdrawable__: _number_ -### PayInvoiceResponse - - __preimage__: _string_ +### DecodeInvoiceResponse + - __amount__: _number_ -### HandleLnurlPayResponse - - __pr__: _string_ - - __routes__: ARRAY of: _[Empty](#Empty)_ +### PayInvoiceRequest + - __invoice__: _string_ + - __amount__: _number_ ### AuthUserRequest - __name__: _string_ - __secret__: _string_ -### UserOperations - - __fromIndex__: _number_ - - __toIndex__: _number_ - - __operations__: ARRAY of: _[UserOperation](#UserOperation)_ - -### PayAddressRequest - - __address__: _string_ - - __amoutSats__: _number_ - - __targetConf__: _number_ +### PayAddressResponse + - __txId__: _string_ ### OpenChannelRequest - __destination__: _string_ @@ -321,33 +461,56 @@ The nostr server will send back a message response, and inside the body there wi - __lnurl__: _string_ - __k1__: _string_ -### Empty - -### NewInvoiceResponse +### SetMockInvoiceAsPaidRequest - __invoice__: _string_ + - __amount__: _number_ -### DecodeInvoiceRequest +### AddAppUserInvoiceRequest + - __receiver_identifier__: _string_ + - __payer_identifier__: _string_ + - __http_callback_url__: _string_ + - __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_ + +### PayAppUserInvoiceRequest + - __user_identifier__: _string_ - __invoice__: _string_ + - __amount__: _number_ -### AuthUserResponse +### SendAppUserToAppPaymentRequest + - __from_user_identifier__: _string_ + - __amount__: _number_ + +### PayAddressRequest + - __address__: _string_ + - __amoutSats__: _number_ + - __targetConf__: _number_ + +### UserOperation + - __paidAtUnix__: _number_ + - __type__: _[UserOperationType](#UserOperationType)_ + - __inbound__: _boolean_ + - __amount__: _number_ + +### UserInfo - __userId__: _string_ - - __authToken__: _string_ + - __balance__: _number_ -### GetUserOperationsResponse - - __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_ - - __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_ - - __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_ - - __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_ +### Product + - __id__: _string_ + - __name__: _string_ + - __price_sats__: _number_ -### LndGetInfoRequest - - __nodeId__: _number_ +### SendAppUserToAppUserPaymentRequest + - __from_user_identifier__: _string_ + - __to_user_identifier__: _string_ + - __amount__: _number_ -### LndGetInfoResponse - - __alias__: _string_ +### SetMockAppUserBalanceRequest + - __user_identifier__: _string_ + - __amount__: _number_ -### AddUserResponse - - __userId__: _string_ - - __authToken__: _string_ +### NewAddressResponse + - __address__: _string_ ### LnurlWithdrawInfoResponse - __tag__: _string_ @@ -359,42 +522,59 @@ The nostr server will send back a message response, and inside the body there wi - __balanceCheck__: _string_ - __payLink__: _string_ +### HandleLnurlPayResponse + - __pr__: _string_ + - __routes__: ARRAY of: _[Empty](#Empty)_ + +### AddUserResponse + - __userId__: _string_ + - __authToken__: _string_ + +### UserOperations + - __fromIndex__: _number_ + - __toIndex__: _number_ + - __operations__: ARRAY of: _[UserOperation](#UserOperation)_ + +### AuthAppRequest + - __name__: _string_ + - __allow_user_creation__: _boolean_ *this field is optional + +### GetAppUserRequest + - __user_identifier__: _string_ + +### NewInvoiceResponse + - __invoice__: _string_ + +### DecodeInvoiceRequest + - __invoice__: _string_ + +### OpenChannelResponse + - __channelId__: _string_ + +### AddAppRequest + - __name__: _string_ + - __allow_user_creation__: _boolean_ + +### PayAppUserInvoiceResponse + - __preimage__: _string_ + - __amount_paid__: _number_ + +### PayInvoiceResponse + - __preimage__: _string_ + - __amount_paid__: _number_ + ### GetProductBuyLinkResponse - __link__: _string_ -### AddUserRequest - - __callbackUrl__: _string_ - - __name__: _string_ - - __secret__: _string_ +### LndGetInfoRequest + - __nodeId__: _number_ -### UserOperation - - __paidAtUnix__: _number_ - - __type__: _[UserOperationType](#UserOperationType)_ - - __inbound__: _boolean_ - - __amount__: _number_ +### LndGetInfoResponse + - __alias__: _string_ -### NewAddressRequest - - __addressType__: _[AddressType](#AddressType)_ - -### NewAddressResponse - - __address__: _string_ - -### PayInvoiceRequest - - __invoice__: _string_ - - __amount__: _number_ - -### PayAddressResponse - - __txId__: _string_ - -### DecodeInvoiceResponse - - __amount__: _number_ - -### LnurlPayInfoResponse - - __tag__: _string_ - - __callback__: _string_ - - __maxSendable__: _number_ - - __minSendable__: _number_ - - __metadata__: _string_ +### AuthApp + - __app__: _[Application](#Application)_ + - __auth_token__: _string_ ## Enums ### The enumerators used in the messages @@ -408,3 +588,5 @@ The nostr server will send back a message response, and inside the body there wi - __OUTGOING_TX__ - __INCOMING_INVOICE__ - __OUTGOING_INVOICE__ + - __OUTGOING_USER_TO_USER__ + - __INCOMING_USER_TO_USER__ diff --git a/proto/autogenerated/debug.txt b/proto/autogenerated/debug.txt index 25826826..1cf9fe77 100644 --- a/proto/autogenerated/debug.txt +++ b/proto/autogenerated/debug.txt @@ -1,5 +1,5 @@ ([]*main.Method) (len=35 cap=64) { - (*main.Method)(0xc000854050)({ + (*main.Method)(0xc0002c40f0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -9,8 +9,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc0005450e0)({ - authType: (*main.supportedAuth)(0xc00084c960)({ + opts: (*main.methodOptions)(0xc000496180)({ + authType: (*main.supportedAuth)(0xc000074690)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -22,10 +22,11 @@ route: (string) (len=11) "/api/health", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008540a0)({ + (*main.Method)(0xc0002c4140)({ in: (main.MethodMessage) { name: (string) (len=25) "EncryptionExchangeRequest", hasZeroFields: (bool) false @@ -35,8 +36,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc000545260)({ - authType: (*main.supportedAuth)(0xc00084ca50)({ + opts: (*main.methodOptions)(0xc000496300)({ + authType: (*main.supportedAuth)(0xc000074750)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -48,10 +49,11 @@ route: (string) (len=24) "/api/encryption/exchange", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854140)({ + (*main.Method)(0xc0002c4500)({ in: (main.MethodMessage) { name: (string) (len=17) "LndGetInfoRequest", hasZeroFields: (bool) false @@ -61,8 +63,8 @@ name: (string) (len=18) "LndGetInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0005453e0)({ - authType: (*main.supportedAuth)(0xc00084cb10)({ + opts: (*main.methodOptions)(0xc000496480)({ + authType: (*main.supportedAuth)(0xc0000747e0)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", encrypted: (bool) false, @@ -75,10 +77,11 @@ route: (string) (len=22) "/api/admin/lnd/getinfo", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854190)({ + (*main.Method)(0xc0002c4730)({ in: (main.MethodMessage) { name: (string) (len=27) "SetMockInvoiceAsPaidRequest", hasZeroFields: (bool) false @@ -88,8 +91,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc0005455c0)({ - authType: (*main.supportedAuth)(0xc00084cbd0)({ + opts: (*main.methodOptions)(0xc000496660)({ + authType: (*main.supportedAuth)(0xc000074870)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -101,12 +104,13 @@ route: (string) (len=26) "/api/lnd/mock/invoice/paid", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854230)({ + (*main.Method)(0xc0002c48c0)({ in: (main.MethodMessage) { - name: (string) (len=14) "AuthAppRequest", + name: (string) (len=13) "AddAppRequest", hasZeroFields: (bool) false }, name: (string) (len=6) "AddApp", @@ -114,8 +118,8 @@ name: (string) (len=7) "AuthApp", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000545740)({ - authType: (*main.supportedAuth)(0xc00084cc90)({ + opts: (*main.methodOptions)(0xc0004967e0)({ + authType: (*main.supportedAuth)(0xc000074900)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", encrypted: (bool) false, @@ -128,10 +132,11 @@ route: (string) (len=18) "/api/admin/app/add", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008542d0)({ + (*main.Method)(0xc0002c4960)({ in: (main.MethodMessage) { name: (string) (len=14) "AuthAppRequest", hasZeroFields: (bool) false @@ -141,8 +146,8 @@ name: (string) (len=7) "AuthApp", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0005458c0)({ - authType: (*main.supportedAuth)(0xc00084cd50)({ + opts: (*main.methodOptions)(0xc000496960)({ + authType: (*main.supportedAuth)(0xc000074990)({ id: (string) (len=5) "admin", name: (string) (len=5) "Admin", encrypted: (bool) false, @@ -155,10 +160,11 @@ route: (string) (len=19) "/api/admin/app/auth", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854320)({ + (*main.Method)(0xc0002c49b0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -168,8 +174,8 @@ name: (string) (len=11) "Application", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000545a40)({ - authType: (*main.supportedAuth)(0xc00084ce10)({ + opts: (*main.methodOptions)(0xc000496ae0)({ + authType: (*main.supportedAuth)(0xc000074a20)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -182,10 +188,11 @@ route: (string) (len=12) "/api/app/get", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008543c0)({ + (*main.Method)(0xc0002c4a50)({ in: (main.MethodMessage) { name: (string) (len=17) "AddAppUserRequest", hasZeroFields: (bool) false @@ -195,8 +202,8 @@ name: (string) (len=7) "AppUser", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000545bc0)({ - authType: (*main.supportedAuth)(0xc00084ced0)({ + opts: (*main.methodOptions)(0xc000496c60)({ + authType: (*main.supportedAuth)(0xc000074ab0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -209,10 +216,11 @@ route: (string) (len=17) "/api/app/user/add", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854460)({ + (*main.Method)(0xc0002c4af0)({ in: (main.MethodMessage) { name: (string) (len=20) "AddAppInvoiceRequest", hasZeroFields: (bool) false @@ -222,8 +230,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000545d40)({ - authType: (*main.supportedAuth)(0xc00084cf90)({ + opts: (*main.methodOptions)(0xc000496de0)({ + authType: (*main.supportedAuth)(0xc000074b40)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -236,10 +244,11 @@ route: (string) (len=20) "/api/app/add/invoice", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008544b0)({ + (*main.Method)(0xc0002c4b40)({ in: (main.MethodMessage) { name: (string) (len=24) "AddAppUserInvoiceRequest", hasZeroFields: (bool) false @@ -249,8 +258,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000545f20)({ - authType: (*main.supportedAuth)(0xc00084d050)({ + opts: (*main.methodOptions)(0xc000496fc0)({ + authType: (*main.supportedAuth)(0xc000074bd0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -263,10 +272,11 @@ route: (string) (len=25) "/api/app/user/add/invoice", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854550)({ + (*main.Method)(0xc0002c4be0)({ in: (main.MethodMessage) { name: (string) (len=17) "GetAppUserRequest", hasZeroFields: (bool) false @@ -276,8 +286,8 @@ name: (string) (len=7) "AppUser", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085e0c0)({ - authType: (*main.supportedAuth)(0xc00084d110)({ + opts: (*main.methodOptions)(0xc000497140)({ + authType: (*main.supportedAuth)(0xc000074c60)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -290,10 +300,11 @@ route: (string) (len=17) "/api/app/user/get", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008545f0)({ + (*main.Method)(0xc0002c4c80)({ in: (main.MethodMessage) { name: (string) (len=24) "PayAppUserInvoiceRequest", hasZeroFields: (bool) false @@ -303,8 +314,8 @@ name: (string) (len=25) "PayAppUserInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085e240)({ - authType: (*main.supportedAuth)(0xc00084d1d0)({ + opts: (*main.methodOptions)(0xc0004972c0)({ + authType: (*main.supportedAuth)(0xc000074cf0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -317,10 +328,11 @@ route: (string) (len=20) "/api/app/invoice/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854640)({ + (*main.Method)(0xc0002c4cd0)({ in: (main.MethodMessage) { name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", hasZeroFields: (bool) false @@ -330,8 +342,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00085e420)({ - authType: (*main.supportedAuth)(0xc00084d290)({ + opts: (*main.methodOptions)(0xc0004974a0)({ + authType: (*main.supportedAuth)(0xc000074d80)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -344,10 +356,11 @@ route: (string) (len=26) "/api/app/user/internal/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008546e0)({ + (*main.Method)(0xc0002c4d70)({ in: (main.MethodMessage) { name: (string) (len=30) "SendAppUserToAppPaymentRequest", hasZeroFields: (bool) false @@ -357,8 +370,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00085e5a0)({ - authType: (*main.supportedAuth)(0xc00084d350)({ + opts: (*main.methodOptions)(0xc000497620)({ + authType: (*main.supportedAuth)(0xc000074e10)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -371,10 +384,11 @@ route: (string) (len=21) "/api/app/internal/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854730)({ + (*main.Method)(0xc0002c4dc0)({ in: (main.MethodMessage) { name: (string) (len=26) "GetAppUserLNURLInfoRequest", hasZeroFields: (bool) false @@ -384,8 +398,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085e720)({ - authType: (*main.supportedAuth)(0xc00084d410)({ + opts: (*main.methodOptions)(0xc0004977a0)({ + authType: (*main.supportedAuth)(0xc000074ea0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -398,10 +412,11 @@ route: (string) (len=28) "/api/app/user/lnurl/pay/info", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854780)({ + (*main.Method)(0xc0002c4e10)({ in: (main.MethodMessage) { name: (string) (len=28) "SetMockAppUserBalanceRequest", hasZeroFields: (bool) false @@ -411,8 +426,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00085e8a0)({ - authType: (*main.supportedAuth)(0xc00084d4d0)({ + opts: (*main.methodOptions)(0xc000497920)({ + authType: (*main.supportedAuth)(0xc000074f30)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -425,10 +440,11 @@ route: (string) (len=29) "/api/app/mock/user/blance/set", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008547d0)({ + (*main.Method)(0xc0002c4e60)({ in: (main.MethodMessage) { name: (string) (len=24) "SetMockAppBalanceRequest", hasZeroFields: (bool) false @@ -438,8 +454,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc00085ea80)({ - authType: (*main.supportedAuth)(0xc00084d590)({ + opts: (*main.methodOptions)(0xc000497b00)({ + authType: (*main.supportedAuth)(0xc000074fc0)({ id: (string) (len=3) "app", name: (string) (len=3) "App", encrypted: (bool) false, @@ -452,10 +468,11 @@ route: (string) (len=24) "/api/app/mock/blance/set", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854820)({ + (*main.Method)(0xc0002c4eb0)({ in: (main.MethodMessage) { name: (string) (len=14) "AddUserRequest", hasZeroFields: (bool) false @@ -465,8 +482,8 @@ name: (string) (len=15) "AddUserResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085ec00)({ - authType: (*main.supportedAuth)(0xc00084d650)({ + opts: (*main.methodOptions)(0xc000497c80)({ + authType: (*main.supportedAuth)(0xc000075050)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -478,10 +495,11 @@ route: (string) (len=13) "/api/user/add", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc000854870)({ + (*main.Method)(0xc0002c4f00)({ in: (main.MethodMessage) { name: (string) (len=15) "AuthUserRequest", hasZeroFields: (bool) false @@ -491,8 +509,8 @@ name: (string) (len=16) "AuthUserResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085ed80)({ - authType: (*main.supportedAuth)(0xc00084d710)({ + opts: (*main.methodOptions)(0xc000497e00)({ + authType: (*main.supportedAuth)(0xc0000750e0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -504,10 +522,11 @@ route: (string) (len=14) "/api/user/auth", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) false }) }), - (*main.Method)(0xc0008548c0)({ + (*main.Method)(0xc0002c4f50)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -517,8 +536,8 @@ name: (string) (len=8) "UserInfo", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085ef60)({ - authType: (*main.supportedAuth)(0xc00084d800)({ + opts: (*main.methodOptions)(0xc000084480)({ + authType: (*main.supportedAuth)(0xc0000751a0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -531,10 +550,11 @@ route: (string) (len=14) "/api/user/info", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854960)({ + (*main.Method)(0xc0002c4ff0)({ in: (main.MethodMessage) { name: (string) (len=17) "AddProductRequest", hasZeroFields: (bool) false @@ -544,8 +564,8 @@ name: (string) (len=7) "Product", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085f140)({ - authType: (*main.supportedAuth)(0xc00084d8c0)({ + opts: (*main.methodOptions)(0xc000084720)({ + authType: (*main.supportedAuth)(0xc000075230)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -558,10 +578,11 @@ route: (string) (len=21) "/api/user/product/add", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc0008549b0)({ + (*main.Method)(0xc0002c5040)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -571,8 +592,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085f5c0)({ - authType: (*main.supportedAuth)(0xc00084da10)({ + opts: (*main.methodOptions)(0xc000084ba0)({ + authType: (*main.supportedAuth)(0xc000075350)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -587,10 +608,11 @@ }, query: ([]string) (len=1 cap=1) { (string) (len=2) "id" - } + }, + nostr: (bool) true }) }), - (*main.Method)(0xc000854a00)({ + (*main.Method)(0xc0002c5090)({ in: (main.MethodMessage) { name: (string) (len=24) "GetUserOperationsRequest", hasZeroFields: (bool) false @@ -600,8 +622,8 @@ name: (string) (len=25) "GetUserOperationsResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085f7a0)({ - authType: (*main.supportedAuth)(0xc00084dad0)({ + opts: (*main.methodOptions)(0xc000084d80)({ + authType: (*main.supportedAuth)(0xc0000753e0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -614,10 +636,11 @@ route: (string) (len=20) "/api/user/operations", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854aa0)({ + (*main.Method)(0xc0002c5130)({ in: (main.MethodMessage) { name: (string) (len=17) "NewAddressRequest", hasZeroFields: (bool) false @@ -627,8 +650,8 @@ name: (string) (len=18) "NewAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085f980)({ - authType: (*main.supportedAuth)(0xc00084db90)({ + opts: (*main.methodOptions)(0xc000084fc0)({ + authType: (*main.supportedAuth)(0xc000075470)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -641,10 +664,11 @@ route: (string) (len=19) "/api/user/chain/new", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854b40)({ + (*main.Method)(0xc0002c51d0)({ in: (main.MethodMessage) { name: (string) (len=17) "PayAddressRequest", hasZeroFields: (bool) false @@ -654,8 +678,8 @@ name: (string) (len=18) "PayAddressResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085fb60)({ - authType: (*main.supportedAuth)(0xc00084dc50)({ + opts: (*main.methodOptions)(0xc000085200)({ + authType: (*main.supportedAuth)(0xc000075500)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -668,10 +692,11 @@ route: (string) (len=19) "/api/user/chain/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854be0)({ + (*main.Method)(0xc0002c5270)({ in: (main.MethodMessage) { name: (string) (len=17) "NewInvoiceRequest", hasZeroFields: (bool) false @@ -681,8 +706,8 @@ name: (string) (len=18) "NewInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085fd40)({ - authType: (*main.supportedAuth)(0xc00084dd10)({ + opts: (*main.methodOptions)(0xc0000853e0)({ + authType: (*main.supportedAuth)(0xc000075590)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -695,10 +720,11 @@ route: (string) (len=21) "/api/user/invoice/new", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854c80)({ + (*main.Method)(0xc0002c5310)({ in: (main.MethodMessage) { name: (string) (len=20) "DecodeInvoiceRequest", hasZeroFields: (bool) false @@ -708,8 +734,8 @@ name: (string) (len=21) "DecodeInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc00085ff20)({ - authType: (*main.supportedAuth)(0xc00084ddd0)({ + opts: (*main.methodOptions)(0xc00007a0c0)({ + authType: (*main.supportedAuth)(0xc000075620)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -722,10 +748,11 @@ route: (string) (len=24) "/api/user/invoice/decode", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854d20)({ + (*main.Method)(0xc0002c53b0)({ in: (main.MethodMessage) { name: (string) (len=17) "PayInvoiceRequest", hasZeroFields: (bool) false @@ -735,8 +762,8 @@ name: (string) (len=18) "PayInvoiceResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000864120)({ - authType: (*main.supportedAuth)(0xc00084de90)({ + opts: (*main.methodOptions)(0xc00007a2a0)({ + authType: (*main.supportedAuth)(0xc0000756b0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -749,10 +776,11 @@ route: (string) (len=21) "/api/user/invoice/pay", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc000854dc0)({ + (*main.Method)(0xc0002c5450)({ in: (main.MethodMessage) { name: (string) (len=18) "OpenChannelRequest", hasZeroFields: (bool) false @@ -762,8 +790,8 @@ name: (string) (len=19) "OpenChannelResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc000864300)({ - authType: (*main.supportedAuth)(0xc00084df50)({ + opts: (*main.methodOptions)(0xc00007a480)({ + authType: (*main.supportedAuth)(0xc000075740)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -776,10 +804,11 @@ route: (string) (len=22) "/api/user/open/channel", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc0002f0050)({ + (*main.Method)(0xc0002c54f0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -789,8 +818,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002ff0e0)({ - authType: (*main.supportedAuth)(0xc0004724e0)({ + opts: (*main.methodOptions)(0xc00007a660)({ + authType: (*main.supportedAuth)(0xc0000757d0)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -803,10 +832,11 @@ route: (string) (len=29) "/api/user/lnurl_withdraw/link", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }), - (*main.Method)(0xc0002f0410)({ + (*main.Method)(0xc0002c5590)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -816,8 +846,8 @@ name: (string) (len=25) "LnurlWithdrawInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002ff440)({ - authType: (*main.supportedAuth)(0xc000472630)({ + opts: (*main.methodOptions)(0xc00007a9c0)({ + authType: (*main.supportedAuth)(0xc0000758f0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -831,10 +861,11 @@ }, query: ([]string) (len=1 cap=1) { (string) (len=2) "k1" - } + }, + nostr: (bool) false }) }), - (*main.Method)(0xc0002f0690)({ + (*main.Method)(0xc0002c5630)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -844,8 +875,8 @@ name: (string) (len=5) "Empty", hasZeroFields: (bool) true }, - opts: (*main.methodOptions)(0xc0002ff7a0)({ - authType: (*main.supportedAuth)(0xc0004727b0)({ + opts: (*main.methodOptions)(0xc00007ad20)({ + authType: (*main.supportedAuth)(0xc000075a40)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -860,10 +891,11 @@ query: ([]string) (len=2 cap=2) { (string) (len=2) "k1", (string) (len=2) "pr" - } + }, + nostr: (bool) false }) }), - (*main.Method)(0xc0002f0820)({ + (*main.Method)(0xc0002c56d0)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -873,8 +905,8 @@ name: (string) (len=20) "LnurlPayInfoResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002ffb00)({ - authType: (*main.supportedAuth)(0xc000472900)({ + opts: (*main.methodOptions)(0xc00007b080)({ + authType: (*main.supportedAuth)(0xc000075b60)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -888,10 +920,11 @@ }, query: ([]string) (len=1 cap=1) { (string) (len=2) "k1" - } + }, + nostr: (bool) false }) }), - (*main.Method)(0xc0002f08c0)({ + (*main.Method)(0xc0002c5770)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -901,8 +934,8 @@ name: (string) (len=22) "HandleLnurlPayResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0002ffe60)({ - authType: (*main.supportedAuth)(0xc000472a80)({ + opts: (*main.methodOptions)(0xc00007b3e0)({ + authType: (*main.supportedAuth)(0xc000075cb0)({ id: (string) (len=5) "guest", name: (string) (len=5) "Guest", encrypted: (bool) false, @@ -917,10 +950,11 @@ query: ([]string) (len=2 cap=2) { (string) (len=2) "k1", (string) (len=6) "amount" - } + }, + nostr: (bool) false }) }), - (*main.Method)(0xc0002f0960)({ + (*main.Method)(0xc0002c5810)({ in: (main.MethodMessage) { name: (string) (len=5) "Empty", hasZeroFields: (bool) true @@ -930,8 +964,8 @@ name: (string) (len=17) "LnurlLinkResponse", hasZeroFields: (bool) false }, - opts: (*main.methodOptions)(0xc0004b20c0)({ - authType: (*main.supportedAuth)(0xc000472b40)({ + opts: (*main.methodOptions)(0xc00007b5c0)({ + authType: (*main.supportedAuth)(0xc000075d40)({ id: (string) (len=4) "user", name: (string) (len=4) "User", encrypted: (bool) false, @@ -944,13 +978,14 @@ route: (string) (len=27) "/api/user/lnurl_channel/url", params: ([]string) }, - query: ([]string) + query: ([]string) , + nostr: (bool) true }) }) } ([]*main.Enum) (len=2 cap=2) { - (*main.Enum)(0xc00084c060)({ + (*main.Enum)(0xc0001f98f0)({ name: (string) (len=11) "AddressType", values: ([]main.EnumValue) (len=3 cap=4) { (main.EnumValue) { @@ -967,7 +1002,7 @@ } } }), - (*main.Enum)(0xc00084c0c0)({ + (*main.Enum)(0xc0001f9c80)({ name: (string) (len=17) "UserOperationType", values: ([]main.EnumValue) (len=6 cap=8) { (main.EnumValue) { @@ -998,620 +1033,12 @@ }) } -(map[string]*main.Message) (len=48) { - (string) (len=21) "DecodeInvoiceResponse": (*main.Message)(0xc0005388c0)({ - fullName: (string) (len=21) "DecodeInvoiceResponse", - name: (string) (len=21) "DecodeInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549440)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=5) "Empty": (*main.Message)(0xc000538200)({ - fullName: (string) (len=5) "Empty", - name: (string) (len=5) "Empty", - fields: ([]*main.Field) - }), - (string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc000538240)({ - fullName: (string) (len=25) "EncryptionExchangeRequest", - name: (string) (len=25) "EncryptionExchangeRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000548ab0)({ - name: (string) (len=9) "publicKey", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548ae0)({ - name: (string) (len=8) "deviceId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "PayAppUserInvoiceResponse": (*main.Message)(0xc000538580)({ - fullName: (string) (len=25) "PayAppUserInvoiceResponse", - name: (string) (len=25) "PayAppUserInvoiceResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549020)({ - name: (string) (len=8) "preimage", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549050)({ - name: (string) (len=11) "amount_paid", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=28) "SetMockAppUserBalanceRequest": (*main.Message)(0xc000538680)({ - fullName: (string) (len=28) "SetMockAppUserBalanceRequest", - name: (string) (len=28) "SetMockAppUserBalanceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0005491d0)({ - name: (string) (len=15) "user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549200)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=24) "SetMockAppBalanceRequest": (*main.Message)(0xc0005386c0)({ - fullName: (string) (len=24) "SetMockAppBalanceRequest", - name: (string) (len=24) "SetMockAppBalanceRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549230)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "PayAddressRequest": (*main.Message)(0xc000538780)({ - fullName: (string) (len=17) "PayAddressRequest", - name: (string) (len=17) "PayAddressRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc0005492c0)({ - name: (string) (len=7) "address", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005492f0)({ - name: (string) (len=9) "amoutSats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549320)({ - name: (string) (len=10) "targetConf", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=20) "DecodeInvoiceRequest": (*main.Message)(0xc000538880)({ - fullName: (string) (len=20) "DecodeInvoiceRequest", - name: (string) (len=20) "DecodeInvoiceRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549410)({ - name: (string) (len=7) "invoice", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "OpenChannelRequest": (*main.Message)(0xc000538980)({ - fullName: (string) (len=18) "OpenChannelRequest", - name: (string) (len=18) "OpenChannelRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc000549530)({ - name: (string) (len=11) "destination", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549560)({ - name: (string) (len=13) "fundingAmount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549590)({ - name: (string) (len=10) "pushAmount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005495c0)({ - name: (string) (len=12) "closeAddress", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc000538b40)({ - fullName: (string) (len=22) "HandleLnurlPayResponse", - name: (string) (len=22) "HandleLnurlPayResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0005498f0)({ - name: (string) (len=2) "pr", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549920)({ - name: (string) (len=6) "routes", - kind: (string) (len=5) "Empty", - isMap: (bool) false, - isArray: (bool) true, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=24) "AddAppUserInvoiceRequest": (*main.Message)(0xc0005384c0)({ - fullName: (string) (len=24) "AddAppUserInvoiceRequest", - name: (string) (len=24) "AddAppUserInvoiceRequest", - fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc000548ea0)({ - name: (string) (len=19) "receiver_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548ed0)({ - name: (string) (len=16) "payer_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548f00)({ - name: (string) (len=17) "http_callback_url", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548f30)({ - name: (string) (len=11) "invoice_req", - kind: (string) (len=17) "NewInvoiceRequest", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "GetAppUserRequest": (*main.Message)(0xc000538500)({ - fullName: (string) (len=17) "GetAppUserRequest", - name: (string) (len=17) "GetAppUserRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000548f60)({ - name: (string) (len=15) "user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc000538800)({ - fullName: (string) (len=17) "NewInvoiceRequest", - name: (string) (len=17) "NewInvoiceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549380)({ - name: (string) (len=10) "amountSats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005493b0)({ - name: (string) (len=4) "memo", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc000538940)({ - fullName: (string) (len=18) "PayInvoiceResponse", - name: (string) (len=18) "PayInvoiceResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0005494d0)({ - name: (string) (len=8) "preimage", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549500)({ - name: (string) (len=11) "amount_paid", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc000538b00)({ - fullName: (string) (len=20) "LnurlPayInfoResponse", - name: (string) (len=20) "LnurlPayInfoResponse", - fields: ([]*main.Field) (len=5 cap=8) { - (*main.Field)(0xc000549800)({ - name: (string) (len=3) "tag", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549830)({ - name: (string) (len=8) "callback", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549860)({ - name: (string) (len=11) "maxSendable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549890)({ - name: (string) (len=11) "minSendable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005498c0)({ - name: (string) (len=8) "metadata", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=8) "UserInfo": (*main.Message)(0xc000538c80)({ - fullName: (string) (len=8) "UserInfo", - name: (string) (len=8) "UserInfo", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549b00)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549b30)({ - name: (string) (len=7) "balance", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=7) "Product": (*main.Message)(0xc000538e80)({ - fullName: (string) (len=7) "Product", - name: (string) (len=7) "Product", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000549f50)({ - name: (string) (len=2) "id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549f80)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549fb0)({ - name: (string) (len=10) "price_sats", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc000538900)({ - fullName: (string) (len=17) "PayInvoiceRequest", - name: (string) (len=17) "PayInvoiceRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549470)({ - name: (string) (len=7) "invoice", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005494a0)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc000538a80)({ - fullName: (string) (len=25) "LnurlWithdrawInfoResponse", - name: (string) (len=25) "LnurlWithdrawInfoResponse", - fields: ([]*main.Field) (len=8 cap=8) { - (*main.Field)(0xc000549680)({ - name: (string) (len=3) "tag", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005496b0)({ - name: (string) (len=8) "callback", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005496e0)({ - name: (string) (len=2) "k1", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549710)({ - name: (string) (len=18) "defaultDescription", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549740)({ - name: (string) (len=15) "minWithdrawable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549770)({ - name: (string) (len=15) "maxWithdrawable", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005497a0)({ - name: (string) (len=12) "balanceCheck", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005497d0)({ - name: (string) (len=7) "payLink", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=14) "AuthAppRequest": (*main.Message)(0xc000538340)({ - fullName: (string) (len=14) "AuthAppRequest", - name: (string) (len=14) "AuthAppRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000548bd0)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=11) "Application": (*main.Message)(0xc000538380)({ - fullName: (string) (len=11) "Application", - name: (string) (len=11) "Application", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000548c00)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548c30)({ - name: (string) (len=2) "id", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548c60)({ - name: (string) (len=7) "balance", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=7) "AuthApp": (*main.Message)(0xc0005383c0)({ - fullName: (string) (len=7) "AuthApp", - name: (string) (len=7) "AuthApp", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000548c90)({ - name: (string) (len=3) "app", - kind: (string) (len=11) "Application", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000548cc0)({ - name: (string) (len=10) "auth_token", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=7) "AppUser": (*main.Message)(0xc000538440)({ +(map[string]*main.Message) (len=49) { + (string) (len=7) "AppUser": (*main.Message)(0xc00022fd00)({ fullName: (string) (len=7) "AppUser", name: (string) (len=7) "AppUser", fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000548d80)({ + (*main.Field)(0xc00049be90)({ name: (string) (len=10) "identifier", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1620,7 +1047,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000548db0)({ + (*main.Field)(0xc00049bec0)({ name: (string) (len=4) "info", kind: (string) (len=8) "UserInfo", isMap: (bool) false, @@ -1629,7 +1056,7 @@ isMessage: (bool) true, isOptional: (bool) false }), - (*main.Field)(0xc000548de0)({ + (*main.Field)(0xc00049bef0)({ name: (string) (len=16) "max_withdrawable", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1640,29 +1067,11 @@ }) } }), - (string) (len=24) "PayAppUserInvoiceRequest": (*main.Message)(0xc000538540)({ - fullName: (string) (len=24) "PayAppUserInvoiceRequest", - name: (string) (len=24) "PayAppUserInvoiceRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000548f90)({ - name: (string) (len=15) "user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548fc0)({ - name: (string) (len=7) "invoice", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548ff0)({ + (string) (len=21) "DecodeInvoiceResponse": (*main.Message)(0xc00048a400)({ + fullName: (string) (len=21) "DecodeInvoiceResponse", + name: (string) (len=21) "DecodeInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0000932f0)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1673,12 +1082,12 @@ }) } }), - (string) (len=26) "GetAppUserLNURLInfoRequest": (*main.Message)(0xc000538640)({ - fullName: (string) (len=26) "GetAppUserLNURLInfoRequest", - name: (string) (len=26) "GetAppUserLNURLInfoRequest", + (string) (len=17) "PayInvoiceRequest": (*main.Message)(0xc00048a440)({ + fullName: (string) (len=17) "PayInvoiceRequest", + name: (string) (len=17) "PayInvoiceRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549170)({ - name: (string) (len=15) "user_identifier", + (*main.Field)(0xc000093320)({ + name: (string) (len=7) "invoice", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1686,9 +1095,9 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc0005491a0)({ - name: (string) (len=17) "base_url_override", - kind: (string) (len=6) "string", + (*main.Field)(0xc000093350)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, @@ -1697,26 +1106,11 @@ }) } }), - (string) (len=18) "NewAddressResponse": (*main.Message)(0xc000538740)({ - fullName: (string) (len=18) "NewAddressResponse", - name: (string) (len=18) "NewAddressResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549290)({ - name: (string) (len=7) "address", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=15) "AuthUserRequest": (*main.Message)(0xc000538c00)({ + (string) (len=15) "AuthUserRequest": (*main.Message)(0xc00048a740)({ fullName: (string) (len=15) "AuthUserRequest", name: (string) (len=15) "AuthUserRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549a40)({ + (*main.Field)(0xc000093e30)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1725,7 +1119,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549a70)({ + (*main.Field)(0xc000093e60)({ name: (string) (len=6) "secret", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1736,11 +1130,35 @@ }) } }), - (string) (len=17) "AddProductRequest": (*main.Message)(0xc000538e40)({ + (string) (len=16) "AuthUserResponse": (*main.Message)(0xc00048a780)({ + fullName: (string) (len=16) "AuthUserResponse", + name: (string) (len=16) "AuthUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001f8000)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8030)({ + name: (string) (len=9) "authToken", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "AddProductRequest": (*main.Message)(0xc00048a980)({ fullName: (string) (len=17) "AddProductRequest", name: (string) (len=17) "AddProductRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549ef0)({ + (*main.Field)(0xc0001f9560)({ name: (string) (len=4) "name", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1749,7 +1167,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549f20)({ + (*main.Field)(0xc0001f9650)({ name: (string) (len=10) "price_sats", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -1760,12 +1178,12 @@ }) } }), - (string) (len=27) "SetMockInvoiceAsPaidRequest": (*main.Message)(0xc0005382c0)({ - fullName: (string) (len=27) "SetMockInvoiceAsPaidRequest", - name: (string) (len=27) "SetMockInvoiceAsPaidRequest", + (string) (len=25) "EncryptionExchangeRequest": (*main.Message)(0xc00022f800)({ + fullName: (string) (len=25) "EncryptionExchangeRequest", + name: (string) (len=25) "EncryptionExchangeRequest", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000548b40)({ - name: (string) (len=7) "invoice", + (*main.Field)(0xc00049bb00)({ + name: (string) (len=9) "publicKey", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1773,38 +1191,8 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000548b70)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "NewAddressRequest": (*main.Message)(0xc000538700)({ - fullName: (string) (len=17) "NewAddressRequest", - name: (string) (len=17) "NewAddressRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549260)({ - name: (string) (len=11) "addressType", - kind: (string) (len=11) "AddressType", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) true, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc000538840)({ - fullName: (string) (len=18) "NewInvoiceResponse", - name: (string) (len=18) "NewInvoiceResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0005493e0)({ - name: (string) (len=7) "invoice", + (*main.Field)(0xc00049bb30)({ + name: (string) (len=8) "deviceId", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -1814,11 +1202,20 @@ }) } }), - (string) (len=20) "AddAppInvoiceRequest": (*main.Message)(0xc000538480)({ - fullName: (string) (len=20) "AddAppInvoiceRequest", - name: (string) (len=20) "AddAppInvoiceRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000548e10)({ + (string) (len=24) "AddAppUserInvoiceRequest": (*main.Message)(0xc00022fdc0)({ + fullName: (string) (len=24) "AddAppUserInvoiceRequest", + name: (string) (len=24) "AddAppUserInvoiceRequest", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc00049bfb0)({ + name: (string) (len=19) "receiver_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000921e0)({ name: (string) (len=16) "payer_identifier", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1827,7 +1224,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000548e40)({ + (*main.Field)(0xc000092210)({ name: (string) (len=17) "http_callback_url", kind: (string) (len=6) "string", isMap: (bool) false, @@ -1836,7 +1233,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000548e70)({ + (*main.Field)(0xc000092270)({ name: (string) (len=11) "invoice_req", kind: (string) (len=17) "NewInvoiceRequest", isMap: (bool) false, @@ -1847,162 +1244,12 @@ }) } }), - (string) (len=25) "GetUserOperationsResponse": (*main.Message)(0xc000538e00)({ - fullName: (string) (len=25) "GetUserOperationsResponse", - name: (string) (len=25) "GetUserOperationsResponse", - fields: ([]*main.Field) (len=6 cap=8) { - (*main.Field)(0xc000549dd0)({ - name: (string) (len=31) "latestOutgoingInvoiceOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000549e00)({ - name: (string) (len=31) "latestIncomingInvoiceOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000549e30)({ - name: (string) (len=26) "latestOutgoingTxOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000549e60)({ - name: (string) (len=26) "latestIncomingTxOperations", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000549e90)({ - name: (string) (len=32) "latestOutgoingUserToUserPayemnts", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }), - (*main.Field)(0xc000549ec0)({ - name: (string) (len=32) "latestIncomingUserToUserPayemnts", - kind: (string) (len=14) "UserOperations", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) true, - isOptional: (bool) false - }) - } - }), - (string) (len=24) "GetUserOperationsRequest": (*main.Message)(0xc000538d00)({ - fullName: (string) (len=24) "GetUserOperationsRequest", - name: (string) (len=24) "GetUserOperationsRequest", - fields: ([]*main.Field) (len=6 cap=8) { - (*main.Field)(0xc000549b60)({ - name: (string) (len=21) "latestIncomingInvoice", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549b90)({ - name: (string) (len=21) "latestOutgoingInvoice", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549bc0)({ - name: (string) (len=16) "latestIncomingTx", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549bf0)({ - name: (string) (len=16) "latestOutgoingTx", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549c20)({ - name: (string) (len=31) "latestIncomingUserToUserPayment", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549c50)({ - name: (string) (len=31) "latestOutgoingUserToUserPayment", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc000538280)({ - fullName: (string) (len=17) "LndGetInfoRequest", - name: (string) (len=17) "LndGetInfoRequest", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000548b10)({ - name: (string) (len=6) "nodeId", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc000538300)({ - fullName: (string) (len=18) "LndGetInfoResponse", - name: (string) (len=18) "LndGetInfoResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000548ba0)({ - name: (string) (len=5) "alias", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=30) "SendAppUserToAppPaymentRequest": (*main.Message)(0xc000538600)({ - fullName: (string) (len=30) "SendAppUserToAppPaymentRequest", - name: (string) (len=30) "SendAppUserToAppPaymentRequest", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549110)({ - name: (string) (len=20) "from_user_identifier", + (string) (len=24) "PayAppUserInvoiceRequest": (*main.Message)(0xc00022fec0)({ + fullName: (string) (len=24) "PayAppUserInvoiceRequest", + name: (string) (len=24) "PayAppUserInvoiceRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc000092300)({ + name: (string) (len=15) "user_identifier", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -2010,7 +1257,16 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549140)({ + (*main.Field)(0xc000092330)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092570)({ name: (string) (len=6) "amount", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2021,11 +1277,68 @@ }) } }), - (string) (len=18) "PayAddressResponse": (*main.Message)(0xc0005387c0)({ + (string) (len=30) "SendAppUserToAppPaymentRequest": (*main.Message)(0xc00048a140)({ + fullName: (string) (len=30) "SendAppUserToAppPaymentRequest", + name: (string) (len=30) "SendAppUserToAppPaymentRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000092e40)({ + name: (string) (len=20) "from_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092e70)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "PayAddressRequest": (*main.Message)(0xc00048a2c0)({ + fullName: (string) (len=17) "PayAddressRequest", + name: (string) (len=17) "PayAddressRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc000093170)({ + name: (string) (len=7) "address", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000931a0)({ + name: (string) (len=9) "amoutSats", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000931d0)({ + name: (string) (len=10) "targetConf", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "PayAddressResponse": (*main.Message)(0xc00048a300)({ fullName: (string) (len=18) "PayAddressResponse", name: (string) (len=18) "PayAddressResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc000549350)({ + (*main.Field)(0xc000093200)({ name: (string) (len=4) "txId", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2036,135 +1349,12 @@ }) } }), - (string) (len=14) "AddUserRequest": (*main.Message)(0xc000538b80)({ - fullName: (string) (len=14) "AddUserRequest", - name: (string) (len=14) "AddUserRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000549950)({ - name: (string) (len=11) "callbackUrl", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549980)({ - name: (string) (len=4) "name", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005499b0)({ - name: (string) (len=6) "secret", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=15) "AddUserResponse": (*main.Message)(0xc000538bc0)({ - fullName: (string) (len=15) "AddUserResponse", - name: (string) (len=15) "AddUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc0005499e0)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549a10)({ - name: (string) (len=9) "authToken", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=16) "AuthUserResponse": (*main.Message)(0xc000538c40)({ - fullName: (string) (len=16) "AuthUserResponse", - name: (string) (len=16) "AuthUserResponse", - fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549aa0)({ - name: (string) (len=6) "userId", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549ad0)({ - name: (string) (len=9) "authToken", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=13) "UserOperation": (*main.Message)(0xc000538d40)({ - fullName: (string) (len=13) "UserOperation", - name: (string) (len=13) "UserOperation", + (string) (len=18) "OpenChannelRequest": (*main.Message)(0xc00048a4c0)({ + fullName: (string) (len=18) "OpenChannelRequest", + name: (string) (len=18) "OpenChannelRequest", fields: ([]*main.Field) (len=4 cap=4) { - (*main.Field)(0xc000549c80)({ - name: (string) (len=10) "paidAtUnix", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549cb0)({ - name: (string) (len=4) "type", - kind: (string) (len=17) "UserOperationType", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) true, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549ce0)({ - name: (string) (len=7) "inbound", - kind: (string) (len=4) "bool", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000549d10)({ - name: (string) (len=6) "amount", - kind: (string) (len=5) "int64", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }) - } - }), - (string) (len=17) "AddAppUserRequest": (*main.Message)(0xc000538400)({ - fullName: (string) (len=17) "AddAppUserRequest", - name: (string) (len=17) "AddAppUserRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000548cf0)({ - name: (string) (len=10) "identifier", + (*main.Field)(0xc0000933e0)({ + name: (string) (len=11) "destination", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -2172,65 +1362,26 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000548d20)({ - name: (string) (len=14) "fail_if_exists", - kind: (string) (len=4) "bool", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc000548d50)({ - name: (string) (len=7) "balance", + (*main.Field)(0xc000093410)({ + name: (string) (len=13) "fundingAmount", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, isMessage: (bool) false, isOptional: (bool) false - }) - } - }), - (string) (len=34) "SendAppUserToAppUserPaymentRequest": (*main.Message)(0xc0005385c0)({ - fullName: (string) (len=34) "SendAppUserToAppUserPaymentRequest", - name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", - fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000549080)({ - name: (string) (len=20) "from_user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false }), - (*main.Field)(0xc0005490b0)({ - name: (string) (len=18) "to_user_identifier", - kind: (string) (len=6) "string", - isMap: (bool) false, - isArray: (bool) false, - isEnum: (bool) false, - isMessage: (bool) false, - isOptional: (bool) false - }), - (*main.Field)(0xc0005490e0)({ - name: (string) (len=6) "amount", + (*main.Field)(0xc000093440)({ + name: (string) (len=10) "pushAmount", kind: (string) (len=5) "int64", isMap: (bool) false, isArray: (bool) false, isEnum: (bool) false, isMessage: (bool) false, isOptional: (bool) false - }) - } - }), - (string) (len=19) "OpenChannelResponse": (*main.Message)(0xc0005389c0)({ - fullName: (string) (len=19) "OpenChannelResponse", - name: (string) (len=19) "OpenChannelResponse", - fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc0005495f0)({ - name: (string) (len=9) "channelId", + }), + (*main.Field)(0xc000093470)({ + name: (string) (len=12) "closeAddress", kind: (string) (len=6) "string", isMap: (bool) false, isArray: (bool) false, @@ -2240,11 +1391,11 @@ }) } }), - (string) (len=17) "LnurlLinkResponse": (*main.Message)(0xc000538a00)({ + (string) (len=17) "LnurlLinkResponse": (*main.Message)(0xc00048a540)({ fullName: (string) (len=17) "LnurlLinkResponse", name: (string) (len=17) "LnurlLinkResponse", fields: ([]*main.Field) (len=2 cap=2) { - (*main.Field)(0xc000549620)({ + (*main.Field)(0xc0000934d0)({ name: (string) (len=5) "lnurl", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2253,7 +1404,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549650)({ + (*main.Field)(0xc000093500)({ name: (string) (len=2) "k1", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2264,11 +1415,392 @@ }) } }), - (string) (len=14) "UserOperations": (*main.Message)(0xc000538d80)({ + (string) (len=27) "SetMockInvoiceAsPaidRequest": (*main.Message)(0xc00022f880)({ + fullName: (string) (len=27) "SetMockInvoiceAsPaidRequest", + name: (string) (len=27) "SetMockInvoiceAsPaidRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00049bb90)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bbc0)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=13) "UserOperation": (*main.Message)(0xc00048a880)({ + fullName: (string) (len=13) "UserOperation", + name: (string) (len=13) "UserOperation", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc0001f8840)({ + name: (string) (len=10) "paidAtUnix", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8870)({ + name: (string) (len=4) "type", + kind: (string) (len=17) "UserOperationType", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) true, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8a20)({ + name: (string) (len=7) "inbound", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8a50)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=28) "SetMockAppUserBalanceRequest": (*main.Message)(0xc00048a1c0)({ + fullName: (string) (len=28) "SetMockAppUserBalanceRequest", + name: (string) (len=28) "SetMockAppUserBalanceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000092f30)({ + name: (string) (len=15) "user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092f60)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "NewAddressResponse": (*main.Message)(0xc00048a280)({ + fullName: (string) (len=18) "NewAddressResponse", + name: (string) (len=18) "NewAddressResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000093140)({ + name: (string) (len=7) "address", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=25) "LnurlWithdrawInfoResponse": (*main.Message)(0xc00048a5c0)({ + fullName: (string) (len=25) "LnurlWithdrawInfoResponse", + name: (string) (len=25) "LnurlWithdrawInfoResponse", + fields: ([]*main.Field) (len=8 cap=8) { + (*main.Field)(0xc000093530)({ + name: (string) (len=3) "tag", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093560)({ + name: (string) (len=8) "callback", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093590)({ + name: (string) (len=2) "k1", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000935c0)({ + name: (string) (len=18) "defaultDescription", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000935f0)({ + name: (string) (len=15) "minWithdrawable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093620)({ + name: (string) (len=15) "maxWithdrawable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093650)({ + name: (string) (len=12) "balanceCheck", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093680)({ + name: (string) (len=7) "payLink", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=22) "HandleLnurlPayResponse": (*main.Message)(0xc00048a680)({ + fullName: (string) (len=22) "HandleLnurlPayResponse", + name: (string) (len=22) "HandleLnurlPayResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000093920)({ + name: (string) (len=2) "pr", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093ad0)({ + name: (string) (len=6) "routes", + kind: (string) (len=5) "Empty", + isMap: (bool) false, + isArray: (bool) true, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=8) "UserInfo": (*main.Message)(0xc00048a7c0)({ + fullName: (string) (len=8) "UserInfo", + name: (string) (len=8) "UserInfo", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc0001f8060)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8090)({ + name: (string) (len=7) "balance", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=7) "Product": (*main.Message)(0xc00048a9c0)({ + fullName: (string) (len=7) "Product", + name: (string) (len=7) "Product", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc0001f9680)({ + name: (string) (len=2) "id", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f96b0)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f96e0)({ + name: (string) (len=10) "price_sats", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=34) "SendAppUserToAppUserPaymentRequest": (*main.Message)(0xc00022ff80)({ + fullName: (string) (len=34) "SendAppUserToAppUserPaymentRequest", + name: (string) (len=34) "SendAppUserToAppUserPaymentRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc000092750)({ + name: (string) (len=20) "from_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092de0)({ + name: (string) (len=18) "to_user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092e10)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "GetAppUserRequest": (*main.Message)(0xc00022fe00)({ + fullName: (string) (len=17) "GetAppUserRequest", + name: (string) (len=17) "GetAppUserRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0000922a0)({ + name: (string) (len=15) "user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "NewInvoiceResponse": (*main.Message)(0xc00048a380)({ + fullName: (string) (len=18) "NewInvoiceResponse", + name: (string) (len=18) "NewInvoiceResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000093290)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=20) "DecodeInvoiceRequest": (*main.Message)(0xc00048a3c0)({ + fullName: (string) (len=20) "DecodeInvoiceRequest", + name: (string) (len=20) "DecodeInvoiceRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0000932c0)({ + name: (string) (len=7) "invoice", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=19) "OpenChannelResponse": (*main.Message)(0xc00048a500)({ + fullName: (string) (len=19) "OpenChannelResponse", + name: (string) (len=19) "OpenChannelResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc0000934a0)({ + name: (string) (len=9) "channelId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=15) "AddUserResponse": (*main.Message)(0xc00048a700)({ + fullName: (string) (len=15) "AddUserResponse", + name: (string) (len=15) "AddUserResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000093dd0)({ + name: (string) (len=6) "userId", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093e00)({ + name: (string) (len=9) "authToken", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=14) "UserOperations": (*main.Message)(0xc00048a8c0)({ fullName: (string) (len=14) "UserOperations", name: (string) (len=14) "UserOperations", fields: ([]*main.Field) (len=3 cap=4) { - (*main.Field)(0xc000549d40)({ + (*main.Field)(0xc0001f8a80)({ name: (string) (len=9) "fromIndex", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2277,7 +1809,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549d70)({ + (*main.Field)(0xc0001f8ab0)({ name: (string) (len=7) "toIndex", kind: (string) (len=5) "int64", isMap: (bool) false, @@ -2286,7 +1818,7 @@ isMessage: (bool) false, isOptional: (bool) false }), - (*main.Field)(0xc000549da0)({ + (*main.Field)(0xc0001f8c30)({ name: (string) (len=10) "operations", kind: (string) (len=13) "UserOperation", isMap: (bool) false, @@ -2297,11 +1829,83 @@ }) } }), - (string) (len=25) "GetProductBuyLinkResponse": (*main.Message)(0xc000538ec0)({ + (string) (len=14) "AuthAppRequest": (*main.Message)(0xc00022f9c0)({ + fullName: (string) (len=14) "AuthAppRequest", + name: (string) (len=14) "AuthAppRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00049bc80)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bcb0)({ + name: (string) (len=19) "allow_user_creation", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) true + }) + } + }), + (string) (len=25) "PayAppUserInvoiceResponse": (*main.Message)(0xc00022ff40)({ + fullName: (string) (len=25) "PayAppUserInvoiceResponse", + name: (string) (len=25) "PayAppUserInvoiceResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000092690)({ + name: (string) (len=8) "preimage", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000926c0)({ + name: (string) (len=11) "amount_paid", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "PayInvoiceResponse": (*main.Message)(0xc00048a480)({ + fullName: (string) (len=18) "PayInvoiceResponse", + name: (string) (len=18) "PayInvoiceResponse", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000093380)({ + name: (string) (len=8) "preimage", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000933b0)({ + name: (string) (len=11) "amount_paid", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=25) "GetProductBuyLinkResponse": (*main.Message)(0xc00048aa00)({ fullName: (string) (len=25) "GetProductBuyLinkResponse", name: (string) (len=25) "GetProductBuyLinkResponse", fields: ([]*main.Field) (len=1 cap=1) { - (*main.Field)(0xc00084c000)({ + (*main.Field)(0xc0001f9890)({ name: (string) (len=4) "link", kind: (string) (len=6) "string", isMap: (bool) false, @@ -2311,10 +1915,483 @@ isOptional: (bool) false }) } + }), + (string) (len=13) "AddAppRequest": (*main.Message)(0xc00022f980)({ + fullName: (string) (len=13) "AddAppRequest", + name: (string) (len=13) "AddAppRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00049bc20)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bc50)({ + name: (string) (len=19) "allow_user_creation", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=18) "LndGetInfoResponse": (*main.Message)(0xc00022f940)({ + fullName: (string) (len=18) "LndGetInfoResponse", + name: (string) (len=18) "LndGetInfoResponse", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00049bbf0)({ + name: (string) (len=5) "alias", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=7) "AuthApp": (*main.Message)(0xc00022fb80)({ + fullName: (string) (len=7) "AuthApp", + name: (string) (len=7) "AuthApp", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc00049bda0)({ + name: (string) (len=3) "app", + kind: (string) (len=11) "Application", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bdd0)({ + name: (string) (len=10) "auth_token", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "LndGetInfoRequest": (*main.Message)(0xc00022f840)({ + fullName: (string) (len=17) "LndGetInfoRequest", + name: (string) (len=17) "LndGetInfoRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc00049bb60)({ + name: (string) (len=6) "nodeId", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "AddAppUserRequest": (*main.Message)(0xc00022fcc0)({ + fullName: (string) (len=17) "AddAppUserRequest", + name: (string) (len=17) "AddAppUserRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc00049be00)({ + name: (string) (len=10) "identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049be30)({ + name: (string) (len=14) "fail_if_exists", + kind: (string) (len=4) "bool", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049be60)({ + name: (string) (len=7) "balance", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=24) "SetMockAppBalanceRequest": (*main.Message)(0xc00048a200)({ + fullName: (string) (len=24) "SetMockAppBalanceRequest", + name: (string) (len=24) "SetMockAppBalanceRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000092f90)({ + name: (string) (len=6) "amount", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "NewAddressRequest": (*main.Message)(0xc00048a240)({ + fullName: (string) (len=17) "NewAddressRequest", + name: (string) (len=17) "NewAddressRequest", + fields: ([]*main.Field) (len=1 cap=1) { + (*main.Field)(0xc000093080)({ + name: (string) (len=11) "addressType", + kind: (string) (len=11) "AddressType", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) true, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=17) "NewInvoiceRequest": (*main.Message)(0xc00048a340)({ + fullName: (string) (len=17) "NewInvoiceRequest", + name: (string) (len=17) "NewInvoiceRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000093230)({ + name: (string) (len=10) "amountSats", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093260)({ + name: (string) (len=4) "memo", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=20) "LnurlPayInfoResponse": (*main.Message)(0xc00048a640)({ + fullName: (string) (len=20) "LnurlPayInfoResponse", + name: (string) (len=20) "LnurlPayInfoResponse", + fields: ([]*main.Field) (len=5 cap=8) { + (*main.Field)(0xc000093830)({ + name: (string) (len=3) "tag", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093860)({ + name: (string) (len=8) "callback", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093890)({ + name: (string) (len=11) "maxSendable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000938c0)({ + name: (string) (len=11) "minSendable", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0000938f0)({ + name: (string) (len=8) "metadata", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=14) "AddUserRequest": (*main.Message)(0xc00048a6c0)({ + fullName: (string) (len=14) "AddUserRequest", + name: (string) (len=14) "AddUserRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc000093b00)({ + name: (string) (len=11) "callbackUrl", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093b30)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000093b60)({ + name: (string) (len=6) "secret", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=24) "GetUserOperationsRequest": (*main.Message)(0xc00048a840)({ + fullName: (string) (len=24) "GetUserOperationsRequest", + name: (string) (len=24) "GetUserOperationsRequest", + fields: ([]*main.Field) (len=6 cap=8) { + (*main.Field)(0xc0001f8630)({ + name: (string) (len=21) "latestIncomingInvoice", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8660)({ + name: (string) (len=21) "latestOutgoingInvoice", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8690)({ + name: (string) (len=16) "latestIncomingTx", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f86c0)({ + name: (string) (len=16) "latestOutgoingTx", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f87e0)({ + name: (string) (len=31) "latestIncomingUserToUserPayment", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8810)({ + name: (string) (len=31) "latestOutgoingUserToUserPayment", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=5) "Empty": (*main.Message)(0xc00022f740)({ + fullName: (string) (len=5) "Empty", + name: (string) (len=5) "Empty", + fields: ([]*main.Field) + }), + (string) (len=25) "GetUserOperationsResponse": (*main.Message)(0xc00048a940)({ + fullName: (string) (len=25) "GetUserOperationsResponse", + name: (string) (len=25) "GetUserOperationsResponse", + fields: ([]*main.Field) (len=6 cap=8) { + (*main.Field)(0xc0001f8c60)({ + name: (string) (len=31) "latestOutgoingInvoiceOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8c90)({ + name: (string) (len=31) "latestIncomingInvoiceOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f8cc0)({ + name: (string) (len=26) "latestOutgoingTxOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f94d0)({ + name: (string) (len=26) "latestIncomingTxOperations", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f9500)({ + name: (string) (len=32) "latestOutgoingUserToUserPayemnts", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }), + (*main.Field)(0xc0001f9530)({ + name: (string) (len=32) "latestIncomingUserToUserPayemnts", + kind: (string) (len=14) "UserOperations", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=20) "AddAppInvoiceRequest": (*main.Message)(0xc00022fd80)({ + fullName: (string) (len=20) "AddAppInvoiceRequest", + name: (string) (len=20) "AddAppInvoiceRequest", + fields: ([]*main.Field) (len=3 cap=4) { + (*main.Field)(0xc00049bf20)({ + name: (string) (len=16) "payer_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bf50)({ + name: (string) (len=17) "http_callback_url", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bf80)({ + name: (string) (len=11) "invoice_req", + kind: (string) (len=17) "NewInvoiceRequest", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) true, + isOptional: (bool) false + }) + } + }), + (string) (len=26) "GetAppUserLNURLInfoRequest": (*main.Message)(0xc00048a180)({ + fullName: (string) (len=26) "GetAppUserLNURLInfoRequest", + name: (string) (len=26) "GetAppUserLNURLInfoRequest", + fields: ([]*main.Field) (len=2 cap=2) { + (*main.Field)(0xc000092ed0)({ + name: (string) (len=15) "user_identifier", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc000092f00)({ + name: (string) (len=17) "base_url_override", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } + }), + (string) (len=11) "Application": (*main.Message)(0xc00022fac0)({ + fullName: (string) (len=11) "Application", + name: (string) (len=11) "Application", + fields: ([]*main.Field) (len=4 cap=4) { + (*main.Field)(0xc00049bce0)({ + name: (string) (len=4) "name", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bd10)({ + name: (string) (len=2) "id", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bd40)({ + name: (string) (len=7) "balance", + kind: (string) (len=5) "int64", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }), + (*main.Field)(0xc00049bd70)({ + name: (string) (len=4) "npub", + kind: (string) (len=6) "string", + isMap: (bool) false, + isArray: (bool) false, + isEnum: (bool) false, + isMessage: (bool) false, + isOptional: (bool) false + }) + } }) } -parsing file: structs 48 +parsing file: structs 49 parsing file: methods 2 -> [{guest Guest false map[]} {user User false map[user_id:string]} {admin Admin false map[admin_id:string]} {app App false map[app_id:string]}] diff --git a/proto/autogenerated/ts/express_server.ts b/proto/autogenerated/ts/express_server.ts index 43a5240d..a7c5120b 100644 --- a/proto/autogenerated/ts/express_server.ts +++ b/proto/autogenerated/ts/express_server.ts @@ -7,9 +7,12 @@ export type Logger = { log: (v: any) => void, error: (v: any) => void } export type ServerOptions = { allowCors?: true staticFiles?: string - allowNotImplementedMethods?: number + allowNotImplementedMethods?: true logger?: Logger throwErrors?: true + overrides?: MethodsOverride + logMethod?: true + logBody?: true GuestAuthGuard: (authorizationHeader?: string) => Promise UserAuthGuard: (authorizationHeader?: string) => Promise AdminAuthGuard: (authorizationHeader?: string) => Promise @@ -26,6 +29,8 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { } app.use(json()) app.use(urlencoded({ extended: true })) + if (opts.logMethod) app.use((req, _, next) => { console.log(req.method, req.path); if (opts.logBody) console.log(req.body); next() }) + const overrides = opts.overrides || {} as MethodsOverride if (!opts.allowNotImplementedMethods && !methods.Health) throw new Error('method: Health is not implemented') app.get('/api/health', async (req, res) => { try { @@ -34,7 +39,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.Health({ ...authContext, ...query, ...params }) - res.json({status: 'OK'}) + if (overrides.Health_Override) await overrides.Health_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.EncryptionExchange) throw new Error('method: EncryptionExchange is not implemented') @@ -48,7 +53,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.EncryptionExchange({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.EncryptionExchange_Override) await overrides.EncryptionExchange_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.LndGetInfo) throw new Error('method: LndGetInfo is not implemented') @@ -62,7 +67,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.LndGetInfo({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.LndGetInfo_Override) await overrides.LndGetInfo_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.SetMockInvoiceAsPaid) throw new Error('method: SetMockInvoiceAsPaid is not implemented') @@ -76,7 +81,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.SetMockInvoiceAsPaid({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.SetMockInvoiceAsPaid_Override) await overrides.SetMockInvoiceAsPaid_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddApp) throw new Error('method: AddApp is not implemented') @@ -85,12 +90,12 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { if (!methods.AddApp) throw new Error('method: AddApp is not implemented') const authContext = await opts.AdminAuthGuard(req.headers['authorization']) const request = req.body - const error = Types.AuthAppRequestValidate(request) + const error = Types.AddAppRequestValidate(request) if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger) const query = req.query const params = req.params const response = await methods.AddApp({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddApp_Override) await overrides.AddApp_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AuthApp) throw new Error('method: AuthApp is not implemented') @@ -104,7 +109,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AuthApp({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AuthApp_Override) await overrides.AuthApp_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetApp) throw new Error('method: GetApp is not implemented') @@ -115,7 +120,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetApp({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetApp_Override) await overrides.GetApp_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddAppUser) throw new Error('method: AddAppUser is not implemented') @@ -129,7 +134,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AddAppUser({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddAppUser_Override) await overrides.AddAppUser_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddAppInvoice) throw new Error('method: AddAppInvoice is not implemented') @@ -143,7 +148,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AddAppInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddAppInvoice_Override) await overrides.AddAppInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddAppUserInvoice) throw new Error('method: AddAppUserInvoice is not implemented') @@ -157,7 +162,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AddAppUserInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddAppUserInvoice_Override) await overrides.AddAppUserInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetAppUser) throw new Error('method: GetAppUser is not implemented') @@ -171,7 +176,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetAppUser({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.GetAppUser_Override) await overrides.GetAppUser_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.PayAppUserInvoice) throw new Error('method: PayAppUserInvoice is not implemented') @@ -185,7 +190,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.PayAppUserInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.PayAppUserInvoice_Override) await overrides.PayAppUserInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.SendAppUserToAppUserPayment) throw new Error('method: SendAppUserToAppUserPayment is not implemented') @@ -199,7 +204,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.SendAppUserToAppUserPayment({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.SendAppUserToAppUserPayment_Override) await overrides.SendAppUserToAppUserPayment_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.SendAppUserToAppPayment) throw new Error('method: SendAppUserToAppPayment is not implemented') @@ -213,7 +218,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.SendAppUserToAppPayment({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.SendAppUserToAppPayment_Override) await overrides.SendAppUserToAppPayment_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetAppUserLNURLInfo) throw new Error('method: GetAppUserLNURLInfo is not implemented') @@ -227,7 +232,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetAppUserLNURLInfo({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.GetAppUserLNURLInfo_Override) await overrides.GetAppUserLNURLInfo_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.SetMockAppUserBalance) throw new Error('method: SetMockAppUserBalance is not implemented') @@ -241,7 +246,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.SetMockAppUserBalance({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.SetMockAppUserBalance_Override) await overrides.SetMockAppUserBalance_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.SetMockAppBalance) throw new Error('method: SetMockAppBalance is not implemented') @@ -255,7 +260,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.SetMockAppBalance({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK'}) + if (overrides.SetMockAppBalance_Override) await overrides.SetMockAppBalance_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddUser) throw new Error('method: AddUser is not implemented') @@ -269,7 +274,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AddUser({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddUser_Override) await overrides.AddUser_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AuthUser) throw new Error('method: AuthUser is not implemented') @@ -283,7 +288,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AuthUser({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AuthUser_Override) await overrides.AuthUser_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented') @@ -294,7 +299,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetUserInfo({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetUserInfo_Override) await overrides.GetUserInfo_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.AddProduct) throw new Error('method: AddProduct is not implemented') @@ -308,7 +313,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.AddProduct({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.AddProduct_Override) await overrides.AddProduct_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.NewProductInvoice) throw new Error('method: NewProductInvoice is not implemented') @@ -319,7 +324,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.NewProductInvoice({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.NewProductInvoice_Override) await overrides.NewProductInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented') @@ -333,7 +338,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetUserOperations({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.GetUserOperations_Override) await overrides.GetUserOperations_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.NewAddress) throw new Error('method: NewAddress is not implemented') @@ -347,7 +352,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.NewAddress({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.NewAddress_Override) await overrides.NewAddress_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.PayAddress) throw new Error('method: PayAddress is not implemented') @@ -361,7 +366,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.PayAddress({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.PayAddress_Override) await overrides.PayAddress_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.NewInvoice) throw new Error('method: NewInvoice is not implemented') @@ -375,7 +380,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.NewInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.NewInvoice_Override) await overrides.NewInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.DecodeInvoice) throw new Error('method: DecodeInvoice is not implemented') @@ -389,7 +394,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.DecodeInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.DecodeInvoice_Override) await overrides.DecodeInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.PayInvoice) throw new Error('method: PayInvoice is not implemented') @@ -403,7 +408,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.PayInvoice({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.PayInvoice_Override) await overrides.PayInvoice_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.OpenChannel) throw new Error('method: OpenChannel is not implemented') @@ -417,7 +422,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.OpenChannel({ ...authContext, ...query, ...params }, request) - res.json({status: 'OK', ...response}) + if (overrides.OpenChannel_Override) await overrides.OpenChannel_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetLnurlWithdrawLink) throw new Error('method: GetLnurlWithdrawLink is not implemented') @@ -428,7 +433,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetLnurlWithdrawLink({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetLnurlWithdrawLink_Override) await overrides.GetLnurlWithdrawLink_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetLnurlWithdrawInfo) throw new Error('method: GetLnurlWithdrawInfo is not implemented') @@ -439,7 +444,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetLnurlWithdrawInfo({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetLnurlWithdrawInfo_Override) await overrides.GetLnurlWithdrawInfo_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.HandleLnurlWithdraw) throw new Error('method: HandleLnurlWithdraw is not implemented') @@ -450,7 +455,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params await methods.HandleLnurlWithdraw({ ...authContext, ...query, ...params }) - res.json({status: 'OK'}) + if (overrides.HandleLnurlWithdraw_Override) await overrides.HandleLnurlWithdraw_Override(res); else res.json({status: 'OK'}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetLnurlPayInfo) throw new Error('method: GetLnurlPayInfo is not implemented') @@ -461,7 +466,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetLnurlPayInfo({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetLnurlPayInfo_Override) await overrides.GetLnurlPayInfo_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.HandleLnurlPay) throw new Error('method: HandleLnurlPay is not implemented') @@ -472,7 +477,7 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.HandleLnurlPay({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.HandleLnurlPay_Override) await overrides.HandleLnurlPay_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (!opts.allowNotImplementedMethods && !methods.GetLNURLChannelLink) throw new Error('method: GetLNURLChannelLink is not implemented') @@ -483,11 +488,12 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { const query = req.query const params = req.params const response = await methods.GetLNURLChannelLink({ ...authContext, ...query, ...params }) - res.json({status: 'OK', ...response}) + if (overrides.GetLNURLChannelLink_Override) await overrides.GetLNURLChannelLink_Override(res, response); else res.json({status: 'OK', ...response}) } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } }) if (opts.staticFiles) { app.use(express.static(opts.staticFiles)) + app.get('*', function (_, res) { res.sendFile('index.html', { root: opts.staticFiles })}) } var server: { close: () => void } | undefined return { @@ -495,3 +501,40 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => { Listen: (port: number) => { server = app.listen(port, () => logger.log('Example app listening on port ' + port)) } } } +export type MethodsOverride = { + Health_Override?: (httpRes:Response) => Promise + EncryptionExchange_Override?: (httpRes:Response) => Promise + LndGetInfo_Override?: (httpRes:Response, handlerRes:Types.LndGetInfoResponse) => Promise + SetMockInvoiceAsPaid_Override?: (httpRes:Response) => Promise + AddApp_Override?: (httpRes:Response, handlerRes:Types.AuthApp) => Promise + AuthApp_Override?: (httpRes:Response, handlerRes:Types.AuthApp) => Promise + GetApp_Override?: (httpRes:Response, handlerRes:Types.Application) => Promise + AddAppUser_Override?: (httpRes:Response, handlerRes:Types.AppUser) => Promise + AddAppInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise + AddAppUserInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise + GetAppUser_Override?: (httpRes:Response, handlerRes:Types.AppUser) => Promise + PayAppUserInvoice_Override?: (httpRes:Response, handlerRes:Types.PayAppUserInvoiceResponse) => Promise + SendAppUserToAppUserPayment_Override?: (httpRes:Response) => Promise + SendAppUserToAppPayment_Override?: (httpRes:Response) => Promise + GetAppUserLNURLInfo_Override?: (httpRes:Response, handlerRes:Types.LnurlPayInfoResponse) => Promise + SetMockAppUserBalance_Override?: (httpRes:Response) => Promise + SetMockAppBalance_Override?: (httpRes:Response) => Promise + AddUser_Override?: (httpRes:Response, handlerRes:Types.AddUserResponse) => Promise + AuthUser_Override?: (httpRes:Response, handlerRes:Types.AuthUserResponse) => Promise + GetUserInfo_Override?: (httpRes:Response, handlerRes:Types.UserInfo) => Promise + AddProduct_Override?: (httpRes:Response, handlerRes:Types.Product) => Promise + NewProductInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise + GetUserOperations_Override?: (httpRes:Response, handlerRes:Types.GetUserOperationsResponse) => Promise + NewAddress_Override?: (httpRes:Response, handlerRes:Types.NewAddressResponse) => Promise + PayAddress_Override?: (httpRes:Response, handlerRes:Types.PayAddressResponse) => Promise + NewInvoice_Override?: (httpRes:Response, handlerRes:Types.NewInvoiceResponse) => Promise + DecodeInvoice_Override?: (httpRes:Response, handlerRes:Types.DecodeInvoiceResponse) => Promise + PayInvoice_Override?: (httpRes:Response, handlerRes:Types.PayInvoiceResponse) => Promise + OpenChannel_Override?: (httpRes:Response, handlerRes:Types.OpenChannelResponse) => Promise + GetLnurlWithdrawLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise + GetLnurlWithdrawInfo_Override?: (httpRes:Response, handlerRes:Types.LnurlWithdrawInfoResponse) => Promise + HandleLnurlWithdraw_Override?: (httpRes:Response) => Promise + GetLnurlPayInfo_Override?: (httpRes:Response, handlerRes:Types.LnurlPayInfoResponse) => Promise + HandleLnurlPay_Override?: (httpRes:Response, handlerRes:Types.HandleLnurlPayResponse) => Promise + GetLNURLChannelLink_Override?: (httpRes:Response, handlerRes:Types.LnurlLinkResponse) => Promise +} diff --git a/proto/autogenerated/ts/http_client.ts b/proto/autogenerated/ts/http_client.ts index ec69a67f..69a9a0e9 100644 --- a/proto/autogenerated/ts/http_client.ts +++ b/proto/autogenerated/ts/http_client.ts @@ -62,7 +62,7 @@ export default (params: ClientParams) => ({ } return { status: 'ERROR', reason: 'invalid response' } }, - AddApp: async (request: Types.AuthAppRequest): Promise => { + AddApp: async (request: Types.AddAppRequest): Promise => { const auth = await params.retrieveAdminAuth() if (auth === null) throw new Error('retrieveAdminAuth() returned null') let finalRoute = '/api/admin/app/add' diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index 99d3bdc4..6a42be6d 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -200,7 +200,7 @@ export type ServerMethods = { EncryptionExchange?: (ctx: EncryptionExchange_Context, req: EncryptionExchangeRequest) => Promise LndGetInfo?: (ctx: LndGetInfo_Context, req: LndGetInfoRequest) => Promise SetMockInvoiceAsPaid?: (ctx: SetMockInvoiceAsPaid_Context, req: SetMockInvoiceAsPaidRequest) => Promise - AddApp?: (ctx: AddApp_Context, req: AuthAppRequest) => Promise + AddApp?: (ctx: AddApp_Context, req: AddAppRequest) => Promise AuthApp?: (ctx: AuthApp_Context, req: AuthAppRequest) => Promise GetApp?: (ctx: GetApp_Context) => Promise AddAppUser?: (ctx: AddAppUser_Context, req: AddAppUserRequest) => Promise @@ -259,398 +259,6 @@ export type OptionsBaseMessage = { allOptionalsAreSet?: true } -export type SetMockInvoiceAsPaidRequest = { - invoice: string - amount: number -} -export const SetMockInvoiceAsPaidRequestOptionalFields: [] = [] -export type SetMockInvoiceAsPaidRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const SetMockInvoiceAsPaidRequestValidate = (o?: SetMockInvoiceAsPaidRequest, opts: SetMockInvoiceAsPaidRequestOptions = {}, path: string = 'SetMockInvoiceAsPaidRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type NewAddressRequest = { - addressType: AddressType -} -export const NewAddressRequestOptionalFields: [] = [] -export type NewAddressRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - addressType_CustomCheck?: (v: AddressType) => boolean -} -export const NewAddressRequestValidate = (o?: NewAddressRequest, opts: NewAddressRequestOptions = {}, path: string = 'NewAddressRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (!enumCheckAddressType(o.addressType)) return new Error(`${path}.addressType: is not a valid AddressType`) - if (opts.addressType_CustomCheck && !opts.addressType_CustomCheck(o.addressType)) return new Error(`${path}.addressType: custom check failed`) - - return null -} - -export type NewInvoiceResponse = { - invoice: string -} -export const NewInvoiceResponseOptionalFields: [] = [] -export type NewInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean -} -export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvoiceResponseOptions = {}, path: string = 'NewInvoiceResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - return null -} - -export type AddAppInvoiceRequest = { - payer_identifier: string - http_callback_url: string - invoice_req: NewInvoiceRequest -} -export const AddAppInvoiceRequestOptionalFields: [] = [] -export type AddAppInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - payer_identifier_CustomCheck?: (v: string) => boolean - http_callback_url_CustomCheck?: (v: string) => boolean - invoice_req_Options?: NewInvoiceRequestOptions -} -export const AddAppInvoiceRequestValidate = (o?: AddAppInvoiceRequest, opts: AddAppInvoiceRequestOptions = {}, path: string = 'AddAppInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) - if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) - - if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) - if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) - - const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) - if (invoice_reqErr !== null) return invoice_reqErr - - - return null -} - -export type GetUserOperationsResponse = { - latestOutgoingInvoiceOperations: UserOperations - latestIncomingInvoiceOperations: UserOperations - latestOutgoingTxOperations: UserOperations - latestIncomingTxOperations: UserOperations - latestOutgoingUserToUserPayemnts: UserOperations - latestIncomingUserToUserPayemnts: UserOperations -} -export const GetUserOperationsResponseOptionalFields: [] = [] -export type GetUserOperationsResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - latestOutgoingInvoiceOperations_Options?: UserOperationsOptions - latestIncomingInvoiceOperations_Options?: UserOperationsOptions - latestOutgoingTxOperations_Options?: UserOperationsOptions - latestIncomingTxOperations_Options?: UserOperationsOptions - latestOutgoingUserToUserPayemnts_Options?: UserOperationsOptions - latestIncomingUserToUserPayemnts_Options?: UserOperationsOptions -} -export const GetUserOperationsResponseValidate = (o?: GetUserOperationsResponse, opts: GetUserOperationsResponseOptions = {}, path: string = 'GetUserOperationsResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - const latestOutgoingInvoiceOperationsErr = UserOperationsValidate(o.latestOutgoingInvoiceOperations, opts.latestOutgoingInvoiceOperations_Options, `${path}.latestOutgoingInvoiceOperations`) - if (latestOutgoingInvoiceOperationsErr !== null) return latestOutgoingInvoiceOperationsErr - - - const latestIncomingInvoiceOperationsErr = UserOperationsValidate(o.latestIncomingInvoiceOperations, opts.latestIncomingInvoiceOperations_Options, `${path}.latestIncomingInvoiceOperations`) - if (latestIncomingInvoiceOperationsErr !== null) return latestIncomingInvoiceOperationsErr - - - const latestOutgoingTxOperationsErr = UserOperationsValidate(o.latestOutgoingTxOperations, opts.latestOutgoingTxOperations_Options, `${path}.latestOutgoingTxOperations`) - if (latestOutgoingTxOperationsErr !== null) return latestOutgoingTxOperationsErr - - - const latestIncomingTxOperationsErr = UserOperationsValidate(o.latestIncomingTxOperations, opts.latestIncomingTxOperations_Options, `${path}.latestIncomingTxOperations`) - if (latestIncomingTxOperationsErr !== null) return latestIncomingTxOperationsErr - - - const latestOutgoingUserToUserPayemntsErr = UserOperationsValidate(o.latestOutgoingUserToUserPayemnts, opts.latestOutgoingUserToUserPayemnts_Options, `${path}.latestOutgoingUserToUserPayemnts`) - if (latestOutgoingUserToUserPayemntsErr !== null) return latestOutgoingUserToUserPayemntsErr - - - const latestIncomingUserToUserPayemntsErr = UserOperationsValidate(o.latestIncomingUserToUserPayemnts, opts.latestIncomingUserToUserPayemnts_Options, `${path}.latestIncomingUserToUserPayemnts`) - if (latestIncomingUserToUserPayemntsErr !== null) return latestIncomingUserToUserPayemntsErr - - - return null -} - -export type LndGetInfoRequest = { - nodeId: number -} -export const LndGetInfoRequestOptionalFields: [] = [] -export type LndGetInfoRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - nodeId_CustomCheck?: (v: number) => boolean -} -export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInfoRequestOptions = {}, path: string = 'LndGetInfoRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.nodeId !== 'number') return new Error(`${path}.nodeId: is not a number`) - if (opts.nodeId_CustomCheck && !opts.nodeId_CustomCheck(o.nodeId)) return new Error(`${path}.nodeId: custom check failed`) - - return null -} - -export type LndGetInfoResponse = { - alias: string -} -export const LndGetInfoResponseOptionalFields: [] = [] -export type LndGetInfoResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - alias_CustomCheck?: (v: string) => boolean -} -export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.alias !== 'string') return new Error(`${path}.alias: is not a string`) - if (opts.alias_CustomCheck && !opts.alias_CustomCheck(o.alias)) return new Error(`${path}.alias: custom check failed`) - - return null -} - -export type SendAppUserToAppPaymentRequest = { - from_user_identifier: string - amount: number -} -export const SendAppUserToAppPaymentRequestOptionalFields: [] = [] -export type SendAppUserToAppPaymentRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - from_user_identifier_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const SendAppUserToAppPaymentRequestValidate = (o?: SendAppUserToAppPaymentRequest, opts: SendAppUserToAppPaymentRequestOptions = {}, path: string = 'SendAppUserToAppPaymentRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) - if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type PayAddressResponse = { - txId: string -} -export const PayAddressResponseOptionalFields: [] = [] -export type PayAddressResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - txId_CustomCheck?: (v: string) => boolean -} -export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.txId !== 'string') return new Error(`${path}.txId: is not a string`) - if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) - - return null -} - -export type AddUserRequest = { - callbackUrl: string - name: string - secret: string -} -export const AddUserRequestOptionalFields: [] = [] -export type AddUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - callbackUrl_CustomCheck?: (v: string) => boolean - name_CustomCheck?: (v: string) => boolean - secret_CustomCheck?: (v: string) => boolean -} -export const AddUserRequestValidate = (o?: AddUserRequest, opts: AddUserRequestOptions = {}, path: string = 'AddUserRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.callbackUrl !== 'string') return new Error(`${path}.callbackUrl: is not a string`) - if (opts.callbackUrl_CustomCheck && !opts.callbackUrl_CustomCheck(o.callbackUrl)) return new Error(`${path}.callbackUrl: custom check failed`) - - if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) - if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) - - if (typeof o.secret !== 'string') return new Error(`${path}.secret: is not a string`) - if (opts.secret_CustomCheck && !opts.secret_CustomCheck(o.secret)) return new Error(`${path}.secret: custom check failed`) - - return null -} - -export type AddUserResponse = { - userId: string - authToken: string -} -export const AddUserResponseOptionalFields: [] = [] -export type AddUserResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - authToken_CustomCheck?: (v: string) => boolean -} -export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserResponseOptions = {}, path: string = 'AddUserResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) - if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) - - if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) - if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) - - return null -} - -export type AuthUserResponse = { - userId: string - authToken: string -} -export const AuthUserResponseOptionalFields: [] = [] -export type AuthUserResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - authToken_CustomCheck?: (v: string) => boolean -} -export const AuthUserResponseValidate = (o?: AuthUserResponse, opts: AuthUserResponseOptions = {}, path: string = 'AuthUserResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) - if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) - - if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) - if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) - - return null -} - -export type GetUserOperationsRequest = { - latestIncomingInvoice: number - latestOutgoingInvoice: number - latestIncomingTx: number - latestOutgoingTx: number - latestIncomingUserToUserPayment: number - latestOutgoingUserToUserPayment: number -} -export const GetUserOperationsRequestOptionalFields: [] = [] -export type GetUserOperationsRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - latestIncomingInvoice_CustomCheck?: (v: number) => boolean - latestOutgoingInvoice_CustomCheck?: (v: number) => boolean - latestIncomingTx_CustomCheck?: (v: number) => boolean - latestOutgoingTx_CustomCheck?: (v: number) => boolean - latestIncomingUserToUserPayment_CustomCheck?: (v: number) => boolean - latestOutgoingUserToUserPayment_CustomCheck?: (v: number) => boolean -} -export const GetUserOperationsRequestValidate = (o?: GetUserOperationsRequest, opts: GetUserOperationsRequestOptions = {}, path: string = 'GetUserOperationsRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.latestIncomingInvoice !== 'number') return new Error(`${path}.latestIncomingInvoice: is not a number`) - if (opts.latestIncomingInvoice_CustomCheck && !opts.latestIncomingInvoice_CustomCheck(o.latestIncomingInvoice)) return new Error(`${path}.latestIncomingInvoice: custom check failed`) - - if (typeof o.latestOutgoingInvoice !== 'number') return new Error(`${path}.latestOutgoingInvoice: is not a number`) - if (opts.latestOutgoingInvoice_CustomCheck && !opts.latestOutgoingInvoice_CustomCheck(o.latestOutgoingInvoice)) return new Error(`${path}.latestOutgoingInvoice: custom check failed`) - - if (typeof o.latestIncomingTx !== 'number') return new Error(`${path}.latestIncomingTx: is not a number`) - if (opts.latestIncomingTx_CustomCheck && !opts.latestIncomingTx_CustomCheck(o.latestIncomingTx)) return new Error(`${path}.latestIncomingTx: custom check failed`) - - if (typeof o.latestOutgoingTx !== 'number') return new Error(`${path}.latestOutgoingTx: is not a number`) - if (opts.latestOutgoingTx_CustomCheck && !opts.latestOutgoingTx_CustomCheck(o.latestOutgoingTx)) return new Error(`${path}.latestOutgoingTx: custom check failed`) - - if (typeof o.latestIncomingUserToUserPayment !== 'number') return new Error(`${path}.latestIncomingUserToUserPayment: is not a number`) - if (opts.latestIncomingUserToUserPayment_CustomCheck && !opts.latestIncomingUserToUserPayment_CustomCheck(o.latestIncomingUserToUserPayment)) return new Error(`${path}.latestIncomingUserToUserPayment: custom check failed`) - - if (typeof o.latestOutgoingUserToUserPayment !== 'number') return new Error(`${path}.latestOutgoingUserToUserPayment: is not a number`) - if (opts.latestOutgoingUserToUserPayment_CustomCheck && !opts.latestOutgoingUserToUserPayment_CustomCheck(o.latestOutgoingUserToUserPayment)) return new Error(`${path}.latestOutgoingUserToUserPayment: custom check failed`) - - return null -} - -export type UserOperation = { - paidAtUnix: number - type: UserOperationType - inbound: boolean - amount: number -} -export const UserOperationOptionalFields: [] = [] -export type UserOperationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - paidAtUnix_CustomCheck?: (v: number) => boolean - type_CustomCheck?: (v: UserOperationType) => boolean - inbound_CustomCheck?: (v: boolean) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOptions = {}, path: string = 'UserOperation::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.paidAtUnix !== 'number') return new Error(`${path}.paidAtUnix: is not a number`) - if (opts.paidAtUnix_CustomCheck && !opts.paidAtUnix_CustomCheck(o.paidAtUnix)) return new Error(`${path}.paidAtUnix: custom check failed`) - - if (!enumCheckUserOperationType(o.type)) return new Error(`${path}.type: is not a valid UserOperationType`) - if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`) - - if (typeof o.inbound !== 'boolean') return new Error(`${path}.inbound: is not a boolean`) - if (opts.inbound_CustomCheck && !opts.inbound_CustomCheck(o.inbound)) return new Error(`${path}.inbound: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type AddAppUserRequest = { - identifier: string - fail_if_exists: boolean - balance: number -} -export const AddAppUserRequestOptionalFields: [] = [] -export type AddAppUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - identifier_CustomCheck?: (v: string) => boolean - fail_if_exists_CustomCheck?: (v: boolean) => boolean - balance_CustomCheck?: (v: number) => boolean -} -export const AddAppUserRequestValidate = (o?: AddAppUserRequest, opts: AddAppUserRequestOptions = {}, path: string = 'AddAppUserRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) - if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) - - if (typeof o.fail_if_exists !== 'boolean') return new Error(`${path}.fail_if_exists: is not a boolean`) - if (opts.fail_if_exists_CustomCheck && !opts.fail_if_exists_CustomCheck(o.fail_if_exists)) return new Error(`${path}.fail_if_exists: custom check failed`) - - if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) - if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) - - return null -} - export type SendAppUserToAppUserPaymentRequest = { from_user_identifier: string to_user_identifier: string @@ -679,157 +287,6 @@ export const SendAppUserToAppUserPaymentRequestValidate = (o?: SendAppUserToAppU return null } -export type OpenChannelResponse = { - channelId: string -} -export const OpenChannelResponseOptionalFields: [] = [] -export type OpenChannelResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - channelId_CustomCheck?: (v: string) => boolean -} -export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) - if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) - - return null -} - -export type LnurlLinkResponse = { - lnurl: string - k1: string -} -export const LnurlLinkResponseOptionalFields: [] = [] -export type LnurlLinkResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - lnurl_CustomCheck?: (v: string) => boolean - k1_CustomCheck?: (v: string) => boolean -} -export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) - if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) - - if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) - if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) - - return null -} - -export type UserOperations = { - fromIndex: number - toIndex: number - operations: UserOperation[] -} -export const UserOperationsOptionalFields: [] = [] -export type UserOperationsOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - fromIndex_CustomCheck?: (v: number) => boolean - toIndex_CustomCheck?: (v: number) => boolean - operations_ItemOptions?: UserOperationOptions - operations_CustomCheck?: (v: UserOperation[]) => boolean -} -export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsOptions = {}, path: string = 'UserOperations::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.fromIndex !== 'number') return new Error(`${path}.fromIndex: is not a number`) - if (opts.fromIndex_CustomCheck && !opts.fromIndex_CustomCheck(o.fromIndex)) return new Error(`${path}.fromIndex: custom check failed`) - - if (typeof o.toIndex !== 'number') return new Error(`${path}.toIndex: is not a number`) - if (opts.toIndex_CustomCheck && !opts.toIndex_CustomCheck(o.toIndex)) return new Error(`${path}.toIndex: custom check failed`) - - if (!Array.isArray(o.operations)) return new Error(`${path}.operations: is not an array`) - for (let index = 0; index < o.operations.length; index++) { - const operationsErr = UserOperationValidate(o.operations[index], opts.operations_ItemOptions, `${path}.operations[${index}]`) - if (operationsErr !== null) return operationsErr - } - if (opts.operations_CustomCheck && !opts.operations_CustomCheck(o.operations)) return new Error(`${path}.operations: custom check failed`) - - return null -} - -export type GetProductBuyLinkResponse = { - link: string -} -export const GetProductBuyLinkResponseOptionalFields: [] = [] -export type GetProductBuyLinkResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - link_CustomCheck?: (v: string) => boolean -} -export const GetProductBuyLinkResponseValidate = (o?: GetProductBuyLinkResponse, opts: GetProductBuyLinkResponseOptions = {}, path: string = 'GetProductBuyLinkResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.link !== 'string') return new Error(`${path}.link: is not a string`) - if (opts.link_CustomCheck && !opts.link_CustomCheck(o.link)) return new Error(`${path}.link: custom check failed`) - - return null -} - -export type Empty = { -} -export const EmptyOptionalFields: [] = [] -export type EmptyOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] -} -export const EmptyValidate = (o?: Empty, opts: EmptyOptions = {}, path: string = 'Empty::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - return null -} - -export type EncryptionExchangeRequest = { - publicKey: string - deviceId: string -} -export const EncryptionExchangeRequestOptionalFields: [] = [] -export type EncryptionExchangeRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - publicKey_CustomCheck?: (v: string) => boolean - deviceId_CustomCheck?: (v: string) => boolean -} -export const EncryptionExchangeRequestValidate = (o?: EncryptionExchangeRequest, opts: EncryptionExchangeRequestOptions = {}, path: string = 'EncryptionExchangeRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.publicKey !== 'string') return new Error(`${path}.publicKey: is not a string`) - if (opts.publicKey_CustomCheck && !opts.publicKey_CustomCheck(o.publicKey)) return new Error(`${path}.publicKey: custom check failed`) - - if (typeof o.deviceId !== 'string') return new Error(`${path}.deviceId: is not a string`) - if (opts.deviceId_CustomCheck && !opts.deviceId_CustomCheck(o.deviceId)) return new Error(`${path}.deviceId: custom check failed`) - - return null -} - -export type PayAppUserInvoiceResponse = { - preimage: string - amount_paid: number -} -export const PayAppUserInvoiceResponseOptionalFields: [] = [] -export type PayAppUserInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - preimage_CustomCheck?: (v: string) => boolean - amount_paid_CustomCheck?: (v: number) => boolean -} -export const PayAppUserInvoiceResponseValidate = (o?: PayAppUserInvoiceResponse, opts: PayAppUserInvoiceResponseOptions = {}, path: string = 'PayAppUserInvoiceResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) - if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) - - if (typeof o.amount_paid !== 'number') return new Error(`${path}.amount_paid: is not a number`) - if (opts.amount_paid_CustomCheck && !opts.amount_paid_CustomCheck(o.amount_paid)) return new Error(`${path}.amount_paid: custom check failed`) - - return null -} - export type SetMockAppUserBalanceRequest = { user_identifier: string amount: number @@ -853,509 +310,6 @@ export const SetMockAppUserBalanceRequestValidate = (o?: SetMockAppUserBalanceRe return null } -export type SetMockAppBalanceRequest = { - amount: number -} -export const SetMockAppBalanceRequestOptionalFields: [] = [] -export type SetMockAppBalanceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amount_CustomCheck?: (v: number) => boolean -} -export const SetMockAppBalanceRequestValidate = (o?: SetMockAppBalanceRequest, opts: SetMockAppBalanceRequestOptions = {}, path: string = 'SetMockAppBalanceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type PayAddressRequest = { - address: string - amoutSats: number - targetConf: number -} -export const PayAddressRequestOptionalFields: [] = [] -export type PayAddressRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - address_CustomCheck?: (v: string) => boolean - amoutSats_CustomCheck?: (v: number) => boolean - targetConf_CustomCheck?: (v: number) => boolean -} -export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddressRequestOptions = {}, path: string = 'PayAddressRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`) - if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) - - if (typeof o.amoutSats !== 'number') return new Error(`${path}.amoutSats: is not a number`) - if (opts.amoutSats_CustomCheck && !opts.amoutSats_CustomCheck(o.amoutSats)) return new Error(`${path}.amoutSats: custom check failed`) - - if (typeof o.targetConf !== 'number') return new Error(`${path}.targetConf: is not a number`) - if (opts.targetConf_CustomCheck && !opts.targetConf_CustomCheck(o.targetConf)) return new Error(`${path}.targetConf: custom check failed`) - - return null -} - -export type DecodeInvoiceRequest = { - invoice: string -} -export const DecodeInvoiceRequestOptionalFields: [] = [] -export type DecodeInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean -} -export const DecodeInvoiceRequestValidate = (o?: DecodeInvoiceRequest, opts: DecodeInvoiceRequestOptions = {}, path: string = 'DecodeInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - return null -} - -export type DecodeInvoiceResponse = { - amount: number -} -export const DecodeInvoiceResponseOptionalFields: [] = [] -export type DecodeInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amount_CustomCheck?: (v: number) => boolean -} -export const DecodeInvoiceResponseValidate = (o?: DecodeInvoiceResponse, opts: DecodeInvoiceResponseOptions = {}, path: string = 'DecodeInvoiceResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type OpenChannelRequest = { - destination: string - fundingAmount: number - pushAmount: number - closeAddress: string -} -export const OpenChannelRequestOptionalFields: [] = [] -export type OpenChannelRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - destination_CustomCheck?: (v: string) => boolean - fundingAmount_CustomCheck?: (v: number) => boolean - pushAmount_CustomCheck?: (v: number) => boolean - closeAddress_CustomCheck?: (v: string) => boolean -} -export const OpenChannelRequestValidate = (o?: OpenChannelRequest, opts: OpenChannelRequestOptions = {}, path: string = 'OpenChannelRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.destination !== 'string') return new Error(`${path}.destination: is not a string`) - if (opts.destination_CustomCheck && !opts.destination_CustomCheck(o.destination)) return new Error(`${path}.destination: custom check failed`) - - if (typeof o.fundingAmount !== 'number') return new Error(`${path}.fundingAmount: is not a number`) - if (opts.fundingAmount_CustomCheck && !opts.fundingAmount_CustomCheck(o.fundingAmount)) return new Error(`${path}.fundingAmount: custom check failed`) - - if (typeof o.pushAmount !== 'number') return new Error(`${path}.pushAmount: is not a number`) - if (opts.pushAmount_CustomCheck && !opts.pushAmount_CustomCheck(o.pushAmount)) return new Error(`${path}.pushAmount: custom check failed`) - - if (typeof o.closeAddress !== 'string') return new Error(`${path}.closeAddress: is not a string`) - if (opts.closeAddress_CustomCheck && !opts.closeAddress_CustomCheck(o.closeAddress)) return new Error(`${path}.closeAddress: custom check failed`) - - return null -} - -export type HandleLnurlPayResponse = { - pr: string - routes: Empty[] -} -export const HandleLnurlPayResponseOptionalFields: [] = [] -export type HandleLnurlPayResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - pr_CustomCheck?: (v: string) => boolean - routes_ItemOptions?: EmptyOptions - routes_CustomCheck?: (v: Empty[]) => boolean -} -export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: HandleLnurlPayResponseOptions = {}, path: string = 'HandleLnurlPayResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.pr !== 'string') return new Error(`${path}.pr: is not a string`) - if (opts.pr_CustomCheck && !opts.pr_CustomCheck(o.pr)) return new Error(`${path}.pr: custom check failed`) - - if (!Array.isArray(o.routes)) return new Error(`${path}.routes: is not an array`) - for (let index = 0; index < o.routes.length; index++) { - const routesErr = EmptyValidate(o.routes[index], opts.routes_ItemOptions, `${path}.routes[${index}]`) - if (routesErr !== null) return routesErr - } - if (opts.routes_CustomCheck && !opts.routes_CustomCheck(o.routes)) return new Error(`${path}.routes: custom check failed`) - - return null -} - -export type AddAppUserInvoiceRequest = { - receiver_identifier: string - payer_identifier: string - http_callback_url: string - invoice_req: NewInvoiceRequest -} -export const AddAppUserInvoiceRequestOptionalFields: [] = [] -export type AddAppUserInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - receiver_identifier_CustomCheck?: (v: string) => boolean - payer_identifier_CustomCheck?: (v: string) => boolean - http_callback_url_CustomCheck?: (v: string) => boolean - invoice_req_Options?: NewInvoiceRequestOptions -} -export const AddAppUserInvoiceRequestValidate = (o?: AddAppUserInvoiceRequest, opts: AddAppUserInvoiceRequestOptions = {}, path: string = 'AddAppUserInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.receiver_identifier !== 'string') return new Error(`${path}.receiver_identifier: is not a string`) - if (opts.receiver_identifier_CustomCheck && !opts.receiver_identifier_CustomCheck(o.receiver_identifier)) return new Error(`${path}.receiver_identifier: custom check failed`) - - if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) - if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) - - if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) - if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) - - const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) - if (invoice_reqErr !== null) return invoice_reqErr - - - return null -} - -export type GetAppUserRequest = { - user_identifier: string -} -export const GetAppUserRequestOptionalFields: [] = [] -export type GetAppUserRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean -} -export const GetAppUserRequestValidate = (o?: GetAppUserRequest, opts: GetAppUserRequestOptions = {}, path: string = 'GetAppUserRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - return null -} - -export type NewInvoiceRequest = { - amountSats: number - memo: string -} -export const NewInvoiceRequestOptionalFields: [] = [] -export type NewInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - amountSats_CustomCheck?: (v: number) => boolean - memo_CustomCheck?: (v: string) => boolean -} -export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.amountSats !== 'number') return new Error(`${path}.amountSats: is not a number`) - if (opts.amountSats_CustomCheck && !opts.amountSats_CustomCheck(o.amountSats)) return new Error(`${path}.amountSats: custom check failed`) - - if (typeof o.memo !== 'string') return new Error(`${path}.memo: is not a string`) - if (opts.memo_CustomCheck && !opts.memo_CustomCheck(o.memo)) return new Error(`${path}.memo: custom check failed`) - - return null -} - -export type PayInvoiceResponse = { - preimage: string - amount_paid: number -} -export const PayInvoiceResponseOptionalFields: [] = [] -export type PayInvoiceResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - preimage_CustomCheck?: (v: string) => boolean - amount_paid_CustomCheck?: (v: number) => boolean -} -export const PayInvoiceResponseValidate = (o?: PayInvoiceResponse, opts: PayInvoiceResponseOptions = {}, path: string = 'PayInvoiceResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) - if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) - - if (typeof o.amount_paid !== 'number') return new Error(`${path}.amount_paid: is not a number`) - if (opts.amount_paid_CustomCheck && !opts.amount_paid_CustomCheck(o.amount_paid)) return new Error(`${path}.amount_paid: custom check failed`) - - return null -} - -export type LnurlPayInfoResponse = { - tag: string - callback: string - maxSendable: number - minSendable: number - metadata: string -} -export const LnurlPayInfoResponseOptionalFields: [] = [] -export type LnurlPayInfoResponseOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - tag_CustomCheck?: (v: string) => boolean - callback_CustomCheck?: (v: string) => boolean - maxSendable_CustomCheck?: (v: number) => boolean - minSendable_CustomCheck?: (v: number) => boolean - metadata_CustomCheck?: (v: string) => boolean -} -export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: LnurlPayInfoResponseOptions = {}, path: string = 'LnurlPayInfoResponse::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.tag !== 'string') return new Error(`${path}.tag: is not a string`) - if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) - - if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) - if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) - - if (typeof o.maxSendable !== 'number') return new Error(`${path}.maxSendable: is not a number`) - if (opts.maxSendable_CustomCheck && !opts.maxSendable_CustomCheck(o.maxSendable)) return new Error(`${path}.maxSendable: custom check failed`) - - if (typeof o.minSendable !== 'number') return new Error(`${path}.minSendable: is not a number`) - if (opts.minSendable_CustomCheck && !opts.minSendable_CustomCheck(o.minSendable)) return new Error(`${path}.minSendable: custom check failed`) - - if (typeof o.metadata !== 'string') return new Error(`${path}.metadata: is not a string`) - if (opts.metadata_CustomCheck && !opts.metadata_CustomCheck(o.metadata)) return new Error(`${path}.metadata: custom check failed`) - - return null -} - -export type UserInfo = { - userId: string - balance: number -} -export const UserInfoOptionalFields: [] = [] -export type UserInfoOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - userId_CustomCheck?: (v: string) => boolean - balance_CustomCheck?: (v: number) => boolean -} -export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: string = 'UserInfo::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) - if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) - - if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) - if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) - - return null -} - -export type Product = { - id: string - name: string - price_sats: number -} -export const ProductOptionalFields: [] = [] -export type ProductOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - id_CustomCheck?: (v: string) => boolean - name_CustomCheck?: (v: string) => boolean - price_sats_CustomCheck?: (v: number) => boolean -} -export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: string = 'Product::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) - if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) - - if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) - if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) - - if (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) - if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) - - return null -} - -export type PayInvoiceRequest = { - invoice: string - amount: number -} -export const PayInvoiceRequestOptionalFields: [] = [] -export type PayInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type AuthAppRequest = { - name: string -} -export const AuthAppRequestOptionalFields: [] = [] -export type AuthAppRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - name_CustomCheck?: (v: string) => boolean -} -export const AuthAppRequestValidate = (o?: AuthAppRequest, opts: AuthAppRequestOptions = {}, path: string = 'AuthAppRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) - if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) - - return null -} - -export type Application = { - name: string - id: string - balance: number -} -export const ApplicationOptionalFields: [] = [] -export type ApplicationOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - name_CustomCheck?: (v: string) => boolean - id_CustomCheck?: (v: string) => boolean - balance_CustomCheck?: (v: number) => boolean -} -export const ApplicationValidate = (o?: Application, opts: ApplicationOptions = {}, path: string = 'Application::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) - if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) - - if (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) - if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) - - if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) - if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) - - return null -} - -export type AuthApp = { - app: Application - auth_token: string -} -export const AuthAppOptionalFields: [] = [] -export type AuthAppOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - app_Options?: ApplicationOptions - auth_token_CustomCheck?: (v: string) => boolean -} -export const AuthAppValidate = (o?: AuthApp, opts: AuthAppOptions = {}, path: string = 'AuthApp::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - const appErr = ApplicationValidate(o.app, opts.app_Options, `${path}.app`) - if (appErr !== null) return appErr - - - if (typeof o.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`) - if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`) - - return null -} - -export type AppUser = { - identifier: string - info: UserInfo - max_withdrawable: number -} -export const AppUserOptionalFields: [] = [] -export type AppUserOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - identifier_CustomCheck?: (v: string) => boolean - info_Options?: UserInfoOptions - max_withdrawable_CustomCheck?: (v: number) => boolean -} -export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) - if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) - - const infoErr = UserInfoValidate(o.info, opts.info_Options, `${path}.info`) - if (infoErr !== null) return infoErr - - - if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`) - if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`) - - return null -} - -export type PayAppUserInvoiceRequest = { - user_identifier: string - invoice: string - amount: number -} -export const PayAppUserInvoiceRequestOptionalFields: [] = [] -export type PayAppUserInvoiceRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean - invoice_CustomCheck?: (v: string) => boolean - amount_CustomCheck?: (v: number) => boolean -} -export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, opts: PayAppUserInvoiceRequestOptions = {}, path: string = 'PayAppUserInvoiceRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) - if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) - - if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) - if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) - - return null -} - -export type GetAppUserLNURLInfoRequest = { - user_identifier: string - base_url_override: string -} -export const GetAppUserLNURLInfoRequestOptionalFields: [] = [] -export type GetAppUserLNURLInfoRequestOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] - user_identifier_CustomCheck?: (v: string) => boolean - base_url_override_CustomCheck?: (v: string) => boolean -} -export const GetAppUserLNURLInfoRequestValidate = (o?: GetAppUserLNURLInfoRequest, opts: GetAppUserLNURLInfoRequestOptions = {}, path: string = 'GetAppUserLNURLInfoRequest::root.'): Error | null => { - if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') - if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') - - if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) - if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) - - if (typeof o.base_url_override !== 'string') return new Error(`${path}.base_url_override: is not a string`) - if (opts.base_url_override_CustomCheck && !opts.base_url_override_CustomCheck(o.base_url_override)) return new Error(`${path}.base_url_override: custom check failed`) - - return null -} - export type NewAddressResponse = { address: string } @@ -1427,6 +381,820 @@ export const LnurlWithdrawInfoResponseValidate = (o?: LnurlWithdrawInfoResponse, return null } +export type HandleLnurlPayResponse = { + pr: string + routes: Empty[] +} +export const HandleLnurlPayResponseOptionalFields: [] = [] +export type HandleLnurlPayResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + pr_CustomCheck?: (v: string) => boolean + routes_ItemOptions?: EmptyOptions + routes_CustomCheck?: (v: Empty[]) => boolean +} +export const HandleLnurlPayResponseValidate = (o?: HandleLnurlPayResponse, opts: HandleLnurlPayResponseOptions = {}, path: string = 'HandleLnurlPayResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.pr !== 'string') return new Error(`${path}.pr: is not a string`) + if (opts.pr_CustomCheck && !opts.pr_CustomCheck(o.pr)) return new Error(`${path}.pr: custom check failed`) + + if (!Array.isArray(o.routes)) return new Error(`${path}.routes: is not an array`) + for (let index = 0; index < o.routes.length; index++) { + const routesErr = EmptyValidate(o.routes[index], opts.routes_ItemOptions, `${path}.routes[${index}]`) + if (routesErr !== null) return routesErr + } + if (opts.routes_CustomCheck && !opts.routes_CustomCheck(o.routes)) return new Error(`${path}.routes: custom check failed`) + + return null +} + +export type UserInfo = { + userId: string + balance: number +} +export const UserInfoOptionalFields: [] = [] +export type UserInfoOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + userId_CustomCheck?: (v: string) => boolean + balance_CustomCheck?: (v: number) => boolean +} +export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: string = 'UserInfo::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) + if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) + + if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) + if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) + + return null +} + +export type Product = { + id: string + name: string + price_sats: number +} +export const ProductOptionalFields: [] = [] +export type ProductOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + id_CustomCheck?: (v: string) => boolean + name_CustomCheck?: (v: string) => boolean + price_sats_CustomCheck?: (v: number) => boolean +} +export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: string = 'Product::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) + if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`) + if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`) + + return null +} + +export type AuthAppRequest = { + name: string + allow_user_creation?: boolean +} +export type AuthAppRequestOptionalField = 'allow_user_creation' +export const AuthAppRequestOptionalFields: AuthAppRequestOptionalField[] = ['allow_user_creation'] +export type AuthAppRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: AuthAppRequestOptionalField[] + name_CustomCheck?: (v: string) => boolean + allow_user_creation_CustomCheck?: (v?: boolean) => boolean +} +export const AuthAppRequestValidate = (o?: AuthAppRequest, opts: AuthAppRequestOptions = {}, path: string = 'AuthAppRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if ((o.allow_user_creation || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('allow_user_creation')) && typeof o.allow_user_creation !== 'boolean') return new Error(`${path}.allow_user_creation: is not a boolean`) + if (opts.allow_user_creation_CustomCheck && !opts.allow_user_creation_CustomCheck(o.allow_user_creation)) return new Error(`${path}.allow_user_creation: custom check failed`) + + return null +} + +export type GetAppUserRequest = { + user_identifier: string +} +export const GetAppUserRequestOptionalFields: [] = [] +export type GetAppUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean +} +export const GetAppUserRequestValidate = (o?: GetAppUserRequest, opts: GetAppUserRequestOptions = {}, path: string = 'GetAppUserRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + return null +} + +export type NewInvoiceResponse = { + invoice: string +} +export const NewInvoiceResponseOptionalFields: [] = [] +export type NewInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean +} +export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvoiceResponseOptions = {}, path: string = 'NewInvoiceResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + return null +} + +export type DecodeInvoiceRequest = { + invoice: string +} +export const DecodeInvoiceRequestOptionalFields: [] = [] +export type DecodeInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean +} +export const DecodeInvoiceRequestValidate = (o?: DecodeInvoiceRequest, opts: DecodeInvoiceRequestOptions = {}, path: string = 'DecodeInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + return null +} + +export type OpenChannelResponse = { + channelId: string +} +export const OpenChannelResponseOptionalFields: [] = [] +export type OpenChannelResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + channelId_CustomCheck?: (v: string) => boolean +} +export const OpenChannelResponseValidate = (o?: OpenChannelResponse, opts: OpenChannelResponseOptions = {}, path: string = 'OpenChannelResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.channelId !== 'string') return new Error(`${path}.channelId: is not a string`) + if (opts.channelId_CustomCheck && !opts.channelId_CustomCheck(o.channelId)) return new Error(`${path}.channelId: custom check failed`) + + return null +} + +export type AddUserResponse = { + userId: string + authToken: string +} +export const AddUserResponseOptionalFields: [] = [] +export type AddUserResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + userId_CustomCheck?: (v: string) => boolean + authToken_CustomCheck?: (v: string) => boolean +} +export const AddUserResponseValidate = (o?: AddUserResponse, opts: AddUserResponseOptions = {}, path: string = 'AddUserResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) + if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) + + if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) + if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) + + return null +} + +export type UserOperations = { + fromIndex: number + toIndex: number + operations: UserOperation[] +} +export const UserOperationsOptionalFields: [] = [] +export type UserOperationsOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + fromIndex_CustomCheck?: (v: number) => boolean + toIndex_CustomCheck?: (v: number) => boolean + operations_ItemOptions?: UserOperationOptions + operations_CustomCheck?: (v: UserOperation[]) => boolean +} +export const UserOperationsValidate = (o?: UserOperations, opts: UserOperationsOptions = {}, path: string = 'UserOperations::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.fromIndex !== 'number') return new Error(`${path}.fromIndex: is not a number`) + if (opts.fromIndex_CustomCheck && !opts.fromIndex_CustomCheck(o.fromIndex)) return new Error(`${path}.fromIndex: custom check failed`) + + if (typeof o.toIndex !== 'number') return new Error(`${path}.toIndex: is not a number`) + if (opts.toIndex_CustomCheck && !opts.toIndex_CustomCheck(o.toIndex)) return new Error(`${path}.toIndex: custom check failed`) + + if (!Array.isArray(o.operations)) return new Error(`${path}.operations: is not an array`) + for (let index = 0; index < o.operations.length; index++) { + const operationsErr = UserOperationValidate(o.operations[index], opts.operations_ItemOptions, `${path}.operations[${index}]`) + if (operationsErr !== null) return operationsErr + } + if (opts.operations_CustomCheck && !opts.operations_CustomCheck(o.operations)) return new Error(`${path}.operations: custom check failed`) + + return null +} + +export type AddAppRequest = { + name: string + allow_user_creation: boolean +} +export const AddAppRequestOptionalFields: [] = [] +export type AddAppRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + name_CustomCheck?: (v: string) => boolean + allow_user_creation_CustomCheck?: (v: boolean) => boolean +} +export const AddAppRequestValidate = (o?: AddAppRequest, opts: AddAppRequestOptions = {}, path: string = 'AddAppRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if (typeof o.allow_user_creation !== 'boolean') return new Error(`${path}.allow_user_creation: is not a boolean`) + if (opts.allow_user_creation_CustomCheck && !opts.allow_user_creation_CustomCheck(o.allow_user_creation)) return new Error(`${path}.allow_user_creation: custom check failed`) + + return null +} + +export type PayAppUserInvoiceResponse = { + preimage: string + amount_paid: number +} +export const PayAppUserInvoiceResponseOptionalFields: [] = [] +export type PayAppUserInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + preimage_CustomCheck?: (v: string) => boolean + amount_paid_CustomCheck?: (v: number) => boolean +} +export const PayAppUserInvoiceResponseValidate = (o?: PayAppUserInvoiceResponse, opts: PayAppUserInvoiceResponseOptions = {}, path: string = 'PayAppUserInvoiceResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) + if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) + + if (typeof o.amount_paid !== 'number') return new Error(`${path}.amount_paid: is not a number`) + if (opts.amount_paid_CustomCheck && !opts.amount_paid_CustomCheck(o.amount_paid)) return new Error(`${path}.amount_paid: custom check failed`) + + return null +} + +export type PayInvoiceResponse = { + preimage: string + amount_paid: number +} +export const PayInvoiceResponseOptionalFields: [] = [] +export type PayInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + preimage_CustomCheck?: (v: string) => boolean + amount_paid_CustomCheck?: (v: number) => boolean +} +export const PayInvoiceResponseValidate = (o?: PayInvoiceResponse, opts: PayInvoiceResponseOptions = {}, path: string = 'PayInvoiceResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.preimage !== 'string') return new Error(`${path}.preimage: is not a string`) + if (opts.preimage_CustomCheck && !opts.preimage_CustomCheck(o.preimage)) return new Error(`${path}.preimage: custom check failed`) + + if (typeof o.amount_paid !== 'number') return new Error(`${path}.amount_paid: is not a number`) + if (opts.amount_paid_CustomCheck && !opts.amount_paid_CustomCheck(o.amount_paid)) return new Error(`${path}.amount_paid: custom check failed`) + + return null +} + +export type GetProductBuyLinkResponse = { + link: string +} +export const GetProductBuyLinkResponseOptionalFields: [] = [] +export type GetProductBuyLinkResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + link_CustomCheck?: (v: string) => boolean +} +export const GetProductBuyLinkResponseValidate = (o?: GetProductBuyLinkResponse, opts: GetProductBuyLinkResponseOptions = {}, path: string = 'GetProductBuyLinkResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.link !== 'string') return new Error(`${path}.link: is not a string`) + if (opts.link_CustomCheck && !opts.link_CustomCheck(o.link)) return new Error(`${path}.link: custom check failed`) + + return null +} + +export type LndGetInfoRequest = { + nodeId: number +} +export const LndGetInfoRequestOptionalFields: [] = [] +export type LndGetInfoRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + nodeId_CustomCheck?: (v: number) => boolean +} +export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInfoRequestOptions = {}, path: string = 'LndGetInfoRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.nodeId !== 'number') return new Error(`${path}.nodeId: is not a number`) + if (opts.nodeId_CustomCheck && !opts.nodeId_CustomCheck(o.nodeId)) return new Error(`${path}.nodeId: custom check failed`) + + return null +} + +export type LndGetInfoResponse = { + alias: string +} +export const LndGetInfoResponseOptionalFields: [] = [] +export type LndGetInfoResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + alias_CustomCheck?: (v: string) => boolean +} +export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.alias !== 'string') return new Error(`${path}.alias: is not a string`) + if (opts.alias_CustomCheck && !opts.alias_CustomCheck(o.alias)) return new Error(`${path}.alias: custom check failed`) + + return null +} + +export type AuthApp = { + app: Application + auth_token: string +} +export const AuthAppOptionalFields: [] = [] +export type AuthAppOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + app_Options?: ApplicationOptions + auth_token_CustomCheck?: (v: string) => boolean +} +export const AuthAppValidate = (o?: AuthApp, opts: AuthAppOptions = {}, path: string = 'AuthApp::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + const appErr = ApplicationValidate(o.app, opts.app_Options, `${path}.app`) + if (appErr !== null) return appErr + + + if (typeof o.auth_token !== 'string') return new Error(`${path}.auth_token: is not a string`) + if (opts.auth_token_CustomCheck && !opts.auth_token_CustomCheck(o.auth_token)) return new Error(`${path}.auth_token: custom check failed`) + + return null +} + +export type Empty = { +} +export const EmptyOptionalFields: [] = [] +export type EmptyOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] +} +export const EmptyValidate = (o?: Empty, opts: EmptyOptions = {}, path: string = 'Empty::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + return null +} + +export type AddAppUserRequest = { + identifier: string + fail_if_exists: boolean + balance: number +} +export const AddAppUserRequestOptionalFields: [] = [] +export type AddAppUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + identifier_CustomCheck?: (v: string) => boolean + fail_if_exists_CustomCheck?: (v: boolean) => boolean + balance_CustomCheck?: (v: number) => boolean +} +export const AddAppUserRequestValidate = (o?: AddAppUserRequest, opts: AddAppUserRequestOptions = {}, path: string = 'AddAppUserRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) + if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) + + if (typeof o.fail_if_exists !== 'boolean') return new Error(`${path}.fail_if_exists: is not a boolean`) + if (opts.fail_if_exists_CustomCheck && !opts.fail_if_exists_CustomCheck(o.fail_if_exists)) return new Error(`${path}.fail_if_exists: custom check failed`) + + if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) + if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) + + return null +} + +export type SetMockAppBalanceRequest = { + amount: number +} +export const SetMockAppBalanceRequestOptionalFields: [] = [] +export type SetMockAppBalanceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amount_CustomCheck?: (v: number) => boolean +} +export const SetMockAppBalanceRequestValidate = (o?: SetMockAppBalanceRequest, opts: SetMockAppBalanceRequestOptions = {}, path: string = 'SetMockAppBalanceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + +export type NewAddressRequest = { + addressType: AddressType +} +export const NewAddressRequestOptionalFields: [] = [] +export type NewAddressRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + addressType_CustomCheck?: (v: AddressType) => boolean +} +export const NewAddressRequestValidate = (o?: NewAddressRequest, opts: NewAddressRequestOptions = {}, path: string = 'NewAddressRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (!enumCheckAddressType(o.addressType)) return new Error(`${path}.addressType: is not a valid AddressType`) + if (opts.addressType_CustomCheck && !opts.addressType_CustomCheck(o.addressType)) return new Error(`${path}.addressType: custom check failed`) + + return null +} + +export type NewInvoiceRequest = { + amountSats: number + memo: string +} +export const NewInvoiceRequestOptionalFields: [] = [] +export type NewInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amountSats_CustomCheck?: (v: number) => boolean + memo_CustomCheck?: (v: string) => boolean +} +export const NewInvoiceRequestValidate = (o?: NewInvoiceRequest, opts: NewInvoiceRequestOptions = {}, path: string = 'NewInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.amountSats !== 'number') return new Error(`${path}.amountSats: is not a number`) + if (opts.amountSats_CustomCheck && !opts.amountSats_CustomCheck(o.amountSats)) return new Error(`${path}.amountSats: custom check failed`) + + if (typeof o.memo !== 'string') return new Error(`${path}.memo: is not a string`) + if (opts.memo_CustomCheck && !opts.memo_CustomCheck(o.memo)) return new Error(`${path}.memo: custom check failed`) + + return null +} + +export type LnurlPayInfoResponse = { + tag: string + callback: string + maxSendable: number + minSendable: number + metadata: string +} +export const LnurlPayInfoResponseOptionalFields: [] = [] +export type LnurlPayInfoResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + tag_CustomCheck?: (v: string) => boolean + callback_CustomCheck?: (v: string) => boolean + maxSendable_CustomCheck?: (v: number) => boolean + minSendable_CustomCheck?: (v: number) => boolean + metadata_CustomCheck?: (v: string) => boolean +} +export const LnurlPayInfoResponseValidate = (o?: LnurlPayInfoResponse, opts: LnurlPayInfoResponseOptions = {}, path: string = 'LnurlPayInfoResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.tag !== 'string') return new Error(`${path}.tag: is not a string`) + if (opts.tag_CustomCheck && !opts.tag_CustomCheck(o.tag)) return new Error(`${path}.tag: custom check failed`) + + if (typeof o.callback !== 'string') return new Error(`${path}.callback: is not a string`) + if (opts.callback_CustomCheck && !opts.callback_CustomCheck(o.callback)) return new Error(`${path}.callback: custom check failed`) + + if (typeof o.maxSendable !== 'number') return new Error(`${path}.maxSendable: is not a number`) + if (opts.maxSendable_CustomCheck && !opts.maxSendable_CustomCheck(o.maxSendable)) return new Error(`${path}.maxSendable: custom check failed`) + + if (typeof o.minSendable !== 'number') return new Error(`${path}.minSendable: is not a number`) + if (opts.minSendable_CustomCheck && !opts.minSendable_CustomCheck(o.minSendable)) return new Error(`${path}.minSendable: custom check failed`) + + if (typeof o.metadata !== 'string') return new Error(`${path}.metadata: is not a string`) + if (opts.metadata_CustomCheck && !opts.metadata_CustomCheck(o.metadata)) return new Error(`${path}.metadata: custom check failed`) + + return null +} + +export type AddUserRequest = { + callbackUrl: string + name: string + secret: string +} +export const AddUserRequestOptionalFields: [] = [] +export type AddUserRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + callbackUrl_CustomCheck?: (v: string) => boolean + name_CustomCheck?: (v: string) => boolean + secret_CustomCheck?: (v: string) => boolean +} +export const AddUserRequestValidate = (o?: AddUserRequest, opts: AddUserRequestOptions = {}, path: string = 'AddUserRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.callbackUrl !== 'string') return new Error(`${path}.callbackUrl: is not a string`) + if (opts.callbackUrl_CustomCheck && !opts.callbackUrl_CustomCheck(o.callbackUrl)) return new Error(`${path}.callbackUrl: custom check failed`) + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if (typeof o.secret !== 'string') return new Error(`${path}.secret: is not a string`) + if (opts.secret_CustomCheck && !opts.secret_CustomCheck(o.secret)) return new Error(`${path}.secret: custom check failed`) + + return null +} + +export type GetUserOperationsRequest = { + latestIncomingInvoice: number + latestOutgoingInvoice: number + latestIncomingTx: number + latestOutgoingTx: number + latestIncomingUserToUserPayment: number + latestOutgoingUserToUserPayment: number +} +export const GetUserOperationsRequestOptionalFields: [] = [] +export type GetUserOperationsRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + latestIncomingInvoice_CustomCheck?: (v: number) => boolean + latestOutgoingInvoice_CustomCheck?: (v: number) => boolean + latestIncomingTx_CustomCheck?: (v: number) => boolean + latestOutgoingTx_CustomCheck?: (v: number) => boolean + latestIncomingUserToUserPayment_CustomCheck?: (v: number) => boolean + latestOutgoingUserToUserPayment_CustomCheck?: (v: number) => boolean +} +export const GetUserOperationsRequestValidate = (o?: GetUserOperationsRequest, opts: GetUserOperationsRequestOptions = {}, path: string = 'GetUserOperationsRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.latestIncomingInvoice !== 'number') return new Error(`${path}.latestIncomingInvoice: is not a number`) + if (opts.latestIncomingInvoice_CustomCheck && !opts.latestIncomingInvoice_CustomCheck(o.latestIncomingInvoice)) return new Error(`${path}.latestIncomingInvoice: custom check failed`) + + if (typeof o.latestOutgoingInvoice !== 'number') return new Error(`${path}.latestOutgoingInvoice: is not a number`) + if (opts.latestOutgoingInvoice_CustomCheck && !opts.latestOutgoingInvoice_CustomCheck(o.latestOutgoingInvoice)) return new Error(`${path}.latestOutgoingInvoice: custom check failed`) + + if (typeof o.latestIncomingTx !== 'number') return new Error(`${path}.latestIncomingTx: is not a number`) + if (opts.latestIncomingTx_CustomCheck && !opts.latestIncomingTx_CustomCheck(o.latestIncomingTx)) return new Error(`${path}.latestIncomingTx: custom check failed`) + + if (typeof o.latestOutgoingTx !== 'number') return new Error(`${path}.latestOutgoingTx: is not a number`) + if (opts.latestOutgoingTx_CustomCheck && !opts.latestOutgoingTx_CustomCheck(o.latestOutgoingTx)) return new Error(`${path}.latestOutgoingTx: custom check failed`) + + if (typeof o.latestIncomingUserToUserPayment !== 'number') return new Error(`${path}.latestIncomingUserToUserPayment: is not a number`) + if (opts.latestIncomingUserToUserPayment_CustomCheck && !opts.latestIncomingUserToUserPayment_CustomCheck(o.latestIncomingUserToUserPayment)) return new Error(`${path}.latestIncomingUserToUserPayment: custom check failed`) + + if (typeof o.latestOutgoingUserToUserPayment !== 'number') return new Error(`${path}.latestOutgoingUserToUserPayment: is not a number`) + if (opts.latestOutgoingUserToUserPayment_CustomCheck && !opts.latestOutgoingUserToUserPayment_CustomCheck(o.latestOutgoingUserToUserPayment)) return new Error(`${path}.latestOutgoingUserToUserPayment: custom check failed`) + + return null +} + +export type GetUserOperationsResponse = { + latestOutgoingInvoiceOperations: UserOperations + latestIncomingInvoiceOperations: UserOperations + latestOutgoingTxOperations: UserOperations + latestIncomingTxOperations: UserOperations + latestOutgoingUserToUserPayemnts: UserOperations + latestIncomingUserToUserPayemnts: UserOperations +} +export const GetUserOperationsResponseOptionalFields: [] = [] +export type GetUserOperationsResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + latestOutgoingInvoiceOperations_Options?: UserOperationsOptions + latestIncomingInvoiceOperations_Options?: UserOperationsOptions + latestOutgoingTxOperations_Options?: UserOperationsOptions + latestIncomingTxOperations_Options?: UserOperationsOptions + latestOutgoingUserToUserPayemnts_Options?: UserOperationsOptions + latestIncomingUserToUserPayemnts_Options?: UserOperationsOptions +} +export const GetUserOperationsResponseValidate = (o?: GetUserOperationsResponse, opts: GetUserOperationsResponseOptions = {}, path: string = 'GetUserOperationsResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + const latestOutgoingInvoiceOperationsErr = UserOperationsValidate(o.latestOutgoingInvoiceOperations, opts.latestOutgoingInvoiceOperations_Options, `${path}.latestOutgoingInvoiceOperations`) + if (latestOutgoingInvoiceOperationsErr !== null) return latestOutgoingInvoiceOperationsErr + + + const latestIncomingInvoiceOperationsErr = UserOperationsValidate(o.latestIncomingInvoiceOperations, opts.latestIncomingInvoiceOperations_Options, `${path}.latestIncomingInvoiceOperations`) + if (latestIncomingInvoiceOperationsErr !== null) return latestIncomingInvoiceOperationsErr + + + const latestOutgoingTxOperationsErr = UserOperationsValidate(o.latestOutgoingTxOperations, opts.latestOutgoingTxOperations_Options, `${path}.latestOutgoingTxOperations`) + if (latestOutgoingTxOperationsErr !== null) return latestOutgoingTxOperationsErr + + + const latestIncomingTxOperationsErr = UserOperationsValidate(o.latestIncomingTxOperations, opts.latestIncomingTxOperations_Options, `${path}.latestIncomingTxOperations`) + if (latestIncomingTxOperationsErr !== null) return latestIncomingTxOperationsErr + + + const latestOutgoingUserToUserPayemntsErr = UserOperationsValidate(o.latestOutgoingUserToUserPayemnts, opts.latestOutgoingUserToUserPayemnts_Options, `${path}.latestOutgoingUserToUserPayemnts`) + if (latestOutgoingUserToUserPayemntsErr !== null) return latestOutgoingUserToUserPayemntsErr + + + const latestIncomingUserToUserPayemntsErr = UserOperationsValidate(o.latestIncomingUserToUserPayemnts, opts.latestIncomingUserToUserPayemnts_Options, `${path}.latestIncomingUserToUserPayemnts`) + if (latestIncomingUserToUserPayemntsErr !== null) return latestIncomingUserToUserPayemntsErr + + + return null +} + +export type Application = { + name: string + id: string + balance: number + npub: string +} +export const ApplicationOptionalFields: [] = [] +export type ApplicationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + name_CustomCheck?: (v: string) => boolean + id_CustomCheck?: (v: string) => boolean + balance_CustomCheck?: (v: number) => boolean + npub_CustomCheck?: (v: string) => boolean +} +export const ApplicationValidate = (o?: Application, opts: ApplicationOptions = {}, path: string = 'Application::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`) + if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`) + + if (typeof o.id !== 'string') return new Error(`${path}.id: is not a string`) + if (opts.id_CustomCheck && !opts.id_CustomCheck(o.id)) return new Error(`${path}.id: custom check failed`) + + if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) + if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) + + if (typeof o.npub !== 'string') return new Error(`${path}.npub: is not a string`) + if (opts.npub_CustomCheck && !opts.npub_CustomCheck(o.npub)) return new Error(`${path}.npub: custom check failed`) + + return null +} + +export type AddAppInvoiceRequest = { + payer_identifier: string + http_callback_url: string + invoice_req: NewInvoiceRequest +} +export const AddAppInvoiceRequestOptionalFields: [] = [] +export type AddAppInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + payer_identifier_CustomCheck?: (v: string) => boolean + http_callback_url_CustomCheck?: (v: string) => boolean + invoice_req_Options?: NewInvoiceRequestOptions +} +export const AddAppInvoiceRequestValidate = (o?: AddAppInvoiceRequest, opts: AddAppInvoiceRequestOptions = {}, path: string = 'AddAppInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) + if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) + + if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) + if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) + + const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) + if (invoice_reqErr !== null) return invoice_reqErr + + + return null +} + +export type GetAppUserLNURLInfoRequest = { + user_identifier: string + base_url_override: string +} +export const GetAppUserLNURLInfoRequestOptionalFields: [] = [] +export type GetAppUserLNURLInfoRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean + base_url_override_CustomCheck?: (v: string) => boolean +} +export const GetAppUserLNURLInfoRequestValidate = (o?: GetAppUserLNURLInfoRequest, opts: GetAppUserLNURLInfoRequestOptions = {}, path: string = 'GetAppUserLNURLInfoRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + if (typeof o.base_url_override !== 'string') return new Error(`${path}.base_url_override: is not a string`) + if (opts.base_url_override_CustomCheck && !opts.base_url_override_CustomCheck(o.base_url_override)) return new Error(`${path}.base_url_override: custom check failed`) + + return null +} + +export type EncryptionExchangeRequest = { + publicKey: string + deviceId: string +} +export const EncryptionExchangeRequestOptionalFields: [] = [] +export type EncryptionExchangeRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + publicKey_CustomCheck?: (v: string) => boolean + deviceId_CustomCheck?: (v: string) => boolean +} +export const EncryptionExchangeRequestValidate = (o?: EncryptionExchangeRequest, opts: EncryptionExchangeRequestOptions = {}, path: string = 'EncryptionExchangeRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.publicKey !== 'string') return new Error(`${path}.publicKey: is not a string`) + if (opts.publicKey_CustomCheck && !opts.publicKey_CustomCheck(o.publicKey)) return new Error(`${path}.publicKey: custom check failed`) + + if (typeof o.deviceId !== 'string') return new Error(`${path}.deviceId: is not a string`) + if (opts.deviceId_CustomCheck && !opts.deviceId_CustomCheck(o.deviceId)) return new Error(`${path}.deviceId: custom check failed`) + + return null +} + +export type AppUser = { + identifier: string + info: UserInfo + max_withdrawable: number +} +export const AppUserOptionalFields: [] = [] +export type AppUserOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + identifier_CustomCheck?: (v: string) => boolean + info_Options?: UserInfoOptions + max_withdrawable_CustomCheck?: (v: number) => boolean +} +export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.identifier !== 'string') return new Error(`${path}.identifier: is not a string`) + if (opts.identifier_CustomCheck && !opts.identifier_CustomCheck(o.identifier)) return new Error(`${path}.identifier: custom check failed`) + + const infoErr = UserInfoValidate(o.info, opts.info_Options, `${path}.info`) + if (infoErr !== null) return infoErr + + + if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`) + if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`) + + return null +} + +export type DecodeInvoiceResponse = { + amount: number +} +export const DecodeInvoiceResponseOptionalFields: [] = [] +export type DecodeInvoiceResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + amount_CustomCheck?: (v: number) => boolean +} +export const DecodeInvoiceResponseValidate = (o?: DecodeInvoiceResponse, opts: DecodeInvoiceResponseOptions = {}, path: string = 'DecodeInvoiceResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + +export type PayInvoiceRequest = { + invoice: string + amount: number +} +export const PayInvoiceRequestOptionalFields: [] = [] +export type PayInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const PayInvoiceRequestValidate = (o?: PayInvoiceRequest, opts: PayInvoiceRequestOptions = {}, path: string = 'PayInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + export type AuthUserRequest = { name: string secret: string @@ -1450,6 +1218,29 @@ export const AuthUserRequestValidate = (o?: AuthUserRequest, opts: AuthUserReque return null } +export type AuthUserResponse = { + userId: string + authToken: string +} +export const AuthUserResponseOptionalFields: [] = [] +export type AuthUserResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + userId_CustomCheck?: (v: string) => boolean + authToken_CustomCheck?: (v: string) => boolean +} +export const AuthUserResponseValidate = (o?: AuthUserResponse, opts: AuthUserResponseOptions = {}, path: string = 'AuthUserResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`) + if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`) + + if (typeof o.authToken !== 'string') return new Error(`${path}.authToken: is not a string`) + if (opts.authToken_CustomCheck && !opts.authToken_CustomCheck(o.authToken)) return new Error(`${path}.authToken: custom check failed`) + + return null +} + export type AddProductRequest = { name: string price_sats: number @@ -1473,3 +1264,246 @@ export const AddProductRequestValidate = (o?: AddProductRequest, opts: AddProduc return null } +export type SetMockInvoiceAsPaidRequest = { + invoice: string + amount: number +} +export const SetMockInvoiceAsPaidRequestOptionalFields: [] = [] +export type SetMockInvoiceAsPaidRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const SetMockInvoiceAsPaidRequestValidate = (o?: SetMockInvoiceAsPaidRequest, opts: SetMockInvoiceAsPaidRequestOptions = {}, path: string = 'SetMockInvoiceAsPaidRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + +export type AddAppUserInvoiceRequest = { + receiver_identifier: string + payer_identifier: string + http_callback_url: string + invoice_req: NewInvoiceRequest +} +export const AddAppUserInvoiceRequestOptionalFields: [] = [] +export type AddAppUserInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + receiver_identifier_CustomCheck?: (v: string) => boolean + payer_identifier_CustomCheck?: (v: string) => boolean + http_callback_url_CustomCheck?: (v: string) => boolean + invoice_req_Options?: NewInvoiceRequestOptions +} +export const AddAppUserInvoiceRequestValidate = (o?: AddAppUserInvoiceRequest, opts: AddAppUserInvoiceRequestOptions = {}, path: string = 'AddAppUserInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.receiver_identifier !== 'string') return new Error(`${path}.receiver_identifier: is not a string`) + if (opts.receiver_identifier_CustomCheck && !opts.receiver_identifier_CustomCheck(o.receiver_identifier)) return new Error(`${path}.receiver_identifier: custom check failed`) + + if (typeof o.payer_identifier !== 'string') return new Error(`${path}.payer_identifier: is not a string`) + if (opts.payer_identifier_CustomCheck && !opts.payer_identifier_CustomCheck(o.payer_identifier)) return new Error(`${path}.payer_identifier: custom check failed`) + + if (typeof o.http_callback_url !== 'string') return new Error(`${path}.http_callback_url: is not a string`) + if (opts.http_callback_url_CustomCheck && !opts.http_callback_url_CustomCheck(o.http_callback_url)) return new Error(`${path}.http_callback_url: custom check failed`) + + const invoice_reqErr = NewInvoiceRequestValidate(o.invoice_req, opts.invoice_req_Options, `${path}.invoice_req`) + if (invoice_reqErr !== null) return invoice_reqErr + + + return null +} + +export type PayAppUserInvoiceRequest = { + user_identifier: string + invoice: string + amount: number +} +export const PayAppUserInvoiceRequestOptionalFields: [] = [] +export type PayAppUserInvoiceRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + user_identifier_CustomCheck?: (v: string) => boolean + invoice_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const PayAppUserInvoiceRequestValidate = (o?: PayAppUserInvoiceRequest, opts: PayAppUserInvoiceRequestOptions = {}, path: string = 'PayAppUserInvoiceRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.user_identifier !== 'string') return new Error(`${path}.user_identifier: is not a string`) + if (opts.user_identifier_CustomCheck && !opts.user_identifier_CustomCheck(o.user_identifier)) return new Error(`${path}.user_identifier: custom check failed`) + + if (typeof o.invoice !== 'string') return new Error(`${path}.invoice: is not a string`) + if (opts.invoice_CustomCheck && !opts.invoice_CustomCheck(o.invoice)) return new Error(`${path}.invoice: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + +export type SendAppUserToAppPaymentRequest = { + from_user_identifier: string + amount: number +} +export const SendAppUserToAppPaymentRequestOptionalFields: [] = [] +export type SendAppUserToAppPaymentRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + from_user_identifier_CustomCheck?: (v: string) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const SendAppUserToAppPaymentRequestValidate = (o?: SendAppUserToAppPaymentRequest, opts: SendAppUserToAppPaymentRequestOptions = {}, path: string = 'SendAppUserToAppPaymentRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.from_user_identifier !== 'string') return new Error(`${path}.from_user_identifier: is not a string`) + if (opts.from_user_identifier_CustomCheck && !opts.from_user_identifier_CustomCheck(o.from_user_identifier)) return new Error(`${path}.from_user_identifier: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + +export type PayAddressRequest = { + address: string + amoutSats: number + targetConf: number +} +export const PayAddressRequestOptionalFields: [] = [] +export type PayAddressRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + address_CustomCheck?: (v: string) => boolean + amoutSats_CustomCheck?: (v: number) => boolean + targetConf_CustomCheck?: (v: number) => boolean +} +export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddressRequestOptions = {}, path: string = 'PayAddressRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`) + if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) + + if (typeof o.amoutSats !== 'number') return new Error(`${path}.amoutSats: is not a number`) + if (opts.amoutSats_CustomCheck && !opts.amoutSats_CustomCheck(o.amoutSats)) return new Error(`${path}.amoutSats: custom check failed`) + + if (typeof o.targetConf !== 'number') return new Error(`${path}.targetConf: is not a number`) + if (opts.targetConf_CustomCheck && !opts.targetConf_CustomCheck(o.targetConf)) return new Error(`${path}.targetConf: custom check failed`) + + return null +} + +export type PayAddressResponse = { + txId: string +} +export const PayAddressResponseOptionalFields: [] = [] +export type PayAddressResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + txId_CustomCheck?: (v: string) => boolean +} +export const PayAddressResponseValidate = (o?: PayAddressResponse, opts: PayAddressResponseOptions = {}, path: string = 'PayAddressResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.txId !== 'string') return new Error(`${path}.txId: is not a string`) + if (opts.txId_CustomCheck && !opts.txId_CustomCheck(o.txId)) return new Error(`${path}.txId: custom check failed`) + + return null +} + +export type OpenChannelRequest = { + destination: string + fundingAmount: number + pushAmount: number + closeAddress: string +} +export const OpenChannelRequestOptionalFields: [] = [] +export type OpenChannelRequestOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + destination_CustomCheck?: (v: string) => boolean + fundingAmount_CustomCheck?: (v: number) => boolean + pushAmount_CustomCheck?: (v: number) => boolean + closeAddress_CustomCheck?: (v: string) => boolean +} +export const OpenChannelRequestValidate = (o?: OpenChannelRequest, opts: OpenChannelRequestOptions = {}, path: string = 'OpenChannelRequest::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.destination !== 'string') return new Error(`${path}.destination: is not a string`) + if (opts.destination_CustomCheck && !opts.destination_CustomCheck(o.destination)) return new Error(`${path}.destination: custom check failed`) + + if (typeof o.fundingAmount !== 'number') return new Error(`${path}.fundingAmount: is not a number`) + if (opts.fundingAmount_CustomCheck && !opts.fundingAmount_CustomCheck(o.fundingAmount)) return new Error(`${path}.fundingAmount: custom check failed`) + + if (typeof o.pushAmount !== 'number') return new Error(`${path}.pushAmount: is not a number`) + if (opts.pushAmount_CustomCheck && !opts.pushAmount_CustomCheck(o.pushAmount)) return new Error(`${path}.pushAmount: custom check failed`) + + if (typeof o.closeAddress !== 'string') return new Error(`${path}.closeAddress: is not a string`) + if (opts.closeAddress_CustomCheck && !opts.closeAddress_CustomCheck(o.closeAddress)) return new Error(`${path}.closeAddress: custom check failed`) + + return null +} + +export type LnurlLinkResponse = { + lnurl: string + k1: string +} +export const LnurlLinkResponseOptionalFields: [] = [] +export type LnurlLinkResponseOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + lnurl_CustomCheck?: (v: string) => boolean + k1_CustomCheck?: (v: string) => boolean +} +export const LnurlLinkResponseValidate = (o?: LnurlLinkResponse, opts: LnurlLinkResponseOptions = {}, path: string = 'LnurlLinkResponse::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.lnurl !== 'string') return new Error(`${path}.lnurl: is not a string`) + if (opts.lnurl_CustomCheck && !opts.lnurl_CustomCheck(o.lnurl)) return new Error(`${path}.lnurl: custom check failed`) + + if (typeof o.k1 !== 'string') return new Error(`${path}.k1: is not a string`) + if (opts.k1_CustomCheck && !opts.k1_CustomCheck(o.k1)) return new Error(`${path}.k1: custom check failed`) + + return null +} + +export type UserOperation = { + paidAtUnix: number + type: UserOperationType + inbound: boolean + amount: number +} +export const UserOperationOptionalFields: [] = [] +export type UserOperationOptions = OptionsBaseMessage & { + checkOptionalsAreSet?: [] + paidAtUnix_CustomCheck?: (v: number) => boolean + type_CustomCheck?: (v: UserOperationType) => boolean + inbound_CustomCheck?: (v: boolean) => boolean + amount_CustomCheck?: (v: number) => boolean +} +export const UserOperationValidate = (o?: UserOperation, opts: UserOperationOptions = {}, path: string = 'UserOperation::root.'): Error | null => { + if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') + if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null') + + if (typeof o.paidAtUnix !== 'number') return new Error(`${path}.paidAtUnix: is not a number`) + if (opts.paidAtUnix_CustomCheck && !opts.paidAtUnix_CustomCheck(o.paidAtUnix)) return new Error(`${path}.paidAtUnix: custom check failed`) + + if (!enumCheckUserOperationType(o.type)) return new Error(`${path}.type: is not a valid UserOperationType`) + if (opts.type_CustomCheck && !opts.type_CustomCheck(o.type)) return new Error(`${path}.type: custom check failed`) + + if (typeof o.inbound !== 'boolean') return new Error(`${path}.inbound: is not a boolean`) + if (opts.inbound_CustomCheck && !opts.inbound_CustomCheck(o.inbound)) return new Error(`${path}.inbound: custom check failed`) + + if (typeof o.amount !== 'number') return new Error(`${path}.amount: is not a number`) + if (opts.amount_CustomCheck && !opts.amount_CustomCheck(o.amount)) return new Error(`${path}.amount: custom check failed`) + + return null +} + diff --git a/proto/protoc-gen-pub b/proto/protoc-gen-pub index fe77f433..8b282494 100755 Binary files a/proto/protoc-gen-pub and b/proto/protoc-gen-pub differ diff --git a/proto/service/methods.proto b/proto/service/methods.proto index a1eb4df4..990f9eee 100644 --- a/proto/service/methods.proto +++ b/proto/service/methods.proto @@ -96,7 +96,7 @@ service LightningPub { // - rpc AddApp(structs.AuthAppRequest) returns (structs.AuthApp) { + rpc AddApp(structs.AddAppRequest) returns (structs.AuthApp) { option (auth_type) = "Admin"; option (http_method) = "post"; option (http_route) = "/api/admin/app/add"; @@ -184,13 +184,13 @@ service LightningPub { option (http_method) = "post"; option (http_route) = "/api/user/auth"; } + // USER rpc GetUserInfo(structs.Empty)returns(structs.UserInfo){ option (auth_type) = "User"; option (http_method) = "post"; option (http_route) = "/api/user/info"; option (nostr) = true; } - // USER rpc AddProduct(structs.AddProductRequest) returns (structs.Product){ option (auth_type) = "User"; option (http_method) = "post"; diff --git a/proto/service/structs.proto b/proto/service/structs.proto index 95495a77..d50b3a43 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -25,15 +25,23 @@ message LndGetInfoResponse { string alias = 1; } +message AddAppRequest { + string name = 1; + bool allow_user_creation = 2; +} + message AuthAppRequest { string name = 1; + optional bool allow_user_creation = 2; } message Application { string name = 1; string id = 2; int64 balance = 3; + string npub = 4; } + message AuthApp { Application app = 1; string auth_token = 2; @@ -212,6 +220,7 @@ message UserInfo{ string userId = 1; int64 balance = 2; } + message GetUserOperationsRequest{ int64 latestIncomingInvoice = 1; int64 latestOutgoingInvoice = 2; @@ -229,7 +238,7 @@ enum UserOperationType { INCOMING_USER_TO_USER=5; } -message UserOperation{ +message UserOperation { int64 paidAtUnix=1; UserOperationType type = 2; bool inbound =3; diff --git a/src/index.spec.ts b/src/index.spec.ts deleted file mode 100644 index e28de54e..00000000 --- a/src/index.spec.ts +++ /dev/null @@ -1,140 +0,0 @@ -import 'dotenv/config' // TODO - test env -import crypto from 'crypto'; -import { generatePrivateKey, getPublicKey } from 'nostr-tools'; -import NewServer from '../proto/autogenerated/ts/express_server.js' -import NewClient from '../proto/autogenerated/ts/http_client.js' -import serverOptions from './auth.js'; -import GetServerMethods from './services/serverMethods/index.js' -import Main, { LoadMainSettingsFromEnv } from './services/main/index.js' -import * as Types from '../proto/autogenerated/ts/types.js'; -import nostrMiddleware from './nostrMiddleware.js' -import { LoadNosrtSettingsFromEnv } from './services/nostr/index.js'; -import { expect } from 'chai'; -import NostrHandler from './services/nostr/index.js' -import NewNostrClient from '../proto/autogenerated/ts/nostr_client.js' -import { NostrRequest } from '../proto/autogenerated/ts/nostr_transport.js'; - - -const settings = LoadNosrtSettingsFromEnv(true) - -const clientPrivateKey = generatePrivateKey() -const clientPublicKey = getPublicKey(clientPrivateKey) - -const serverPrivateKey = generatePrivateKey() -const serverPublicKey = getPublicKey(serverPrivateKey) - -const testPort = 4000 -var userAuthHeader = "" -const client = NewClient({ - baseUrl: `http://localhost:${testPort}`, - retrieveAdminAuth: async () => (""), - retrieveGuestAuth: async () => (""), - retrieveUserAuth: async () => userAuthHeader, - retrieveAppAuth: async () => (""), - decryptCallback: async (b) => b, - encryptCallback: async (b) => b, - deviceId: "device0" -}) -const clientCbs: Record void> = {} -const clientNostrHandler = new NostrHandler({ - allowedPubs: [], - privateKey: clientPrivateKey, - publicKey: clientPublicKey, - relays: settings.relays -}, (e) => { - const res = JSON.parse(e.content) as { requestId: string } - if (clientCbs[res.requestId]) { - const cb = clientCbs[res.requestId] - cb(res) - delete clientCbs[res.requestId] - } -}) -const clientSend = (to: string, message: NostrRequest): Promise => { - console.log("sending", message) - if (!message.requestId) { - message.requestId = crypto.randomBytes(20).toString('hex') - } - const reqId = message.requestId - if (clientCbs[reqId]) { - throw new Error("request was already sent") - } - clientNostrHandler.Send(to, JSON.stringify(message)) - return new Promise(res => { - clientCbs[reqId] = (response: any) => { - res(response) - } - }) -} -const clientNostr = NewNostrClient({ - pubDestination: serverPublicKey, - retrieveNostrUserAuth: async () => { return clientPublicKey } -}, clientSend) -/* new NostrHandler({ - allowedPubs: [], - privateKey: clientPrivateKey, - publicKey: clientPublicKey, - relays: settings.relays -}, (event) => { - console.log(event.content) -})*/ -const mainSettings = LoadMainSettingsFromEnv(true) -const mainHandler = new Main(mainSettings) // TODO - test env file -const serverMethods = GetServerMethods(mainHandler) -const serverNostr = nostrMiddleware(serverMethods, mainHandler, { - allowedPubs: [clientPublicKey], - privateKey: serverPrivateKey, - publicKey: serverPublicKey, - relays: settings.relays -}) -const server = NewServer(serverMethods, { ...serverOptions(mainHandler), throwErrors: true }) -export const ignore = false - -export const setup = async () => { - await mainHandler.storage.Connect() - await mainHandler.lnd.Warmup() - server.Listen(testPort) -} -export const teardown = async () => { - clientNostrHandler.Stop() - serverNostr.Stop() - mainHandler.lnd.Stop() - server.Close() -} - - -export default async (d: (message: string, failure?: boolean) => void) => { - await client.Health() - d("health ok") - - console.log(await client.LndGetInfo({ nodeId: 0 })) - d("lnd info ok") - - const res = await client.AddUser({ name: "test", callbackUrl: "http://...", secret: "shhhhhht" }) - if (res.status === 'ERROR') throw new Error(res.reason) - console.log(res) - const user = await mainHandler.storage.userStorage.GetUser(res.userId) - console.log(user) - userAuthHeader = res.authToken - d("create user ok") - - console.log(await client.NewAddress({ addressType: Types.AddressType.WITNESS_PUBKEY_HASH })) - d("new address ok") - await new Promise(res => setTimeout(res, 2000)) - //clientNostr.Send(serverPublicKey, JSON.stringify({ requestId: "a", method: '/api/user/chain/new', body: { address_type: 'WITNESS_PUBKEY_HASH' } })) - const nostrRes = await clientNostr.NewAddress({ addressType: Types.AddressType.WITNESS_PUBKEY_HASH }) - console.log(nostrRes) - d("nostr ok") - const lnurlWithdrawLink = await client.GetLnurlWithdrawLink() - if (lnurlWithdrawLink.status === 'ERROR') throw new Error(lnurlWithdrawLink.reason) - const lnurlWithdrawInfo = await client.GetLnurlWithdrawInfo({ k1: lnurlWithdrawLink.k1 }) - const expectedInfo: Partial & { status: 'OK' } = { - status: 'OK', - tag: "withdrawRequest", - defaultDescription: "lnurl withdraw from lightning.pub", - maxWithdrawable: 0, - minWithdrawable: 0, - } - expect(lnurlWithdrawInfo).to.deep.include(expectedInfo) - d("lnurl info ok") - -} diff --git a/src/index.ts b/src/index.ts index d9f21f9a..78b27e4a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,17 @@ const start = async () => { await mainHandler.lnd.Warmup() const serverMethods = GetServerMethods(mainHandler) const nostrSettings = LoadNosrtSettingsFromEnv() - nostrMiddleware(serverMethods, mainHandler, nostrSettings) + const appsData = await mainHandler.storage.applicationStorage.GetApplications() + + const apps = await Promise.all(appsData.map(app => { + if (!app.nostr_private_key) { // TMP -- + return mainHandler.storage.applicationStorage.GenerateApplicationKeys(app); + } // -- + else { + return { privateKey: app.nostr_private_key, publicKey: app.nostr_public_key, appId: app.app_id, name: app.name } + } + })) + nostrMiddleware(serverMethods, mainHandler, { ...nostrSettings, apps }) const Server = NewServer(serverMethods, serverOptions(mainHandler)) if (process.argv[2] === 'unlock') { const u = process.argv[3] diff --git a/src/nostrMiddleware.ts b/src/nostrMiddleware.ts index 368590e6..1946a320 100644 --- a/src/nostrMiddleware.ts +++ b/src/nostrMiddleware.ts @@ -7,14 +7,10 @@ const handledRequests: string[] = [] // TODO: - big memory leak here, add TTL export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSettings: NostrSettings) => { const nostrTransport = NewNostrTransport(serverMethods, { - NostrUserAuthGuard: async pub => { - if (!pub || !nostrSettings.allowedPubs.includes(pub)) { - throw new Error("nostr pub invalid or not allowed" + pub) - } - let nostrUser = await mainHandler.storage.userStorage.FindNostrUser(pub) - if (!nostrUser) { // TODO: add POW - nostrUser = await mainHandler.storage.userStorage.AddNostrUser(pub) - } + NostrUserAuthGuard: async (appId, pub) => { + console.log({ appId }) + const app = await mainHandler.storage.applicationStorage.GetApplication(appId || "") + let nostrUser = await mainHandler.storage.applicationStorage.GetOrCreateNostrAppUser(app, pub || "") return { user_id: nostrUser.user.user_id } } }) @@ -27,8 +23,8 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett console.error("invalid json event received", event.content) return } - nostrTransport(j, res => { - nostr.Send(event.pub, JSON.stringify({ ...res, requestId: j.requestId })) + nostrTransport({ ...j, appId: event.appId }, res => { + nostr.Send(event.appId, event.pub, JSON.stringify({ ...res, requestId: j.requestId })) }) }) return { Stop: nostr.Stop } diff --git a/src/services/main/applicationManager.ts b/src/services/main/applicationManager.ts index 8af7fe4b..9a1124e5 100644 --- a/src/services/main/applicationManager.ts +++ b/src/services/main/applicationManager.ts @@ -47,15 +47,16 @@ export default class { } - async AddApp(req: Types.AuthAppRequest): Promise { - const app = await this.storage.applicationStorage.AddApplication(req.name) + async AddApp(req: Types.AddAppRequest): Promise { + const app = await this.storage.applicationStorage.AddApplication(req.name, req.allow_user_creation) getLogger({ appName: app.name })("app created") return { app: { id: app.app_id, name: app.name, - balance: app.owner.balance_sats + balance: app.owner.balance_sats, + npub: app.nostr_public_key }, auth_token: this.SignAppToken(app.app_id) } @@ -63,11 +64,15 @@ export default class { async AuthApp(req: Types.AuthAppRequest): Promise { const app = await this.storage.applicationStorage.GetApplicationByName(req.name) + if (typeof req.allow_user_creation === 'boolean') { + await this.storage.applicationStorage.UpdateApplication(app, { allow_user_creation: req.allow_user_creation }) + } return { app: { id: app.app_id, name: app.name, - balance: app.owner.balance_sats + balance: app.owner.balance_sats, + npub: app.nostr_public_key }, auth_token: this.SignAppToken(app.app_id) } @@ -78,7 +83,8 @@ export default class { return { name: app.name, id: app.app_id, - balance: app.owner.balance_sats + balance: app.owner.balance_sats, + npub: app.nostr_public_key } } diff --git a/src/services/main/userManager.ts b/src/services/main/userManager.ts index 84a14914..462bc369 100644 --- a/src/services/main/userManager.ts +++ b/src/services/main/userManager.ts @@ -15,8 +15,7 @@ export default class { } DecodeUserToken(token?: string): string { - throw new Error("users methods temporarely disabled") - /*if (!token) throw new Error("empty user token provided") + if (!token) throw new Error("empty user token provided") let t = token if (token.startsWith("Bearer ")) { t = token.substring("Bearer ".length) @@ -26,7 +25,7 @@ export default class { if (!decoded.userId) { throw new Error("the provided token is not an app token") } - return decoded.userId*/ + return decoded.userId } async AddBasicUser(req: Types.AddUserRequest): Promise { diff --git a/src/services/nostr/handler.ts b/src/services/nostr/handler.ts index 052e8394..5cb65d2f 100644 --- a/src/services/nostr/handler.ts +++ b/src/services/nostr/handler.ts @@ -1,15 +1,17 @@ -import { SimplePool, Sub, Event, UnsignedEvent, nip04, getEventHash, signEvent } from 'nostr-tools' +//import { SimplePool, Sub, Event, UnsignedEvent, getEventHash, signEvent } from 'nostr-tools' +import { SimplePool, Sub, Event, UnsignedEvent, getEventHash, finishEvent, relayInit } from './tools/index.js' +import { encryptData, decryptData, getSharedSecret, decodePayload, encodePayload } from './nip44.js' const handledEvents: string[] = [] // TODO: - big memory leak here, add TTL +type AppInfo = { appId: string, publicKey: string, privateKey: string, name: string } export type NostrSettings = { - privateKey: string - publicKey: string + apps: AppInfo[] relays: string[] - allowedPubs: string[] } export type NostrEvent = { id: string pub: string content: string + appId: string } type SettingsRequest = { type: 'settings' @@ -18,6 +20,7 @@ type SettingsRequest = { type SendRequest = { type: 'send' + appId: string pub: string message: string } @@ -43,7 +46,7 @@ process.on("message", (message: ChildProcessRequest) => { initSubprocessHandler(message.settings) break case 'send': - sendToNostr(message.pub, message.message) + sendToNostr(message.appId, message.pub, message.message) break default: console.error("unknown nostr request", message) @@ -62,30 +65,47 @@ const initSubprocessHandler = (settings: NostrSettings) => { }) }) } -const sendToNostr = (pub: string, message: string) => { +const sendToNostr = (appId: string, pub: string, message: string) => { if (!subProcessHandler) { console.error("nostr was not initialized") return } - subProcessHandler.Send(pub, message) + subProcessHandler.Send(appId, pub, message) } send({ type: 'ready' }) export default class Handler { pool = new SimplePool() settings: NostrSettings - sub: Sub + subs: Sub[] = [] constructor(settings: NostrSettings, eventCallback: (event: NostrEvent) => void) { this.settings = settings console.log(settings) - this.sub = this.pool.sub(settings.relays, [ + this.settings.apps.forEach(app => { + this.SubForApp(app, eventCallback) + }) + } + + async SubForApp(appInfo: AppInfo, eventCallback: (event: NostrEvent) => void) { + const relay = relayInit(this.settings.relays[0]) + relay.on('connect', () => { + console.log(`connected to ${relay.url}`) + }) + relay.on('error', () => { + console.log(`failed to connect to ${relay.url}`) + }) + + await relay.connect() + console.log("relay connected") + const sub = relay.sub([ { since: Math.ceil(Date.now() / 1000), kinds: [4], - '#p': [settings.publicKey], + '#p': [appInfo.publicKey], } ]) - this.sub.on("event", async (e) => { + sub.on("event", async (e) => { + console.log({ nostrEvent: e }) if (e.kind !== 4 || !e.pubkey) { return } @@ -96,22 +116,47 @@ export default class Handler { return } handledEvents.push(eventId) - eventCallback({ id: eventId, content: await nip04.decrypt(this.settings.privateKey, e.pubkey, e.content), pub: e.pubkey }) + const decoded = decodePayload(e.content) + const content = await decryptData(decoded, getSharedSecret(appInfo.privateKey, e.pubkey)) + eventCallback({ id: eventId, content, pub: e.pubkey, appId: appInfo.appId }) + //eventCallback({ id: eventId, content: await nip04.decrypt(appInfo.privateKey, e.pubkey, e.content), pub: e.pubkey, appId: appInfo.appId }) + }) + this.subs.push(sub) + } + + async Send(appId: string, pubKey: string, message: string) { + const appInfo = this.GetAppKeys({ appId }) + const decoded = await encryptData(message, getSharedSecret(appInfo.privateKey, pubKey)) + const content = encodePayload(decoded) + const event: UnsignedEvent = { + content, + created_at: Math.floor(Date.now() / 1000), + kind: 4, + pubkey: appInfo.publicKey, + tags: [['p', pubKey]], + } + const signed = finishEvent(event, appInfo.privateKey) + this.pool.publish(this.settings.relays, signed).forEach(p => { + p.then(() => console.log("sent ok")) + p.catch(() => console.log("failed to send")) }) } - async Send(nostrPub: string, message: string) { - const event: UnsignedEvent = { - content: await nip04.encrypt(this.settings.privateKey, nostrPub, message), - created_at: Math.floor(Date.now() / 1000), - kind: 4, - pubkey: this.settings.publicKey, - tags: [['p', nostrPub]], + GetAppKeys(appInfo: Partial) { + let check: (info: AppInfo) => boolean + if (appInfo.appId) { + check = (info: AppInfo) => info.appId === appInfo.appId + } else if (appInfo.privateKey) { + check = (info: AppInfo) => info.privateKey === appInfo.privateKey + } else if (appInfo.publicKey) { + check = (info: AppInfo) => info.publicKey === appInfo.publicKey + } else { + throw new Error("app info is empty") } - const eventId = getEventHash(event) - const sign = signEvent(event, this.settings.privateKey) - const op = this.pool.publish(this.settings.relays, - { ...event, id: eventId, sig: sign }) - op.on('failed', (reason: string) => { console.log('failed to send message cuz: ', reason) }) + const found = this.settings.apps.find(check) + if (!found) { + throw new Error("unkown app") + } + return found } } \ No newline at end of file diff --git a/src/services/nostr/index.spec.ts b/src/services/nostr/index.spec.ts deleted file mode 100644 index 72dfbf4c..00000000 --- a/src/services/nostr/index.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import 'dotenv/config' // TODO - test env -import { Buffer } from 'buffer' -import { generatePrivateKey, getPublicKey } from 'nostr-tools' - -import NostrHandler, { LoadNosrtSettingsFromEnv } from './index.js' -import { expect } from 'chai' -export const ignore = true -const settings = LoadNosrtSettingsFromEnv(true) - -const clientPrivateKey = generatePrivateKey() -const clientPublicKey = getPublicKey(clientPrivateKey) - -const serverPrivateKey = generatePrivateKey() -const serverPublicKey = getPublicKey(serverPrivateKey) -let clientNostr: NostrHandler -let serverNostr: NostrHandler - -let receivedServerEvents = 0 -let latestReceivedServerEvent = "" -export const setup = () => { - clientNostr = new NostrHandler({ - allowedPubs: [], - privateKey: clientPrivateKey, - publicKey: clientPublicKey, - relays: settings.relays - }, (event) => { - - }) - serverNostr = new NostrHandler({ - allowedPubs: [clientPublicKey], - privateKey: serverPrivateKey, - publicKey: serverPublicKey, - relays: settings.relays - }, (event) => { - receivedServerEvents++ - latestReceivedServerEvent = event.content - }) -} -export const teardown = () => { - clientNostr.Stop() - serverNostr.Stop() -} - -export default async (d: (message: string, failure?: boolean) => void) => { - await new Promise(res => setTimeout(res, 2000)) - clientNostr.Send(serverPublicKey, "test") - await new Promise(res => setTimeout(res, 1000)) - console.log(receivedServerEvents, latestReceivedServerEvent) - expect(receivedServerEvents).to.equal(1) - expect(latestReceivedServerEvent).to.equal("test") - d("nostr ok") -} \ No newline at end of file diff --git a/src/services/nostr/index.ts b/src/services/nostr/index.ts index b8dbe7c1..b7acb046 100644 --- a/src/services/nostr/index.ts +++ b/src/services/nostr/index.ts @@ -4,9 +4,6 @@ import { NostrSettings, NostrEvent, ChildProcessRequest, ChildProcessResponse } type EventCallback = (event: NostrEvent) => void export const LoadNosrtSettingsFromEnv = (test = false) => { return { - allowedPubs: EnvMustBeNonEmptyString("NOSTR_ALLOWED_PUBS").split(' '), - privateKey: EnvMustBeNonEmptyString("NOSTR_PRIVATE_KEY"), - publicKey: EnvMustBeNonEmptyString("NOSTR_PUBLIC_KEY"), relays: EnvMustBeNonEmptyString("NOSTR_RELAYS").split(' ') } } @@ -34,8 +31,8 @@ export default class NostrSubprocess { this.childProcess.send(message) } - Send(pub: string, message: string) { - this.sendToChildProcess({ type: 'send', pub: pub, message: message }) + Send(appId: string, pub: string, message: string) { + this.sendToChildProcess({ type: 'send', pub, message, appId }) } Stop() { this.childProcess.kill() diff --git a/src/services/nostr/nip44.ts b/src/services/nostr/nip44.ts new file mode 100644 index 00000000..80eea903 --- /dev/null +++ b/src/services/nostr/nip44.ts @@ -0,0 +1,55 @@ +import { base64 } from "@scure/base"; +import { randomBytes } from "@noble/hashes/utils"; +import { streamXOR as xchacha20 } from "@stablelib/xchacha20"; +import { secp256k1 } from "@noble/curves/secp256k1"; +import { sha256 } from "@noble/hashes/sha256"; +type EncryptedData = { + ciphertext: Uint8Array; + nonce: Uint8Array; +} +export const getSharedSecret = (privateKey: string, publicKey: string) => { + const key = secp256k1.getSharedSecret(privateKey, "02" + publicKey); + return sha256(key.slice(1, 33)); +} + +export const encryptData = (content: string, sharedSecret: Uint8Array) => { + const nonce = randomBytes(24); + const plaintext = new TextEncoder().encode(content); + const ciphertext = xchacha20(sharedSecret, nonce, plaintext, plaintext); + return { + ciphertext: Uint8Array.from(ciphertext), + nonce: nonce, + } as EncryptedData; +} + +export const decryptData = (payload: EncryptedData, sharedSecret: Uint8Array) => { + const dst = xchacha20(sharedSecret, payload.nonce, payload.ciphertext, payload.ciphertext); + const decoded = new TextDecoder().decode(dst); + return decoded; +} +const xchacha20EncryptionVersion = 1 +export const decodePayload = (p: string) => { + if (p.startsWith("{") && p.endsWith("}")) { + const pj = JSON.parse(p) as { v: number; nonce: string; ciphertext: string }; + if (pj.v !== xchacha20EncryptionVersion) { + throw new Error("Encryption version unsupported") + } + return { + nonce: base64.decode(pj.nonce), + ciphertext: base64.decode(pj.ciphertext), + } as EncryptedData; + } else { + const buf = base64.decode(p); + if (buf[0] !== xchacha20EncryptionVersion) { + throw new Error("Encryption version unsupported") + } + return { + nonce: buf.subarray(1, 25), + ciphertext: buf.subarray(25), + } as EncryptedData; + } +} + +export const encodePayload = (p: EncryptedData) => { + return base64.encode(new Uint8Array([xchacha20EncryptionVersion, ...p.nonce, ...p.ciphertext])); +} \ No newline at end of file diff --git a/src/services/nostr/tools/event.ts b/src/services/nostr/tools/event.ts new file mode 100644 index 00000000..57908e2c --- /dev/null +++ b/src/services/nostr/tools/event.ts @@ -0,0 +1,144 @@ +import { schnorr } from '@noble/curves/secp256k1' +import { sha256 } from '@noble/hashes/sha256' +import { bytesToHex } from '@noble/hashes/utils' + +import { getPublicKey } from './keys.js' +import { utf8Encoder } from './utils.js' + +/** Designates a verified event signature. */ +export const verifiedSymbol = Symbol('verified') + +/** @deprecated Use numbers instead. */ +/* eslint-disable no-unused-vars */ +export enum Kind { + Metadata = 0, + Text = 1, + RecommendRelay = 2, + Contacts = 3, + EncryptedDirectMessage = 4, + EventDeletion = 5, + Repost = 6, + Reaction = 7, + BadgeAward = 8, + ChannelCreation = 40, + ChannelMetadata = 41, + ChannelMessage = 42, + ChannelHideMessage = 43, + ChannelMuteUser = 44, + Blank = 255, + Report = 1984, + ZapRequest = 9734, + Zap = 9735, + RelayList = 10002, + ClientAuth = 22242, + HttpAuth = 27235, + ProfileBadge = 30008, + BadgeDefinition = 30009, + Article = 30023, + FileMetadata = 1063, +} + +export interface Event { + kind: K + tags: string[][] + content: string + created_at: number + pubkey: string + id: string + sig: string + [verifiedSymbol]?: boolean +} + +export type EventTemplate = Pick, 'kind' | 'tags' | 'content' | 'created_at'> +export type UnsignedEvent = Pick< + Event, + 'kind' | 'tags' | 'content' | 'created_at' | 'pubkey' +> + +/** An event whose signature has been verified. */ +export interface VerifiedEvent extends Event { + [verifiedSymbol]: true +} + +export function getBlankEvent(): EventTemplate +export function getBlankEvent(kind: K): EventTemplate +export function getBlankEvent(kind: K | Kind.Blank = Kind.Blank) { + return { + kind, + content: '', + tags: [], + created_at: 0, + } +} + +export function finishEvent(t: EventTemplate, privateKey: string): VerifiedEvent { + const event = t as VerifiedEvent + event.pubkey = getPublicKey(privateKey) + event.id = getEventHash(event) + event.sig = getSignature(event, privateKey) + event[verifiedSymbol] = true + return event +} + +export function serializeEvent(evt: UnsignedEvent): string { + if (!validateEvent(evt)) throw new Error("can't serialize event with wrong or missing properties") + + return JSON.stringify([0, evt.pubkey, evt.created_at, evt.kind, evt.tags, evt.content]) +} + +export function getEventHash(event: UnsignedEvent): string { + let eventHash = sha256(utf8Encoder.encode(serializeEvent(event))) + return bytesToHex(eventHash) +} + +const isRecord = (obj: unknown): obj is Record => obj instanceof Object + +export function validateEvent(event: T): event is T & UnsignedEvent { + if (!isRecord(event)) return false + if (typeof event.kind !== 'number') return false + if (typeof event.content !== 'string') return false + if (typeof event.created_at !== 'number') return false + if (typeof event.pubkey !== 'string') return false + if (!event.pubkey.match(/^[a-f0-9]{64}$/)) return false + + if (!Array.isArray(event.tags)) return false + for (let i = 0; i < event.tags.length; i++) { + let tag = event.tags[i] + if (!Array.isArray(tag)) return false + for (let j = 0; j < tag.length; j++) { + if (typeof tag[j] === 'object') return false + } + } + + return true +} + +/** Verify the event's signature. This function mutates the event with a `verified` symbol, making it idempotent. */ +export function verifySignature(event: Event): event is VerifiedEvent { + //@ts-ignore + if (typeof event[verifiedSymbol] === 'boolean') return event[verifiedSymbol] + + const hash = getEventHash(event) + if (hash !== event.id) { + return (event[verifiedSymbol] = false) + } + + try { + return (event[verifiedSymbol] = schnorr.verify(event.sig, hash, event.pubkey)) + } catch (err) { + return (event[verifiedSymbol] = false) + } +} + +/** @deprecated Use `getSignature` instead. */ +export function signEvent(event: UnsignedEvent, key: string): string { + console.warn( + 'nostr-tools: `signEvent` is deprecated and will be removed or changed in the future. Please use `getSignature` instead.', + ) + return getSignature(event, key) +} + +/** Calculate the signature for an event. */ +export function getSignature(event: UnsignedEvent, key: string): string { + return bytesToHex(schnorr.sign(getEventHash(event), key)) +} \ No newline at end of file diff --git a/src/services/nostr/tools/fakejson.ts b/src/services/nostr/tools/fakejson.ts new file mode 100644 index 00000000..7e710ed0 --- /dev/null +++ b/src/services/nostr/tools/fakejson.ts @@ -0,0 +1,41 @@ +export function getHex64(json: string, field: string): string { + let len = field.length + 3 + let idx = json.indexOf(`"${field}":`) + len + let s = json.slice(idx).indexOf(`"`) + idx + 1 + return json.slice(s, s + 64) +} + +export function getInt(json: string, field: string): number { + let len = field.length + let idx = json.indexOf(`"${field}":`) + len + 3 + let sliced = json.slice(idx) + let end = Math.min(sliced.indexOf(','), sliced.indexOf('}')) + return parseInt(sliced.slice(0, end), 10) +} + +export function getSubscriptionId(json: string): string | null { + let idx = json.slice(0, 22).indexOf(`"EVENT"`) + if (idx === -1) return null + + let pstart = json.slice(idx + 7 + 1).indexOf(`"`) + if (pstart === -1) return null + let start = idx + 7 + 1 + pstart + + let pend = json.slice(start + 1, 80).indexOf(`"`) + if (pend === -1) return null + let end = start + 1 + pend + + return json.slice(start + 1, end) +} + +export function matchEventId(json: string, id: string): boolean { + return id === getHex64(json, 'id') +} + +export function matchEventPubkey(json: string, pubkey: string): boolean { + return pubkey === getHex64(json, 'pubkey') +} + +export function matchEventKind(json: string, kind: number): boolean { + return kind === getInt(json, 'kind') +} \ No newline at end of file diff --git a/src/services/nostr/tools/filter.ts b/src/services/nostr/tools/filter.ts new file mode 100644 index 00000000..f93c37e6 --- /dev/null +++ b/src/services/nostr/tools/filter.ts @@ -0,0 +1,72 @@ +import { Event } from './event.js' + +export type Filter = { + ids?: string[] + kinds?: K[] + authors?: string[] + since?: number + until?: number + limit?: number + search?: string + [key: `#${string}`]: string[] | undefined +} + +export function matchFilter(filter: Filter, event: Event): boolean { + if (filter.ids && filter.ids.indexOf(event.id) === -1) { + if (!filter.ids.some(prefix => event.id.startsWith(prefix))) { + return false + } + } + if (filter.kinds && filter.kinds.indexOf(event.kind) === -1) return false + if (filter.authors && filter.authors.indexOf(event.pubkey) === -1) { + if (!filter.authors.some(prefix => event.pubkey.startsWith(prefix))) { + return false + } + } + + for (let f in filter) { + if (f[0] === '#') { + let tagName = f.slice(1) + let values = filter[`#${tagName}`] + if (values && !event.tags.find(([t, v]) => t === f.slice(1) && values!.indexOf(v) !== -1)) return false + } + } + + if (filter.since && event.created_at < filter.since) return false + if (filter.until && event.created_at > filter.until) return false + + return true +} + +export function matchFilters(filters: Filter[], event: Event): boolean { + for (let i = 0; i < filters.length; i++) { + if (matchFilter(filters[i], event)) return true + } + return false +} + +export function mergeFilters(...filters: Filter[]): Filter { + let result: Filter = {} + for (let i = 0; i < filters.length; i++) { + let filter = filters[i] + Object.entries(filter).forEach(([property, values]) => { + if (property === 'kinds' || property === 'ids' || property === 'authors' || property[0] === '#') { + // @ts-ignore + result[property] = result[property] || [] + // @ts-ignore + for (let v = 0; v < values.length; v++) { + // @ts-ignore + let value = values[v] + // @ts-ignore + if (!result[property].includes(value)) result[property].push(value) + } + } + }) + + if (filter.limit && (!result.limit || filter.limit > result.limit)) result.limit = filter.limit + if (filter.until && (!result.until || filter.until > result.until)) result.until = filter.until + if (filter.since && (!result.since || filter.since < result.since)) result.since = filter.since + } + + return result +} \ No newline at end of file diff --git a/src/services/nostr/tools/index.ts b/src/services/nostr/tools/index.ts new file mode 100644 index 00000000..3e7e0518 --- /dev/null +++ b/src/services/nostr/tools/index.ts @@ -0,0 +1,7 @@ +export * from './event.js' +export * from './fakejson.js' +export * from './filter.js' +export * from './keys.js' +export * from './pool.js' +export * from './relay.js' +export * from './utils.js' diff --git a/src/services/nostr/tools/keys.ts b/src/services/nostr/tools/keys.ts new file mode 100644 index 00000000..18b3aff3 --- /dev/null +++ b/src/services/nostr/tools/keys.ts @@ -0,0 +1,10 @@ +import { schnorr } from '@noble/curves/secp256k1' +import { bytesToHex } from '@noble/hashes/utils' + +export function generatePrivateKey(): string { + return bytesToHex(schnorr.utils.randomPrivateKey()) +} + +export function getPublicKey(privateKey: string): string { + return bytesToHex(schnorr.getPublicKey(privateKey)) +} \ No newline at end of file diff --git a/src/services/nostr/tools/pool.ts b/src/services/nostr/tools/pool.ts new file mode 100644 index 00000000..efdd177a --- /dev/null +++ b/src/services/nostr/tools/pool.ts @@ -0,0 +1,249 @@ +import { relayInit, eventsGenerator, type Relay, type Sub, type SubscriptionOptions } from './relay.js' +import { normalizeURL } from './utils.js' + +import type { Event } from './event.js' +import { matchFilters, type Filter } from './filter.js' + +type BatchedRequest = { + filters: Filter[] + relays: string[] + resolve: (events: Event[]) => void + events: Event[] +} + +export class SimplePool { + private _conn: { [url: string]: Relay } + private _seenOn: { [id: string]: Set } = {} // a map of all events we've seen in each relay + private batchedByKey: { [batchKey: string]: BatchedRequest[] } = {} + + private eoseSubTimeout: number + private getTimeout: number + private seenOnEnabled: boolean = true + private batchInterval: number = 100 + + constructor( + options: { + eoseSubTimeout?: number + getTimeout?: number + seenOnEnabled?: boolean + batchInterval?: number + } = {}, + ) { + this._conn = {} + this.eoseSubTimeout = options.eoseSubTimeout || 3400 + this.getTimeout = options.getTimeout || 3400 + this.seenOnEnabled = options.seenOnEnabled !== false + this.batchInterval = options.batchInterval || 100 + } + + close(relays: string[]): void { + relays.forEach(url => { + let relay = this._conn[normalizeURL(url)] + if (relay) relay.close() + }) + } + + async ensureRelay(url: string): Promise { + const nm = normalizeURL(url) + + if (!this._conn[nm]) { + this._conn[nm] = relayInit(nm, { + getTimeout: this.getTimeout * 0.9, + listTimeout: this.getTimeout * 0.9, + }) + } + + const relay = this._conn[nm] + await relay.connect() + return relay + } + + sub(relays: string[], filters: Filter[], opts?: SubscriptionOptions): Sub { + let _knownIds: Set = new Set() + let modifiedOpts = { ...(opts || {}) } + modifiedOpts.alreadyHaveEvent = (id, url) => { + if (opts?.alreadyHaveEvent?.(id, url)) { + return true + } + if (this.seenOnEnabled) { + let set = this._seenOn[id] || new Set() + set.add(url) + this._seenOn[id] = set + } + return _knownIds.has(id) + } + + let subs: Sub[] = [] + let eventListeners: Set = new Set() + let eoseListeners: Set<() => void> = new Set() + let eosesMissing = relays.length + + let eoseSent = false + let eoseTimeout = setTimeout( + () => { + eoseSent = true + for (let cb of eoseListeners.values()) cb() + }, + opts?.eoseSubTimeout || this.eoseSubTimeout, + ) + + relays + .filter((r, i, a) => a.indexOf(r) === i) + .forEach(async relay => { + let r + try { + r = await this.ensureRelay(relay) + } catch (err) { + handleEose() + return + } + if (!r) return + let s = r.sub(filters, modifiedOpts) + s.on('event', event => { + _knownIds.add(event.id as string) + for (let cb of eventListeners.values()) cb(event) + }) + s.on('eose', () => { + if (eoseSent) return + handleEose() + }) + subs.push(s) + + function handleEose() { + eosesMissing-- + if (eosesMissing === 0) { + clearTimeout(eoseTimeout) + for (let cb of eoseListeners.values()) cb() + } + } + }) + + let greaterSub: Sub = { + sub(filters, opts) { + subs.forEach(sub => sub.sub(filters, opts)) + return greaterSub as any + }, + unsub() { + subs.forEach(sub => sub.unsub()) + }, + on(type, cb) { + if (type === 'event') { + eventListeners.add(cb) + } else if (type === 'eose') { + eoseListeners.add(cb as () => void | Promise) + } + }, + off(type, cb) { + if (type === 'event') { + eventListeners.delete(cb) + } else if (type === 'eose') eoseListeners.delete(cb as () => void | Promise) + }, + get events() { + return eventsGenerator(greaterSub) + }, + } + + return greaterSub + } + + get( + relays: string[], + filter: Filter, + opts?: SubscriptionOptions, + ): Promise | null> { + return new Promise(resolve => { + let sub = this.sub(relays, [filter], opts) + let timeout = setTimeout(() => { + sub.unsub() + resolve(null) + }, this.getTimeout) + sub.on('event', event => { + resolve(event) + clearTimeout(timeout) + sub.unsub() + }) + }) + } + + list( + relays: string[], + filters: Filter[], + opts?: SubscriptionOptions, + ): Promise[]> { + return new Promise(resolve => { + let events: Event[] = [] + let sub = this.sub(relays, filters, opts) + + sub.on('event', event => { + events.push(event) + }) + + // we can rely on an eose being emitted here because pool.sub() will fake one + sub.on('eose', () => { + sub.unsub() + resolve(events) + }) + }) + } + + batchedList( + batchKey: string, + relays: string[], + filters: Filter[], + ): Promise[]> { + return new Promise(resolve => { + if (!this.batchedByKey[batchKey]) { + this.batchedByKey[batchKey] = [ + { + filters, + relays, + resolve, + events: [], + }, + ] + + setTimeout(() => { + Object.keys(this.batchedByKey).forEach(async batchKey => { + const batchedRequests = this.batchedByKey[batchKey] + + const filters = [] as Filter[] + const relays = [] as string[] + batchedRequests.forEach(br => { + filters.push(...br.filters) + relays.push(...br.relays) + }) + + const sub = this.sub(relays, filters) + sub.on('event', event => { + batchedRequests.forEach(br => matchFilters(br.filters, event) && br.events.push(event)) + }) + sub.on('eose', () => { + sub.unsub() + batchedRequests.forEach(br => br.resolve(br.events)) + }) + + delete this.batchedByKey[batchKey] + }) + }, this.batchInterval) + } else { + this.batchedByKey[batchKey].push({ + filters, + relays, + resolve, + events: [], + }) + } + }) + } + + publish(relays: string[], event: Event): Promise[] { + return relays.map(async relay => { + let r = await this.ensureRelay(relay) + return r.publish(event) + }) + } + + seenOn(id: string): string[] { + return Array.from(this._seenOn[id]?.values?.() || []) + } +} \ No newline at end of file diff --git a/src/services/nostr/tools/relay.ts b/src/services/nostr/tools/relay.ts new file mode 100644 index 00000000..b4135c37 --- /dev/null +++ b/src/services/nostr/tools/relay.ts @@ -0,0 +1,402 @@ +/* global WebSocket */ +import "websocket-polyfill" +import { verifySignature, validateEvent, type Event } from './event.js' +import { matchFilters, type Filter } from './filter.js' +import { getHex64, getSubscriptionId } from './fakejson.js' +import { MessageQueue } from './utils.js' + +type RelayEvent = { + connect: () => void | Promise + disconnect: () => void | Promise + error: () => void | Promise + notice: (msg: string) => void | Promise + auth: (challenge: string) => void | Promise +} +export type CountPayload = { + count: number +} +export type SubEvent = { + event: (event: Event) => void | Promise + count: (payload: CountPayload) => void | Promise + eose: () => void | Promise +} +export type Relay = { + url: string + status: number + connect: () => Promise + close: () => void + sub: (filters: Filter[], opts?: SubscriptionOptions) => Sub + list: (filters: Filter[], opts?: SubscriptionOptions) => Promise[]> + get: (filter: Filter, opts?: SubscriptionOptions) => Promise | null> + count: (filters: Filter[], opts?: SubscriptionOptions) => Promise + publish: (event: Event) => Promise + auth: (event: Event) => Promise + off: (event: T, listener: U) => void + on: (event: T, listener: U) => void +} +export type Sub = { + sub: (filters: Filter[], opts: SubscriptionOptions) => Sub + unsub: () => void + on: , U extends SubEvent[T]>(event: T, listener: U) => void + off: , U extends SubEvent[T]>(event: T, listener: U) => void + events: AsyncGenerator, void, unknown> +} + +export type SubscriptionOptions = { + id?: string + verb?: 'REQ' | 'COUNT' + skipVerification?: boolean + alreadyHaveEvent?: null | ((id: string, relay: string) => boolean) + eoseSubTimeout?: number +} + +const newListeners = (): { [TK in keyof RelayEvent]: RelayEvent[TK][] } => ({ + connect: [], + disconnect: [], + error: [], + notice: [], + auth: [], +}) + +export function relayInit( + url: string, + options: { + getTimeout?: number + listTimeout?: number + countTimeout?: number + } = {}, +): Relay { + let { listTimeout = 3000, getTimeout = 3000, countTimeout = 3000 } = options + + var ws: WebSocket + var openSubs: { [id: string]: { filters: Filter[] } & SubscriptionOptions } = {} + var listeners = newListeners() + var subListeners: { + [subid: string]: { [TK in keyof SubEvent]: SubEvent[TK][] } + } = {} + var pubListeners: { + [eventid: string]: { + resolve: (_: unknown) => void + reject: (err: Error) => void + } + } = {} + + var connectionPromise: Promise | undefined + async function connectRelay(): Promise { + if (connectionPromise) return connectionPromise + connectionPromise = new Promise((resolve, reject) => { + try { + ws = new WebSocket(url) + } catch (err) { + reject(err) + } + + ws.onopen = () => { + listeners.connect.forEach(cb => cb()) + resolve() + } + ws.onerror = () => { + connectionPromise = undefined + listeners.error.forEach(cb => cb()) + reject() + } + ws.onclose = async () => { + connectionPromise = undefined + listeners.disconnect.forEach(cb => cb()) + } + + let incomingMessageQueue: MessageQueue = new MessageQueue() + let handleNextInterval: any + + ws.onmessage = e => { + incomingMessageQueue.enqueue(e.data) + if (!handleNextInterval) { + handleNextInterval = setInterval(handleNext, 0) + } + } + + function handleNext() { + if (incomingMessageQueue.size === 0) { + clearInterval(handleNextInterval) + handleNextInterval = null + return + } + + var json = incomingMessageQueue.dequeue() + if (!json) return + + let subid = getSubscriptionId(json) + if (subid) { + let so = openSubs[subid] + if (so && so.alreadyHaveEvent && so.alreadyHaveEvent(getHex64(json, 'id'), url)) { + return + } + } + + try { + let data = JSON.parse(json) + + // we won't do any checks against the data since all failures (i.e. invalid messages from relays) + // will naturally be caught by the encompassing try..catch block + + switch (data[0]) { + case 'EVENT': { + let id = data[1] + let event = data[2] + if ( + validateEvent(event) && + openSubs[id] && + (openSubs[id].skipVerification || verifySignature(event)) && + matchFilters(openSubs[id].filters, event) + ) { + openSubs[id] + ; (subListeners[id]?.event || []).forEach(cb => cb(event)) + } + return + } + case 'COUNT': + let id = data[1] + let payload = data[2] + if (openSubs[id]) { + ; (subListeners[id]?.count || []).forEach(cb => cb(payload)) + } + return + case 'EOSE': { + let id = data[1] + if (id in subListeners) { + subListeners[id].eose.forEach(cb => cb()) + subListeners[id].eose = [] // 'eose' only happens once per sub, so stop listeners here + } + return + } + case 'OK': { + let id: string = data[1] + let ok: boolean = data[2] + let reason: string = data[3] || '' + if (id in pubListeners) { + let { resolve, reject } = pubListeners[id] + if (ok) resolve(null) + else reject(new Error(reason)) + } + return + } + case 'NOTICE': + let notice = data[1] + listeners.notice.forEach(cb => cb(notice)) + return + case 'AUTH': { + let challenge = data[1] + listeners.auth?.forEach(cb => cb(challenge)) + return + } + } + } catch (err) { + return + } + } + }) + + return connectionPromise + } + + function connected() { + return ws?.readyState === 1 + } + + async function connect(): Promise { + if (connected()) return // ws already open + await connectRelay() + } + + async function trySend(params: [string, ...any]) { + let msg = JSON.stringify(params) + if (!connected()) { + await new Promise(resolve => setTimeout(resolve, 1000)) + if (!connected()) { + return + } + } + try { + ws.send(msg) + } catch (err) { + console.log(err) + } + } + + const sub = ( + filters: Filter[], + { + verb = 'REQ', + skipVerification = false, + alreadyHaveEvent = null, + id = Math.random().toString().slice(2), + }: SubscriptionOptions = {}, + ): Sub => { + let subid = id + + openSubs[subid] = { + id: subid, + filters, + skipVerification, + alreadyHaveEvent, + } + trySend([verb, subid, ...filters]) + + let subscription: Sub = { + sub: (newFilters, newOpts = {}) => + sub(newFilters || filters, { + skipVerification: newOpts.skipVerification || skipVerification, + alreadyHaveEvent: newOpts.alreadyHaveEvent || alreadyHaveEvent, + id: subid, + }), + unsub: () => { + delete openSubs[subid] + delete subListeners[subid] + trySend(['CLOSE', subid]) + }, + on: (type, cb) => { + subListeners[subid] = subListeners[subid] || { + event: [], + count: [], + eose: [], + } + //@ts-ignore + subListeners[subid][type].push(cb) + }, + off: (type, cb): void => { + let listeners = subListeners[subid] + //@ts-ignore + let idx = listeners[type].indexOf(cb) + if (idx >= 0) listeners[type].splice(idx, 1) + }, + get events() { + return eventsGenerator(subscription) + }, + } + + return subscription + } + + function _publishEvent(event: Event, type: string) { + return new Promise((resolve, reject) => { + if (!event.id) { + reject(new Error(`event ${event} has no id`)) + return + } + + let id = event.id + trySend([type, event]) + pubListeners[id] = { resolve, reject } + }) + } + + return { + url, + sub, + on: (type: T, cb: U): void => { + //@ts-ignore + listeners[type].push(cb) + if (type === 'connect' && ws?.readyState === 1) { + // i would love to know why we need this + ; (cb as () => void)() + } + }, + off: (type: T, cb: U): void => { + //@ts-ignore + let index = listeners[type].indexOf(cb) + if (index !== -1) listeners[type].splice(index, 1) + }, + list: (filters, opts?: SubscriptionOptions) => + new Promise(resolve => { + let s = sub(filters, opts) + let events: Event[] = [] + let timeout = setTimeout(() => { + s.unsub() + resolve(events) + }, listTimeout) + s.on('eose', () => { + s.unsub() + clearTimeout(timeout) + resolve(events) + }) + s.on('event', event => { + events.push(event) + }) + }), + get: (filter, opts?: SubscriptionOptions) => + new Promise(resolve => { + let s = sub([filter], opts) + let timeout = setTimeout(() => { + s.unsub() + resolve(null) + }, getTimeout) + s.on('event', event => { + s.unsub() + clearTimeout(timeout) + resolve(event) + }) + }), + count: (filters: Filter[]): Promise => + new Promise(resolve => { + let s = sub(filters, { ...sub, verb: 'COUNT' }) + let timeout = setTimeout(() => { + s.unsub() + resolve(null) + }, countTimeout) + s.on('count', (event: CountPayload) => { + s.unsub() + clearTimeout(timeout) + resolve(event) + }) + }), + async publish(event): Promise { + await _publishEvent(event, 'EVENT') + }, + async auth(event): Promise { + await _publishEvent(event, 'AUTH') + }, + connect, + close(): void { + listeners = newListeners() + subListeners = {} + pubListeners = {} + if (ws?.readyState === WebSocket.OPEN) { + ws.close() + } + }, + get status() { + return ws?.readyState ?? 3 + }, + } +} + +export async function* eventsGenerator(sub: Sub): AsyncGenerator, void, unknown> { + let nextResolve: ((event: Event) => void) | undefined + const eventQueue: Event[] = [] + + const pushToQueue = (event: Event) => { + if (nextResolve) { + nextResolve(event) + nextResolve = undefined + } else { + eventQueue.push(event) + } + } + + sub.on('event', pushToQueue) + + try { + while (true) { + if (eventQueue.length > 0) { + yield eventQueue.shift()! + } else { + const event = await new Promise>(resolve => { + nextResolve = resolve + }) + yield event + } + } + } finally { + sub.off('event', pushToQueue) + } +} \ No newline at end of file diff --git a/src/services/nostr/tools/utils.ts b/src/services/nostr/tools/utils.ts new file mode 100644 index 00000000..e7d3d7e4 --- /dev/null +++ b/src/services/nostr/tools/utils.ts @@ -0,0 +1,169 @@ +import type { Event } from './event.js' + +export const utf8Decoder = new TextDecoder('utf-8') +export const utf8Encoder = new TextEncoder() + +export function normalizeURL(url: string): string { + let p = new URL(url) + p.pathname = p.pathname.replace(/\/+/g, '/') + if (p.pathname.endsWith('/')) p.pathname = p.pathname.slice(0, -1) + if ((p.port === '80' && p.protocol === 'ws:') || (p.port === '443' && p.protocol === 'wss:')) p.port = '' + p.searchParams.sort() + p.hash = '' + return p.toString() +} + +// +// fast insert-into-sorted-array functions adapted from https://github.com/terrymorse58/fast-sorted-array +// +export function insertEventIntoDescendingList(sortedArray: Event[], event: Event) { + let start = 0 + let end = sortedArray.length - 1 + let midPoint + let position = start + + if (end < 0) { + position = 0 + } else if (event.created_at < sortedArray[end].created_at) { + position = end + 1 + } else if (event.created_at >= sortedArray[start].created_at) { + position = start + } else + while (true) { + if (end <= start + 1) { + position = end + break + } + midPoint = Math.floor(start + (end - start) / 2) + if (sortedArray[midPoint].created_at > event.created_at) { + start = midPoint + } else if (sortedArray[midPoint].created_at < event.created_at) { + end = midPoint + } else { + // aMidPoint === num + position = midPoint + break + } + } + + // insert when num is NOT already in (no duplicates) + if (sortedArray[position]?.id !== event.id) { + return [...sortedArray.slice(0, position), event, ...sortedArray.slice(position)] + } + + return sortedArray +} + +export function insertEventIntoAscendingList(sortedArray: Event[], event: Event) { + let start = 0 + let end = sortedArray.length - 1 + let midPoint + let position = start + + if (end < 0) { + position = 0 + } else if (event.created_at > sortedArray[end].created_at) { + position = end + 1 + } else if (event.created_at <= sortedArray[start].created_at) { + position = start + } else + while (true) { + if (end <= start + 1) { + position = end + break + } + midPoint = Math.floor(start + (end - start) / 2) + if (sortedArray[midPoint].created_at < event.created_at) { + start = midPoint + } else if (sortedArray[midPoint].created_at > event.created_at) { + end = midPoint + } else { + // aMidPoint === num + position = midPoint + break + } + } + + // insert when num is NOT already in (no duplicates) + if (sortedArray[position]?.id !== event.id) { + return [...sortedArray.slice(0, position), event, ...sortedArray.slice(position)] + } + + return sortedArray +} + +export class MessageNode { + private _value: string + private _next: MessageNode | null + + public get value(): string { + return this._value + } + public set value(message: string) { + this._value = message + } + public get next(): MessageNode | null { + return this._next + } + public set next(node: MessageNode | null) { + this._next = node + } + + constructor(message: string) { + this._value = message + this._next = null + } +} + +export class MessageQueue { + private _first: MessageNode | null + private _last: MessageNode | null + + public get first(): MessageNode | null { + return this._first + } + public set first(messageNode: MessageNode | null) { + this._first = messageNode + } + public get last(): MessageNode | null { + return this._last + } + public set last(messageNode: MessageNode | null) { + this._last = messageNode + } + private _size: number + public get size(): number { + return this._size + } + public set size(v: number) { + this._size = v + } + + constructor() { + this._first = null + this._last = null + this._size = 0 + } + enqueue(message: string): boolean { + const newNode = new MessageNode(message) + if (this._size === 0 || !this._last) { + this._first = newNode + this._last = newNode + } else { + this._last.next = newNode + this._last = newNode + } + this._size++ + return true + } + dequeue(): string | null { + if (this._size === 0 || !this._first) return null + + let prev = this._first + this._first = prev.next + prev.next = null + + this._size-- + return prev.value + } +} \ No newline at end of file diff --git a/src/services/storage/applicationStorage.ts b/src/services/storage/applicationStorage.ts index 93a1891f..57fa3201 100644 --- a/src/services/storage/applicationStorage.ts +++ b/src/services/storage/applicationStorage.ts @@ -1,5 +1,6 @@ import crypto from 'crypto'; import { DataSource, EntityManager } from "typeorm" +import { generatePrivateKey, getPublicKey } from 'nostr-tools'; import { Application } from "./entity/Application.js" import UserStorage from './userStorage.js'; import { ApplicationUser } from './entity/ApplicationUser.js'; @@ -12,13 +13,14 @@ export default class { this.userStorage = userStorage } - async AddApplication(name: string, entityManager = this.DB): Promise { + async AddApplication(name: string, allowUserCreation: boolean, entityManager = this.DB): Promise { const owner = await this.userStorage.AddUser(0, entityManager) const repo = entityManager.getRepository(Application) const newApplication = repo.create({ app_id: crypto.randomBytes(32).toString('hex'), name, - owner + owner, + allow_user_creation: allowUserCreation }) return repo.save(newApplication) } @@ -35,7 +37,13 @@ export default class { return found } + async GetApplications(entityManager = this.DB): Promise { + return entityManager.getRepository(Application).find() + } async GetApplication(appId: string, entityManager = this.DB): Promise { + if (!appId) { + throw new Error("invalid app id provided") + } const found = await entityManager.getRepository(Application).findOne({ where: { app_id: appId @@ -47,7 +55,18 @@ export default class { return found } - async AddApplicationUser(application: Application, userIdentifier: string, balance: number) { + async UpdateApplication(app: Application, update: Partial, entityManager = this.DB) { + await entityManager.getRepository(Application).update(app.serial_id, update) + } + + async GenerateApplicationKeys(app: Application) { + const priv = generatePrivateKey() + const pub = getPublicKey(priv) + await this.UpdateApplication(app, { nostr_private_key: priv, nostr_public_key: pub }) + return { privateKey: priv, publicKey: pub, appId: app.app_id, name: app.name } + } + + async AddApplicationUser(application: Application, userIdentifier: string, balance: number, nostrPub?: string) { return this.DB.transaction(async tx => { const user = await this.userStorage.AddUser(balance, tx) const repo = tx.getRepository(ApplicationUser) @@ -55,6 +74,7 @@ export default class { user: user, application, identifier: userIdentifier, + nostr_public_key: nostrPub }) return repo.save(appUser) }) @@ -64,6 +84,20 @@ export default class { return entityManager.getRepository(ApplicationUser).findOne({ where: { identifier: userIdentifier, application: { serial_id: application.serial_id } } }) } + async GetOrCreateNostrAppUser(application: Application, nostrPub: string, entityManager = this.DB): Promise { + if (!nostrPub) { + throw new Error("no nostrPub provided") + } + const user = await entityManager.getRepository(ApplicationUser).findOne({ where: { application: { serial_id: application.serial_id }, nostr_public_key: nostrPub } }) + if (user) { + return user + } + if (!application.allow_user_creation) { + throw new Error("user creation by client is not allowed in this app") + } + return this.AddApplicationUser(application, crypto.randomBytes(32).toString('hex'), 0, nostrPub) + } + async GetOrCreateApplicationUser(application: Application, userIdentifier: string, balance: number, entityManager = this.DB): Promise<{ user: ApplicationUser, created: boolean }> { const user = await this.GetApplicationUserIfExists(application, userIdentifier, entityManager) if (user) { diff --git a/src/services/storage/db.ts b/src/services/storage/db.ts index f75c618b..582cafcf 100644 --- a/src/services/storage/db.ts +++ b/src/services/storage/db.ts @@ -7,7 +7,6 @@ import { UserReceivingInvoice } from "./entity/UserReceivingInvoice.js" import { UserInvoicePayment } from "./entity/UserInvoicePayment.js" import { EnvMustBeNonEmptyString } from "../helpers/envParser.js" import { UserTransactionPayment } from "./entity/UserTransactionPayment.js" -import { UserNostrAuth } from "./entity/UserNostrAuth.js" import { UserBasicAuth } from "./entity/UserBasicAuth.js" import { UserEphemeralKey } from "./entity/UserEphemeralKey.js" import { Product } from "./entity/Product.js" @@ -25,7 +24,7 @@ export default async (settings: DbSettings) => { type: "sqlite", database: settings.databaseFile, //logging: true, - entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment, UserNostrAuth, UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment], + entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment, UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment], synchronize: true, }).initialize() } \ No newline at end of file diff --git a/src/services/storage/entity/Application.ts b/src/services/storage/entity/Application.ts index 4bea325e..aa355151 100644 --- a/src/services/storage/entity/Application.ts +++ b/src/services/storage/entity/Application.ts @@ -18,6 +18,15 @@ export class Application { @JoinColumn() owner: User + @Column({ default: false }) + allow_user_creation: boolean + + @Column({ nullable: true, unique: true }) + nostr_private_key: string + + @Column({ nullable: true, unique: true }) + nostr_public_key: string + @CreateDateColumn() created_at: Date diff --git a/src/services/storage/entity/ApplicationUser.ts b/src/services/storage/entity/ApplicationUser.ts index 733ea538..010972ef 100644 --- a/src/services/storage/entity/ApplicationUser.ts +++ b/src/services/storage/entity/ApplicationUser.ts @@ -20,6 +20,9 @@ export class ApplicationUser { @Index({ unique: true }) identifier: string + @Column({ nullable: true, unique: true }) + nostr_public_key: string + @CreateDateColumn() created_at: Date diff --git a/src/services/storage/entity/UserNostrAuth.ts b/src/services/storage/entity/UserNostrAuth.ts deleted file mode 100644 index 2e32c79f..00000000 --- a/src/services/storage/entity/UserNostrAuth.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Entity, PrimaryGeneratedColumn, Column, Index, JoinColumn, OneToOne, CreateDateColumn, UpdateDateColumn } from "typeorm" -import { User } from "./User.js" - -@Entity() -export class UserNostrAuth { - - @PrimaryGeneratedColumn() - serial_id: number - - @OneToOne(type => User, { eager: true }) - @JoinColumn() - user: User - - @Column() - @Index({ unique: true }) - nostr_pub: string - - @CreateDateColumn() - created_at: Date - - @UpdateDateColumn() - updated_at: Date -} diff --git a/src/services/storage/index.ts b/src/services/storage/index.ts index 544331ae..245f0426 100644 --- a/src/services/storage/index.ts +++ b/src/services/storage/index.ts @@ -1,18 +1,7 @@ -import { DataSource, EntityManager, MoreThan, MoreThanOrEqual, TransactionAlreadyStartedError } from "typeorm" -import crypto from 'crypto'; +import { DataSource, EntityManager } from "typeorm" import NewDB, { DbSettings, LoadDbSettingsFromEnv } from "./db.js" -import { User } from "./entity/User.js" -import { UserReceivingAddress } from "./entity/UserReceivingAddress.js"; -import { UserReceivingInvoice } from "./entity/UserReceivingInvoice.js"; -import { AddressReceivingTransaction } from "./entity/AddressReceivingTransaction.js"; -import { UserInvoicePayment } from "./entity/UserInvoicePayment.js"; -import { UserTransactionPayment } from "./entity/UserTransactionPayment.js"; -import { UserNostrAuth } from "./entity/UserNostrAuth.js"; -import { UserBasicAuth } from "./entity/UserBasicAuth.js"; -import { EphemeralKeyType, UserEphemeralKey } from "./entity/UserEphemeralKey.js"; import ProductStorage from './productStorage.js' import ApplicationStorage from './applicationStorage.js' -import { Product } from "./entity/Product.js"; import UserStorage from "./userStorage.js"; import PaymentStorage from "./paymentStorage.js"; export type StorageSettings = { diff --git a/src/services/storage/paymentStorage.ts b/src/services/storage/paymentStorage.ts index ee72d306..2ad98d04 100644 --- a/src/services/storage/paymentStorage.ts +++ b/src/services/storage/paymentStorage.ts @@ -1,8 +1,6 @@ import crypto from 'crypto'; import { DataSource, EntityManager, MoreThan, MoreThanOrEqual } from "typeorm" import { User } from './entity/User.js'; -import { UserBasicAuth } from './entity/UserBasicAuth.js'; -import { UserNostrAuth } from './entity/UserNostrAuth.js'; import { UserTransactionPayment } from './entity/UserTransactionPayment.js'; import { EphemeralKeyType, UserEphemeralKey } from './entity/UserEphemeralKey.js'; import { UserReceivingInvoice } from './entity/UserReceivingInvoice.js'; diff --git a/src/services/storage/userStorage.ts b/src/services/storage/userStorage.ts index 006843ff..0f146c0a 100644 --- a/src/services/storage/userStorage.ts +++ b/src/services/storage/userStorage.ts @@ -2,7 +2,6 @@ import crypto from 'crypto'; import { DataSource, EntityManager } from "typeorm" import { User } from './entity/User.js'; import { UserBasicAuth } from './entity/UserBasicAuth.js'; -import { UserNostrAuth } from './entity/UserNostrAuth.js'; import { getLogger } from '../helpers/logger.js'; export default class { DB: DataSource | EntityManager @@ -21,7 +20,6 @@ export default class { return entityManager.getRepository(User).save(newUser) } - async AddBasicUser(name: string, secret: string): Promise { return this.DB.transaction(async tx => { const user = await this.AddUser(0, tx) @@ -49,24 +47,6 @@ export default class { return user } - async FindNostrUser(nostrPub: string, entityManager = this.DB): Promise { - return entityManager.getRepository(UserNostrAuth).findOne({ - where: { nostr_pub: nostrPub } - }) - - } - async AddNostrUser(nostrPub: string): Promise { - return this.DB.transaction(async tx => { - const user = await this.AddUser(0, tx) - const newAuth = tx.getRepository(UserNostrAuth).create({ - user: user, - nostr_pub: nostrPub - }) - return tx.getRepository(UserNostrAuth).save(newAuth) - }) - - } - async LockUser(userId: string, entityManager = this.DB) { const res = await entityManager.getRepository(User).update({ user_id: userId