workos 4.1.0 → 4.2.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.
- 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 +32 -243
- 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 +0 -1
- data/spec/lib/workos/webhooks_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -9
- data/spec/support/shared_examples/client_spec.rb +0 -1
- data/workos.gemspec +1 -6
- metadata +11 -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,11 +509,6 @@ 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
513
|
execute_request(
|
|
629
514
|
request: post_request(
|
|
@@ -642,11 +527,6 @@ module WorkOS
|
|
|
642
527
|
# @param [String] client_id The WorkOS client ID for the environment
|
|
643
528
|
#
|
|
644
529
|
# @return String
|
|
645
|
-
sig do
|
|
646
|
-
params(
|
|
647
|
-
client_id: String,
|
|
648
|
-
).returns(String)
|
|
649
|
-
end
|
|
650
530
|
def get_jwks_url(client_id)
|
|
651
531
|
URI::HTTPS.build(
|
|
652
532
|
host: WorkOS.config.api_hostname,
|
|
@@ -659,11 +539,6 @@ module WorkOS
|
|
|
659
539
|
# @param [String] email The email address the one-time code will be sent to.
|
|
660
540
|
#
|
|
661
541
|
# @return Boolean
|
|
662
|
-
sig do
|
|
663
|
-
params(
|
|
664
|
-
email: String,
|
|
665
|
-
).returns(T::Boolean)
|
|
666
|
-
end
|
|
667
542
|
def send_magic_auth_code(email:)
|
|
668
543
|
response = execute_request(
|
|
669
544
|
request: post_request(
|
|
@@ -687,14 +562,6 @@ module WorkOS
|
|
|
687
562
|
# @param [String] totp_user For totp factors. Used as the account name in authenticator apps.
|
|
688
563
|
#
|
|
689
564
|
# @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
565
|
def enroll_auth_factor(user_id:, type:, totp_issuer: nil, totp_user: nil)
|
|
699
566
|
validate_auth_factor_type(
|
|
700
567
|
type: type,
|
|
@@ -720,11 +587,6 @@ module WorkOS
|
|
|
720
587
|
# @param [String] user_id The id for the user.
|
|
721
588
|
#
|
|
722
589
|
# @return WorkOS::ListStruct
|
|
723
|
-
sig do
|
|
724
|
-
params(
|
|
725
|
-
user_id: String,
|
|
726
|
-
).returns(WorkOS::Types::ListStruct)
|
|
727
|
-
end
|
|
728
590
|
def list_auth_factors(user_id:)
|
|
729
591
|
response = execute_request(
|
|
730
592
|
request: get_request(
|
|
@@ -750,11 +612,6 @@ module WorkOS
|
|
|
750
612
|
# @param [String] user_id The unique ID of the User whose email address will be verified.
|
|
751
613
|
#
|
|
752
614
|
# @return WorkOS::UserResponse
|
|
753
|
-
sig do
|
|
754
|
-
params(
|
|
755
|
-
user_id: String,
|
|
756
|
-
).returns(WorkOS::UserResponse)
|
|
757
|
-
end
|
|
758
615
|
def send_verification_email(user_id:)
|
|
759
616
|
response = execute_request(
|
|
760
617
|
request: post_request(
|
|
@@ -772,12 +629,6 @@ module WorkOS
|
|
|
772
629
|
# @param [String] code The one-time code emailed to the user.
|
|
773
630
|
#
|
|
774
631
|
# @return WorkOS::UserResponse
|
|
775
|
-
sig do
|
|
776
|
-
params(
|
|
777
|
-
user_id: String,
|
|
778
|
-
code: String,
|
|
779
|
-
).returns(WorkOS::UserResponse)
|
|
780
|
-
end
|
|
781
632
|
def verify_email(user_id:, code:)
|
|
782
633
|
response = execute_request(
|
|
783
634
|
request: post_request(
|
|
@@ -798,12 +649,6 @@ module WorkOS
|
|
|
798
649
|
# @param [String] password_reset_url The URL that will be linked to in the email.
|
|
799
650
|
#
|
|
800
651
|
# @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
652
|
def send_password_reset_email(email:, password_reset_url:)
|
|
808
653
|
request = post_request(
|
|
809
654
|
path: '/user_management/password_reset/send',
|
|
@@ -825,12 +670,6 @@ module WorkOS
|
|
|
825
670
|
# @param [String] new_password The new password to set for the user.
|
|
826
671
|
#
|
|
827
672
|
# @return WorkOS::User
|
|
828
|
-
sig do
|
|
829
|
-
params(
|
|
830
|
-
token: String,
|
|
831
|
-
new_password: String,
|
|
832
|
-
).returns(WorkOS::User)
|
|
833
|
-
end
|
|
834
673
|
def reset_password(token:, new_password:)
|
|
835
674
|
response = execute_request(
|
|
836
675
|
request: post_request(
|
|
@@ -851,9 +690,6 @@ module WorkOS
|
|
|
851
690
|
# @param [String] id The unique ID of the Organization Membership.
|
|
852
691
|
#
|
|
853
692
|
# @return WorkOS::OrganizationMembership
|
|
854
|
-
sig do
|
|
855
|
-
params(id: String).returns(WorkOS::OrganizationMembership)
|
|
856
|
-
end
|
|
857
693
|
def get_organization_membership(id:)
|
|
858
694
|
response = execute_request(
|
|
859
695
|
request: get_request(
|
|
@@ -878,11 +714,6 @@ module WorkOS
|
|
|
878
714
|
# before a provided User ID.
|
|
879
715
|
#
|
|
880
716
|
# @return [WorkOS::OrganizationMembership]
|
|
881
|
-
sig do
|
|
882
|
-
params(
|
|
883
|
-
options: T::Hash[Symbol, String],
|
|
884
|
-
).returns(WorkOS::Types::ListStruct)
|
|
885
|
-
end
|
|
886
717
|
def list_organization_memberships(options = {})
|
|
887
718
|
options[:order] ||= 'desc'
|
|
888
719
|
response = execute_request(
|
|
@@ -911,12 +742,6 @@ module WorkOS
|
|
|
911
742
|
# @param [String] organization_id The ID of the Organization to which the user belongs to.
|
|
912
743
|
#
|
|
913
744
|
# @return [WorkOS::OrganizationMembership]
|
|
914
|
-
sig do
|
|
915
|
-
params(
|
|
916
|
-
user_id: String,
|
|
917
|
-
organization_id: String,
|
|
918
|
-
).returns(WorkOS::OrganizationMembership)
|
|
919
|
-
end
|
|
920
745
|
def create_organization_membership(user_id:, organization_id:)
|
|
921
746
|
request = post_request(
|
|
922
747
|
path: '/user_management/organization_memberships',
|
|
@@ -937,11 +762,6 @@ module WorkOS
|
|
|
937
762
|
# @param [String] id The unique ID of the Organization Membership.
|
|
938
763
|
#
|
|
939
764
|
# @return [Bool] - returns `true` if successful
|
|
940
|
-
sig do
|
|
941
|
-
params(
|
|
942
|
-
id: String,
|
|
943
|
-
).returns(T::Boolean)
|
|
944
|
-
end
|
|
945
765
|
def delete_organization_membership(id:)
|
|
946
766
|
response = execute_request(
|
|
947
767
|
request: delete_request(
|
|
@@ -958,9 +778,6 @@ module WorkOS
|
|
|
958
778
|
# @param [String] id The unique ID of the Invitation.
|
|
959
779
|
#
|
|
960
780
|
# @return WorkOS::Invitation
|
|
961
|
-
sig do
|
|
962
|
-
params(id: String).returns(WorkOS::Invitation)
|
|
963
|
-
end
|
|
964
781
|
def get_invitation(id:)
|
|
965
782
|
response = execute_request(
|
|
966
783
|
request: get_request(
|
|
@@ -985,11 +802,6 @@ module WorkOS
|
|
|
985
802
|
# before a provided User ID.
|
|
986
803
|
#
|
|
987
804
|
# @return [WorkOS::Invitation]
|
|
988
|
-
sig do
|
|
989
|
-
params(
|
|
990
|
-
options: T::Hash[Symbol, String],
|
|
991
|
-
).returns(WorkOS::Types::ListStruct)
|
|
992
|
-
end
|
|
993
805
|
def list_invitations(options = {})
|
|
994
806
|
options[:order] ||= 'desc'
|
|
995
807
|
response = execute_request(
|
|
@@ -1019,17 +831,10 @@ module WorkOS
|
|
|
1019
831
|
# @param [Integer] expires_in_days The number of days the invitations will be valid for.
|
|
1020
832
|
# Must be between 1 and 30, defaults to 7 if not specified.
|
|
1021
833
|
# @param [String] inviter_user_id The ID of the User sending the invitation.
|
|
834
|
+
# @param [String] role_slug The slug of the role to assign to the user upon invitation.
|
|
1022
835
|
#
|
|
1023
836
|
# @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)
|
|
837
|
+
def send_invitation(email:, organization_id: nil, expires_in_days: nil, inviter_user_id: nil, role_slug: nil)
|
|
1033
838
|
response = execute_request(
|
|
1034
839
|
request: post_request(
|
|
1035
840
|
path: '/user_management/invitations',
|
|
@@ -1038,6 +843,7 @@ module WorkOS
|
|
|
1038
843
|
organization_id: organization_id,
|
|
1039
844
|
expires_in_days: expires_in_days,
|
|
1040
845
|
inviter_user_id: inviter_user_id,
|
|
846
|
+
role_slug: role_slug,
|
|
1041
847
|
},
|
|
1042
848
|
auth: true,
|
|
1043
849
|
),
|
|
@@ -1051,9 +857,6 @@ module WorkOS
|
|
|
1051
857
|
# @param [String] id The unique ID of the Invitation.
|
|
1052
858
|
#
|
|
1053
859
|
# @return WorkOS::Invitation
|
|
1054
|
-
sig do
|
|
1055
|
-
params(id: String).returns(WorkOS::Invitation)
|
|
1056
|
-
end
|
|
1057
860
|
def revoke_invitation(id:)
|
|
1058
861
|
request = post_request(
|
|
1059
862
|
path: "/user_management/invitations/#{id}/revoke",
|
|
@@ -1067,14 +870,6 @@ module WorkOS
|
|
|
1067
870
|
|
|
1068
871
|
private
|
|
1069
872
|
|
|
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
873
|
def validate_authorization_url_arguments(
|
|
1079
874
|
provider:,
|
|
1080
875
|
connection_id:,
|
|
@@ -1091,12 +886,6 @@ module WorkOS
|
|
|
1091
886
|
" `provider` must be in #{PROVIDERS}"
|
|
1092
887
|
end
|
|
1093
888
|
|
|
1094
|
-
sig do
|
|
1095
|
-
params(
|
|
1096
|
-
type: String,
|
|
1097
|
-
).void
|
|
1098
|
-
end
|
|
1099
|
-
|
|
1100
889
|
def validate_auth_factor_type(
|
|
1101
890
|
type:
|
|
1102
891
|
)
|
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
|