@productcraft/platform-auth 0.0.2 → 0.0.3

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,58 @@
1
+ # @productcraft/platform-auth
2
+
3
+ Typed Node.js SDK for [ProductCraft Platform-Auth](https://productcraft.co) — workspaces, PlatformUser sign-in, API keys, members, invites.
4
+
5
+ ```bash
6
+ npm install @productcraft/platform-auth
7
+ ```
8
+
9
+ Server-side only. The SDK ships a Platform API Key; never embed it in a browser bundle.
10
+
11
+ This package targets the **platform-side** identity model — the ProductCraft workspace owners who administer your apps. For end-user authentication on a product you build on top of Heimdall, you want [`@productcraft/heimdall`](https://www.npmjs.com/package/@productcraft/heimdall) instead.
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import { PlatformAuth } from "@productcraft/platform-auth";
17
+
18
+ const platformAuth = new PlatformAuth({
19
+ auth: { type: "apiKey", key: process.env.PCFT_KEY! },
20
+ });
21
+
22
+ // Resolve the caller's effective policy + enabled services for a workspace
23
+ const { data } = await platformAuth.client.GET(
24
+ "/v1/introspect/workspaces/{workspaceId}",
25
+ { params: { path: { workspaceId: "ws_..." } } },
26
+ );
27
+
28
+ // Create a workspace API key for a CI bot
29
+ await platformAuth.client.POST(
30
+ "/v1/workspaces/{slug}/api-keys",
31
+ {
32
+ params: { path: { slug: "my-workspace" } },
33
+ body: { name: "ci-bot", permissions: ["envoi.read", "rally.read"] },
34
+ },
35
+ );
36
+ ```
37
+
38
+ The `client` is an [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) instance bound to `https://api.auth.productcraft.co` and your auth credential.
39
+
40
+ ## Configuration
41
+
42
+ ```ts
43
+ new PlatformAuth({
44
+ auth: { type: "apiKey", key: "pcft_live_..." }
45
+ | { type: "bearer", token: "eyJ..." }
46
+ | { type: "cookie", value: "auth_token=..." },
47
+ baseUrl: "https://api.auth.example.test", // optional override
48
+ fetch: customFetch, // optional
49
+ });
50
+ ```
51
+
52
+ ## How this SDK is built
53
+
54
+ Generated from the live OpenAPI spec at `https://api.auth.productcraft.co/docs-json` via [`openapi-typescript`](https://openapi-ts.dev/) + [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/). The nightly `spec-refresh` workflow opens a PR whenever the spec changes.
55
+
56
+ ## License
57
+
58
+ [MIT](https://github.com/clauderanelagh/productcraft-node/blob/main/LICENSE).