Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Remove node 14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomarg committed Oct 10, 2023
1 parent 3712db8 commit c6a53ec
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 63 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [14, 16, 18, 20]
version: [16, 18, 20]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
# TODO Remove the --ignore-engines flag when we drop support for Node 14
- name: Install
run: yarn install --ignore-engines
run: yarn install
- name: Lint
run: yarn lint
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can open a new issue on the GitHub issues and describe the feature you would

Requirements:

- [Node](https://nodejs.org/en/) v14 or above
- [Node](https://nodejs.org/en/) v16 or above
- [Yarn](https://yarnpkg.com/) v1.22 or above

You can set up your development environment by running the following:
Expand Down
14 changes: 2 additions & 12 deletions packages/shopify-api/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import type {Config} from 'jest';
import {compare} from 'compare-versions';

const projects = [
'./lib/__tests__/jest_projects/library.jest.config.ts',
'./lib/__tests__/jest_projects/rest_resources.jest.config.ts',
'./lib/__tests__/jest_projects/eslint.jest.config.ts',
'./lib/__tests__/jest_projects/adapters.mock.jest.config.ts',
'./lib/__tests__/jest_projects/adapters.node.jest.config.ts',
'./lib/__tests__/jest_projects/adapters.cf-worker.jest.config.ts',
'./lib/__tests__/jest_projects/adapters.web-api.jest.config.ts',
];

// eslint-disable-next-line no-warning-comments
// TODO Make all projects permanent after support for version 14 is dropped
if (compare(process.version, '15.0.0', '>=')) {
projects.push(
'./lib/__tests__/jest_projects/adapters.cf-worker.jest.config.ts',
);
projects.push(
'./lib/__tests__/jest_projects/adapters.web-api.jest.config.ts',
);
}

const config: Config = {
testTimeout: 30000,
projects,
Expand Down
4 changes: 0 additions & 4 deletions packages/shopify-api/lib/__tests__/initialization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ describe('shopifyApi', () => {
version: 'Cloudflare Worker',
deprecated: false,
},
{
version: 'Node v14.0.0',
deprecated: true,
},
{
version: 'Node v16.0.0',
deprecated: false,
Expand Down
6 changes: 1 addition & 5 deletions packages/shopify-api/lib/auth/decode-host.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function decodeHost(host: string): string {
// eslint-disable-next-line no-warning-comments
// TODO Remove the Buffer.from call when dropping Node 14 support
return typeof atob === 'undefined'
? Buffer.from(host, 'base64').toString()
: atob(host);
return atob(host);
}
6 changes: 1 addition & 5 deletions packages/shopify-api/lib/auth/oauth/nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import {crypto} from '../../../runtime/crypto';
export function nonce(): string {
const length = 15;

// eslint-disable-next-line no-warning-comments
// TODO Remove the randomBytes call when dropping Node 14 support
const bytes = crypto.getRandomValues
? crypto.getRandomValues(new Uint8Array(length))
: (crypto as any).randomBytes(length);
const bytes = crypto.getRandomValues(new Uint8Array(length));

const nonce = bytes
.map((byte: number) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@swc/core": "^1.3.3",
"@types/express": "^4.17.13",
"@types/jest": "^29.5.0",
"@types/node": "^14.18.12",
"@types/node": "^16.0.0",
"@types/node-fetch": "^2.5.7",
"@types/supertest": "^2.0.10",
"@types/uuid": "^9.0.0",
Expand Down
47 changes: 19 additions & 28 deletions packages/shopify-api/runtime/crypto/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,26 @@ export async function createSHA256HMAC(
? crypto
: (crypto as any).webcrypto;

// eslint-disable-next-line no-warning-comments
// TODO Make the subtle implementation the default when dropping Node 14 support
if (cryptoLib?.subtle) {
const enc = new TextEncoder();
const key = await cryptoLib.subtle.importKey(
'raw',
enc.encode(secret),
{
name: 'HMAC',
hash: {name: 'SHA-256'},
},
false,
['sign'],
);
const enc = new TextEncoder();
const key = await cryptoLib.subtle.importKey(
'raw',
enc.encode(secret),
{
name: 'HMAC',
hash: {name: 'SHA-256'},
},
false,
['sign'],
);

const signature = await cryptoLib.subtle.sign(
'HMAC',
key,
enc.encode(payload),
);
return returnFormat === HashFormat.Base64
? asBase64(signature)
: asHex(signature);
}

return (cryptoLib as any)
.createHmac('sha256', secret)
.update(payload)
.digest(returnFormat);
const signature = await cryptoLib.subtle.sign(
'HMAC',
key,
enc.encode(payload),
);
return returnFormat === HashFormat.Base64
? asBase64(signature)
: asHex(signature);
}

export function asHex(buffer: ArrayBuffer): string {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1445,10 +1445,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==

"@types/node@^14.18.12":
version "14.18.63"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.63.tgz#1788fa8da838dbb5f9ea994b834278205db6ca2b"
integrity sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==
"@types/node@^16.0.0":
version "16.18.58"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.58.tgz#bf66f63983104ed57c754f4e84ccaf16f8235adb"
integrity sha512-YGncyA25/MaVtQkjWW9r0EFBukZ+JulsLcVZBlGUfIb96OBMjkoRWwQo5IEWJ8Fj06Go3GHw+bjYDitv6BaGsA==

"@types/normalize-package-data@^2.4.0":
version "2.4.2"
Expand Down

0 comments on commit c6a53ec

Please sign in to comment.