@productcraft/waitlist 0.1.1 → 0.2.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.
package/README.md CHANGED
@@ -40,9 +40,8 @@ If the waitlist has `settings.recaptcha_site_key` set, also pass a `recaptcha_to
40
40
  ```ts
41
41
  import { Waitlist } from "@productcraft/waitlist";
42
42
 
43
- const waitlist = new Waitlist({
44
- auth: { type: "apiKey", key: process.env.PCFT_KEY! },
45
- });
43
+ // Reads PRODUCTCRAFT_API_KEY from the environment
44
+ const waitlist = new Waitlist();
46
45
 
47
46
  // Create a waitlist — body uses `display_name`, not `name`.
48
47
  const { data } = await waitlist.client.POST(
@@ -56,11 +55,25 @@ const { data } = await waitlist.client.POST(
56
55
 
57
56
  `{workspace_id}` is the workspace UUID returned by `@productcraft/platform-auth`'s introspect endpoint.
58
57
 
58
+ ## Credentials from the environment
59
+
60
+ Server-side, omit `auth` and the client reads your workspace key from the environment:
61
+
62
+ ```bash
63
+ # .env
64
+ PRODUCTCRAFT_API_KEY=pcft_live_...
65
+ ```
66
+
67
+ - An explicit `auth` always wins over the environment.
68
+ - Hosts are never read from the environment. Override them in code with `baseUrl`.
69
+ - This is a server-only fallback. Never put a key in `NEXT_PUBLIC_*` or any other variable a bundler inlines into browser code.
70
+
59
71
  ## Configuration
60
72
 
61
73
  ```ts
62
74
  new Waitlist({
63
75
  // Optional: required for workspace-admin calls. Public submit works without auth.
76
+ // Omit to use PRODUCTCRAFT_API_KEY from the environment
64
77
  auth: { type: "apiKey", key: "pcft_live_..." }
65
78
  | { type: "bearer", token: "eyJ..." }
66
79
  | { type: "cookie", value: "auth_token=..." },