New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

verify-xrpl-signature

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

verify-xrpl-signature - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

2

dist/index.d.ts

@@ -20,3 +20,3 @@ export interface Signer {

};
export declare const getDefinitions: (network: number | string) => Promise<XrplDefinitions | undefined>;
export declare const getDefinitions: (network: number | string, request: (url: string, body?: string | undefined) => Promise<any>) => Promise<XrplDefinitions | undefined>;
export declare const verifySignature: (txBlob: string, explicitMultiSigner?: string | undefined, definitions?: XrplDefinitions | undefined) => verifySignatureResult;

@@ -11,5 +11,2 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,9 +17,7 @@ exports.verifySignature = exports.getDefinitions = void 0;

const ripple_keypairs_1 = require("ripple-keypairs");
const node_fetch_1 = __importDefault(require("node-fetch"));
const getDefinitions = (network) => __awaiter(void 0, void 0, void 0, function* () {
const getDefinitions = (network, request) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
try {
// Dynamic definitions
const call = yield (0, node_fetch_1.default)("https://xumm.app/api/v1/platform/rails");
const rails = yield call.json();
const rails = yield request("https://xumm.app/api/v1/platform/rails");
const networkData = typeof rails === "object" && rails

@@ -34,7 +29,3 @@ ? typeof network === "string"

if (networkData === null || networkData === void 0 ? void 0 : networkData.rpc) {
const defsCall = yield (0, node_fetch_1.default)(networkData.rpc, {
method: "POST",
body: '{"method":"server_definitions"}',
});
const defsJson = yield defsCall.json();
const defsJson = yield request(networkData.rpc, '{"method":"server_definitions"}');
if (typeof defsJson === "object" && defsJson) {

@@ -41,0 +32,0 @@ if ((_b = defsJson === null || defsJson === void 0 ? void 0 : defsJson.result) === null || _b === void 0 ? void 0 : _b.FIELDS) {

{
"name": "verify-xrpl-signature",
"version": "4.1.1",
"version": "4.1.2",
"description": "Verify XRPL signed TX blob",

@@ -25,4 +25,2 @@ "main": "dist/index.js",

"dependencies": {
"axios": "^1.6.2",
"node-fetch": "^2.7.0",
"ripple-keypairs": "^1.1.4",

@@ -37,2 +35,3 @@ "xrpl-accountlib": "^3.2.0",

"jest": "^27.3.1",
"node-fetch": "^2.7.0",
"ts-jest": "^27.0.7",

@@ -39,0 +38,0 @@ "typescript": "4.5"

@@ -29,23 +29,11 @@ # Verify XRPL tx blob signatures [![npm version](https://badge.fury.io/js/verify-xrpl-signature.svg)](https://www.npmjs.com/verify-xrpl-signature)

##### Auto-definition fetching
This lib. offers a helper to fetch network definitions dynamically. The example below (`.js`) shows how to
verify the signature of a transaction using dynamically fetched network definitions of `Xahau`:
Since v4.1.0 this lib ships a `getDefinitions(network)` async method. The only input argument can be `string` (network code, e.g. `MAINNET`) or integer (e.g. `21337`). The method will then fetch definitions accordingly from the right network, providing it's known in XRPL Lab's `rails` endpoint. You can then use the response to pass as the third argument (`definitions`) of `verifySignature(...)`
Please note the `getDefinitions` method requires the second argument to be a custom method to map to your own
preferred lib. to obtain external JSON data.
```javascript
const { verifySignature, getDefinitions } = require('verify-xrpl-signature')
// Or for `.mjs`:
// import verifyXrplSignature from 'verify-xrpl-signature'
// const { verifySignature, getDefinitions } = verifyXrplSignature
The output must be an already parsed object. It must use GET method
if no body is given, and POST method if the second argument is the body to post in JSON stringified format.
;(async () => {
const someTx = '<<binhex>>'
// console.log(verifySignature(someTx, undefined, await getDefinitions('XAHAU') )) // Network identifier
console.log(verifySignature(someTx, undefined, await getDefinitions(21337) )) // Network ID
})()
```
##### Manual definition fetching
The example below (`.js`) shows how to verify the signature of a transaction using dynamically fetched network definitions of `Xahau`:
```javascript

@@ -56,6 +44,9 @@ const verifySignature = require('verify-xrpl-signature').verifySignature

const request = (url, body) => {
return fetch(url, { method: body ? "POST" : "GET", body }).then(r => r.json());
};
;(async () => {
const definitionsCall = await fetch('https://xahau.network', { method: 'POST', body: '{"method":"server_definitions"}' })
const definitionsJson = await definitionsCall.json()
const definitions = new XrplDefinitions(definitionsJson.result)
const definitions = await getDefinitions("XAHAU", request) // Network = XAHHAU (id: 21337 would work too), pass `request` method.

@@ -65,2 +56,5 @@ const someTx = '2280000000240000000268400000000000000C73210333C718C9CB716E0575454F4A343D46B284ED51151B9C7383524B82C10B262095744730450221009A4D99017F8FD6881D888047E2F9F90C068C09EC9308BC8526116B539D6DD44102207FAA7E8756F67FE7EE1A88884F120A00A8EC37E7D3E5ED3E02FEA7B1D97AA05581146C0994D3FCB140CAB36BAE9465137448883FA487'

console.log(verifySignature(someTx, undefined, definitions))
// In case of explicit MultiSign signer verification:
// console.log(verifySignature(someTx, 'rwiETSee2wMz3SBnAG8hkMsCgvGy9LWbZ1', definitions))
})()

@@ -85,2 +79,5 @@ ```

console.log(verifySignature(someTx, undefined, definitions))
// In case of explicit MultiSign signer verification:
// console.log(verifySignature(someTx, 'rwiETSee2wMz3SBnAG8hkMsCgvGy9LWbZ1', definitions))
```

@@ -87,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc