productcraft 0.2.10 → 0.3.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 +16 -3
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -25,9 +25,8 @@ The per-product packages are leaner (no bundled deps for the surfaces you don't
|
|
|
25
25
|
```ts
|
|
26
26
|
import { ProductCraft } from "productcraft";
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
28
|
+
// Reads PRODUCTCRAFT_API_KEY from the environment
|
|
29
|
+
const pc = new ProductCraft();
|
|
31
30
|
|
|
32
31
|
// Auth — sign in an EndUser through the BFF flow
|
|
33
32
|
const consumer = pc.auth.consumer("my-app-slug");
|
|
@@ -78,11 +77,25 @@ class ProductCraft {
|
|
|
78
77
|
|
|
79
78
|
Each is the same class you'd get from installing its per-product package directly — `pc.auth` is `new Auth(config)`, etc. The classes are re-exported so you can refer to their types: `import type { Auth } from "productcraft"`.
|
|
80
79
|
|
|
80
|
+
## Credentials from the environment
|
|
81
|
+
|
|
82
|
+
Server-side, omit `auth` and the client reads your workspace key from the environment:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# .env
|
|
86
|
+
PRODUCTCRAFT_API_KEY=pcft_live_...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- An explicit `auth` always wins over the environment.
|
|
90
|
+
- Hosts are never read from the environment. Override them in code with `baseUrl`.
|
|
91
|
+
- This is a server-only fallback. Never put a key in `NEXT_PUBLIC_*` or any other variable a bundler inlines into browser code.
|
|
92
|
+
|
|
81
93
|
## Configuration
|
|
82
94
|
|
|
83
95
|
```ts
|
|
84
96
|
new ProductCraft({
|
|
85
97
|
// Shared auth credential — applied to every surface
|
|
98
|
+
// Omit to use PRODUCTCRAFT_API_KEY from the environment
|
|
86
99
|
auth: { type: "apiKey", key: "pcft_live_..." }
|
|
87
100
|
| { type: "bearer", token: "eyJ..." }
|
|
88
101
|
| { type: "cookie", value: "auth_token=..." },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "productcraft",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "All-in-one Node.js / TypeScript SDK for the ProductCraft platform — Auth, Mail, Waitlist, Social, Platform-Auth, and Trawl from a single import. Install per-product packages (`@productcraft/auth`, ...) if you only need one.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"provenance": true
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@productcraft/social": "^0.
|
|
54
|
-
"@productcraft/core": "^0.
|
|
55
|
-
"@productcraft/mail": "^0.
|
|
56
|
-
"@productcraft/auth": "^0.
|
|
57
|
-
"@productcraft/platform-auth": "^0.0
|
|
58
|
-
"@productcraft/waitlist": "^0.
|
|
59
|
-
"@productcraft/trawl": "^0.
|
|
53
|
+
"@productcraft/social": "^0.8.0",
|
|
54
|
+
"@productcraft/core": "^0.3.0",
|
|
55
|
+
"@productcraft/mail": "^0.2.0",
|
|
56
|
+
"@productcraft/auth": "^0.8.0",
|
|
57
|
+
"@productcraft/platform-auth": "^0.1.0",
|
|
58
|
+
"@productcraft/waitlist": "^0.2.0",
|
|
59
|
+
"@productcraft/trawl": "^0.2.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsup",
|