Skip to content

Commit 1946a49

Browse files
committed
chore: update changelog & documentation
1 parent ae61409 commit 1946a49

3 files changed

Lines changed: 69 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

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

6+
- feat!: replace axios with native `fetch` for cross-platform support (Node.js, browsers, Deno, Cloudflare Workers, Vercel Edge).
7+
- **BREAKING**: `AxiosResponse` is no longer exposed on `$response`. The new type is `FgaResponse<T>` (with `status`, `statusText`, `headers`, `data`).
8+
- **BREAKING**: `AxiosInstance` injection is replaced by the `HttpClient` interface (`{ fetch, defaultHeaders, defaultTimeout }`).
9+
- Timeouts now use `AbortSignal.timeout()`.
10+
- chore: all `options?: any` parameters in the API layer are now properly typed as `RequestBuilderOptions`.
11+
612
## v0.9.4
713

814
### [v0.9.4](https://github.com/openfga/js-sdk/compare/v0.9.3...v0.9.4) (2026-03-31)

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper aroun
1818
- [Getting Started](#getting-started)
1919
- [Initializing the API Client](#initializing-the-api-client)
2020
- [Custom Headers](#custom-headers)
21+
- [Custom HTTP Client](#custom-http-client)
2122
- [Get your Store ID](#get-your-store-id)
2223
- [Calling the API](#calling-the-api)
2324
- [Stores](#stores)
@@ -84,7 +85,7 @@ Using [yarn](https://yarnpkg.com):
8485
yarn add @openfga/sdk
8586
```
8687

87-
#### Supported Node.js Versions
88+
### Supported Runtimes
8889

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

@@ -94,7 +95,7 @@ For details on the supported Node.js versions and our support policy, see [SUPPO
9495

9596
[Learn how to initialize your SDK](https://openfga.dev/docs/getting-started/setup-sdk-client)
9697

97-
We strongly recommend you initialize the `OpenFgaClient` only once and then re-use it throughout your app, otherwise you will incur the cost of having to re-initialize multiple times or at every request, the cost of reduced connection pooling and re-use, and would be particularly costly in the client credentials flow, as that flow will be performed on every request.
98+
We strongly recommend you initialize the `OpenFgaClient` only once and then re-use it throughout your app, otherwise you will incur the cost of having to re-initialize multiple times or at every request, and would be particularly costly in the client credentials flow, as that flow will be performed on every request. In Node.js, connection pooling is handled automatically by the runtime's native `fetch` implementation.
9899

99100
> The `OpenFgaClient` will by default retry API requests up to 3 times on 429 and 5xx errors.
100101
@@ -189,6 +190,55 @@ const result = await fgaClient.check({
189190
});
190191
```
191192

193+
### Custom HTTP Client
194+
195+
The SDK uses the native `fetch` API by default. You can provide a custom `HttpClient` to control the underlying HTTP behavior.
196+
197+
```javascript
198+
const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';
199+
200+
const fgaClient = new OpenFgaClient({
201+
apiUrl: process.env.FGA_API_URL,
202+
storeId: process.env.FGA_STORE_ID,
203+
httpClient: {
204+
fetch: globalThis.fetch.bind(globalThis), // or a custom fetch implementation
205+
defaultHeaders: {
206+
"X-Custom-Header": "value",
207+
},
208+
defaultTimeout: 15000, // timeout in milliseconds (default: 10000)
209+
},
210+
});
211+
```
212+
213+
The `HttpClient` interface accepts:
214+
215+
| Property | Type | Description |
216+
| --- | --- | --- |
217+
| `fetch` | `typeof globalThis.fetch` | The fetch function to use for HTTP requests |
218+
| `defaultHeaders` | `Record<string, string>` | *(Optional)* Headers to include with every request |
219+
| `defaultTimeout` | `number` | *(Optional)* Default request timeout in milliseconds |
220+
221+
#### Response Type
222+
223+
Most SDK methods that are a direct call to the API return an `FgaResponse<T>` on the `$response` property:
224+
225+
```typescript
226+
interface FgaResponse<T> {
227+
status: number;
228+
statusText: string;
229+
headers: Record<string, string>;
230+
data: T;
231+
}
232+
```
233+
234+
You can access it via the `$response` property on the method's return value:
235+
236+
```javascript
237+
const { headers, status } = await fgaClient.getStore().$response;
238+
```
239+
240+
Methods that have custom logic, such as `clientBatchCheck`, `listRelations` and non-transactional `write` operations, will not contain this field.
241+
192242
### Get your Store ID
193243

194244
You need your store id to call the OpenFGA API (unless it is to call the [CreateStore](#create-store) or [ListStores](#list-stores) methods).

SUPPORTED_RUNTIMES.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
## Node.js Support Policy for OpenFGA JS SDK
1+
## Runtime Support Policy for OpenFGA JS SDK
2+
3+
### Node.js Support
24

35
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.
46

5-
### Currently Supported Versions
7+
#### Currently Supported Versions
68

79
| Node.js Version | Upstream Support Status | Tested in CI/CD Pipelines |
810
|:----------------|:------------------------|:-------------------------:|
@@ -11,12 +13,16 @@ The OpenFGA JavaScript SDK follows the upstream [Node.js release policy](https:/
1113
| **24** | LTS | Yes |
1214
| **25** | Current | Yes |
1315

14-
### Support Details
16+
#### Support Details
1517

16-
#### Best-Effort Support
18+
##### Best-Effort Support
1719

1820
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).
1921

20-
#### Long-term plan
22+
##### Long-term plan
2123

2224
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.
25+
26+
### Alternate Runtimes
27+
28+
Support for alternate runtimes such as Deno, Cloudflare Workers, and Vercel Edge is being gradually added. We will provide updates on our progress in the future.

0 commit comments

Comments
 (0)