@productcraft/platform-auth 0.0.13 → 0.1.1

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 CHANGED
@@ -22,9 +22,8 @@ The two are easy to confuse because both have "auth" in the name. Platform-Auth
22
22
  ```ts
23
23
  import { PlatformAuth } from "@productcraft/platform-auth";
24
24
 
25
- const platformAuth = new PlatformAuth({
26
- auth: { type: "apiKey", key: process.env.PCFT_KEY! },
27
- });
25
+ // Reads PRODUCTCRAFT_API_KEY from the environment
26
+ const platformAuth = new PlatformAuth();
28
27
 
29
28
  // Resolve the caller's effective policy + enabled services for a workspace
30
29
  const { data } = await platformAuth.client.GET(
@@ -48,10 +47,24 @@ The `client` is an [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) inst
48
47
 
49
48
  PAKs are workspace-scoped credentials — they read + introspect freely against the workspace they're bound to but cannot mint another PAK or reshape the human-admin surface. Cross-workspace probes by a PAK return the uniform non-member shape (no slug → UUID oracle).
50
49
 
50
+ ## Credentials from the environment
51
+
52
+ Server-side, omit `auth` and the client reads your workspace key from the environment:
53
+
54
+ ```bash
55
+ # .env
56
+ PRODUCTCRAFT_API_KEY=pcft_live_...
57
+ ```
58
+
59
+ - An explicit `auth` always wins over the environment.
60
+ - Hosts are never read from the environment. Override them in code with `baseUrl`.
61
+ - This is a server-only fallback. Never put a key in `NEXT_PUBLIC_*` or any other variable a bundler inlines into browser code.
62
+
51
63
  ## Configuration
52
64
 
53
65
  ```ts
54
66
  new PlatformAuth({
67
+ // Omit to use PRODUCTCRAFT_API_KEY from the environment
55
68
  auth: { type: "apiKey", key: "pcft_live_..." }
56
69
  | { type: "bearer", token: "eyJ..." }
57
70
  | { type: "cookie", value: "auth_token=..." },