@lumiblue/secrets 0.1.15

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.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # `@lumiblue/secrets`
2
+
3
+ Typed client for the Lumiblue Secrets HTTP API. Built around `createSdkClient` + `Sdk`. Uses the runtime `fetch` API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @lumiblue/secrets
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Always pass a client into `Sdk` so credentials stay encapsulated on that instance:
14
+
15
+ ```ts
16
+ import { createSdkClient, Sdk } from "@lumiblue/secrets";
17
+
18
+ const sdk = new Sdk({
19
+ client: createSdkClient({
20
+ apiKey: process.env.LUMIBLUE_API_KEY!,
21
+ // servers: ["https://secrets.lumiblue.nl"], // optional failover list
22
+ // aud: ["secrets"], // optional; default ["secrets"]
23
+ }),
24
+ });
25
+
26
+ const health = await sdk.getApiHealth();
27
+ if (health.error) {
28
+ console.error(health.error);
29
+ } else {
30
+ console.log(health.data);
31
+ }
32
+
33
+ await sdk.getApiHealthMe();
34
+ ```
35
+
36
+ Methods map 1:1 to Secrets routes. Each call returns `data` / `error` / `response` unless you pass `throwOnError: true`.
37
+
38
+ ### `createSdkClient` options
39
+
40
+ - `apiKey` — M2M secret; sent as `x-api-key` when minting JWTs
41
+ - `servers` — API base URLs for failover (defaults to package OpenAPI servers)
42
+ - `aud` — audience list on `POST /api/lumiblue-token` (defaults to `["secrets"]`)
43
+
44
+ ### Auth flow (M2M)
45
+
46
+ 1. On 401, `POST /api/lumiblue-token` with header `x-api-key` and body `{ aud }`.
47
+ 2. The returned JWT is kept in that client’s memory and sent as `Authorization: Bearer`.
48
+ 3. `logout()` on the client clears its in-memory API key and JWT.
49
+
50
+ Machine keys are created in the Secrets UI (Machines). The full secret is returned only once on create — list/get do not expose it again.