Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/typescript-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Typescript CI
'on':
on:
push:
branches:
- main
pull_request: null
workflow_dispatch: null
pull_request:
workflow_dispatch:
jobs:
typescript-ci:
uses: IronCoreLabs/workflows/.github/workflows/typescript-ci.yaml@typescript-ci-v0
with:
test_matrix_node_version: '["18", "20"]'
test_matrix_node_version: '["20", "22", "24"]'
# this repo runs coverage in its default test command, which will fail if
# under the thresholds defined in jest.config.js, so coverage delta doesn't matter as much
run_coverage: false
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.1.0

### Breaking Changes

Removed support for Node 16 and 18 (EOL).

### Changed

Added support for Node 22 and 24.

## 1.0.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SDK for using IronCore Labs from your NodeJS server side applications. Read [our

## Supported Platforms

| | Node 16 | Node 18 | Node 20 |
| | Node 20 | Node 22 | Node 24 |
| --------------------- | ------- | ------- | ------- |
| Linux x64 glibc | ✓ | ✓ | ✓ |
| Linux x64 musl-libc | ✓ | ✓ | ✓ |
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironcorelabs/ironnode",
"version": "1.0.0",
"version": "1.1.0",
"description": "IronCore Labs SDK for NodeJS Applications",
"homepage": "https://docs.ironcorelabs.com",
"main": "index.js",
Expand All @@ -9,7 +9,7 @@
"license": "AGPL-3.0-only",
"types": "ironnode.d.ts",
"engines": {
"node": ">=12.0.0"
"node": ">=20.0.0"
},
"os": [
"darwin",
Expand All @@ -28,16 +28,14 @@
"lint": "tslint -p \"tsconfig.json\" -e \"**/tests/**\" \"src/**/*.ts\""
},
"dependencies": {
"@ironcorelabs/recrypt-node-binding": "^0.10.0",
"futurejs": "2.1.1",
"node-fetch": "^2.6.7"
"@ironcorelabs/recrypt-node-binding": "^0.11.0",
"futurejs": "2.2.1"
},
"devDependencies": {
"@types/inquirer": "^9.0.9",
"@types/jest": "^26.0.7",
"@types/jsonwebtoken": "^8.5.0",
"@types/node": "^12.12.52",
"@types/node-fetch": "^2.5.7",
"@types/node": "^24.8.0",
"inquirer": "^12.9.2",
"jest": "^26.6.0",
"jest-extended": "^0.11.5",
Expand Down
1 change: 0 additions & 1 deletion src/api/ApiRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Future from "futurejs";
import fetch, {RequestInit, Response} from "node-fetch";
import {MessageSignature, SigningKeyPair} from "../commonTypes";
import {ErrorCodes} from "../Constants";
import {ed25519Sign} from "../crypto/Recrypt";
Expand Down
25 changes: 12 additions & 13 deletions src/api/tests/ApiRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import * as fetch from "node-fetch";
import * as ApiRequest from "../ApiRequest";
import {ErrorCodes} from "../../Constants";
import {getSigningKeyPair} from "../../tests/TestUtils";

describe("ApiRequest", () => {
describe("fetchJSON", () => {
beforeEach(() => {
jest.spyOn(fetch, "default").mockReturnValue(Promise.resolve({
global.fetch = jest.fn().mockResolvedValue({
foo: "bar",
}) as any);
} as any);
});

afterEach(() => {
(fetch.default as any).mockClear();
jest.restoreAllMocks();
});

test("invokes fetch with expected parameters", () => {
const fetchFuture = ApiRequest.fetchJSON("api/method", -1, {method: "POST"});
fetchFuture.engage(() => null, () => null);
expect(fetch.default).toHaveBeenCalledWith(expect.stringContaining("/api/1/api/method"), {method: "POST"});
expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("/api/1/api/method"), {method: "POST"});
});

test("converts failed request to SDK error", (done) => {
(fetch.default as any).mockReturnValue(Promise.reject(new Error("forced error")));
(global.fetch as jest.Mock).mockReturnValue(Promise.reject(new Error("forced error")));

ApiRequest.fetchJSON("api/method", -1, {method: "POST"}).engage(
(error) => {
Expand All @@ -35,7 +34,7 @@ describe("ApiRequest", () => {
});

test("converts failed request with JSON error into SDK Error", (done) => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: false,
statusText: "not good",
Expand All @@ -54,7 +53,7 @@ describe("ApiRequest", () => {
});

test("falls back to status text if response JSON is not in the expected format", (done) => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: false,
statusText: "not good",
Expand All @@ -73,7 +72,7 @@ describe("ApiRequest", () => {
});

test("falls back to status text if response body cannot be JSON parsed", (done) => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: false,
statusText: "not good",
Expand All @@ -92,7 +91,7 @@ describe("ApiRequest", () => {
});

test("returns empty object if request status is a 204", (done) => {
(fetch.default as any).mockReturnValue(Promise.resolve({ok: true, status: 204}));
(global.fetch as jest.Mock).mockReturnValue(Promise.resolve({ok: true, status: 204}));

ApiRequest.fetchJSON("api/method", -1, {method: "POST"}).engage(
(e) => done.fail(e),
Expand All @@ -104,7 +103,7 @@ describe("ApiRequest", () => {
});

test("falls back to hardcoded message text when response is success but JSON parsing fails", (done) => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: true,
status: 200,
Expand All @@ -123,7 +122,7 @@ describe("ApiRequest", () => {
});

test("invokes response.json on result and maps data to result and response", (done) => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: true,
status: 200,
Expand All @@ -143,7 +142,7 @@ describe("ApiRequest", () => {
});

test("returns special rate limiting error message when 429 response is returned", () => {
(fetch.default as any).mockReturnValue(
(global.fetch as jest.Mock).mockReturnValue(
Promise.resolve({
ok: false,
status: 429,
Expand Down
41 changes: 20 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,10 @@
resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-3.0.8.tgz#efc293ba0ed91e90e6267f1aacc1c70d20b8b4e8"
integrity sha512-lg9Whz8onIHRthWaN1Q9EGLa/0LFJjyM8mEUbL1eTi6yMGvBf8gvyDLtxSXztQsxMvhxxNpJYrwa1YHdq+w4Jw==

"@ironcorelabs/recrypt-node-binding@^0.10.0":
version "0.10.0"
resolved "https://registry.yarnpkg.com/@ironcorelabs/recrypt-node-binding/-/recrypt-node-binding-0.10.0.tgz#65db0ed6e4d52bc07a19684cd5fa56de8f0c11ff"
integrity sha512-nVIOiklTSMnA+pG3PxCYA4J4uua+C9x1a1bz0qEzudCAjF2HH4nrzpaxwQMRideXxMdeX7YWg3zp93LJyFp9cA==
"@ironcorelabs/recrypt-node-binding@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@ironcorelabs/recrypt-node-binding/-/recrypt-node-binding-0.11.0.tgz#dd1e484fe598a8f8fc03235d2bde6fb778f8da31"
integrity sha512-X4J1heksDJzBh5V06FfEOk7N9KcvuERVonLvdMDbzwtMBtD+gnc4KXTX5z8TnR8CqwYpp525pJlVrYWTLItuVA==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.7"

Expand Down Expand Up @@ -1074,23 +1074,17 @@
dependencies:
"@types/node" "*"

"@types/node-fetch@^2.5.7":
version "2.5.10"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"
integrity sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==
dependencies:
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*":
version "14.14.37"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
integrity sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==

"@types/node@^12.12.52":
version "12.20.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.7.tgz#1cb61fd0c85cb87e728c43107b5fd82b69bc9ef8"
integrity sha512-gWL8VUkg8VRaCAUgG9WmhefMqHmMblxe2rVpMF86nZY/+ZysU+BkAp+3cz03AixWDSSz0ks5WX59yAhv/cDwFA==
"@types/node@^24.8.0":
version "24.8.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-24.8.0.tgz#a98a689a687c31d9c553f603961230333e4b5230"
integrity sha512-5x08bUtU8hfboMTrJ7mEO4CpepS9yBwAqcL52y86SWNmbPX8LVbNs3EP4cNrIZgdjk2NAlP2ahNihozpoZIxSg==
dependencies:
undici-types "~7.14.0"

"@types/normalize-package-data@^2.4.0":
version "2.4.4"
Expand Down Expand Up @@ -1960,10 +1954,10 @@ function-bind@^1.1.2:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c"
integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==

futurejs@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/futurejs/-/futurejs-2.1.1.tgz#11d4503634b050a7c891ccbbe824c5ffa1bf1de3"
integrity sha512-5rSRikHpVNWY55pbQFPF3zUpvAkuVHdIAonwCJ6JRn0jIjxgN6KrMs9e59bH2YiSNCKn+PyIFfMEbVWrha2i0g==
futurejs@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/futurejs/-/futurejs-2.2.1.tgz#cf33a34469f64afe34ddb5635bc5734ee7098b3b"
integrity sha512-Cu7CcMGi9pGxSgReNo2flwxLmOCKOOc5VZQvusfhtUT2MPeoap42c6ommcl0aqEI1XKO5d5z/w6fM7VyWs0GDA==

gauge@^3.0.0:
version "3.0.2"
Expand Down Expand Up @@ -3065,7 +3059,7 @@ nice-try@^1.0.4:
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-fetch@^2.6.5, node-fetch@^2.6.7:
node-fetch@^2.6.5:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
Expand Down Expand Up @@ -3948,6 +3942,11 @@ typestrict@^1.0.2:
tslint-microsoft-contrib "^5.0.3"
tslint-sonarts "^1.8.0"

undici-types@~7.14.0:
version "7.14.0"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.14.0.tgz#4c037b32ca4d7d62fae042174604341588bc0840"
integrity sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==

universalify@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
Expand Down