workos 0.8.2 → 0.10.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.
Files changed (70) hide show
  1. package/README.md +10 -8
  2. package/dist/bin.js +62 -27
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/auth-status.d.ts +1 -0
  5. package/dist/commands/auth-status.js +56 -0
  6. package/dist/commands/auth-status.js.map +1 -0
  7. package/dist/commands/install-skill.d.ts +0 -1
  8. package/dist/commands/install-skill.js +2 -10
  9. package/dist/commands/install-skill.js.map +1 -1
  10. package/dist/commands/list-skills.d.ts +4 -0
  11. package/dist/commands/list-skills.js +52 -0
  12. package/dist/commands/list-skills.js.map +1 -0
  13. package/dist/commands/login.js +5 -4
  14. package/dist/commands/login.js.map +1 -1
  15. package/dist/commands/uninstall-skill.d.ts +11 -0
  16. package/dist/commands/uninstall-skill.js +116 -0
  17. package/dist/commands/uninstall-skill.js.map +1 -0
  18. package/dist/doctor/checks/ai-analysis.js +3 -3
  19. package/dist/doctor/checks/ai-analysis.js.map +1 -1
  20. package/dist/integrations/dotnet/index.js +7 -12
  21. package/dist/integrations/dotnet/index.js.map +1 -1
  22. package/dist/integrations/elixir/index.js +7 -13
  23. package/dist/integrations/elixir/index.js.map +1 -1
  24. package/dist/integrations/go/index.js +5 -11
  25. package/dist/integrations/go/index.js.map +1 -1
  26. package/dist/integrations/python/index.js +7 -13
  27. package/dist/integrations/python/index.js.map +1 -1
  28. package/dist/integrations/ruby/index.js +9 -14
  29. package/dist/integrations/ruby/index.js.map +1 -1
  30. package/dist/lib/adapters/cli-adapter.js +1 -1
  31. package/dist/lib/adapters/cli-adapter.js.map +1 -1
  32. package/dist/lib/agent-interface.js +10 -9
  33. package/dist/lib/agent-interface.js.map +1 -1
  34. package/dist/lib/agent-runner.js +24 -19
  35. package/dist/lib/agent-runner.js.map +1 -1
  36. package/dist/lib/credential-proxy.js +1 -1
  37. package/dist/lib/credential-proxy.js.map +1 -1
  38. package/dist/lib/ensure-auth.js +3 -3
  39. package/dist/lib/ensure-auth.js.map +1 -1
  40. package/dist/lib/run-with-core.js +1 -1
  41. package/dist/lib/run-with-core.js.map +1 -1
  42. package/dist/lib/token-refresh-client.js +1 -1
  43. package/dist/lib/token-refresh-client.js.map +1 -1
  44. package/dist/lib/token-refresh.js +1 -1
  45. package/dist/lib/token-refresh.js.map +1 -1
  46. package/dist/lib/version-check.js +2 -1
  47. package/dist/lib/version-check.js.map +1 -1
  48. package/dist/utils/exit-codes.js +1 -1
  49. package/dist/utils/exit-codes.js.map +1 -1
  50. package/dist/utils/help-json.js +62 -23
  51. package/dist/utils/help-json.js.map +1 -1
  52. package/package.json +2 -3
  53. package/.claude-plugin/plugin.json +0 -13
  54. package/skills/workos-authkit-base/SKILL.md +0 -123
  55. package/skills/workos-authkit-nextjs/SKILL.md +0 -247
  56. package/skills/workos-authkit-react/SKILL.md +0 -91
  57. package/skills/workos-authkit-react-router/SKILL.md +0 -107
  58. package/skills/workos-authkit-sveltekit/SKILL.md +0 -160
  59. package/skills/workos-authkit-tanstack-start/SKILL.md +0 -300
  60. package/skills/workos-authkit-vanilla-js/SKILL.md +0 -83
  61. package/skills/workos-dotnet/SKILL.md +0 -163
  62. package/skills/workos-elixir/SKILL.md +0 -194
  63. package/skills/workos-go/SKILL.md +0 -191
  64. package/skills/workos-kotlin/SKILL.md +0 -161
  65. package/skills/workos-management/SKILL.md +0 -250
  66. package/skills/workos-node/SKILL.md +0 -164
  67. package/skills/workos-php/SKILL.md +0 -127
  68. package/skills/workos-php-laravel/SKILL.md +0 -147
  69. package/skills/workos-python/SKILL.md +0 -159
  70. package/skills/workos-ruby/SKILL.md +0 -163
