From 4cca7c9088ea60fd95a5bba47373b63e6e3b60b7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 16 May 2023 15:02:33 -0400 Subject: [PATCH 1/2] feat: add support for node v20 (#2303) * run tests on node v20 * update linter to node v16 * update docs * update browser node version * update checkout --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/nodejs.yml | 8 ++++---- CONTRIBUTING.md | 2 +- README.md | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 83db958b..68dadab9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 02df714a..719fdbb7 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [16.x] steps: - uses: actions/checkout@v3 @@ -57,7 +57,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x, 20.x] steps: - uses: actions/checkout@v3 @@ -98,7 +98,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x, 20.x] steps: - uses: actions/checkout@v3 @@ -150,7 +150,7 @@ jobs: strategy: matrix: - node-version: [14.x] # This just needs to be compatible w/ puppeteer + node-version: [16.x] steps: - uses: actions/checkout@v3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95f1a8a7..24c60464 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ ### Requirements -We use Node v14 for development - that is the version that our linters require. +We use Node v16 for development - that is the version that our linters require. You must also use `npm` v7. You can check your `npm` version with: ```bash diff --git a/README.md b/README.md index 48ab5f78..34f3f0e2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ All of which works in Node.js (tested for v14+) & web browsers (tested for Chrom ### Requirements -+ **[Node.js v14](https://nodejs.org/)** is recommended. We also support v16 and v18. Other versions may work but are not frequently tested. ++ **[Node.js v16](https://nodejs.org/)** is recommended. We also support v14, v18 and v20. Other versions may work but are not frequently tested. ### Installing xrpl.js From 6b1ac0bd4f6f4c036a8e68a91d76a3df5e6d7953 Mon Sep 17 00:00:00 2001 From: Wo Jake Date: Wed, 17 May 2023 04:28:23 +0800 Subject: [PATCH 2/2] Add guard check for signing algorithm (#2278) Previously unsupported algorithm would not throw exceptions. Co-authored-by: Caleb Kniffen --- packages/xrpl/HISTORY.md | 1 + packages/xrpl/src/Wallet/index.ts | 5 +++++ packages/xrpl/test/wallet/index.test.ts | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/packages/xrpl/HISTORY.md b/packages/xrpl/HISTORY.md index a20d41c6..f3b0fea2 100644 --- a/packages/xrpl/HISTORY.md +++ b/packages/xrpl/HISTORY.md @@ -4,6 +4,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr ## Unreleased ### Added +* Guard check for signing algorithm used in `Wallet.generate()` * Null and undefined values in transactions are now treated as though the field was not passed in. ### Fixed diff --git a/packages/xrpl/src/Wallet/index.ts b/packages/xrpl/src/Wallet/index.ts index aaafbf8b..d20afed0 100644 --- a/packages/xrpl/src/Wallet/index.ts +++ b/packages/xrpl/src/Wallet/index.ts @@ -129,8 +129,13 @@ class Wallet { * * @param algorithm - The digital signature algorithm to generate an address for. * @returns A new Wallet derived from a generated seed. + * + * @throws ValidationError when signing algorithm isn't valid */ public static generate(algorithm: ECDSA = DEFAULT_ALGORITHM): Wallet { + if (!Object.values(ECDSA).includes(algorithm)) { + throw new ValidationError('Invalid cryptographic signing algorithm') + } const seed = generateSeed({ algorithm }) return Wallet.fromSeed(seed) } diff --git a/packages/xrpl/test/wallet/index.test.ts b/packages/xrpl/test/wallet/index.test.ts index 6ff132e1..05e089c2 100644 --- a/packages/xrpl/test/wallet/index.test.ts +++ b/packages/xrpl/test/wallet/index.test.ts @@ -57,6 +57,15 @@ describe('Wallet', function () { assert.isTrue(wallet.classicAddress.startsWith(classicAddressPrefix)) }) + it('generates a new wallet using an invalid/unknown algorithm', function () { + const algorithm = 'test' + + assert.throws(() => { + // @ts-expect-error -- We know it is an invalid algorithm + Wallet.generate(algorithm) + }, /Invalid cryptographic signing algorithm/u) + }) + it('generates a new wallet using algorithm ecdsa-secp256k1', function () { const algorithm = ECDSA.secp256k1 const wallet = Wallet.generate(algorithm)