Skip to content

Commit a41f5cf

Browse files
feat: jwt client
1 parent 6408d39 commit a41f5cf

File tree

6 files changed

+6731
-787
lines changed

6 files changed

+6731
-787
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ const client = new ReferralExchangeClient({
165165
});
166166
```
167167

168+
### JWT Authenticated Client
169+
170+
If you need to authenticate requests by signing short-lived JWTs locally, use the `ReferralExchangeJwtClient`. It
171+
accepts a PEM-encoded ES256 private key and the API key name to embed as the issuer claim. Each request automatically
172+
receives a freshly signed token (15 second TTL) in the `Authorization` header.
173+
174+
```typescript
175+
import { ReferralExchangeJwtClient } from "@opengovsg/refx-ts-sdk";
176+
177+
const client = new ReferralExchangeJwtClient({
178+
privateKey: process.env.REFX_PRIVATE_KEY!,
179+
apiKeyName: process.env.REFX_API_KEY_NAME!,
180+
environment: "Production", // or pass baseUrl
181+
});
182+
183+
const offerings = await client.offerings.list();
184+
```
185+
168186
## Contributing
169187

170188
While we value open-source contributions to this SDK, this library is generated programmatically.

0 commit comments

Comments
 (0)