workos 0.4.5 → 0.5.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/dist/bin.js +32 -3
- package/dist/bin.js.map +1 -1
- package/dist/commands/doctor.d.ts +10 -0
- package/dist/commands/doctor.js +30 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/doctor/checks/connectivity.d.ts +2 -0
- package/dist/doctor/checks/connectivity.js +35 -0
- package/dist/doctor/checks/connectivity.js.map +1 -0
- package/dist/doctor/checks/dashboard.d.ts +3 -0
- package/dist/doctor/checks/dashboard.js +123 -0
- package/dist/doctor/checks/dashboard.js.map +1 -0
- package/dist/doctor/checks/environment.d.ts +2 -0
- package/dist/doctor/checks/environment.js +68 -0
- package/dist/doctor/checks/environment.js.map +1 -0
- package/dist/doctor/checks/framework.d.ts +2 -0
- package/dist/doctor/checks/framework.js +75 -0
- package/dist/doctor/checks/framework.js.map +1 -0
- package/dist/doctor/checks/runtime.d.ts +2 -0
- package/dist/doctor/checks/runtime.js +20 -0
- package/dist/doctor/checks/runtime.js.map +1 -0
- package/dist/doctor/checks/sdk.d.ts +2 -0
- package/dist/doctor/checks/sdk.js +111 -0
- package/dist/doctor/checks/sdk.js.map +1 -0
- package/dist/doctor/clipboard.d.ts +1 -0
- package/dist/doctor/clipboard.js +43 -0
- package/dist/doctor/clipboard.js.map +1 -0
- package/dist/doctor/index.d.ts +6 -0
- package/dist/doctor/index.js +94 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/doctor/issues.d.ts +58 -0
- package/dist/doctor/issues.js +134 -0
- package/dist/doctor/issues.js.map +1 -0
- package/dist/doctor/json-output.d.ts +2 -0
- package/dist/doctor/json-output.js +4 -0
- package/dist/doctor/json-output.js.map +1 -0
- package/dist/doctor/output.d.ts +5 -0
- package/dist/doctor/output.js +149 -0
- package/dist/doctor/output.js.map +1 -0
- package/dist/doctor/types.d.ts +105 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/types.js.map +1 -0
- package/dist/integrations/dotnet/index.d.ts +8 -0
- package/dist/integrations/dotnet/index.js +163 -0
- package/dist/integrations/dotnet/index.js.map +1 -0
- package/dist/integrations/elixir/index.d.ts +8 -0
- package/dist/integrations/elixir/index.js +152 -0
- package/dist/integrations/elixir/index.js.map +1 -0
- package/dist/integrations/go/index.d.ts +11 -0
- package/dist/integrations/go/index.js +220 -0
- package/dist/integrations/go/index.js.map +1 -0
- package/dist/integrations/kotlin/index.d.ts +4 -0
- package/dist/integrations/kotlin/index.js +53 -0
- package/dist/integrations/kotlin/index.js.map +1 -0
- package/dist/integrations/nextjs/index.d.ts +4 -0
- package/dist/integrations/nextjs/index.js +90 -0
- package/dist/integrations/nextjs/index.js.map +1 -0
- package/dist/integrations/nextjs/utils.d.ts +8 -0
- package/dist/integrations/nextjs/utils.js +53 -0
- package/dist/integrations/nextjs/utils.js.map +1 -0
- package/dist/integrations/node/index.d.ts +4 -0
- package/dist/integrations/node/index.js +52 -0
- package/dist/integrations/node/index.js.map +1 -0
- package/dist/integrations/php/index.d.ts +4 -0
- package/dist/integrations/php/index.js +51 -0
- package/dist/integrations/php/index.js.map +1 -0
- package/dist/integrations/php-laravel/index.d.ts +4 -0
- package/dist/integrations/php-laravel/index.js +51 -0
- package/dist/integrations/php-laravel/index.js.map +1 -0
- package/dist/integrations/python/index.d.ts +9 -0
- package/dist/integrations/python/index.js +254 -0
- package/dist/integrations/python/index.js.map +1 -0
- package/dist/integrations/react/index.d.ts +4 -0
- package/dist/integrations/react/index.js +49 -0
- package/dist/integrations/react/index.js.map +1 -0
- package/dist/integrations/react-router/index.d.ts +4 -0
- package/dist/integrations/react-router/index.js +94 -0
- package/dist/integrations/react-router/index.js.map +1 -0
- package/dist/integrations/react-router/utils.d.ts +10 -0
- package/dist/integrations/react-router/utils.js +146 -0
- package/dist/integrations/react-router/utils.js.map +1 -0
- package/dist/integrations/ruby/index.d.ts +8 -0
- package/dist/integrations/ruby/index.js +142 -0
- package/dist/integrations/ruby/index.js.map +1 -0
- package/dist/integrations/sveltekit/index.d.ts +4 -0
- package/dist/integrations/sveltekit/index.js +50 -0
- package/dist/integrations/sveltekit/index.js.map +1 -0
- package/dist/integrations/tanstack-start/index.d.ts +4 -0
- package/dist/integrations/tanstack-start/index.js +51 -0
- package/dist/integrations/tanstack-start/index.js.map +1 -0
- package/dist/integrations/vanilla-js/index.d.ts +4 -0
- package/dist/integrations/vanilla-js/index.js +49 -0
- package/dist/integrations/vanilla-js/index.js.map +1 -0
- package/dist/lib/agent-interface.js +66 -1
- package/dist/lib/agent-interface.js.map +1 -1
- package/dist/lib/config.d.ts +32 -58
- package/dist/lib/config.js +19 -70
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +17 -14
- package/dist/lib/constants.js +12 -31
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/framework-config.d.ts +13 -4
- package/dist/lib/framework-config.js.map +1 -1
- package/dist/lib/language-detection.d.ts +20 -0
- package/dist/lib/language-detection.js +96 -0
- package/dist/lib/language-detection.js.map +1 -0
- package/dist/lib/port-detection.js +4 -2
- package/dist/lib/port-detection.js.map +1 -1
- package/dist/lib/registry.d.ts +43 -0
- package/dist/lib/registry.js +96 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/run-with-core.js +70 -26
- package/dist/lib/run-with-core.js.map +1 -1
- package/dist/nextjs/nextjs-installer-agent.d.ts +3 -4
- package/dist/nextjs/nextjs-installer-agent.js +3 -94
- package/dist/nextjs/nextjs-installer-agent.js.map +1 -1
- package/dist/nextjs/utils.d.ts +4 -8
- package/dist/nextjs/utils.js +4 -52
- package/dist/nextjs/utils.js.map +1 -1
- package/dist/react/react-installer-agent.d.ts +4 -2
- package/dist/react/react-installer-agent.js +4 -46
- package/dist/react/react-installer-agent.js.map +1 -1
- package/dist/react-router/react-router-installer-agent.d.ts +2 -4
- package/dist/react-router/react-router-installer-agent.js +2 -100
- package/dist/react-router/react-router-installer-agent.js.map +1 -1
- package/dist/react-router/utils.d.ts +2 -17
- package/dist/react-router/utils.js +2 -207
- package/dist/react-router/utils.js.map +1 -1
- package/dist/tanstack-start/tanstack-start-installer-agent.d.ts +4 -2
- package/dist/tanstack-start/tanstack-start-installer-agent.js +4 -48
- package/dist/tanstack-start/tanstack-start-installer-agent.js.map +1 -1
- package/dist/vanilla-js/vanilla-js-installer-agent.d.ts +4 -2
- package/dist/vanilla-js/vanilla-js-installer-agent.js +4 -46
- package/dist/vanilla-js/vanilla-js-installer-agent.js.map +1 -1
- package/package.json +6 -5
- package/skills/workos-authkit-sveltekit/SKILL.md +160 -0
- package/skills/workos-dotnet/SKILL.md +163 -0
- package/skills/workos-elixir/SKILL.md +194 -0
- package/skills/workos-go/SKILL.md +191 -0
- package/skills/workos-kotlin/SKILL.md +161 -0
- package/skills/workos-node/SKILL.md +164 -0
- package/skills/workos-php/SKILL.md +127 -0
- package/skills/workos-php-laravel/SKILL.md +147 -0
- package/skills/workos-python/SKILL.md +159 -0
- package/skills/workos-ruby/SKILL.md +163 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workos-ruby
|
|
3
|
+
description: Integrate WorkOS AuthKit with Ruby applications. Adapts to Rails, Sinatra, or vanilla Ruby. Server-side authentication with redirect-based OAuth flow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WorkOS AuthKit for Ruby
|
|
7
|
+
|
|
8
|
+
## Step 1: Fetch SDK Documentation (BLOCKING)
|
|
9
|
+
|
|
10
|
+
**STOP — Do not proceed until this fetch is complete.**
|
|
11
|
+
|
|
12
|
+
WebFetch: `https://raw.githubusercontent.com/workos/workos-ruby/main/README.md`
|
|
13
|
+
|
|
14
|
+
Also fetch the AuthKit quickstart for reference:
|
|
15
|
+
WebFetch: `https://workos.com/docs/authkit/vanilla/ruby`
|
|
16
|
+
|
|
17
|
+
The README is the **source of truth** for gem API usage. If this skill conflicts with the README, **follow the README**.
|
|
18
|
+
|
|
19
|
+
## Step 2: Detect Framework
|
|
20
|
+
|
|
21
|
+
Examine the project to determine which Ruby web framework is in use:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
config/routes.rb exists? → Rails
|
|
25
|
+
Gemfile has 'rails' gem? → Confirmed Rails
|
|
26
|
+
|
|
27
|
+
Gemfile has 'sinatra' gem? → Sinatra
|
|
28
|
+
server.rb/app.rb has Sinatra routes? → Confirmed Sinatra
|
|
29
|
+
|
|
30
|
+
None of the above? → Vanilla Ruby (use Sinatra quickstart pattern)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Adapt all subsequent steps to the detected framework.** Do not force Rails on a Sinatra project or vice versa.
|
|
34
|
+
|
|
35
|
+
## Step 3: Install WorkOS Gem
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bundle add workos
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If `dotenv` is not in the Gemfile:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Rails
|
|
45
|
+
bundle add dotenv-rails --group development,test
|
|
46
|
+
|
|
47
|
+
# Sinatra / other
|
|
48
|
+
bundle add dotenv
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Verify:** `bundle show workos`
|
|
52
|
+
|
|
53
|
+
## Step 4: Integrate Authentication
|
|
54
|
+
|
|
55
|
+
### If Rails
|
|
56
|
+
|
|
57
|
+
1. **Create initializer** — `config/initializers/workos.rb`:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
WorkOS.configure do |config|
|
|
61
|
+
config.api_key = ENV.fetch("WORKOS_API_KEY")
|
|
62
|
+
config.client_id = ENV.fetch("WORKOS_CLIENT_ID")
|
|
63
|
+
end
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. **Create AuthController** — `app/controllers/auth_controller.rb`:
|
|
67
|
+
- `login` action: call `WorkOS::UserManagement.get_authorization_url(provider: "authkit", redirect_uri: ...)`, redirect
|
|
68
|
+
- `callback` action: call `WorkOS::UserManagement.authenticate_with_code(code: params[:code])`, store user in session
|
|
69
|
+
- `logout` action: clear session, redirect
|
|
70
|
+
|
|
71
|
+
3. **Add routes** to `config/routes.rb`:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
get "/auth/login", to: "auth#login"
|
|
75
|
+
get "/auth/callback", to: "auth#callback"
|
|
76
|
+
get "/auth/logout", to: "auth#logout"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. **Add current_user helper** to `ApplicationController` (optional):
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
helper_method :current_user
|
|
83
|
+
def current_user
|
|
84
|
+
@current_user ||= session[:user] && JSON.parse(session[:user])
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
5. **Verify:** `bundle exec rails routes | grep auth`
|
|
89
|
+
|
|
90
|
+
### If Sinatra
|
|
91
|
+
|
|
92
|
+
Follow the quickstart pattern exactly:
|
|
93
|
+
|
|
94
|
+
1. **Configure WorkOS** in `server.rb`:
|
|
95
|
+
|
|
96
|
+
```ruby
|
|
97
|
+
require "dotenv/load"
|
|
98
|
+
require "workos"
|
|
99
|
+
require "sinatra"
|
|
100
|
+
|
|
101
|
+
WorkOS.configure do |config|
|
|
102
|
+
config.key = ENV["WORKOS_API_KEY"]
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
2. **Create `/login` route** — call `WorkOS::UserManagement.authorization_url(provider: "authkit", client_id: ..., redirect_uri: ...)`, redirect
|
|
107
|
+
|
|
108
|
+
3. **Create `/callback` route** — call `WorkOS::UserManagement.authenticate_with_code(client_id: ..., code: ...)`, store in session cookie
|
|
109
|
+
|
|
110
|
+
4. **Create `/logout` route** — clear session cookie, redirect
|
|
111
|
+
|
|
112
|
+
5. **Update home route** — read session, show user info if present
|
|
113
|
+
|
|
114
|
+
6. **Verify:** `ruby -c server.rb`
|
|
115
|
+
|
|
116
|
+
### If Vanilla Ruby (no framework detected)
|
|
117
|
+
|
|
118
|
+
Install Sinatra and follow the Sinatra pattern above. This matches the official quickstart.
|
|
119
|
+
|
|
120
|
+
## Step 5: Environment Setup
|
|
121
|
+
|
|
122
|
+
Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
WORKOS_API_KEY=sk_...
|
|
126
|
+
WORKOS_CLIENT_ID=client_...
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Step 6: Verification
|
|
130
|
+
|
|
131
|
+
### Rails
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bundle show workos
|
|
135
|
+
bundle exec rails routes | grep auth
|
|
136
|
+
grep WORKOS .env
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Sinatra
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
bundle show workos
|
|
143
|
+
ruby -c server.rb
|
|
144
|
+
grep WORKOS .env
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Error Recovery
|
|
148
|
+
|
|
149
|
+
### "uninitialized constant WorkOS"
|
|
150
|
+
|
|
151
|
+
Gem not loaded. Verify `bundle show workos` succeeds. For Rails, ensure initializer exists. For Sinatra, ensure `require "workos"` is at top of server file.
|
|
152
|
+
|
|
153
|
+
### "NoMethodError" on WorkOS methods
|
|
154
|
+
|
|
155
|
+
SDK API may differ from this skill. Re-read the README (Step 1) and use exact method names.
|
|
156
|
+
|
|
157
|
+
### Routes not working (Rails)
|
|
158
|
+
|
|
159
|
+
Run `bundle exec rails routes | grep auth`. Verify routes are inside `Rails.application.routes.draw` block.
|
|
160
|
+
|
|
161
|
+
### Session not persisting (Sinatra)
|
|
162
|
+
|
|
163
|
+
Enable sessions: `enable :sessions` in server.rb, or use `rack-session` gem.
|