@auth-craft/backend-sdk 0.7.9 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +28 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -58,6 +58,7 @@ if (result.ok) {
58
58
  | `fetchImpl` | `typeof fetch` | `globalThis.fetch` | Custom fetch implementation |
59
59
  | `timeout` | `number` | `30000` | Request timeout in milliseconds |
60
60
  | `headers` | `Record<string, string>` | `{}` | Custom headers for all requests |
61
+ | `secretHeader` | `{ value: string; name?: string }` | — | Optional shared secret header for direct backend access |
61
62
  | `logger` | `{ warn(...) }` | — | Optional transport diagnostic logger |
62
63
 
63
64
  ### `ServiceJwtConfig`
@@ -214,6 +215,33 @@ const client = new InternalClient({
214
215
  });
215
216
  ```
216
217
 
218
+ ### Direct Lambda / Docker Access
219
+
220
+ If you call the backend directly instead of going through the Cloudflare Worker, the backend may require a secret header such as `X-Gateway-Secret`.
221
+
222
+ ```typescript
223
+ const client = new InternalClient({
224
+ baseUrl: 'https://lambda-or-docker.example.com',
225
+ jwt: {
226
+ privateKey: process.env.INTERNAL_JWT_PRIVATE_KEY!,
227
+ serviceId: 'my-service',
228
+ },
229
+ secretHeader: {
230
+ value: process.env.GATEWAY_SECRET!,
231
+ // name defaults to 'X-Gateway-Secret'
232
+ },
233
+ });
234
+ ```
235
+
236
+ You can override the header name if your backend expects a different one:
237
+
238
+ ```typescript
239
+ secretHeader: {
240
+ name: 'X-Internal-Secret',
241
+ value: process.env.INTERNAL_SECRET!,
242
+ }
243
+ ```
244
+
217
245
  ## Auth Permission Strings
218
246
 
219
247
  Use `AUTH_PERM_STRINGS` constants when setting `authPerms`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth-craft/backend-sdk",
3
- "version": "0.7.9",
3
+ "version": "0.8.0",
4
4
  "description": "Type-safe internal service SDK for Auth-Craft service-to-service calls",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",