workos 0.0.24 → 0.1.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/.claude-plugin/plugin.json +13 -0
- package/LICENSE +47 -0
- package/README.md +154 -1
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +163 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.config.d.ts +52 -0
- package/dist/cli.config.js +70 -0
- package/dist/cli.config.js.map +1 -0
- package/dist/package.json +87 -0
- package/dist/src/commands/install-skill.d.ts +20 -0
- package/dist/src/commands/install-skill.js +130 -0
- package/dist/src/commands/install-skill.js.map +1 -0
- package/dist/src/commands/install.d.ts +22 -0
- package/dist/src/commands/install.js +57 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/login.d.ts +1 -0
- package/dist/src/commands/login.js +141 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/logout.d.ts +1 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/logout.js.map +1 -0
- package/dist/src/dashboard/components/AnimatedLogo.d.ts +8 -0
- package/dist/src/dashboard/components/AnimatedLogo.js +16 -0
- package/dist/src/dashboard/components/AnimatedLogo.js.map +1 -0
- package/dist/src/dashboard/components/CompletionView.d.ts +13 -0
- package/dist/src/dashboard/components/CompletionView.js +21 -0
- package/dist/src/dashboard/components/CompletionView.js.map +1 -0
- package/dist/src/dashboard/components/ConfirmPrompt.d.ts +9 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js +25 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js.map +1 -0
- package/dist/src/dashboard/components/CredentialsForm.d.ts +10 -0
- package/dist/src/dashboard/components/CredentialsForm.js +47 -0
- package/dist/src/dashboard/components/CredentialsForm.js.map +1 -0
- package/dist/src/dashboard/components/Dashboard.d.ts +3 -0
- package/dist/src/dashboard/components/Dashboard.js +100 -0
- package/dist/src/dashboard/components/Dashboard.js.map +1 -0
- package/dist/src/dashboard/components/DashboardLayout.d.ts +24 -0
- package/dist/src/dashboard/components/DashboardLayout.js +25 -0
- package/dist/src/dashboard/components/DashboardLayout.js.map +1 -0
- package/dist/src/dashboard/components/DiffPanel.d.ts +9 -0
- package/dist/src/dashboard/components/DiffPanel.js +136 -0
- package/dist/src/dashboard/components/DiffPanel.js.map +1 -0
- package/dist/src/dashboard/components/InlinePrompt.d.ts +8 -0
- package/dist/src/dashboard/components/InlinePrompt.js +19 -0
- package/dist/src/dashboard/components/InlinePrompt.js.map +1 -0
- package/dist/src/dashboard/components/OutputPanel.d.ts +10 -0
- package/dist/src/dashboard/components/OutputPanel.js +100 -0
- package/dist/src/dashboard/components/OutputPanel.js.map +1 -0
- package/dist/src/dashboard/components/Panel.d.ts +12 -0
- package/dist/src/dashboard/components/Panel.js +6 -0
- package/dist/src/dashboard/components/Panel.js.map +1 -0
- package/dist/src/dashboard/components/TextInput.d.ts +13 -0
- package/dist/src/dashboard/components/TextInput.js +57 -0
- package/dist/src/dashboard/components/TextInput.js.map +1 -0
- package/dist/src/dashboard/components/WelcomeArt.d.ts +2 -0
- package/dist/src/dashboard/components/WelcomeArt.js +9 -0
- package/dist/src/dashboard/components/WelcomeArt.js.map +1 -0
- package/dist/src/dashboard/hooks/useAnimation.d.ts +7 -0
- package/dist/src/dashboard/hooks/useAnimation.js +24 -0
- package/dist/src/dashboard/hooks/useAnimation.js.map +1 -0
- package/dist/src/dashboard/hooks/useKeyboard.d.ts +8 -0
- package/dist/src/dashboard/hooks/useKeyboard.js +18 -0
- package/dist/src/dashboard/hooks/useKeyboard.js.map +1 -0
- package/dist/src/dashboard/hooks/useTerminalSize.d.ts +8 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js +23 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +6 -0
- package/dist/src/dashboard/index.js +36 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/lib/diff-utils.d.ts +21 -0
- package/dist/src/dashboard/lib/diff-utils.js +271 -0
- package/dist/src/dashboard/lib/diff-utils.js.map +1 -0
- package/dist/src/dashboard/lib/logo-frames.d.ts +20 -0
- package/dist/src/dashboard/lib/logo-frames.js +109 -0
- package/dist/src/dashboard/lib/logo-frames.js.map +1 -0
- package/dist/src/dashboard/lib/welcome-art.d.ts +1 -0
- package/dist/src/dashboard/lib/welcome-art.js +5 -0
- package/dist/src/dashboard/lib/welcome-art.js.map +1 -0
- package/dist/src/dashboard/types.d.ts +5 -0
- package/dist/src/dashboard/types.js +2 -0
- package/dist/src/dashboard/types.js.map +1 -0
- package/dist/src/lib/__tests__/test-utils.d.ts +40 -0
- package/dist/src/lib/__tests__/test-utils.js +108 -0
- package/dist/src/lib/__tests__/test-utils.js.map +1 -0
- package/dist/src/lib/adapters/cli-adapter.d.ts +56 -0
- package/dist/src/lib/adapters/cli-adapter.js +318 -0
- package/dist/src/lib/adapters/cli-adapter.js.map +1 -0
- package/dist/src/lib/adapters/dashboard-adapter.d.ts +30 -0
- package/dist/src/lib/adapters/dashboard-adapter.js +97 -0
- package/dist/src/lib/adapters/dashboard-adapter.js.map +1 -0
- package/dist/src/lib/adapters/index.d.ts +3 -0
- package/dist/src/lib/adapters/index.js +3 -0
- package/dist/src/lib/adapters/index.js.map +1 -0
- package/dist/src/lib/adapters/types.d.ts +41 -0
- package/dist/src/lib/adapters/types.js +2 -0
- package/dist/src/lib/adapters/types.js.map +1 -0
- package/dist/src/lib/agent-interface.d.ts +75 -0
- package/dist/src/lib/agent-interface.js +563 -0
- package/dist/src/lib/agent-interface.js.map +1 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +213 -0
- package/dist/src/lib/agent-runner.js.map +1 -0
- package/dist/src/lib/api.d.ts +25 -0
- package/dist/src/lib/api.js +120 -0
- package/dist/src/lib/api.js.map +1 -0
- package/dist/src/lib/config.d.ts +60 -0
- package/dist/src/lib/config.js +88 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +32 -0
- package/dist/src/lib/constants.js +53 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/credentials.d.ts +19 -0
- package/dist/src/lib/credentials.js +55 -0
- package/dist/src/lib/credentials.js.map +1 -0
- package/dist/src/lib/env-writer.d.ts +14 -0
- package/dist/src/lib/env-writer.js +39 -0
- package/dist/src/lib/env-writer.js.map +1 -0
- package/dist/src/lib/events.d.ts +114 -0
- package/dist/src/lib/events.js +19 -0
- package/dist/src/lib/events.js.map +1 -0
- package/dist/src/lib/framework-config.d.ts +108 -0
- package/dist/src/lib/framework-config.js +11 -0
- package/dist/src/lib/framework-config.js.map +1 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +2 -0
- package/dist/src/lib/helper-functions.js.map +1 -0
- package/dist/src/lib/port-detection.d.ts +7 -0
- package/dist/src/lib/port-detection.js +112 -0
- package/dist/src/lib/port-detection.js.map +1 -0
- package/dist/src/lib/progress-tracker.d.ts +22 -0
- package/dist/src/lib/progress-tracker.js +47 -0
- package/dist/src/lib/progress-tracker.js.map +1 -0
- package/dist/src/lib/run-with-core.d.ts +2 -0
- package/dist/src/lib/run-with-core.js +266 -0
- package/dist/src/lib/run-with-core.js.map +1 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +212 -0
- package/dist/src/lib/safe-tools.js.map +1 -0
- package/dist/src/lib/settings.d.ts +59 -0
- package/dist/src/lib/settings.js +36 -0
- package/dist/src/lib/settings.js.map +1 -0
- package/dist/src/lib/token-refresh.d.ts +12 -0
- package/dist/src/lib/token-refresh.js +26 -0
- package/dist/src/lib/token-refresh.js.map +1 -0
- package/dist/src/lib/validation/build-validator.d.ts +9 -0
- package/dist/src/lib/validation/build-validator.js +118 -0
- package/dist/src/lib/validation/build-validator.js.map +1 -0
- package/dist/src/lib/validation/index.d.ts +3 -0
- package/dist/src/lib/validation/index.js +3 -0
- package/dist/src/lib/validation/index.js.map +1 -0
- package/dist/src/lib/validation/types.d.ts +41 -0
- package/dist/src/lib/validation/types.js +2 -0
- package/dist/src/lib/validation/types.js.map +1 -0
- package/dist/src/lib/validation/validator.d.ts +6 -0
- package/dist/src/lib/validation/validator.js +647 -0
- package/dist/src/lib/validation/validator.js.map +1 -0
- package/dist/src/lib/wizard-core.d.ts +200 -0
- package/dist/src/lib/wizard-core.js +392 -0
- package/dist/src/lib/wizard-core.js.map +1 -0
- package/dist/src/lib/wizard-core.types.d.ts +73 -0
- package/dist/src/lib/wizard-core.types.js +2 -0
- package/dist/src/lib/wizard-core.types.js.map +1 -0
- package/dist/src/lib/workos-management.d.ts +32 -0
- package/dist/src/lib/workos-management.js +142 -0
- package/dist/src/lib/workos-management.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard-agent.d.ts +6 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js +97 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -0
- package/dist/src/nextjs/utils.d.ts +8 -0
- package/dist/src/nextjs/utils.js +53 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/react/react-wizard-agent.d.ts +2 -0
- package/dist/src/react/react-wizard-agent.js +47 -0
- package/dist/src/react/react-wizard-agent.js.map +1 -0
- package/dist/src/react-router/react-router-wizard-agent.d.ts +6 -0
- package/dist/src/react-router/react-router-wizard-agent.js +103 -0
- package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/react-router/utils.d.ts +19 -0
- package/dist/src/react-router/utils.js +210 -0
- package/dist/src/react-router/utils.js.map +1 -0
- package/dist/src/run.d.ts +24 -0
- package/dist/src/run.js +48 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +155 -0
- package/dist/src/steps/add-or-update-environment-variables.js.map +1 -0
- package/dist/src/steps/index.d.ts +3 -0
- package/dist/src/steps/index.js +4 -0
- package/dist/src/steps/index.js.map +1 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +54 -0
- package/dist/src/steps/run-prettier.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +8 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +7 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +57 -0
- package/dist/src/steps/upload-environment-variables/index.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +14 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +104 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.d.ts +2 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js +49 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +29 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/utils/analytics.d.ts +24 -0
- package/dist/src/utils/analytics.js +139 -0
- package/dist/src/utils/analytics.js.map +1 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +17 -0
- package/dist/src/utils/bash.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +93 -0
- package/dist/src/utils/clack-utils.js +397 -0
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/dist/src/utils/clack.d.ts +5 -0
- package/dist/src/utils/clack.js +34 -0
- package/dist/src/utils/clack.js.map +1 -0
- package/dist/src/utils/cli-symbols.d.ts +32 -0
- package/dist/src/utils/cli-symbols.js +46 -0
- package/dist/src/utils/cli-symbols.js.map +1 -0
- package/dist/src/utils/debug.d.ts +7 -0
- package/dist/src/utils/debug.js +88 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/env-parser.d.ts +5 -0
- package/dist/src/utils/env-parser.js +18 -0
- package/dist/src/utils/env-parser.js.map +1 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +69 -0
- package/dist/src/utils/environment.js.map +1 -0
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +7 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +36 -0
- package/dist/src/utils/logging.js.map +1 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +21 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +167 -0
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/redact.d.ts +5 -0
- package/dist/src/utils/redact.js +29 -0
- package/dist/src/utils/redact.js.map +1 -0
- package/dist/src/utils/semver.d.ts +10 -0
- package/dist/src/utils/semver.js +43 -0
- package/dist/src/utils/semver.js.map +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +6 -0
- package/dist/src/utils/string.js.map +1 -0
- package/dist/src/utils/telemetry-client.d.ts +15 -0
- package/dist/src/utils/telemetry-client.js +57 -0
- package/dist/src/utils/telemetry-client.js.map +1 -0
- package/dist/src/utils/telemetry-types.d.ts +51 -0
- package/dist/src/utils/telemetry-types.js +6 -0
- package/dist/src/utils/telemetry-types.js.map +1 -0
- package/dist/src/utils/types.d.ts +80 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/src/utils/urls.d.ts +7 -0
- package/dist/src/utils/urls.js +8 -0
- package/dist/src/utils/urls.js.map +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +21 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js.map +1 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.d.ts +2 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js +47 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js.map +1 -0
- package/package.json +76 -84
- package/skills/workos-authkit-base/SKILL.md +113 -0
- package/skills/workos-authkit-nextjs/SKILL.md +115 -0
- package/skills/workos-authkit-react/SKILL.md +91 -0
- package/skills/workos-authkit-react-router/SKILL.md +106 -0
- package/skills/workos-authkit-tanstack-start/SKILL.md +104 -0
- package/skills/workos-authkit-vanilla-js/SKILL.md +81 -0
- package/build/apps/index.js +0 -50
- package/build/apps/slack.js +0 -151
- package/build/cli.js +0 -42
- package/build/config.js +0 -34
- package/build/dev.js +0 -5
- package/build/enable-api-access.png +0 -0
- package/build/groups.js +0 -480
- package/build/index.js +0 -3
- package/build/info.js +0 -69
- package/build/login.js +0 -161
- package/build/main.js +0 -214
- package/build/users.js +0 -402
- package/build/util.js +0 -157
- package/coverage/clover.xml +0 -66
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/cli.ts.html +0 -329
- package/coverage/lcov-report/config.ts.html +0 -152
- package/coverage/lcov-report/index.html +0 -119
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov-report/util.ts.html +0 -350
- package/coverage/lcov.info +0 -121
- package/package-lock.json +0 -7617
- package/tests/util.test.ts +0 -35
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workos-authkit-base
|
|
3
|
+
description: Architectural reference for WorkOS AuthKit integrations. Fetch README first for implementation details.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WorkOS AuthKit Base Template
|
|
7
|
+
|
|
8
|
+
## First Action: Fetch README
|
|
9
|
+
|
|
10
|
+
Before any implementation, fetch the framework-specific README:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
WebFetch: {sdk-package-name} README from npmjs.com or GitHub
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
README is the source of truth for: install commands, imports, API usage, code patterns.
|
|
17
|
+
|
|
18
|
+
## Task Structure (Required)
|
|
19
|
+
|
|
20
|
+
| Phase | Task | Blocked By | Purpose |
|
|
21
|
+
|-------|------|------------|---------|
|
|
22
|
+
| 1 | preflight | - | Verify env vars, detect framework |
|
|
23
|
+
| 2 | install | preflight | Install SDK package |
|
|
24
|
+
| 3 | callback | install | Create OAuth callback route |
|
|
25
|
+
| 4 | provider | install | Setup auth context/middleware |
|
|
26
|
+
| 5 | ui | callback, provider | Add sign-in/out UI |
|
|
27
|
+
| 6 | verify | ui | Build confirmation |
|
|
28
|
+
|
|
29
|
+
## Decision Trees
|
|
30
|
+
|
|
31
|
+
### Package Manager Detection
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
pnpm-lock.yaml? → pnpm
|
|
35
|
+
yarn.lock? → yarn
|
|
36
|
+
bun.lockb? → bun
|
|
37
|
+
else → npm
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Provider vs Middleware
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Client-side framework? → AuthKitProvider wraps app
|
|
44
|
+
Server-side framework? → Middleware handles sessions
|
|
45
|
+
Hybrid (Next.js)? → Both may be needed
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Callback Route Location
|
|
49
|
+
|
|
50
|
+
Extract path from `WORKOS_REDIRECT_URI` → create route at that exact path.
|
|
51
|
+
|
|
52
|
+
## Environment Variables
|
|
53
|
+
|
|
54
|
+
| Variable | Purpose | When Required |
|
|
55
|
+
|----------|---------|---------------|
|
|
56
|
+
| `WORKOS_API_KEY` | Server authentication | Server SDKs |
|
|
57
|
+
| `WORKOS_CLIENT_ID` | Client identification | All SDKs |
|
|
58
|
+
| `WORKOS_REDIRECT_URI` | OAuth callback URL | Server SDKs |
|
|
59
|
+
| `WORKOS_COOKIE_PASSWORD` | Session encryption (32+ chars) | Server SDKs |
|
|
60
|
+
|
|
61
|
+
Note: Some frameworks use prefixed variants (e.g., `NEXT_PUBLIC_*`). Check README.
|
|
62
|
+
|
|
63
|
+
## Verification Checklists
|
|
64
|
+
|
|
65
|
+
### After Install
|
|
66
|
+
- [ ] SDK package installed in node_modules
|
|
67
|
+
- [ ] No install errors in output
|
|
68
|
+
|
|
69
|
+
### After Callback Route
|
|
70
|
+
- [ ] Route file exists at path matching `WORKOS_REDIRECT_URI`
|
|
71
|
+
- [ ] Imports SDK callback handler (not custom OAuth)
|
|
72
|
+
|
|
73
|
+
### After Provider/Middleware
|
|
74
|
+
- [ ] Provider wraps entire app (client-side)
|
|
75
|
+
- [ ] Middleware configured in correct location (server-side)
|
|
76
|
+
|
|
77
|
+
### After UI
|
|
78
|
+
- [ ] Home page shows conditional auth state
|
|
79
|
+
- [ ] Uses SDK functions for sign-in/out URLs
|
|
80
|
+
|
|
81
|
+
### Final Verification
|
|
82
|
+
- [ ] Build completes with exit code 0
|
|
83
|
+
- [ ] No import resolution errors
|
|
84
|
+
|
|
85
|
+
## Error Recovery
|
|
86
|
+
|
|
87
|
+
### Module not found
|
|
88
|
+
- [ ] Verify install completed successfully
|
|
89
|
+
- [ ] Verify SDK exists in node_modules
|
|
90
|
+
- [ ] Re-run install if missing
|
|
91
|
+
|
|
92
|
+
### Build import errors
|
|
93
|
+
- [ ] Delete `node_modules`, reinstall
|
|
94
|
+
- [ ] Verify package.json has SDK dependency
|
|
95
|
+
|
|
96
|
+
### Invalid redirect URI
|
|
97
|
+
- [ ] Compare route path to `WORKOS_REDIRECT_URI`
|
|
98
|
+
- [ ] Paths must match exactly
|
|
99
|
+
|
|
100
|
+
### Cookie password error
|
|
101
|
+
- [ ] Verify `WORKOS_COOKIE_PASSWORD` is 32+ characters
|
|
102
|
+
- [ ] Generate new: `openssl rand -base64 32`
|
|
103
|
+
|
|
104
|
+
### Auth state not persisting
|
|
105
|
+
- [ ] Verify provider wraps entire app
|
|
106
|
+
- [ ] Check middleware is in correct location
|
|
107
|
+
|
|
108
|
+
## Critical Rules
|
|
109
|
+
|
|
110
|
+
1. **Install SDK before writing imports** - never create import statements for uninstalled packages
|
|
111
|
+
2. **Use SDK functions** - never construct OAuth URLs manually
|
|
112
|
+
3. **Follow README patterns** - SDK APIs change between versions
|
|
113
|
+
4. **Extract callback path from env** - don't hardcode `/auth/callback`
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workos-authkit-nextjs
|
|
3
|
+
description: Integrate WorkOS AuthKit with Next.js App Router (13+). Server-side rendering required.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WorkOS AuthKit for Next.js
|
|
7
|
+
|
|
8
|
+
## Step 1: Fetch SDK Documentation (BLOCKING)
|
|
9
|
+
|
|
10
|
+
**STOP. Do not proceed until complete.**
|
|
11
|
+
|
|
12
|
+
WebFetch: `https://github.com/workos/authkit-nextjs/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
|
+
- Confirm `next.config.js` or `next.config.mjs` exists
|
|
20
|
+
- Confirm `package.json` contains `"next"` dependency
|
|
21
|
+
|
|
22
|
+
### Environment Variables
|
|
23
|
+
Check `.env.local` for:
|
|
24
|
+
- `WORKOS_API_KEY` - starts with `sk_`
|
|
25
|
+
- `WORKOS_CLIENT_ID` - starts with `client_`
|
|
26
|
+
- `NEXT_PUBLIC_WORKOS_REDIRECT_URI` - valid callback URL
|
|
27
|
+
- `WORKOS_COOKIE_PASSWORD` - 32+ characters
|
|
28
|
+
|
|
29
|
+
## Step 3: Install SDK
|
|
30
|
+
|
|
31
|
+
Detect package manager, install SDK package from README.
|
|
32
|
+
|
|
33
|
+
**Verify:** SDK package exists in node_modules before continuing.
|
|
34
|
+
|
|
35
|
+
## Step 4: Version Detection (Decision Tree)
|
|
36
|
+
|
|
37
|
+
Read Next.js version from `package.json`:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Next.js version?
|
|
41
|
+
|
|
|
42
|
+
+-- 16+ --> Create proxy.ts at project root
|
|
43
|
+
|
|
|
44
|
+
+-- 13-15 --> Create middleware.ts at project root
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Critical:** File MUST be at project root (or `src/` if using src directory). Never in `app/`.
|
|
48
|
+
|
|
49
|
+
Middleware/proxy code: See README for `authkitMiddleware()` export pattern.
|
|
50
|
+
|
|
51
|
+
## Step 5: Create Callback Route
|
|
52
|
+
|
|
53
|
+
Parse `NEXT_PUBLIC_WORKOS_REDIRECT_URI` to determine route path:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
URI path --> Route location
|
|
57
|
+
/auth/callback --> app/auth/callback/route.ts
|
|
58
|
+
/callback --> app/callback/route.ts
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `handleAuth()` from SDK. Do not write custom OAuth logic.
|
|
62
|
+
|
|
63
|
+
## Step 6: Provider Setup
|
|
64
|
+
|
|
65
|
+
Wrap app in `AuthKitProvider` in `app/layout.tsx`. See README for import path.
|
|
66
|
+
|
|
67
|
+
## Step 7: UI Integration
|
|
68
|
+
|
|
69
|
+
Add auth UI to `app/page.tsx` using SDK functions. See README for `getUser`, `getSignInUrl`, `signOut` usage.
|
|
70
|
+
|
|
71
|
+
## Verification Checklist
|
|
72
|
+
|
|
73
|
+
Run these commands to confirm integration:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Check middleware/proxy exists (one should match)
|
|
77
|
+
ls proxy.ts middleware.ts src/proxy.ts src/middleware.ts 2>/dev/null
|
|
78
|
+
|
|
79
|
+
# Check provider is wrapped
|
|
80
|
+
grep -l "AuthKitProvider" app/layout.tsx
|
|
81
|
+
|
|
82
|
+
# Check callback route exists
|
|
83
|
+
find app -name "route.ts" -path "*/callback/*"
|
|
84
|
+
|
|
85
|
+
# Build succeeds
|
|
86
|
+
npm run build
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
All checks must pass before marking complete.
|
|
90
|
+
|
|
91
|
+
## Error Recovery
|
|
92
|
+
|
|
93
|
+
### "middleware.ts not found"
|
|
94
|
+
- Check: File at project root or `src/`, not inside `app/`
|
|
95
|
+
- Check: Filename matches Next.js version (proxy.ts for 16+, middleware.ts for 13-15)
|
|
96
|
+
|
|
97
|
+
### "Cannot use getUser in client component"
|
|
98
|
+
- Check: Component has no `'use client'` directive, or
|
|
99
|
+
- Check: Move auth logic to server component/API route
|
|
100
|
+
|
|
101
|
+
### "Module not found" for SDK import
|
|
102
|
+
- Check: SDK installed before writing imports
|
|
103
|
+
- Check: SDK package directory exists in node_modules
|
|
104
|
+
|
|
105
|
+
### "withAuth route not covered by middleware"
|
|
106
|
+
- Check: Middleware/proxy file exists at correct location
|
|
107
|
+
- Check: Matcher config includes the route path
|
|
108
|
+
|
|
109
|
+
### Build fails after AuthKitProvider
|
|
110
|
+
- Check: README for correct import path (may be subpath export)
|
|
111
|
+
- Check: No client/server boundary violations
|
|
112
|
+
|
|
113
|
+
### NEXT_PUBLIC_ prefix issues
|
|
114
|
+
- Client components need `NEXT_PUBLIC_*` prefix
|
|
115
|
+
- Server components use plain env var names
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workos-authkit-react
|
|
3
|
+
description: Integrate WorkOS AuthKit with React single-page applications. Client-side only authentication. Use when the project is a React SPA without Next.js or React Router.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WorkOS AuthKit for React (SPA)
|
|
7
|
+
|
|
8
|
+
## Decision Tree
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
START
|
|
12
|
+
│
|
|
13
|
+
├─► Fetch README (BLOCKING)
|
|
14
|
+
│ github.com/workos/authkit-react/blob/main/README.md
|
|
15
|
+
│ README is source of truth. Stop if fetch fails.
|
|
16
|
+
│
|
|
17
|
+
├─► Detect Build Tool
|
|
18
|
+
│ ├─ vite.config.ts exists? → Vite
|
|
19
|
+
│ └─ otherwise → Create React App
|
|
20
|
+
│
|
|
21
|
+
├─► Set Env Var Prefix
|
|
22
|
+
│ ├─ Vite → VITE_WORKOS_CLIENT_ID
|
|
23
|
+
│ └─ CRA → REACT_APP_WORKOS_CLIENT_ID
|
|
24
|
+
│
|
|
25
|
+
└─► Implement per README
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Critical: Build Tool Detection
|
|
29
|
+
|
|
30
|
+
| Marker File | Build Tool | Env Prefix | Access Pattern |
|
|
31
|
+
|-------------|------------|------------|----------------|
|
|
32
|
+
| `vite.config.ts` | Vite | `VITE_` | `import.meta.env.VITE_*` |
|
|
33
|
+
| `craco.config.js` or none | CRA | `REACT_APP_` | `process.env.REACT_APP_*` |
|
|
34
|
+
|
|
35
|
+
**Wrong prefix = undefined values at runtime.** This is the #1 integration failure.
|
|
36
|
+
|
|
37
|
+
## Key Clarification: No Callback Route
|
|
38
|
+
|
|
39
|
+
The React SDK handles OAuth callbacks **internally** via AuthKitProvider.
|
|
40
|
+
|
|
41
|
+
- No server-side callback route needed
|
|
42
|
+
- SDK intercepts redirect URI client-side
|
|
43
|
+
- Token exchange happens automatically
|
|
44
|
+
|
|
45
|
+
Just ensure redirect URI env var matches WorkOS Dashboard exactly.
|
|
46
|
+
|
|
47
|
+
## Required Environment Variables
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
{PREFIX}WORKOS_CLIENT_ID=client_...
|
|
51
|
+
{PREFIX}WORKOS_REDIRECT_URI=http://localhost:5173/callback
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
No `WORKOS_API_KEY` needed. Client-side only SDK.
|
|
55
|
+
|
|
56
|
+
## Verification Checklist
|
|
57
|
+
|
|
58
|
+
- [ ] README fetched and read
|
|
59
|
+
- [ ] Build tool detected correctly
|
|
60
|
+
- [ ] Env var prefix matches build tool
|
|
61
|
+
- [ ] `.env` or `.env.local` has required vars
|
|
62
|
+
- [ ] No `next` dependency (wrong skill)
|
|
63
|
+
- [ ] No `react-router` dependency (wrong skill)
|
|
64
|
+
- [ ] AuthKitProvider wraps app root
|
|
65
|
+
- [ ] `pnpm build` exits 0
|
|
66
|
+
|
|
67
|
+
## Error Recovery
|
|
68
|
+
|
|
69
|
+
### "clientId is required"
|
|
70
|
+
|
|
71
|
+
**Cause:** Env var inaccessible (wrong prefix)
|
|
72
|
+
|
|
73
|
+
Check: Does prefix match build tool? Vite needs `VITE_`, CRA needs `REACT_APP_`.
|
|
74
|
+
|
|
75
|
+
### Auth state lost on refresh
|
|
76
|
+
|
|
77
|
+
**Cause:** Token persistence issue
|
|
78
|
+
|
|
79
|
+
Check: Browser dev tools → Application → Local Storage. SDK stores tokens here automatically.
|
|
80
|
+
|
|
81
|
+
### useAuth returns undefined
|
|
82
|
+
|
|
83
|
+
**Cause:** Component outside provider tree
|
|
84
|
+
|
|
85
|
+
Check: Entry file (`main.tsx` or `index.tsx`) wraps `<App />` in `<AuthKitProvider>`.
|
|
86
|
+
|
|
87
|
+
### Callback redirect fails
|
|
88
|
+
|
|
89
|
+
**Cause:** URI mismatch
|
|
90
|
+
|
|
91
|
+
Check: Env var redirect URI exactly matches WorkOS Dashboard → Redirects configuration.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workos-authkit-react-router
|
|
3
|
+
description: Integrate WorkOS AuthKit with React Router applications. Supports v6 and v7 (Framework, Data, Declarative modes). Use when project uses react-router, react-router-dom, or mentions React Router authentication.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WorkOS AuthKit for React Router
|
|
7
|
+
|
|
8
|
+
## Decision Tree
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
1. Fetch README (BLOCKING)
|
|
12
|
+
2. Detect router mode
|
|
13
|
+
3. Follow README for that mode
|
|
14
|
+
4. Verify with checklist below
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Phase 1: Fetch SDK Documentation (BLOCKING)
|
|
18
|
+
|
|
19
|
+
**STOP - Do not write any code until this completes.**
|
|
20
|
+
|
|
21
|
+
WebFetch: `https://github.com/workos/authkit-react-router/blob/main/README.md`
|
|
22
|
+
|
|
23
|
+
The README is the source of truth. If this skill conflicts with README, **follow the README**.
|
|
24
|
+
|
|
25
|
+
## Phase 2: Detect Router Mode
|
|
26
|
+
|
|
27
|
+
| Mode | Detection Signal | Key Indicator |
|
|
28
|
+
| -------------- | ------------------------------- | --------------------------- |
|
|
29
|
+
| v7 Framework | `react-router.config.ts` exists | Routes in `app/routes/` |
|
|
30
|
+
| v7 Data | `createBrowserRouter` in source | Loaders in route config |
|
|
31
|
+
| v7 Declarative | `<BrowserRouter>` component | Routes as JSX, no loaders |
|
|
32
|
+
| v6 | package.json version `"6.x"` | Similar to v7 Declarative |
|
|
33
|
+
|
|
34
|
+
**Detection order:**
|
|
35
|
+
1. Check for `react-router.config.ts` (Framework mode)
|
|
36
|
+
2. Grep for `createBrowserRouter` (Data mode)
|
|
37
|
+
3. Check package.json version (v6 vs v7)
|
|
38
|
+
4. Default to Declarative if v7 with `<BrowserRouter>`
|
|
39
|
+
|
|
40
|
+
## Phase 3: Follow README
|
|
41
|
+
|
|
42
|
+
Based on detected mode, apply the corresponding README section. The README contains current API signatures and code patterns.
|
|
43
|
+
|
|
44
|
+
## Critical Distinctions
|
|
45
|
+
|
|
46
|
+
### authLoader vs authkitLoader
|
|
47
|
+
|
|
48
|
+
| Function | Purpose | Where to use |
|
|
49
|
+
| -------------- | -------------------------------- | ----------------------- |
|
|
50
|
+
| `authLoader` | OAuth callback handler | Callback route ONLY |
|
|
51
|
+
| `authkitLoader`| Fetch user data in routes | Any route needing auth |
|
|
52
|
+
|
|
53
|
+
**Common mistake:** Using `authkitLoader` for callback route. Use `authLoader()`.
|
|
54
|
+
|
|
55
|
+
### Root Route Requirement
|
|
56
|
+
|
|
57
|
+
Auth loader MUST be on root route for child routes to access auth context.
|
|
58
|
+
|
|
59
|
+
**Wrong:** Auth loader only on `/dashboard`
|
|
60
|
+
**Right:** Auth loader on `/` (root), children inherit context
|
|
61
|
+
|
|
62
|
+
## Environment Variables
|
|
63
|
+
|
|
64
|
+
Required in `.env` or `.env.local`:
|
|
65
|
+
|
|
66
|
+
- `WORKOS_API_KEY` - starts with `sk_`
|
|
67
|
+
- `WORKOS_CLIENT_ID` - starts with `client_`
|
|
68
|
+
- `WORKOS_REDIRECT_URI` - full URL (e.g., `http://localhost:3000/auth/callback`)
|
|
69
|
+
- `WORKOS_COOKIE_PASSWORD` - 32+ chars (server modes only)
|
|
70
|
+
|
|
71
|
+
## Verification Checklist
|
|
72
|
+
|
|
73
|
+
After implementation, verify:
|
|
74
|
+
|
|
75
|
+
- [ ] SDK installed in node_modules (package name from README)
|
|
76
|
+
- [ ] Callback route path matches `WORKOS_REDIRECT_URI` path segment
|
|
77
|
+
- [ ] Auth loader/provider on root route (not just child routes)
|
|
78
|
+
- [ ] Build succeeds: `npm run build` exits 0
|
|
79
|
+
- [ ] Correct mode pattern applied (loaders vs hooks)
|
|
80
|
+
|
|
81
|
+
## Error Recovery
|
|
82
|
+
|
|
83
|
+
### "loader is not a function"
|
|
84
|
+
|
|
85
|
+
**Cause:** Using loader pattern in Declarative/v6 mode
|
|
86
|
+
**Fix:** Declarative/v6 modes use `AuthKitProvider` + `useAuth` hook, not loaders
|
|
87
|
+
|
|
88
|
+
### Auth state not available in child routes
|
|
89
|
+
|
|
90
|
+
**Cause:** Auth loader missing from root route
|
|
91
|
+
**Fix:** Add `authkitLoader` (or `AuthKitProvider`) to root route so children inherit context
|
|
92
|
+
|
|
93
|
+
### useAuth returns undefined
|
|
94
|
+
|
|
95
|
+
**Cause:** Missing `AuthKitProvider` wrapper
|
|
96
|
+
**Fix:** Wrap app with `AuthKitProvider` (required for Declarative/v6 modes)
|
|
97
|
+
|
|
98
|
+
### Callback route 404
|
|
99
|
+
|
|
100
|
+
**Cause:** Route path mismatch with `WORKOS_REDIRECT_URI`
|
|
101
|
+
**Fix:** Extract exact path from env var, create route at that path
|
|
102
|
+
|
|
103
|
+
### "Module not found" for SDK
|
|
104
|
+
|
|
105
|
+
**Cause:** SDK not installed
|
|
106
|
+
**Fix:** Install SDK, wait for completion, verify `node_modules` before writing imports
|
|
@@ -0,0 +1,104 @@
|
|
|
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. Verify TanStack Start project
|
|
16
|
+
├── @tanstack/start or @tanstack/react-start in package.json
|
|
17
|
+
└── app.config.ts exists (vinxi)
|
|
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
|
+
1. Package name from install command (e.g., `pnpm add @workos/...`)
|
|
31
|
+
2. Use that exact name for all imports
|
|
32
|
+
|
|
33
|
+
**README overrides this skill if conflict.**
|
|
34
|
+
|
|
35
|
+
## Pre-Flight Checklist
|
|
36
|
+
|
|
37
|
+
- [ ] README fetched and package name extracted
|
|
38
|
+
- [ ] `@tanstack/start` or `@tanstack/react-start` in package.json
|
|
39
|
+
- [ ] `app.config.ts` exists
|
|
40
|
+
- [ ] Environment variables set (see below)
|
|
41
|
+
|
|
42
|
+
## Environment Variables
|
|
43
|
+
|
|
44
|
+
| Variable | Format | Required |
|
|
45
|
+
|----------|--------|----------|
|
|
46
|
+
| `WORKOS_API_KEY` | `sk_...` | Yes |
|
|
47
|
+
| `WORKOS_CLIENT_ID` | `client_...` | Yes |
|
|
48
|
+
| `WORKOS_REDIRECT_URI` | Full URL | Yes |
|
|
49
|
+
| `WORKOS_COOKIE_PASSWORD` | 32+ chars | Yes |
|
|
50
|
+
|
|
51
|
+
Generate password if missing: `openssl rand -base64 32`
|
|
52
|
+
|
|
53
|
+
## Middleware Configuration (CRITICAL)
|
|
54
|
+
|
|
55
|
+
**authkitMiddleware MUST be configured or auth will fail.**
|
|
56
|
+
|
|
57
|
+
Find file with `createRouter` (typically `app/router.tsx` or `app.tsx`).
|
|
58
|
+
|
|
59
|
+
### Verification Checklist
|
|
60
|
+
|
|
61
|
+
- [ ] `authkitMiddleware` imported from SDK package
|
|
62
|
+
- [ ] `middleware: [authkitMiddleware()]` in createRouter config
|
|
63
|
+
- [ ] Array syntax used: `[authkitMiddleware()]` not `authkitMiddleware()`
|
|
64
|
+
|
|
65
|
+
Verify: `grep "authkitMiddleware" app/router.tsx app.tsx src/router.tsx`
|
|
66
|
+
|
|
67
|
+
## Logout Route Pattern
|
|
68
|
+
|
|
69
|
+
Logout requires `signOut()` followed by redirect in a route loader. See README for exact implementation.
|
|
70
|
+
|
|
71
|
+
## Callback Route
|
|
72
|
+
|
|
73
|
+
Path must match `WORKOS_REDIRECT_URI`. If URI is `/api/auth/callback`:
|
|
74
|
+
- File: `app/routes/api/auth/callback.tsx`
|
|
75
|
+
- Use `handleAuth()` from SDK - do not write custom OAuth logic
|
|
76
|
+
|
|
77
|
+
## Error Recovery
|
|
78
|
+
|
|
79
|
+
### "AuthKit middleware is not configured"
|
|
80
|
+
|
|
81
|
+
**Cause:** `authkitMiddleware()` not added to router
|
|
82
|
+
**Fix:** Add `middleware: [authkitMiddleware()]` to createRouter config
|
|
83
|
+
**Verify:** `grep "authkitMiddleware" app/router.tsx app.tsx`
|
|
84
|
+
|
|
85
|
+
### "Module not found" for SDK
|
|
86
|
+
|
|
87
|
+
**Cause:** Wrong package name or not installed
|
|
88
|
+
**Fix:** Re-read README, extract correct package name, reinstall
|
|
89
|
+
**Verify:** `ls node_modules/` + package name from README
|
|
90
|
+
|
|
91
|
+
### Callback 404
|
|
92
|
+
|
|
93
|
+
**Cause:** Route path doesn't match WORKOS_REDIRECT_URI
|
|
94
|
+
**Fix:** File path must mirror URI path under `app/routes/`
|
|
95
|
+
|
|
96
|
+
### getAuth returns undefined
|
|
97
|
+
|
|
98
|
+
**Cause:** Middleware not configured
|
|
99
|
+
**Fix:** Same as "AuthKit middleware not configured" above
|
|
100
|
+
|
|
101
|
+
### "Cookie password too short"
|
|
102
|
+
|
|
103
|
+
**Cause:** WORKOS_COOKIE_PASSWORD < 32 chars
|
|
104
|
+
**Fix:** `openssl rand -base64 32`, update .env
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
- Client initialization
|
|
33
|
+
- Sign in/out handlers
|
|
34
|
+
- User state management
|
|
35
|
+
|
|
36
|
+
## Critical API Quirk
|
|
37
|
+
|
|
38
|
+
`createClient()` is **async** - returns a Promise, not a client directly.
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// CORRECT
|
|
42
|
+
const authkit = await createClient(clientId);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Verification Checklist
|
|
46
|
+
|
|
47
|
+
- [ ] README fetched and read before writing code
|
|
48
|
+
- [ ] Project type detected (bundled vs CDN)
|
|
49
|
+
- [ ] SDK installed/script added
|
|
50
|
+
- [ ] `createClient()` called with `await`
|
|
51
|
+
- [ ] Client ID provided (env var or hardcoded)
|
|
52
|
+
- [ ] Sign in called from user gesture (click handler)
|
|
53
|
+
- [ ] No console errors on page load
|
|
54
|
+
- [ ] Auth UI updates on sign in/out
|
|
55
|
+
|
|
56
|
+
## Environment Variables
|
|
57
|
+
|
|
58
|
+
**Bundled projects only:**
|
|
59
|
+
- Vite: `VITE_WORKOS_CLIENT_ID`
|
|
60
|
+
- Webpack: `REACT_APP_WORKOS_CLIENT_ID` or custom
|
|
61
|
+
- No `WORKOS_API_KEY` needed (client-side SDK)
|
|
62
|
+
|
|
63
|
+
## Error Recovery
|
|
64
|
+
|
|
65
|
+
| Error | Cause | Fix |
|
|
66
|
+
|-------|-------|-----|
|
|
67
|
+
| `WorkOS is not defined` | CDN not loaded | Add script to `<head>` before your code |
|
|
68
|
+
| `createClient is not a function` | Wrong import | npm: check import path; CDN: use `WorkOS.createClient` |
|
|
69
|
+
| `clientId is required` | Undefined env var | Check env prefix matches build tool |
|
|
70
|
+
| CORS errors | `file://` protocol | Use local dev server (`npx serve`) |
|
|
71
|
+
| Popup blocked | Not user gesture | Call `signIn()` only from click handler |
|
|
72
|
+
| Auth state lost | Token not persisted | Check localStorage in dev tools |
|
|
73
|
+
|
|
74
|
+
## Task Flow
|
|
75
|
+
|
|
76
|
+
1. **preflight**: Fetch README, detect project type, verify env vars
|
|
77
|
+
2. **install**: Add SDK per project type
|
|
78
|
+
3. **callback**: SDK handles internally (no server route needed)
|
|
79
|
+
4. **provider**: Initialize client with `await createClient()`
|
|
80
|
+
5. **ui**: Add auth buttons and state display
|
|
81
|
+
6. **verify**: Build (if bundled), check console
|
package/build/apps/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var _this = this;
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var slack_1 = require("./slack");
|
|
40
|
-
exports.appCommand = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
41
|
-
return __generator(this, function (_a) {
|
|
42
|
-
switch (_a.label) {
|
|
43
|
-
case 0: return [4 /*yield*/, slack_1.authSlack()];
|
|
44
|
-
case 1:
|
|
45
|
-
_a.sent();
|
|
46
|
-
return [2 /*return*/];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}); };
|
|
50
|
-
//# sourceMappingURL=index.js.map
|