@@ -1,160 +0,0 @@
1
- ---
2
- name: workos-authkit-sveltekit
3
- description: Integrate WorkOS AuthKit with SvelteKit. Server-side authentication with hooks and file-based routing.
4
- ---
5
-
6
- # WorkOS AuthKit for SvelteKit
7
-
8
- ## Step 1: Fetch SDK Documentation (BLOCKING)
9
-
10
- **STOP. Do not proceed until complete.**
11
-
12
- WebFetch: `https://github.com/workos/authkit-sveltekit/blob/main/README.md`
13
-
14
- The README is the source of truth. If this skill conflicts with README, follow README.
15
-
16
- ## Step 2: Pre-Flight Validation
17
-
18
- ### Project Structure
19
-
20
- - Confirm `svelte.config.js` (or `svelte.config.ts`) exists
21
- - Confirm `package.json` contains `@sveltejs/kit` dependency
22
- - Confirm `src/routes/` directory exists
23
-
24
- ### Environment Variables
25
-
26
- Check `.env` or `.env.local` for:
27
-
28
- - `WORKOS_API_KEY` - starts with `sk_`
29
- - `WORKOS_CLIENT_ID` - starts with `client_`
30
- - `WORKOS_REDIRECT_URI` - valid callback URL
31
- - `WORKOS_COOKIE_PASSWORD` - 32+ characters
32
-
33
- SvelteKit uses `$env/static/private` and `$env/dynamic/private` natively. The agent should write env vars to `.env` (SvelteKit's default) or `.env.local`.
34
-
35
- ## Step 3: Install SDK
36
-
37
- Detect package manager, install SDK package from README.
38
-
39
- ```
40
- pnpm-lock.yaml? → pnpm add @workos-inc/authkit-sveltekit
41
- yarn.lock? → yarn add @workos-inc/authkit-sveltekit
42
- bun.lockb? → bun add @workos-inc/authkit-sveltekit
43
- else → npm install @workos-inc/authkit-sveltekit
44
- ```
45
-
46
- **Verify:** SDK package exists in node_modules before continuing.
47
-
48
- ## Step 4: Configure Server Hooks
49
-
50
- SvelteKit uses `src/hooks.server.ts` for server-side middleware. This is where the AuthKit handler is registered.
51
-
52
- Create or update `src/hooks.server.ts` with the authkit handle function from the README.
53
-
54
- ### Existing Hooks (IMPORTANT)
55
-
56
- If `src/hooks.server.ts` already exists with custom logic, use SvelteKit's `sequence()` helper to compose hooks:
57
-
58
- ```typescript
59
- import { sequence } from '@sveltejs/kit/hooks';
60
- import { authkitHandle } from '@workos-inc/authkit-sveltekit'; // Check README for exact export
61
-
62
- export const handle = sequence(authkitHandle, yourExistingHandle);
63
- ```
64
-
65
- Check README for the exact export name and usage pattern.
66
-
67
- ## Step 5: Create Callback Route
68
-
69
- Parse `WORKOS_REDIRECT_URI` to determine route path:
70
-
71
- ```
72
- URI path --> Route location
73
- /callback --> src/routes/callback/+server.ts
74
- /auth/callback --> src/routes/auth/callback/+server.ts
75
- ```
76
-
77
- Use the SDK's callback handler from the README. Do not write custom OAuth logic.
78
-
79
- **Critical:** SvelteKit uses `+server.ts` for API routes, not `+page.server.ts`.
80
-
81
- ## Step 6: Layout Setup
82
-
83
- Update `src/routes/+layout.server.ts` to load the auth session and pass it to all pages.
84
-
85
- Check README for the exact pattern — typically a `load` function that returns the user session from locals.
86
-
87
- ```typescript
88
- // src/routes/+layout.server.ts
89
- import type { LayoutServerLoad } from './$types';
90
-
91
- export const load: LayoutServerLoad = async (event) => {
92
- // Check README for exact API — session is typically on event.locals
93
- return {
94
- user: event.locals.user, // or similar from README
95
- };
96
- };
97
- ```
98
-
99
- ## Step 7: UI Integration
100
-
101
- Add auth UI to `src/routes/+page.svelte` using the session data from the layout.
102
-
103
- - Show user info when authenticated
104
- - Show sign-in link/button when not authenticated
105
- - Add sign-out functionality
106
-
107
- Check README for sign-in URL generation and sign-out patterns.
108
-
109
- ## Verification Checklist (ALL MUST PASS)
110
-
111
- Run these commands to confirm integration. **Do not mark complete until all pass:**
112
-
113
- ```bash
114
- # 1. Check hooks.server.ts exists and has authkit
115
- grep -i "workos\|authkit" src/hooks.server.ts || echo "FAIL: authkit missing from hooks.server.ts"
116
-
117
- # 2. Check callback route exists
118
- find src/routes -name "+server.ts" -path "*/callback/*"
119
-
120
- # 3. Check layout loads auth session
121
- grep -i "user\|auth\|session" src/routes/+layout.server.ts || echo "FAIL: auth session missing from layout"
122
-
123
- # 4. Build succeeds
124
- pnpm build || npm run build
125
- ```
126
-
127
- ## Error Recovery
128
-
129
- ### "Cannot find module '@workos-inc/authkit-sveltekit'"
130
-
131
- - Check: SDK installed before writing imports
132
- - Check: SDK package directory exists in node_modules
133
- - Re-run install if missing
134
-
135
- ### hooks.server.ts not taking effect
136
-
137
- - Check: File is at `src/hooks.server.ts`, not `src/hooks.ts` or elsewhere
138
- - Check: Named export is `handle` (SvelteKit requirement)
139
- - Check: If using `sequence()`, all handles are properly composed
140
-
141
- ### Callback route not found (404)
142
-
143
- - Check: File uses `+server.ts` (not `+page.server.ts`)
144
- - Check: Route path matches `WORKOS_REDIRECT_URI` path exactly
145
- - Check: Exports `GET` handler (SvelteKit convention)
146
-
147
- ### "locals" type errors
148
-
149
- - Check: App.Locals interface is augmented in `src/app.d.ts`
150
- - Check README for TypeScript setup instructions
151
-
152
- ### Cookie password error
153
-
154
- - Verify `WORKOS_COOKIE_PASSWORD` is 32+ characters
155
- - Generate new: `openssl rand -base64 32`
156
-
157
- ### Auth state not available in pages
158
-
159
- - Check: `+layout.server.ts` load function returns user data
160
- - Check: Pages access data via `export let data` (Svelte 4) or `$page.data` (Svelte 5)
@@ -1,300 +0,0 @@
1
- ---
2
- name: workos-authkit-tanstack-start
3
- description: Integrate WorkOS AuthKit with TanStack Start applications. Full-stack TypeScript with server functions. Use when project uses TanStack Start, @tanstack/start, or vinxi.
4
- ---
5
-
6
- # WorkOS AuthKit for TanStack Start
7
-
8
- ## Decision Tree
9
-
10
- ```
11
- 1. Fetch README (BLOCKING)
12
- ├── Extract package name from install command
13
- └── README is source of truth for ALL code patterns
14
-
15
- 2. Detect directory structure
16
- ├── src/ (TanStack Start v1.132+, default)
17
- └── app/ (legacy vinxi-based projects)
18
-
19
- 3. Follow README install/setup exactly
20
- └── Do not invent commands or patterns
21
- ```
22
-
23
- ## Fetch SDK Documentation (BLOCKING)
24
-
25
- **STOP - Do not proceed until complete.**
26
-
27
- WebFetch: `https://github.com/workos/authkit-tanstack-start/blob/main/README.md`
28
-
29
- From README, extract:
30
-
31
- 1. Package name: `@workos/authkit-tanstack-react-start`
32
- 2. Use that exact name for all imports
33
-
34
- **README overrides this skill if conflict.**
35
-
36
- ## Pre-Flight Checklist
37
-
38
- - [ ] README fetched and package name extracted
39
- - [ ] `@tanstack/start` or `@tanstack/react-start` in package.json
40
- - [ ] Identify directory structure: `src/` (modern) or `app/` (legacy)
41
- - [ ] Environment variables set (see below)
42
-
43
- ## Directory Structure Detection
44
-
45
- **Modern TanStack Start (v1.132+)** uses `src/`:
46
-
47
- ```
48
- src/
49
- ├── start.ts # Middleware config (CRITICAL)
50
- ├── router.tsx # Router setup
51
- ├── routes/
52
- │ ├── __root.tsx # Root layout
53
- │ ├── api.auth.callback.tsx # OAuth callback (flat route)
54
- │ └── ...
55
- ```
56
-
57
- **Legacy (vinxi-based)** uses `app/`:
58
-
59
- ```
60
- app/
61
- ├── start.ts or router.tsx
62
- ├── routes/
63
- │ └── api/auth/callback.tsx # OAuth callback (nested route)
64
- ```
65
-
66
- **Detection:**
67
-
68
- ```bash
69
- ls src/routes 2>/dev/null && echo "Modern (src/)" || echo "Legacy (app/)"
70
- ```
71
-
72
- ## Environment Variables
73
-
74
- | Variable | Format | Required |
75
- | ------------------------ | ------------ | -------- |
76
- | `WORKOS_API_KEY` | `sk_...` | Yes |
77
- | `WORKOS_CLIENT_ID` | `client_...` | Yes |
78
- | `WORKOS_REDIRECT_URI` | Full URL | Yes |
79
- | `WORKOS_COOKIE_PASSWORD` | 32+ chars | Yes |
80
-
81
- Generate password if missing: `openssl rand -base64 32`
82
-
83
- Default redirect URI: `http://localhost:3000/api/auth/callback`
84
-
85
- ## Middleware Configuration (CRITICAL)
86
-
87
- **authkitMiddleware MUST be configured or auth will fail silently.**
88
-
89
- **WARNING: Do NOT add middleware to `createRouter()` in `router.tsx` or `app.tsx`. That is TanStack Router (client-side only). Server middleware belongs in `start.ts` using `requestMiddleware`.**
90
-
91
- ### If `start.ts` already exists
92
-
93
- Read the existing file first. Add `authkitMiddleware` to the existing `requestMiddleware` array (or create the array if missing). Preserve the existing export style. Do not rewrite the file from scratch.
94
-
95
- ### If `start.ts` does not exist
96
-
97
- Create `src/start.ts` (or `app/start.ts` for legacy) using `createStart`:
98
-
99
- ```typescript
100
- import { createStart } from '@tanstack/react-start';
101
- import { authkitMiddleware } from '@workos/authkit-tanstack-react-start';
102
-
103
- export const startInstance = createStart(() => ({
104
- requestMiddleware: [authkitMiddleware()],
105
- }));
106
- ```
107
-
108
- **Two things matter here:**
109
-
110
- 1. **Named export `startInstance`** — the build plugin generates `import type { startInstance }` from this file. A `default` export will cause a build error.
111
- 2. **`createStart` takes a function** returning the options object, not the options directly. `createStart({ ... })` will fail.
112
-
113
- ### Verification Checklist
114
-
115
- - [ ] `authkitMiddleware` imported from `@workos/authkit-tanstack-react-start`
116
- - [ ] Middleware in `requestMiddleware` array (not `middleware`)
117
- - [ ] Named export: `export const startInstance = createStart(...)` (not `export default`)
118
-
119
- Verify: `grep -r "authkitMiddleware" src/ app/ 2>/dev/null`
120
-
121
- ## Callback Route (CRITICAL)
122
-
123
- Path must match `WORKOS_REDIRECT_URI`. For `/api/auth/callback`:
124
-
125
- **Modern (flat routes):** `src/routes/api.auth.callback.tsx`
126
- **Legacy (nested routes):** `app/routes/api/auth/callback.tsx`
127
-
128
- ```typescript
129
- import { createFileRoute } from '@tanstack/react-router';
130
- import { handleCallbackRoute } from '@workos/authkit-tanstack-react-start';
131
-
132
- export const Route = createFileRoute('/api/auth/callback')({
133
- server: {
134
- handlers: {
135
- GET: handleCallbackRoute(),
136
- },
137
- },
138
- });
139
- ```
140
-
141
- **Key points:**
142
-
143
- - Use `handleCallbackRoute()` - do not write custom OAuth logic
144
- - Route path string must match the URI path exactly
145
- - This is a server-only route (no component needed)
146
-
147
- ## Protected Routes
148
-
149
- Use `getAuth()` in route loaders to check authentication:
150
-
151
- ```typescript
152
- import { createFileRoute, redirect } from '@tanstack/react-router';
153
- import { getAuth, getSignInUrl } from '@workos/authkit-tanstack-react-start';
154
-
155
- export const Route = createFileRoute('/dashboard')({
156
- loader: async () => {
157
- const { user } = await getAuth();
158
- if (!user) {
159
- const signInUrl = await getSignInUrl();
160
- throw redirect({ href: signInUrl });
161
- }
162
- return { user };
163
- },
164
- component: Dashboard,
165
- });
166
- ```
167
-
168
- ## Sign Out Route
169
-
170
- ```typescript
171
- import { createFileRoute, redirect } from '@tanstack/react-router';
172
- import { signOut } from '@workos/authkit-tanstack-react-start';
173
-
174
- export const Route = createFileRoute('/signout')({
175
- loader: async () => {
176
- await signOut();
177
- throw redirect({ href: '/' });
178
- },
179
- });
180
- ```
181
-
182
- ## Client-Side Hooks (Optional)
183
-
184
- Only needed if you want reactive auth state in components.
185
-
186
- **1. Add AuthKitProvider to root:**
187
-
188
- ```typescript
189
- // src/routes/__root.tsx
190
- import { AuthKitProvider } from '@workos/authkit-tanstack-react-start/client';
191
-
192
- function RootComponent() {
193
- return (
194
- <AuthKitProvider>
195
- <Outlet />
196
- </AuthKitProvider>
197
- );
198
- }
199
- ```
200
-
201
- **2. Use hooks in components:**
202
-
203
- ```typescript
204
- import { useAuth } from '@workos/authkit-tanstack-react-start/client';
205
-
206
- function Profile() {
207
- const { user, isLoading } = useAuth();
208
- // ...
209
- }
210
- ```
211
-
212
- **Note:** Server-side `getAuth()` is preferred for most use cases.
213
-
214
- ## Finalize (REQUIRED before declaring success)
215
-
216
- After creating/editing all files, run these steps in order. Skipping them is the most common cause of build failures.
217
-
218
- ### 1. Regenerate the route tree
219
-
220
- Adding new route files (callback, signout, etc.) makes the existing `routeTree.gen.ts` stale. The build will fail with type errors about missing routes until it is regenerated.
221
-
222
- ```bash
223
- pnpm build 2>/dev/null || npx tsr generate
224
- ```
225
-
226
- The build itself triggers route tree regeneration. If it fails for other reasons, use `tsr generate` directly.
227
-
228
- ### 2. Ensure Vite type declarations exist
229
-
230
- TanStack Start projects import CSS with `import styles from './styles.css?url'`. Without Vite's type declarations, TypeScript will error on these imports. Check if `src/vite-env.d.ts` (or `app/vite-env.d.ts`) exists — if not, create it now (before attempting the build):
231
-
232
- ```typescript
233
- /// <reference types="vite/client" />
234
- ```
235
-
236
- ### 3. Verify the build
237
-
238
- ```bash
239
- pnpm build
240
- ```
241
-
242
- Do not skip this step. If the build fails, fix the errors before finishing. Common causes:
243
-
244
- - Stale route tree → re-run step 1
245
- - Missing Vite types → re-run step 2
246
- - Wrong import paths → check package name is `@workos/authkit-tanstack-react-start`
247
-
248
- ## Error Recovery
249
-
250
- ### "AuthKit middleware is not configured"
251
-
252
- **Cause:** `authkitMiddleware()` not in start.ts
253
- **Fix:** Create/update `src/start.ts` with middleware config
254
- **Verify:** `grep -r "authkitMiddleware" src/`
255
-
256
- ### "Module not found" for SDK
257
-
258
- **Cause:** Wrong package name or not installed
259
- **Fix:** `pnpm add @workos/authkit-tanstack-react-start`
260
- **Verify:** `ls node_modules/@workos/authkit-tanstack-react-start`
261
-
262
- ### Callback 404
263
-
264
- **Cause:** Route file path doesn't match WORKOS_REDIRECT_URI
265
- **Fix:**
266
-
267
- - URI `/api/auth/callback` → file `src/routes/api.auth.callback.tsx` (flat) or `app/routes/api/auth/callback.tsx` (nested)
268
- - Route path string in `createFileRoute()` must match exactly
269
-
270
- ### getAuth returns undefined user
271
-
272
- **Cause:** Middleware not configured or not running
273
- **Fix:** Ensure `authkitMiddleware()` is in start.ts requestMiddleware array
274
-
275
- ### "Cookie password too short"
276
-
277
- **Cause:** WORKOS_COOKIE_PASSWORD < 32 chars
278
- **Fix:** `openssl rand -base64 32`, update .env
279
-
280
- ### Build fails with route type errors
281
-
282
- **Cause:** Route tree not regenerated after adding routes
283
- **Fix:** `pnpm dev` to regenerate `routeTree.gen.ts`
284
-
285
- ## SDK Exports Reference
286
-
287
- **Server (main export):**
288
-
289
- - `authkitMiddleware()` - Request middleware
290
- - `handleCallbackRoute()` - OAuth callback handler
291
- - `getAuth()` - Get current session
292
- - `signOut()` - Sign out user
293
- - `getSignInUrl()` / `getSignUpUrl()` - Auth URLs
294
- - `switchToOrganization()` - Change org context
295
-
296
- **Client (`/client` subpath):**
297
-
298
- - `AuthKitProvider` - Context provider
299
- - `useAuth()` - Auth state hook
300
- - `useAccessToken()` - Token management
@@ -1,83 +0,0 @@
1
- ---
2
- name: workos-authkit-vanilla-js
3
- description: Integrate WorkOS AuthKit with vanilla JavaScript applications. No framework required, browser-only. Use when project is plain HTML/JS, doesn't use React/Vue/etc, or mentions vanilla JavaScript authentication.
4
- ---
5
-
6
- # WorkOS AuthKit for Vanilla JavaScript
7
-
8
- ## Decision Tree
9
-
10
- ### Step 1: Fetch README (BLOCKING)
11
-
12
- WebFetch: `https://github.com/workos/authkit-js/blob/main/README.md`
13
-
14
- **README is source of truth.** If this skill conflicts, follow README.
15
-
16
- ### Step 2: Detect Project Type
17
-
18
- ```
19
- Has package.json with build tool (Vite, webpack, Parcel)?
20
- YES -> Bundled project (npm install)
21
- NO -> CDN/Static project (script tag)
22
- ```
23
-
24
- ### Step 3: Follow README Installation
25
-
26
- - **Bundled**: Use package manager install from README
27
- - **CDN**: Use unpkg script tag from README
28
-
29
- ### Step 4: Implement Per README
30
-
31
- Follow README examples for:
32
-
33
- - Client initialization
34
- - Sign in/out handlers
35
- - User state management
36
-
37
- ## Critical API Quirk
38
-
39
- `createClient()` is **async** - returns a Promise, not a client directly.
40
-
41
- ```javascript
42
- // CORRECT
43
- const authkit = await createClient(clientId);
44
- ```
45
-
46
- ## Verification Checklist
47
-
48
- - [ ] README fetched and read before writing code
49
- - [ ] Project type detected (bundled vs CDN)
50
- - [ ] SDK installed/script added
51
- - [ ] `createClient()` called with `await`
52
- - [ ] Client ID provided (env var or hardcoded)
53
- - [ ] Sign in called from user gesture (click handler)
54
- - [ ] No console errors on page load
55
- - [ ] Auth UI updates on sign in/out
56
-
57
- ## Environment Variables
58
-
59
- **Bundled projects only:**
60
-
61
- - Vite: `VITE_WORKOS_CLIENT_ID`
62
- - Webpack: `REACT_APP_WORKOS_CLIENT_ID` or custom
63
- - No `WORKOS_API_KEY` needed (client-side SDK)
64
-
65
- ## Error Recovery
66
-
67
- | Error | Cause | Fix |
68
- | -------------------------------- | ------------------- | ------------------------------------------------------ |
69
- | `WorkOS is not defined` | CDN not loaded | Add script to `<head>` before your code |
70
- | `createClient is not a function` | Wrong import | npm: check import path; CDN: use `WorkOS.createClient` |
71
- | `clientId is required` | Undefined env var | Check env prefix matches build tool |
72
- | CORS errors | `file://` protocol | Use local dev server (`npx serve`) |
73
- | Popup blocked | Not user gesture | Call `signIn()` only from click handler |
74
- | Auth state lost | Token not persisted | Check localStorage in dev tools |
75
-
76
- ## Task Flow
77
-
78
- 1. **preflight**: Fetch README, detect project type, verify env vars
79
- 2. **install**: Add SDK per project type
80
- 3. **callback**: SDK handles internally (no server route needed)
81
- 4. **provider**: Initialize client with `await createClient()`
82
- 5. **ui**: Add auth buttons and state display
83
- 6. **verify**: Build (if bundled), check console
@@ -1,163 +0,0 @@
1
- ---
2
- name: workos-dotnet
3
- description: Integrate WorkOS AuthKit with .NET (ASP.NET Core). Backend authentication with DI registration, auth endpoints, and appsettings configuration.
4
- ---
5
-
6
- # WorkOS AuthKit for .NET (ASP.NET Core)
7
-
8
- ## Step 1: Fetch SDK Documentation (BLOCKING)
9
-
10
- **STOP. Do not proceed until complete.**
11
-
12
- WebFetch: `https://raw.githubusercontent.com/workos/workos-dotnet/main/README.md`
13
-
14
- The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
15
-
16
- ## Step 2: Pre-Flight Validation
17
-
18
- ### Project Structure
19
-
20
- - Confirm a `*.csproj` file exists in the project root
21
- - Detect project style:
22
- - **Minimal API** (modern): `Program.cs` with `WebApplication.CreateBuilder()` — .NET 6+
23
- - **Startup pattern** (older): `Startup.cs` with `ConfigureServices()` / `Configure()` — .NET 5 and earlier
24
-
25
- This detection determines WHERE to register WorkOS services and middleware.
26
-
27
- ### Environment Variables
28
-
29
- Check `appsettings.Development.json` for:
30
-
31
- - `WORKOS_API_KEY` — starts with `sk_`
32
- - `WORKOS_CLIENT_ID` — starts with `client_`
33
-
34
- ## Step 3: Install SDK
35
-
36
- ```bash
37
- dotnet add package WorkOS.net
38
- ```
39
-
40
- **Verify:** Check the `*.csproj` file contains a `<PackageReference Include="WorkOS.net"` entry.
41
-
42
- If `dotnet` CLI is not available, stop and inform the user to install the .NET SDK.
43
-
44
- ## Step 4: Configure WorkOS Client
45
-
46
- ### Minimal API Pattern (Program.cs)
47
-
48
- Add WorkOS configuration to `Program.cs`:
49
-
50
- 1. Read WorkOS settings from `IConfiguration`
51
- 2. Register the WorkOS client in the DI container
52
- 3. The WorkOS client needs API key for initialization
53
-
54
- ```csharp
55
- // In Program.cs, after builder creation:
56
- var workosApiKey = builder.Configuration["WorkOS:ApiKey"];
57
- var workosClientId = builder.Configuration["WorkOS:ClientId"];
58
- ```
59
-
60
- ### Startup Pattern (Startup.cs)
61
-
62
- Add to `ConfigureServices()`:
63
-
64
- 1. Read WorkOS settings from `IConfiguration`
65
- 2. Register services
66
-
67
- Choose the pattern that matches the detected project structure.
68
-
69
- ## Step 5: Create Authentication Endpoints
70
-
71
- Create auth endpoints following the WorkOS AuthKit pattern. Use minimal API `app.MapGet()` for minimal API projects, or a Controller for Startup-pattern projects.
72
-
73
- ### Required Endpoints
74
-
75
- **GET /auth/login** — Redirect to WorkOS AuthKit:
76
-
77
- - Use the WorkOS SDK to generate an authorization URL
78
- - Include `clientId`, `redirectUri`, and `provider: "authkit"` parameters
79
- - Redirect the user to the authorization URL
80
-
81
- **GET /auth/callback** — Handle OAuth callback:
82
-
83
- - Extract `code` from query parameters
84
- - Exchange authorization code for user profile using the WorkOS SDK
85
- - Store user info in session or cookie
86
- - Redirect to home page
87
-
88
- **GET /auth/logout** — Clear session:
89
-
90
- - Clear the authentication session/cookie
91
- - Redirect to home page
92
-
93
- ### Session Management
94
-
95
- Use ASP.NET Core's built-in session or cookie authentication:
96
-
97
- ```csharp
98
- // Enable session middleware in Program.cs
99
- builder.Services.AddDistributedMemoryCache();
100
- builder.Services.AddSession();
101
- // ...
102
- app.UseSession();
103
- ```
104
-
105
- ## Step 6: Environment Setup
106
-
107
- Configure `appsettings.Development.json` with WorkOS credentials:
108
-
109
- ```json
110
- {
111
- "WorkOS": {
112
- "ApiKey": "<WORKOS_API_KEY value>",
113
- "ClientId": "<WORKOS_CLIENT_ID value>",
114
- "RedirectUri": "http://localhost:5000/auth/callback"
115
- }
116
- }
117
- ```
118
-
119
- Use the actual credential values provided in the environment context.
120
-
121
- **Important:** Do NOT put secrets in `appsettings.json` (committed to git). Use `appsettings.Development.json` (gitignored) or `dotnet user-secrets`.
122
-
123
- ## Step 7: Verification
124
-
125
- Run these checks — **do not mark complete until all pass:**
126
-
127
- ```bash
128
- # 1. Check WorkOS.net is in csproj
129
- grep -i "WorkOS" *.csproj
130
-
131
- # 2. Check auth endpoints exist
132
- grep -r "auth/login\|auth/callback\|auth/logout" *.cs
133
-
134
- # 3. Build succeeds
135
- dotnet build
136
- ```
137
-
138
- **If build fails:** Read the error output carefully. Common issues:
139
-
140
- - Missing `using` statements for WorkOS namespaces
141
- - Incorrect DI registration order
142
- - Missing session/cookie middleware registration
143
-
144
- ## Error Recovery
145
-
146
- ### "dotnet: command not found"
147
-
148
- - .NET SDK is not installed. Inform the user to install from https://dotnet.microsoft.com/download
149
-
150
- ### NuGet restore failures
151
-
152
- - Check internet connectivity
153
- - Try `dotnet restore` explicitly before `dotnet build`
154
-
155
- ### "No project file found"
156
-
157
- - Ensure you're in the correct directory with a `*.csproj` file
158
-
159
- ### Build errors after integration
160
-
161
- - Check that all `using` statements are correct
162
- - Verify DI registration order (services before middleware)
163
- - Ensure `app.UseSession()` is called before mapping auth endpoints