workos 4.1.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +37 -0
- data/.github/workflows/release.yml +43 -0
- data/.rubocop.yml +8 -1
- data/Gemfile.lock +22 -69
- data/lib/workos/audit_log_export.rb +8 -31
- data/lib/workos/audit_logs.rb +0 -26
- data/lib/workos/authentication_factor_and_challenge.rb +0 -3
- data/lib/workos/authentication_response.rb +3 -6
- data/lib/workos/challenge.rb +9 -28
- data/lib/workos/client.rb +0 -41
- data/lib/workos/configuration.rb +0 -1
- data/lib/workos/connection.rb +11 -35
- data/lib/workos/directory.rb +10 -37
- data/lib/workos/directory_group.rb +9 -36
- data/lib/workos/directory_sync.rb +0 -21
- data/lib/workos/directory_user.rb +17 -51
- data/lib/workos/errors.rb +0 -16
- data/lib/workos/event.rb +5 -26
- data/lib/workos/events.rb +0 -7
- data/lib/workos/factor.rb +9 -28
- data/lib/workos/hash_provider.rb +0 -1
- data/lib/workos/impersonator.rb +0 -3
- data/lib/workos/invitation.rb +12 -37
- data/lib/workos/mfa.rb +0 -42
- data/lib/workos/organization.rb +8 -31
- data/lib/workos/organization_membership.rb +8 -27
- data/lib/workos/organizations.rb +0 -26
- data/lib/workos/passwordless.rb +0 -14
- data/lib/workos/portal.rb +1 -13
- data/lib/workos/profile.rb +12 -39
- data/lib/workos/profile_and_token.rb +1 -4
- data/lib/workos/refresh_authentication_response.rb +2 -5
- data/lib/workos/sso.rb +1 -43
- data/lib/workos/types/intent.rb +16 -0
- data/lib/workos/types/list_struct.rb +8 -5
- data/lib/workos/types/passwordless_session_struct.rb +10 -9
- data/lib/workos/types/provider.rb +15 -0
- data/lib/workos/types.rb +5 -23
- data/lib/workos/user.rb +10 -31
- data/lib/workos/user_and_token.rb +1 -4
- data/lib/workos/user_management.rb +36 -244
- data/lib/workos/user_response.rb +0 -3
- data/lib/workos/verify_challenge.rb +4 -18
- data/lib/workos/version.rb +1 -2
- data/lib/workos/webhook.rb +5 -26
- data/lib/workos/webhooks.rb +1 -38
- data/lib/workos.rb +0 -2
- data/spec/lib/workos/audit_logs_spec.rb +2 -3
- data/spec/lib/workos/configuration_spec.rb +0 -1
- data/spec/lib/workos/directory_sync_spec.rb +0 -1
- data/spec/lib/workos/directory_user_spec.rb +0 -1
- data/spec/lib/workos/event_spec.rb +0 -1
- data/spec/lib/workos/mfa_spec.rb +0 -1
- data/spec/lib/workos/organizations_spec.rb +0 -1
- data/spec/lib/workos/passwordless_spec.rb +0 -1
- data/spec/lib/workos/portal_spec.rb +0 -1
- data/spec/lib/workos/sso_spec.rb +0 -1
- data/spec/lib/workos/user_management_spec.rb +29 -1
- data/spec/lib/workos/webhooks_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -9
- data/spec/support/fixtures/vcr_cassettes/user_management/revoke_session/not_found.yml +80 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/revoke_session/valid.yml +76 -0
- data/spec/support/shared_examples/client_spec.rb +0 -1
- data/workos.gemspec +1 -6
- metadata +15 -129
- data/.semaphore/rubygems.yml +0 -24
- data/.semaphore/semaphore.yml +0 -51
- data/bin/tapioca +0 -29
- data/codecov.yml +0 -12
- data/devbox.json +0 -18
- data/devbox.lock +0 -11
- data/lib/workos/types/audit_log_export_struct.rb +0 -17
- data/lib/workos/types/challenge_struct.rb +0 -18
- data/lib/workos/types/connection_struct.rb +0 -20
- data/lib/workos/types/directory_group_struct.rb +0 -19
- data/lib/workos/types/directory_struct.rb +0 -19
- data/lib/workos/types/directory_user_struct.rb +0 -26
- data/lib/workos/types/event_struct.rb +0 -15
- data/lib/workos/types/factor_struct.rb +0 -18
- data/lib/workos/types/intent_enum.rb +0 -17
- data/lib/workos/types/invitation_struct.rb +0 -20
- data/lib/workos/types/magic_auth_challenge_struct.rb +0 -12
- data/lib/workos/types/organization_membership_struct.rb +0 -16
- data/lib/workos/types/organization_struct.rb +0 -17
- data/lib/workos/types/profile_struct.rb +0 -21
- data/lib/workos/types/provider_enum.rb +0 -16
- data/lib/workos/types/user_struct.rb +0 -18
- data/lib/workos/types/verify_challenge_struct.rb +0 -13
- data/lib/workos/types/webhook_struct.rb +0 -15
- data/sorbet/config +0 -2
- data/sorbet/rbi/gems/addressable@2.8.0.rbi +0 -290
- data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -54
- data/sorbet/rbi/gems/codecov@0.2.12.rbi +0 -55
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -8
- data/sorbet/rbi/gems/crack@0.4.5.rbi +0 -57
- data/sorbet/rbi/gems/diff-lcs@1.4.4.rbi +0 -185
- data/sorbet/rbi/gems/docile@1.3.5.rbi +0 -54
- data/sorbet/rbi/gems/hashdiff@1.0.1.rbi +0 -82
- data/sorbet/rbi/gems/json@2.5.1.rbi +0 -109
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -8
- data/sorbet/rbi/gems/parallel@1.20.1.rbi +0 -113
- data/sorbet/rbi/gems/parser@3.0.1.0.rbi +0 -1187
- data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -8
- data/sorbet/rbi/gems/public_suffix@4.0.6.rbi +0 -146
- data/sorbet/rbi/gems/rainbow@3.0.0.rbi +0 -153
- data/sorbet/rbi/gems/rake@13.0.3.rbi +0 -807
- data/sorbet/rbi/gems/rbi@0.0.16.rbi +0 -2118
- data/sorbet/rbi/gems/regexp_parser@2.1.1.rbi +0 -1117
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -709
- data/sorbet/rbi/gems/rspec-core@3.9.3.rbi +0 -2467
- data/sorbet/rbi/gems/rspec-expectations@3.9.4.rbi +0 -1569
- data/sorbet/rbi/gems/rspec-mocks@3.9.1.rbi +0 -1493
- data/sorbet/rbi/gems/rspec-support@3.9.4.rbi +0 -511
- data/sorbet/rbi/gems/rspec@3.9.0.rbi +0 -38
- data/sorbet/rbi/gems/rubocop-ast@1.4.1.rbi +0 -1881
- data/sorbet/rbi/gems/rubocop@0.93.1.rbi +0 -11497
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -405
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -89
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +0 -577
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.2.rbi +0 -8
- data/sorbet/rbi/gems/spoom@1.1.15.rbi +0 -1549
- data/sorbet/rbi/gems/tapioca@0.7.3.rbi +0 -1718
- data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -844
- data/sorbet/rbi/gems/unicode-display_width@1.7.0.rbi +0 -22
- data/sorbet/rbi/gems/unparser@0.6.2.rbi +0 -8
- data/sorbet/rbi/gems/vcr@5.0.0.rbi +0 -699
- data/sorbet/rbi/gems/webmock@3.12.2.rbi +0 -662
- data/sorbet/rbi/gems/yard-sorbet@0.8.0.rbi +0 -268
- data/sorbet/rbi/gems/yard@0.9.26.rbi +0 -4048
- data/sorbet/tapioca/config.yml +0 -13
- data/sorbet/tapioca/require.rb +0 -4
data/lib/workos/user.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The User class provides a lightweight wrapper around a WorkOS User
|
@@ -7,23 +6,21 @@ module WorkOS
|
|
7
6
|
# and is instantiated internally but exposed.
|
8
7
|
class User
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :email, :first_name, :last_name, :email_verified,
|
13
11
|
:profile_picture_url, :created_at, :updated_at
|
14
12
|
|
15
|
-
sig { params(json: String).void }
|
16
13
|
def initialize(json)
|
17
|
-
|
18
|
-
|
19
|
-
@id =
|
20
|
-
@email =
|
21
|
-
@first_name =
|
22
|
-
@last_name =
|
23
|
-
@email_verified =
|
24
|
-
@profile_picture_url =
|
25
|
-
@created_at =
|
26
|
-
@updated_at =
|
14
|
+
hash = JSON.parse(json, symbolize_names: true)
|
15
|
+
|
16
|
+
@id = hash[:id]
|
17
|
+
@email = hash[:email]
|
18
|
+
@first_name = hash[:first_name]
|
19
|
+
@last_name = hash[:last_name]
|
20
|
+
@email_verified = hash[:email_verified]
|
21
|
+
@profile_picture_url = hash[:profile_picture_url]
|
22
|
+
@created_at = hash[:created_at]
|
23
|
+
@updated_at = hash[:updated_at]
|
27
24
|
end
|
28
25
|
|
29
26
|
def to_json(*)
|
@@ -38,23 +35,5 @@ module WorkOS
|
|
38
35
|
updated_at: updated_at,
|
39
36
|
}
|
40
37
|
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
sig { params(json_string: String).returns(WorkOS::Types::UserStruct) }
|
45
|
-
def parse_json(json_string)
|
46
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
47
|
-
|
48
|
-
WorkOS::Types::UserStruct.new(
|
49
|
-
id: hash[:id],
|
50
|
-
email: hash[:email],
|
51
|
-
first_name: hash[:first_name],
|
52
|
-
last_name: hash[:last_name],
|
53
|
-
email_verified: hash[:email_verified],
|
54
|
-
profile_picture_url: hash[:profile_picture_url],
|
55
|
-
created_at: hash[:created_at],
|
56
|
-
updated_at: hash[:updated_at],
|
57
|
-
)
|
58
|
-
end
|
59
38
|
end
|
60
39
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The UserAndToken class represents a User and a corresponding Token. This
|
@@ -7,15 +6,13 @@ module WorkOS
|
|
7
6
|
# internally but exposed.
|
8
7
|
class UserAndToken
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :token, :user
|
13
11
|
|
14
|
-
sig { params(user_and_token_json: String).void }
|
15
12
|
def initialize(user_and_token_json)
|
16
13
|
json = JSON.parse(user_and_token_json, symbolize_names: true)
|
17
14
|
|
18
|
-
@token =
|
15
|
+
@token = json[:token]
|
19
16
|
@user = WorkOS::User.new(json[:user].to_json)
|
20
17
|
end
|
21
18
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
require 'net/http'
|
5
4
|
require 'uri'
|
@@ -11,32 +10,31 @@ module WorkOS
|
|
11
10
|
# rubocop:disable Metrics/ModuleLength
|
12
11
|
module UserManagement
|
13
12
|
module Types
|
14
|
-
# The ProviderEnum is
|
13
|
+
# The ProviderEnum is a declaration of a
|
15
14
|
# fixed set of values for User Management Providers.
|
16
|
-
class Provider
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
class Provider
|
16
|
+
GitHub = 'GitHubOAuth'
|
17
|
+
Google = 'GoogleOAuth'
|
18
|
+
Microsoft = 'MicrosoftOAuth'
|
19
|
+
AuthKit = 'authkit'
|
20
|
+
|
21
|
+
ALL = [GitHub, Google, Microsoft, AuthKit].freeze
|
23
22
|
end
|
24
23
|
|
25
|
-
# The AuthFactorType is
|
24
|
+
# The AuthFactorType is a declaration of a
|
26
25
|
# fixed set of factor values to enroll
|
27
|
-
class AuthFactorType
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
class AuthFactorType
|
27
|
+
Totp = 'totp'
|
28
|
+
|
29
|
+
ALL = [Totp].freeze
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
33
|
class << self
|
35
|
-
extend T::Sig
|
36
34
|
include Client
|
37
35
|
|
38
|
-
PROVIDERS = WorkOS::UserManagement::Types::Provider
|
39
|
-
AUTH_FACTOR_TYPES = WorkOS::UserManagement::Types::AuthFactorType
|
36
|
+
PROVIDERS = WorkOS::UserManagement::Types::Provider::ALL
|
37
|
+
AUTH_FACTOR_TYPES = WorkOS::UserManagement::Types::AuthFactorType::ALL
|
40
38
|
|
41
39
|
# Generate an OAuth 2.0 authorization URL that automatically directs a user
|
42
40
|
# to their Identity Provider.
|
@@ -74,18 +72,6 @@ module WorkOS
|
|
74
72
|
#
|
75
73
|
# @return [String]
|
76
74
|
# rubocop:disable Metrics/ParameterLists
|
77
|
-
sig do
|
78
|
-
params(
|
79
|
-
redirect_uri: String,
|
80
|
-
client_id: T.nilable(String),
|
81
|
-
domain_hint: T.nilable(String),
|
82
|
-
login_hint: T.nilable(String),
|
83
|
-
provider: T.nilable(String),
|
84
|
-
connection_id: T.nilable(String),
|
85
|
-
organization_id: T.nilable(String),
|
86
|
-
state: T.nilable(String),
|
87
|
-
).returns(String)
|
88
|
-
end
|
89
75
|
def authorization_url(
|
90
76
|
redirect_uri:,
|
91
77
|
client_id: nil,
|
@@ -124,9 +110,6 @@ module WorkOS
|
|
124
110
|
# @param [String] id The unique ID of the User.
|
125
111
|
#
|
126
112
|
# @return WorkOS::User
|
127
|
-
sig do
|
128
|
-
params(id: String).returns(WorkOS::User)
|
129
|
-
end
|
130
113
|
def get_user(id:)
|
131
114
|
response = execute_request(
|
132
115
|
request: get_request(
|
@@ -151,11 +134,6 @@ module WorkOS
|
|
151
134
|
# before a provided User ID.
|
152
135
|
#
|
153
136
|
# @return [WorkOS::User]
|
154
|
-
sig do
|
155
|
-
params(
|
156
|
-
options: T::Hash[Symbol, String],
|
157
|
-
).returns(WorkOS::Types::ListStruct)
|
158
|
-
end
|
159
137
|
def list_users(options = {})
|
160
138
|
options[:order] ||= 'desc'
|
161
139
|
response = execute_request(
|
@@ -185,18 +163,20 @@ module WorkOS
|
|
185
163
|
# @param [String] first_name The user's first name.
|
186
164
|
# @param [String] last_name The user's last name.
|
187
165
|
# @param [Boolean] email_verified Whether the user's email address was previously verified.
|
166
|
+
# @param [String] password_hash The user's hashed password.
|
167
|
+
# @option [String] password_hash_type The algorithm originally used to hash the password.
|
188
168
|
#
|
189
169
|
# @return [WorkOS::User]
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
170
|
+
# rubocop:disable Metrics/ParameterLists
|
171
|
+
def create_user(
|
172
|
+
email:,
|
173
|
+
password: nil,
|
174
|
+
first_name: nil,
|
175
|
+
last_name: nil,
|
176
|
+
email_verified: nil,
|
177
|
+
password_hash: nil,
|
178
|
+
password_hash_type: nil
|
179
|
+
)
|
200
180
|
request = post_request(
|
201
181
|
path: '/user_management/users',
|
202
182
|
body: {
|
@@ -205,6 +185,8 @@ module WorkOS
|
|
205
185
|
first_name: first_name,
|
206
186
|
last_name: last_name,
|
207
187
|
email_verified: email_verified,
|
188
|
+
password_hash: password_hash,
|
189
|
+
password_hash_type: password_hash_type,
|
208
190
|
},
|
209
191
|
auth: true,
|
210
192
|
)
|
@@ -226,18 +208,6 @@ module WorkOS
|
|
226
208
|
# Valid values are bcrypt.
|
227
209
|
#
|
228
210
|
# @return [WorkOS::User]
|
229
|
-
# rubocop:disable Metrics/ParameterLists
|
230
|
-
sig do
|
231
|
-
params(
|
232
|
-
id: String,
|
233
|
-
first_name: T.nilable(String),
|
234
|
-
last_name: T.nilable(String),
|
235
|
-
email_verified: T.nilable(T::Boolean),
|
236
|
-
password: T.nilable(String),
|
237
|
-
password_hash: T.nilable(String),
|
238
|
-
password_hash_type: T.nilable(String),
|
239
|
-
).returns(WorkOS::User)
|
240
|
-
end
|
241
211
|
def update_user(
|
242
212
|
id:,
|
243
213
|
first_name: nil,
|
@@ -271,11 +241,6 @@ module WorkOS
|
|
271
241
|
# @param [String] id The unique ID of the User.
|
272
242
|
#
|
273
243
|
# @return [Bool] - returns `true` if successful
|
274
|
-
sig do
|
275
|
-
params(
|
276
|
-
id: String,
|
277
|
-
).returns(T::Boolean)
|
278
|
-
end
|
279
244
|
def delete_user(id:)
|
280
245
|
response = execute_request(
|
281
246
|
request: delete_request(
|
@@ -296,16 +261,6 @@ module WorkOS
|
|
296
261
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
297
262
|
#
|
298
263
|
# @return WorkOS::AuthenticationResponse
|
299
|
-
|
300
|
-
sig do
|
301
|
-
params(
|
302
|
-
email: String,
|
303
|
-
password: String,
|
304
|
-
client_id: String,
|
305
|
-
ip_address: T.nilable(String),
|
306
|
-
user_agent: T.nilable(String),
|
307
|
-
).returns(WorkOS::AuthenticationResponse)
|
308
|
-
end
|
309
264
|
def authenticate_with_password(email:, password:, client_id:, ip_address: nil, user_agent: nil)
|
310
265
|
response = execute_request(
|
311
266
|
request: post_request(
|
@@ -334,15 +289,6 @@ module WorkOS
|
|
334
289
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
335
290
|
#
|
336
291
|
# @return WorkOS::AuthenticationResponse
|
337
|
-
|
338
|
-
sig do
|
339
|
-
params(
|
340
|
-
code: String,
|
341
|
-
client_id: String,
|
342
|
-
ip_address: T.nilable(String),
|
343
|
-
user_agent: T.nilable(String),
|
344
|
-
).returns(WorkOS::AuthenticationResponse)
|
345
|
-
end
|
346
292
|
def authenticate_with_code(
|
347
293
|
code:,
|
348
294
|
client_id:,
|
@@ -374,15 +320,6 @@ module WorkOS
|
|
374
320
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
375
321
|
#
|
376
322
|
# @return WorkOS::RefreshAuthenticationResponse
|
377
|
-
|
378
|
-
sig do
|
379
|
-
params(
|
380
|
-
refresh_token: String,
|
381
|
-
client_id: String,
|
382
|
-
ip_address: T.nilable(String),
|
383
|
-
user_agent: T.nilable(String),
|
384
|
-
).returns(WorkOS::RefreshAuthenticationResponse)
|
385
|
-
end
|
386
323
|
def authenticate_with_refresh_token(
|
387
324
|
refresh_token:,
|
388
325
|
client_id:,
|
@@ -417,17 +354,6 @@ module WorkOS
|
|
417
354
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
418
355
|
#
|
419
356
|
# @return WorkOS::AuthenticationResponse
|
420
|
-
|
421
|
-
sig do
|
422
|
-
params(
|
423
|
-
code: String,
|
424
|
-
email: String,
|
425
|
-
client_id: String,
|
426
|
-
ip_address: T.nilable(String),
|
427
|
-
user_agent: T.nilable(String),
|
428
|
-
link_authorization_code: T.nilable(String),
|
429
|
-
).returns(WorkOS::AuthenticationResponse)
|
430
|
-
end
|
431
357
|
def authenticate_with_magic_auth(
|
432
358
|
code:,
|
433
359
|
email:,
|
@@ -455,7 +381,6 @@ module WorkOS
|
|
455
381
|
WorkOS::AuthenticationResponse.new(response.body)
|
456
382
|
end
|
457
383
|
|
458
|
-
|
459
384
|
# Authenticate a user into an organization they are a member of.
|
460
385
|
#
|
461
386
|
# @param [String] client_id The WorkOS client ID for the environment.
|
@@ -465,15 +390,6 @@ module WorkOS
|
|
465
390
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
466
391
|
#
|
467
392
|
# @return WorkOS::AuthenticationResponse
|
468
|
-
sig do
|
469
|
-
params(
|
470
|
-
client_id: String,
|
471
|
-
organization_id: String,
|
472
|
-
pending_authentication_token: String,
|
473
|
-
ip_address: T.nilable(String),
|
474
|
-
user_agent: T.nilable(String),
|
475
|
-
).returns(WorkOS::AuthenticationResponse)
|
476
|
-
end
|
477
393
|
def authenticate_with_organization_selection(
|
478
394
|
client_id:,
|
479
395
|
organization_id:,
|
@@ -511,17 +427,6 @@ module WorkOS
|
|
511
427
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
512
428
|
#
|
513
429
|
# @return WorkOS::AuthenticationResponse
|
514
|
-
|
515
|
-
sig do
|
516
|
-
params(
|
517
|
-
code: String,
|
518
|
-
client_id: String,
|
519
|
-
pending_authentication_token: String,
|
520
|
-
authentication_challenge_id: String,
|
521
|
-
ip_address: T.nilable(String),
|
522
|
-
user_agent: T.nilable(String),
|
523
|
-
).returns(WorkOS::AuthenticationResponse)
|
524
|
-
end
|
525
430
|
def authenticate_with_totp(
|
526
431
|
code:,
|
527
432
|
client_id:,
|
@@ -559,16 +464,6 @@ module WorkOS
|
|
559
464
|
# @param [String] user_agent The user agent of the request from the user who is attempting to authenticate.
|
560
465
|
#
|
561
466
|
# @return WorkOS::AuthenticationResponse
|
562
|
-
|
563
|
-
sig do
|
564
|
-
params(
|
565
|
-
code: String,
|
566
|
-
client_id: String,
|
567
|
-
pending_authentication_token: String,
|
568
|
-
ip_address: T.nilable(String),
|
569
|
-
user_agent: T.nilable(String),
|
570
|
-
).returns(WorkOS::AuthenticationResponse)
|
571
|
-
end
|
572
467
|
def authenticate_with_email_verification(
|
573
468
|
code:,
|
574
469
|
client_id:,
|
@@ -602,11 +497,6 @@ module WorkOS
|
|
602
497
|
# claim of the access token
|
603
498
|
#
|
604
499
|
# @return String
|
605
|
-
sig do
|
606
|
-
params(
|
607
|
-
session_id: String,
|
608
|
-
).returns(String)
|
609
|
-
end
|
610
500
|
def get_logout_url(session_id:)
|
611
501
|
URI::HTTPS.build(
|
612
502
|
host: WorkOS.config.api_hostname,
|
@@ -619,20 +509,18 @@ module WorkOS
|
|
619
509
|
#
|
620
510
|
# @param [String] session_id The session ID can be found in the `sid`
|
621
511
|
# claim of the access token
|
622
|
-
sig do
|
623
|
-
params(
|
624
|
-
session_id: String,
|
625
|
-
).void
|
626
|
-
end
|
627
512
|
def revoke_session(session_id:)
|
628
|
-
execute_request(
|
513
|
+
response = execute_request(
|
629
514
|
request: post_request(
|
630
515
|
path: '/user_management/sessions/revoke',
|
631
516
|
body: {
|
632
517
|
session_id: session_id,
|
633
518
|
},
|
519
|
+
auth: true,
|
634
520
|
),
|
635
521
|
)
|
522
|
+
|
523
|
+
response.is_a? Net::HTTPSuccess
|
636
524
|
end
|
637
525
|
|
638
526
|
# Get the JWKS URL
|
@@ -642,11 +530,6 @@ module WorkOS
|
|
642
530
|
# @param [String] client_id The WorkOS client ID for the environment
|
643
531
|
#
|
644
532
|
# @return String
|
645
|
-
sig do
|
646
|
-
params(
|
647
|
-
client_id: String,
|
648
|
-
).returns(String)
|
649
|
-
end
|
650
533
|
def get_jwks_url(client_id)
|
651
534
|
URI::HTTPS.build(
|
652
535
|
host: WorkOS.config.api_hostname,
|
@@ -659,11 +542,6 @@ module WorkOS
|
|
659
542
|
# @param [String] email The email address the one-time code will be sent to.
|
660
543
|
#
|
661
544
|
# @return Boolean
|
662
|
-
sig do
|
663
|
-
params(
|
664
|
-
email: String,
|
665
|
-
).returns(T::Boolean)
|
666
|
-
end
|
667
545
|
def send_magic_auth_code(email:)
|
668
546
|
response = execute_request(
|
669
547
|
request: post_request(
|
@@ -687,14 +565,6 @@ module WorkOS
|
|
687
565
|
# @param [String] totp_user For totp factors. Used as the account name in authenticator apps.
|
688
566
|
#
|
689
567
|
# @return WorkOS::AuthenticationFactorAndChallenge
|
690
|
-
sig do
|
691
|
-
params(
|
692
|
-
user_id: String,
|
693
|
-
type: String,
|
694
|
-
totp_issuer: T.nilable(String),
|
695
|
-
totp_user: T.nilable(String),
|
696
|
-
).returns(WorkOS::AuthenticationFactorAndChallenge)
|
697
|
-
end
|
698
568
|
def enroll_auth_factor(user_id:, type:, totp_issuer: nil, totp_user: nil)
|
699
569
|
validate_auth_factor_type(
|
700
570
|
type: type,
|
@@ -720,11 +590,6 @@ module WorkOS
|
|
720
590
|
# @param [String] user_id The id for the user.
|
721
591
|
#
|
722
592
|
# @return WorkOS::ListStruct
|
723
|
-
sig do
|
724
|
-
params(
|
725
|
-
user_id: String,
|
726
|
-
).returns(WorkOS::Types::ListStruct)
|
727
|
-
end
|
728
593
|
def list_auth_factors(user_id:)
|
729
594
|
response = execute_request(
|
730
595
|
request: get_request(
|
@@ -750,11 +615,6 @@ module WorkOS
|
|
750
615
|
# @param [String] user_id The unique ID of the User whose email address will be verified.
|
751
616
|
#
|
752
617
|
# @return WorkOS::UserResponse
|
753
|
-
sig do
|
754
|
-
params(
|
755
|
-
user_id: String,
|
756
|
-
).returns(WorkOS::UserResponse)
|
757
|
-
end
|
758
618
|
def send_verification_email(user_id:)
|
759
619
|
response = execute_request(
|
760
620
|
request: post_request(
|
@@ -772,12 +632,6 @@ module WorkOS
|
|
772
632
|
# @param [String] code The one-time code emailed to the user.
|
773
633
|
#
|
774
634
|
# @return WorkOS::UserResponse
|
775
|
-
sig do
|
776
|
-
params(
|
777
|
-
user_id: String,
|
778
|
-
code: String,
|
779
|
-
).returns(WorkOS::UserResponse)
|
780
|
-
end
|
781
635
|
def verify_email(user_id:, code:)
|
782
636
|
response = execute_request(
|
783
637
|
request: post_request(
|
@@ -798,12 +652,6 @@ module WorkOS
|
|
798
652
|
# @param [String] password_reset_url The URL that will be linked to in the email.
|
799
653
|
#
|
800
654
|
# @return [Bool] - returns `true` if successful
|
801
|
-
sig do
|
802
|
-
params(
|
803
|
-
email: String,
|
804
|
-
password_reset_url: String,
|
805
|
-
).returns(T::Boolean)
|
806
|
-
end
|
807
655
|
def send_password_reset_email(email:, password_reset_url:)
|
808
656
|
request = post_request(
|
809
657
|
path: '/user_management/password_reset/send',
|
@@ -825,12 +673,6 @@ module WorkOS
|
|
825
673
|
# @param [String] new_password The new password to set for the user.
|
826
674
|
#
|
827
675
|
# @return WorkOS::User
|
828
|
-
sig do
|
829
|
-
params(
|
830
|
-
token: String,
|
831
|
-
new_password: String,
|
832
|
-
).returns(WorkOS::User)
|
833
|
-
end
|
834
676
|
def reset_password(token:, new_password:)
|
835
677
|
response = execute_request(
|
836
678
|
request: post_request(
|
@@ -851,9 +693,6 @@ module WorkOS
|
|
851
693
|
# @param [String] id The unique ID of the Organization Membership.
|
852
694
|
#
|
853
695
|
# @return WorkOS::OrganizationMembership
|
854
|
-
sig do
|
855
|
-
params(id: String).returns(WorkOS::OrganizationMembership)
|
856
|
-
end
|
857
696
|
def get_organization_membership(id:)
|
858
697
|
response = execute_request(
|
859
698
|
request: get_request(
|
@@ -878,11 +717,6 @@ module WorkOS
|
|
878
717
|
# before a provided User ID.
|
879
718
|
#
|
880
719
|
# @return [WorkOS::OrganizationMembership]
|
881
|
-
sig do
|
882
|
-
params(
|
883
|
-
options: T::Hash[Symbol, String],
|
884
|
-
).returns(WorkOS::Types::ListStruct)
|
885
|
-
end
|
886
720
|
def list_organization_memberships(options = {})
|
887
721
|
options[:order] ||= 'desc'
|
888
722
|
response = execute_request(
|
@@ -911,12 +745,6 @@ module WorkOS
|
|
911
745
|
# @param [String] organization_id The ID of the Organization to which the user belongs to.
|
912
746
|
#
|
913
747
|
# @return [WorkOS::OrganizationMembership]
|
914
|
-
sig do
|
915
|
-
params(
|
916
|
-
user_id: String,
|
917
|
-
organization_id: String,
|
918
|
-
).returns(WorkOS::OrganizationMembership)
|
919
|
-
end
|
920
748
|
def create_organization_membership(user_id:, organization_id:)
|
921
749
|
request = post_request(
|
922
750
|
path: '/user_management/organization_memberships',
|
@@ -937,11 +765,6 @@ module WorkOS
|
|
937
765
|
# @param [String] id The unique ID of the Organization Membership.
|
938
766
|
#
|
939
767
|
# @return [Bool] - returns `true` if successful
|
940
|
-
sig do
|
941
|
-
params(
|
942
|
-
id: String,
|
943
|
-
).returns(T::Boolean)
|
944
|
-
end
|
945
768
|
def delete_organization_membership(id:)
|
946
769
|
response = execute_request(
|
947
770
|
request: delete_request(
|
@@ -958,9 +781,6 @@ module WorkOS
|
|
958
781
|
# @param [String] id The unique ID of the Invitation.
|
959
782
|
#
|
960
783
|
# @return WorkOS::Invitation
|
961
|
-
sig do
|
962
|
-
params(id: String).returns(WorkOS::Invitation)
|
963
|
-
end
|
964
784
|
def get_invitation(id:)
|
965
785
|
response = execute_request(
|
966
786
|
request: get_request(
|
@@ -985,11 +805,6 @@ module WorkOS
|
|
985
805
|
# before a provided User ID.
|
986
806
|
#
|
987
807
|
# @return [WorkOS::Invitation]
|
988
|
-
sig do
|
989
|
-
params(
|
990
|
-
options: T::Hash[Symbol, String],
|
991
|
-
).returns(WorkOS::Types::ListStruct)
|
992
|
-
end
|
993
808
|
def list_invitations(options = {})
|
994
809
|
options[:order] ||= 'desc'
|
995
810
|
response = execute_request(
|
@@ -1019,17 +834,10 @@ module WorkOS
|
|
1019
834
|
# @param [Integer] expires_in_days The number of days the invitations will be valid for.
|
1020
835
|
# Must be between 1 and 30, defaults to 7 if not specified.
|
1021
836
|
# @param [String] inviter_user_id The ID of the User sending the invitation.
|
837
|
+
# @param [String] role_slug The slug of the role to assign to the user upon invitation.
|
1022
838
|
#
|
1023
839
|
# @return WorkOS::Invitation
|
1024
|
-
|
1025
|
-
params(
|
1026
|
-
email: String,
|
1027
|
-
organization_id: T.nilable(String),
|
1028
|
-
expires_in_days: T.nilable(Integer),
|
1029
|
-
inviter_user_id: T.nilable(String),
|
1030
|
-
).returns(WorkOS::Invitation)
|
1031
|
-
end
|
1032
|
-
def send_invitation(email:, organization_id: nil, expires_in_days: nil, inviter_user_id: nil)
|
840
|
+
def send_invitation(email:, organization_id: nil, expires_in_days: nil, inviter_user_id: nil, role_slug: nil)
|
1033
841
|
response = execute_request(
|
1034
842
|
request: post_request(
|
1035
843
|
path: '/user_management/invitations',
|
@@ -1038,6 +846,7 @@ module WorkOS
|
|
1038
846
|
organization_id: organization_id,
|
1039
847
|
expires_in_days: expires_in_days,
|
1040
848
|
inviter_user_id: inviter_user_id,
|
849
|
+
role_slug: role_slug,
|
1041
850
|
},
|
1042
851
|
auth: true,
|
1043
852
|
),
|
@@ -1051,9 +860,6 @@ module WorkOS
|
|
1051
860
|
# @param [String] id The unique ID of the Invitation.
|
1052
861
|
#
|
1053
862
|
# @return WorkOS::Invitation
|
1054
|
-
sig do
|
1055
|
-
params(id: String).returns(WorkOS::Invitation)
|
1056
|
-
end
|
1057
863
|
def revoke_invitation(id:)
|
1058
864
|
request = post_request(
|
1059
865
|
path: "/user_management/invitations/#{id}/revoke",
|
@@ -1067,14 +873,6 @@ module WorkOS
|
|
1067
873
|
|
1068
874
|
private
|
1069
875
|
|
1070
|
-
sig do
|
1071
|
-
params(
|
1072
|
-
provider: T.nilable(String),
|
1073
|
-
connection_id: T.nilable(String),
|
1074
|
-
organization_id: T.nilable(String),
|
1075
|
-
).void
|
1076
|
-
end
|
1077
|
-
|
1078
876
|
def validate_authorization_url_arguments(
|
1079
877
|
provider:,
|
1080
878
|
connection_id:,
|
@@ -1091,12 +889,6 @@ module WorkOS
|
|
1091
889
|
" `provider` must be in #{PROVIDERS}"
|
1092
890
|
end
|
1093
891
|
|
1094
|
-
sig do
|
1095
|
-
params(
|
1096
|
-
type: String,
|
1097
|
-
).void
|
1098
|
-
end
|
1099
|
-
|
1100
892
|
def validate_auth_factor_type(
|
1101
893
|
type:
|
1102
894
|
)
|
data/lib/workos/user_response.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The UserResponse class represents a User as well as an corresponding
|
6
5
|
# response data that can later be appended on.
|
7
6
|
class UserResponse
|
8
7
|
include HashProvider
|
9
|
-
extend T::Sig
|
10
8
|
|
11
9
|
attr_accessor :user
|
12
10
|
|
13
|
-
sig { params(user_response_json: String).void }
|
14
11
|
def initialize(user_response_json)
|
15
12
|
json = JSON.parse(user_response_json, symbolize_names: true)
|
16
13
|
@user = WorkOS::User.new(json[:user].to_json)
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: false
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The VerifyChallenge class provides a lightweight wrapper around
|
6
5
|
# a WorkOS Authentication Challenge resource.
|
7
6
|
class VerifyChallenge
|
8
7
|
include HashProvider
|
9
|
-
extend T::Sig
|
10
8
|
|
11
9
|
attr_accessor :challenge, :valid
|
12
10
|
|
13
|
-
sig { params(json: String).void }
|
14
11
|
def initialize(json)
|
15
|
-
|
16
|
-
|
17
|
-
@
|
12
|
+
hash = JSON.parse(json, symbolize_names: true)
|
13
|
+
|
14
|
+
@challenge = hash[:challenge]
|
15
|
+
@valid = hash[:valid]
|
18
16
|
end
|
19
17
|
|
20
18
|
def to_json(*)
|
@@ -23,17 +21,5 @@ module WorkOS
|
|
23
21
|
valid: valid,
|
24
22
|
}
|
25
23
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
sig { params(json_string: String).returns(WorkOS::Types::VerifyChallengeStruct) }
|
30
|
-
def parse_json(json_string)
|
31
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
32
|
-
|
33
|
-
WorkOS::Types::VerifyChallengeStruct.new(
|
34
|
-
challenge: hash[:challenge],
|
35
|
-
valid: hash[:valid],
|
36
|
-
)
|
37
|
-
end
|
38
24
|
end
|
39
25
|
end
|