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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
node-version: [20.x, 22.x, 24.x, 25.x]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

## [Unreleased](https://github.com/openfga/js-sdk/compare/v0.9.2...HEAD)

- chore!: drop support for Node.js v16 & 18. We recommend updating to a node-runtime that is [supported upstream](https://nodejs.org/en/about/previous-releases) - currently 20 (maintenance), 22 (maintenance), 24 (LTS) and 25 (current).
The minimum supported version of Node.js is now v20. This is in line with our [stated supported environments](./SUPPORTED_RUNTIMES.md)
- feat: add `executeApiRequest` and `executeStreamedApiRequest` methods to `OpenFgaClient` for calling arbitrary API endpoints with full SDK support (authentication, retries, telemetry, error handling). See [documentation](https://github.com/openfga/js-sdk#calling-other-endpoints) for more.

## v0.9.2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ Using [yarn](https://yarnpkg.com):
yarn add @openfga/sdk
```

#### Supported Node.js Versions

For details on the supported Node.js versions and our support policy, see [SUPPORTED_RUNTIMES.md](./SUPPORTED_RUNTIMES.md).

## Getting Started

### Initializing the API Client
Expand Down
22 changes: 22 additions & 0 deletions SUPPORTED_RUNTIMES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Node.js Support Policy for OpenFGA JS SDK

The OpenFGA JavaScript SDK follows the upstream [Node.js release policy](https://nodejs.org/en/about/previous-releases). We support Node.js versions that are currently in **LTS** or **Maintenance** status.

### Currently Supported Versions

| Node.js Version | Upstream Support Status | Tested in CI/CD Pipelines |
|:----------------|:------------------------|:-------------------------:|
| **20** | Maintenance | Yes |
| **22** | Maintenance | Yes |
| **24** | LTS | Yes |
| **25** | Current | Yes |

### Support Details

#### Best-Effort Support

We will make a best effort to maintain compatibility with Node.js versions that have reached End-of-Life (EOL), but **we will not test** against them in our CI/CD pipelines. This means you may be able to use the JS SDK with older versions of Node.js (with yarn you can use the `--ignore-engines` flag), but you may not be able to run tests (because many of our testing dependencies have dropped support for EOL versions).

#### Long-term plan

This best-effort support will not continue indefinitely. We plan to modernize our JS SDK, adopt more functionality now native to the language, and add support for alternate runtimes such as Deno, Cloudflare Workers, and Vercel Edge.
2 changes: 1 addition & 1 deletion common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const setSearchParams = function (url: URL, ...objects: any[]) {
* @return True if the given MIME is JSON, false otherwise.
*/
const isJsonMime = (mime: string): boolean => {
// eslint-disable-next-line no-control-regex
const jsonMime = new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$", "i");
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === "application/json-patch+json");
};
Expand Down
4 changes: 1 addition & 3 deletions errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ export class FgaApiRateLimitExceededError extends FgaApiError {
super(err);
this.apiErrorCode = (err.response?.data as any)?.code;

const { endpointCategory } = getRequestMetadataFromPath(err.request?.path);
const errResponseHeaders = getResponseHeaders(err);
this.message = msg
? msg
: `FGA API Rate Limit Error for ${this.method} ${endpointCategory}`;
: `FGA API Rate Limit Error for ${this.method} ${this.endpointCategory}`;
}
}

Expand Down
37 changes: 37 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
const typescriptParser = require("@typescript-eslint/parser");
const globals = require("globals");

module.exports = [
{
ignores: ["dist/"]
},
{
files: ["**/*.ts"],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 13,
sourceType: "module"
},
globals: {
...globals.browser,
...globals.node,
...globals.es2021
}
Comment thread
rhamzeh marked this conversation as resolved.
},
plugins: {
"@typescript-eslint": typescriptEslint
},
rules: {
...typescriptEslint.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": ["warn"],
"@typescript-eslint/no-explicit-any": ["warn"],
"@typescript-eslint/no-require-imports": ["error", { allowAsImport: true }],
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
}
];
2 changes: 0 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* tslint:disable */
/* eslint-disable */
/**
* JavaScript and Node.js SDK for OpenFGA
*
Expand Down
2 changes: 2 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
node = "24"
Loading
Loading