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/directory.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The Directory class provides a lightweight wrapper around
|
@@ -7,25 +6,21 @@ module WorkOS
|
|
7
6
|
# in user space, and is instantiated internally but exposed.
|
8
7
|
class Directory
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :domain, :name, :type, :state, :organization_id, :created_at, :updated_at
|
13
11
|
|
14
|
-
# rubocop:disable Metrics/AbcSize
|
15
|
-
sig { params(json: String).void }
|
16
12
|
def initialize(json)
|
17
|
-
|
18
|
-
|
19
|
-
@id =
|
20
|
-
@name =
|
21
|
-
@domain =
|
22
|
-
@type =
|
23
|
-
@state =
|
24
|
-
@organization_id =
|
25
|
-
@created_at =
|
26
|
-
@updated_at =
|
13
|
+
hash = JSON.parse(json, symbolize_names: true)
|
14
|
+
|
15
|
+
@id = hash[:id]
|
16
|
+
@name = hash[:name]
|
17
|
+
@domain = hash[:domain]
|
18
|
+
@type = hash[:type]
|
19
|
+
@state = hash[:state]
|
20
|
+
@organization_id = hash[:organization_id]
|
21
|
+
@created_at = hash[:created_at]
|
22
|
+
@updated_at = hash[:updated_at]
|
27
23
|
end
|
28
|
-
# rubocop:enable Metrics/AbcSize
|
29
24
|
|
30
25
|
def to_json(*)
|
31
26
|
{
|
@@ -39,27 +34,5 @@ module WorkOS
|
|
39
34
|
updated_at: updated_at,
|
40
35
|
}
|
41
36
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
sig do
|
46
|
-
params(
|
47
|
-
json_string: String,
|
48
|
-
).returns(WorkOS::Types::DirectoryStruct)
|
49
|
-
end
|
50
|
-
def parse_json(json_string)
|
51
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
52
|
-
|
53
|
-
WorkOS::Types::DirectoryStruct.new(
|
54
|
-
id: hash[:id],
|
55
|
-
name: hash[:name],
|
56
|
-
domain: hash[:domain],
|
57
|
-
type: hash[:type],
|
58
|
-
state: hash[:state],
|
59
|
-
organization_id: hash[:organization_id],
|
60
|
-
created_at: hash[:created_at],
|
61
|
-
updated_at: hash[:updated_at],
|
62
|
-
)
|
63
|
-
end
|
64
37
|
end
|
65
38
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The DirectoryGroup class provides a lightweight wrapper around
|
@@ -7,28 +6,24 @@ module WorkOS
|
|
7
6
|
# in user space, and is instantiated internally but exposed.
|
8
7
|
class DirectoryGroup < DeprecatedHashWrapper
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :directory_id, :idp_id, :name, :created_at, :updated_at,
|
13
11
|
:raw_attributes, :organization_id
|
14
12
|
|
15
|
-
# rubocop:disable Metrics/AbcSize
|
16
|
-
sig { params(json: String).void }
|
17
13
|
def initialize(json)
|
18
|
-
|
14
|
+
hash = JSON.parse(json, symbolize_names: true)
|
19
15
|
|
20
|
-
@id =
|
21
|
-
@directory_id =
|
22
|
-
@organization_id =
|
23
|
-
@idp_id =
|
24
|
-
@name =
|
25
|
-
@created_at =
|
26
|
-
@updated_at =
|
27
|
-
@raw_attributes =
|
16
|
+
@id = hash[:id]
|
17
|
+
@directory_id = hash[:directory_id]
|
18
|
+
@organization_id = hash[:organization_id]
|
19
|
+
@idp_id = hash[:idp_id]
|
20
|
+
@name = hash[:name]
|
21
|
+
@created_at = hash[:created_at]
|
22
|
+
@updated_at = hash[:updated_at]
|
23
|
+
@raw_attributes = hash[:raw_attributes]
|
28
24
|
|
29
25
|
replace_without_warning(to_json)
|
30
26
|
end
|
31
|
-
# rubocop:enable Metrics/AbcSize
|
32
27
|
|
33
28
|
def to_json(*)
|
34
29
|
{
|
@@ -42,27 +37,5 @@ module WorkOS
|
|
42
37
|
raw_attributes: raw_attributes,
|
43
38
|
}
|
44
39
|
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
sig do
|
49
|
-
params(
|
50
|
-
json_string: String,
|
51
|
-
).returns(WorkOS::Types::DirectoryGroupStruct)
|
52
|
-
end
|
53
|
-
def parse_json(json_string)
|
54
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
55
|
-
|
56
|
-
WorkOS::Types::DirectoryGroupStruct.new(
|
57
|
-
id: hash[:id],
|
58
|
-
directory_id: hash[:directory_id],
|
59
|
-
organization_id: hash[:organization_id],
|
60
|
-
idp_id: hash[:idp_id],
|
61
|
-
name: hash[:name],
|
62
|
-
created_at: hash[:created_at],
|
63
|
-
updated_at: hash[:updated_at],
|
64
|
-
raw_attributes: hash[:raw_attributes],
|
65
|
-
)
|
66
|
-
end
|
67
40
|
end
|
68
41
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: strict
|
3
2
|
|
4
3
|
require 'net/http'
|
5
4
|
|
@@ -11,7 +10,6 @@ module WorkOS
|
|
11
10
|
# @see https://docs.workos.com/directory-sync/overview
|
12
11
|
module DirectorySync
|
13
12
|
class << self
|
14
|
-
extend T::Sig
|
15
13
|
include Client
|
16
14
|
|
17
15
|
# Retrieve directories.
|
@@ -29,11 +27,6 @@ module WorkOS
|
|
29
27
|
# @option options [String] organization_id The ID for an Organization configured on WorkOS.
|
30
28
|
#
|
31
29
|
# @return [Hash]
|
32
|
-
sig do
|
33
|
-
params(
|
34
|
-
options: T::Hash[Symbol, String],
|
35
|
-
).returns(WorkOS::Types::ListStruct)
|
36
|
-
end
|
37
30
|
def list_directories(options = {})
|
38
31
|
options[:order] ||= 'desc'
|
39
32
|
response = execute_request(
|
@@ -72,7 +65,6 @@ module WorkOS
|
|
72
65
|
# @updated_at="2021-10-27T16:03:43.990Z"
|
73
66
|
#
|
74
67
|
# @return [WorkOS::Directory]
|
75
|
-
sig { params(id: String).returns(WorkOS::Directory) }
|
76
68
|
def get_directory(id:)
|
77
69
|
request = get_request(
|
78
70
|
auth: true,
|
@@ -99,11 +91,6 @@ module WorkOS
|
|
99
91
|
# before a provided Directory Group ID.
|
100
92
|
#
|
101
93
|
# @return [WorkOS::DirectoryGroup]
|
102
|
-
sig do
|
103
|
-
params(
|
104
|
-
options: T::Hash[Symbol, String],
|
105
|
-
).returns(WorkOS::Types::ListStruct)
|
106
|
-
end
|
107
94
|
def list_groups(options = {})
|
108
95
|
options[:order] ||= 'desc'
|
109
96
|
response = execute_request(
|
@@ -140,11 +127,6 @@ module WorkOS
|
|
140
127
|
# before a provided Directory User ID.
|
141
128
|
#
|
142
129
|
# @return [WorkOS::DirectoryUser]
|
143
|
-
sig do
|
144
|
-
params(
|
145
|
-
options: T::Hash[Symbol, String],
|
146
|
-
).returns(WorkOS::Types::ListStruct)
|
147
|
-
end
|
148
130
|
def list_users(options = {})
|
149
131
|
options[:order] ||= 'desc'
|
150
132
|
response = execute_request(
|
@@ -171,7 +153,6 @@ module WorkOS
|
|
171
153
|
# @param [String] id The ID of the directory group.
|
172
154
|
#
|
173
155
|
# @return WorkOS::DirectoryGroup
|
174
|
-
sig { params(id: String).returns(WorkOS::DirectoryGroup) }
|
175
156
|
def get_group(id)
|
176
157
|
response = execute_request(
|
177
158
|
request: get_request(
|
@@ -188,7 +169,6 @@ module WorkOS
|
|
188
169
|
# @param [String] id The ID of the directory user.
|
189
170
|
#
|
190
171
|
# @return WorkOS::DirectoryUser
|
191
|
-
sig { params(id: String).returns(WorkOS::DirectoryUser) }
|
192
172
|
def get_user(id)
|
193
173
|
response = execute_request(
|
194
174
|
request: get_request(
|
@@ -205,7 +185,6 @@ module WorkOS
|
|
205
185
|
# @param [String] id The ID of the directory.
|
206
186
|
#
|
207
187
|
# @return Boolean
|
208
|
-
sig { params(id: String).returns(T::Boolean) }
|
209
188
|
def delete_directory(id)
|
210
189
|
request = delete_request(
|
211
190
|
auth: true,
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The DirectoryUser class provides a lightweight wrapper around
|
@@ -7,32 +6,30 @@ module WorkOS
|
|
7
6
|
# in DirectoryUser space, and is instantiated internally but exposed.
|
8
7
|
class DirectoryUser < DeprecatedHashWrapper
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :idp_id, :emails, :first_name, :last_name, :job_title, :username, :state,
|
13
11
|
:groups, :custom_attributes, :raw_attributes, :directory_id, :organization_id,
|
14
12
|
:created_at, :updated_at
|
15
13
|
|
16
14
|
# rubocop:disable Metrics/AbcSize
|
17
|
-
sig { params(json: String).void }
|
18
15
|
def initialize(json)
|
19
|
-
|
20
|
-
|
21
|
-
@id =
|
22
|
-
@directory_id =
|
23
|
-
@organization_id =
|
24
|
-
@idp_id =
|
25
|
-
@emails =
|
26
|
-
@first_name =
|
27
|
-
@last_name =
|
28
|
-
@job_title =
|
29
|
-
@username =
|
30
|
-
@state =
|
31
|
-
@groups =
|
32
|
-
@custom_attributes =
|
33
|
-
@raw_attributes =
|
34
|
-
@created_at =
|
35
|
-
@updated_at =
|
16
|
+
hash = JSON.parse(json, symbolize_names: true)
|
17
|
+
|
18
|
+
@id = hash[:id]
|
19
|
+
@directory_id = hash[:directory_id]
|
20
|
+
@organization_id = hash[:organization_id]
|
21
|
+
@idp_id = hash[:idp_id]
|
22
|
+
@emails = hash[:emails]
|
23
|
+
@first_name = hash[:first_name]
|
24
|
+
@last_name = hash[:last_name]
|
25
|
+
@job_title = hash[:job_title]
|
26
|
+
@username = hash[:username]
|
27
|
+
@state = hash[:state]
|
28
|
+
@groups = hash[:groups]
|
29
|
+
@custom_attributes = hash[:custom_attributes]
|
30
|
+
@raw_attributes = hash[:raw_attributes]
|
31
|
+
@created_at = hash[:created_at]
|
32
|
+
@updated_at = hash[:updated_at]
|
36
33
|
|
37
34
|
replace_without_warning(to_json)
|
38
35
|
end
|
@@ -62,36 +59,5 @@ module WorkOS
|
|
62
59
|
primary_email = (emails || []).find { |email| email[:primary] }
|
63
60
|
return primary_email[:value] if primary_email
|
64
61
|
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
# rubocop:disable Metrics/AbcSize
|
69
|
-
sig do
|
70
|
-
params(
|
71
|
-
json_string: String,
|
72
|
-
).returns(WorkOS::Types::DirectoryUserStruct)
|
73
|
-
end
|
74
|
-
def parse_json(json_string)
|
75
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
76
|
-
|
77
|
-
WorkOS::Types::DirectoryUserStruct.new(
|
78
|
-
id: hash[:id],
|
79
|
-
directory_id: hash[:directory_id],
|
80
|
-
organization_id: hash[:organization_id],
|
81
|
-
idp_id: hash[:idp_id],
|
82
|
-
emails: hash[:emails],
|
83
|
-
first_name: hash[:first_name],
|
84
|
-
last_name: hash[:last_name],
|
85
|
-
job_title: hash[:job_title],
|
86
|
-
username: hash[:username],
|
87
|
-
state: hash[:state],
|
88
|
-
groups: hash[:groups],
|
89
|
-
custom_attributes: hash[:custom_attributes],
|
90
|
-
created_at: hash[:created_at],
|
91
|
-
updated_at: hash[:updated_at],
|
92
|
-
raw_attributes: hash[:raw_attributes],
|
93
|
-
)
|
94
|
-
end
|
95
|
-
# rubocop:enable Metrics/AbcSize
|
96
62
|
end
|
97
63
|
end
|
data/lib/workos/errors.rb
CHANGED
@@ -1,29 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
|
-
|
4
2
|
|
5
3
|
module WorkOS
|
6
4
|
# Parent class for WorkOS related errors
|
7
5
|
class WorkOSError < StandardError
|
8
|
-
extend T::Sig
|
9
|
-
|
10
6
|
attr_reader :http_status
|
11
7
|
attr_reader :request_id
|
12
8
|
attr_reader :code
|
13
9
|
attr_reader :errors
|
14
10
|
|
15
11
|
# rubocop:disable Metrics/ParameterLists
|
16
|
-
sig do
|
17
|
-
params(
|
18
|
-
message: T.nilable(String),
|
19
|
-
error: T.nilable(String),
|
20
|
-
error_description: T.nilable(String),
|
21
|
-
http_status: T.nilable(Integer),
|
22
|
-
request_id: T.nilable(String),
|
23
|
-
code: T.nilable(String),
|
24
|
-
errors: T.nilable(T::Array[T::Hash[T.untyped, T.untyped]]),
|
25
|
-
).void
|
26
|
-
end
|
27
12
|
def initialize(
|
28
13
|
message: nil,
|
29
14
|
error: nil,
|
@@ -43,7 +28,6 @@ module WorkOS
|
|
43
28
|
end
|
44
29
|
# rubocop:enable Metrics/ParameterLists
|
45
30
|
|
46
|
-
sig { returns(String) }
|
47
31
|
def to_s
|
48
32
|
status_string = @http_status.nil? ? '' : "Status #{@http_status}, "
|
49
33
|
id_string = @request_id.nil? ? '' : " - request ID: #{@request_id}"
|
data/lib/workos/event.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The Event class provides a lightweight wrapper around
|
@@ -7,18 +6,16 @@ module WorkOS
|
|
7
6
|
# in user space, and is instantiated internally but exposed.
|
8
7
|
class Event
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :event, :data, :created_at
|
13
11
|
|
14
|
-
sig { params(json: String).void }
|
15
12
|
def initialize(json)
|
16
|
-
|
13
|
+
hash = JSON.parse(json, symbolize_names: true)
|
17
14
|
|
18
|
-
@id =
|
19
|
-
@event =
|
20
|
-
@created_at =
|
21
|
-
@data =
|
15
|
+
@id = hash[:id]
|
16
|
+
@event = hash[:event]
|
17
|
+
@created_at = hash[:created_at]
|
18
|
+
@data = hash[:data]
|
22
19
|
end
|
23
20
|
|
24
21
|
def to_json(*)
|
@@ -29,23 +26,5 @@ module WorkOS
|
|
29
26
|
created_at: created_at,
|
30
27
|
}
|
31
28
|
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
sig do
|
36
|
-
params(
|
37
|
-
json_string: String,
|
38
|
-
).returns(WorkOS::Types::EventStruct)
|
39
|
-
end
|
40
|
-
def parse_json(json_string)
|
41
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
42
|
-
|
43
|
-
WorkOS::Types::EventStruct.new(
|
44
|
-
id: hash[:id],
|
45
|
-
event: hash[:event],
|
46
|
-
data: hash[:data],
|
47
|
-
created_at: hash[:created_at],
|
48
|
-
)
|
49
|
-
end
|
50
29
|
end
|
51
30
|
end
|
data/lib/workos/events.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: strict
|
3
2
|
|
4
3
|
require 'net/http'
|
5
4
|
|
@@ -10,7 +9,6 @@ module WorkOS
|
|
10
9
|
#
|
11
10
|
module Events
|
12
11
|
class << self
|
13
|
-
extend T::Sig
|
14
12
|
include Client
|
15
13
|
|
16
14
|
# Retrieve events.
|
@@ -23,11 +21,6 @@ module WorkOS
|
|
23
21
|
# after a provided Event ID.
|
24
22
|
#
|
25
23
|
# @return [Hash]
|
26
|
-
sig do
|
27
|
-
params(
|
28
|
-
options: T::Hash[Symbol, String],
|
29
|
-
).returns(WorkOS::Types::ListStruct)
|
30
|
-
end
|
31
24
|
def list_events(options = {})
|
32
25
|
response = execute_request(
|
33
26
|
request: get_request(
|
data/lib/workos/factor.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: false
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The Factor class provides a lightweight wrapper around
|
@@ -7,19 +6,18 @@ module WorkOS
|
|
7
6
|
# in DirectoryUser space, and is instantiated internally but exposed.
|
8
7
|
class Factor
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
attr_accessor :id, :object, :type, :sms, :totp, :updated_at, :created_at
|
12
10
|
|
13
|
-
sig { params(json: String).void }
|
14
11
|
def initialize(json)
|
15
|
-
|
16
|
-
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
12
|
+
hash = JSON.parse(json, symbolize_names: true)
|
13
|
+
|
14
|
+
@id = hash[:id]
|
15
|
+
@object = hash[:object]
|
16
|
+
@type = hash[:type]
|
17
|
+
@created_at = hash[:created_at]
|
18
|
+
@updated_at = hash[:updated_at]
|
19
|
+
@totp = hash[:totp]
|
20
|
+
@sms = hash[:sms]
|
23
21
|
end
|
24
22
|
|
25
23
|
def to_json(*)
|
@@ -33,22 +31,5 @@ module WorkOS
|
|
33
31
|
updated_at: updated_at,
|
34
32
|
}
|
35
33
|
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
sig { params(json_string: String).returns(WorkOS::Types::FactorStruct) }
|
40
|
-
def parse_json(json_string)
|
41
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
42
|
-
|
43
|
-
WorkOS::Types::FactorStruct.new(
|
44
|
-
id: hash[:id],
|
45
|
-
object: hash[:object],
|
46
|
-
type: hash[:type],
|
47
|
-
totp: hash[:totp],
|
48
|
-
sms: hash[:sms],
|
49
|
-
created_at: hash[:created_at],
|
50
|
-
updated_at: hash[:updated_at],
|
51
|
-
)
|
52
|
-
end
|
53
34
|
end
|
54
35
|
end
|
data/lib/workos/hash_provider.rb
CHANGED
data/lib/workos/impersonator.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# Contains information about a WorkOS Dashboard user impersonating
|
6
5
|
# a User Management user.
|
7
6
|
class Impersonator
|
8
7
|
include HashProvider
|
9
|
-
extend T::Sig
|
10
8
|
|
11
9
|
attr_accessor :email, :reason
|
12
10
|
|
13
|
-
sig { params(email: String, reason: T.nilable(String)).void }
|
14
11
|
def initialize(email:, reason:)
|
15
12
|
@email = email
|
16
13
|
@reason = reason
|
data/lib/workos/invitation.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
2
|
|
4
3
|
module WorkOS
|
5
4
|
# The Invitation class provides a lightweight wrapper around a WorkOS Invitation
|
@@ -7,28 +6,24 @@ module WorkOS
|
|
7
6
|
# and is instantiated internally but exposed.
|
8
7
|
class Invitation
|
9
8
|
include HashProvider
|
10
|
-
extend T::Sig
|
11
9
|
|
12
10
|
attr_accessor :id, :email, :state, :accepted_at, :revoked_at,
|
13
11
|
:expires_at, :token, :organization_id, :created_at, :updated_at
|
14
12
|
|
15
|
-
# rubocop:disable Metrics/AbcSize
|
16
|
-
sig { params(json: String).void }
|
17
13
|
def initialize(json)
|
18
|
-
|
19
|
-
|
20
|
-
@id =
|
21
|
-
@email =
|
22
|
-
@state =
|
23
|
-
@token =
|
24
|
-
@organization_id =
|
25
|
-
@accepted_at =
|
26
|
-
@revoked_at =
|
27
|
-
@expires_at =
|
28
|
-
@created_at =
|
29
|
-
@updated_at =
|
14
|
+
hash = JSON.parse(json, symbolize_names: true)
|
15
|
+
|
16
|
+
@id = hash[:id]
|
17
|
+
@email = hash[:email]
|
18
|
+
@state = hash[:state]
|
19
|
+
@token = hash[:token]
|
20
|
+
@organization_id = hash[:organization_id]
|
21
|
+
@accepted_at = hash[:accepted_at]
|
22
|
+
@revoked_at = hash[:revoked_at]
|
23
|
+
@expires_at = hash[:expires_at]
|
24
|
+
@created_at = hash[:created_at]
|
25
|
+
@updated_at = hash[:updated_at]
|
30
26
|
end
|
31
|
-
# rubocop:enable Metrics/AbcSize
|
32
27
|
|
33
28
|
def to_json(*)
|
34
29
|
{
|
@@ -44,25 +39,5 @@ module WorkOS
|
|
44
39
|
updated_at: updated_at,
|
45
40
|
}
|
46
41
|
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
sig { params(json_string: String).returns(WorkOS::Types::InvitationStruct) }
|
51
|
-
def parse_json(json_string)
|
52
|
-
hash = JSON.parse(json_string, symbolize_names: true)
|
53
|
-
|
54
|
-
WorkOS::Types::InvitationStruct.new(
|
55
|
-
id: hash[:id],
|
56
|
-
email: hash[:email],
|
57
|
-
state: hash[:state],
|
58
|
-
token: hash[:token],
|
59
|
-
organization_id: hash[:organization_id],
|
60
|
-
accepted_at: hash[:accepted_at],
|
61
|
-
revoked_at: hash[:revoked_at],
|
62
|
-
expires_at: hash[:expires_at],
|
63
|
-
created_at: hash[:created_at],
|
64
|
-
updated_at: hash[:updated_at],
|
65
|
-
)
|
66
|
-
end
|
67
42
|
end
|
68
43
|
end
|
data/lib/workos/mfa.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
|
-
|
4
2
|
|
5
3
|
require 'net/http'
|
6
4
|
require 'uri'
|
@@ -10,9 +8,7 @@ module WorkOS
|
|
10
8
|
# MFA platform. You'll need a valid API key
|
11
9
|
module MFA
|
12
10
|
class << self
|
13
|
-
extend T::Sig
|
14
11
|
include Client
|
15
|
-
sig { params(id: String).returns(T::Boolean) }
|
16
12
|
def delete_factor(id:)
|
17
13
|
response = execute_request(
|
18
14
|
request: delete_request(
|
@@ -23,9 +19,6 @@ module WorkOS
|
|
23
19
|
response.is_a? Net::HTTPSuccess
|
24
20
|
end
|
25
21
|
|
26
|
-
sig do
|
27
|
-
params(id: String).returns(WorkOS::Factor)
|
28
|
-
end
|
29
22
|
def get_factor(
|
30
23
|
id:
|
31
24
|
)
|
@@ -38,17 +31,8 @@ module WorkOS
|
|
38
31
|
WorkOS::Factor.new(response.body)
|
39
32
|
end
|
40
33
|
|
41
|
-
sig do
|
42
|
-
params(
|
43
|
-
type: String,
|
44
|
-
totp_issuer: T.nilable(String),
|
45
|
-
totp_user: T.nilable(String),
|
46
|
-
phone_number: T.nilable(String),
|
47
|
-
).void
|
48
|
-
end
|
49
34
|
# rubocop:disable Metrics/CyclomaticComplexity
|
50
35
|
# rubocop:disable Metrics/PerceivedComplexity
|
51
|
-
|
52
36
|
def validate_args(
|
53
37
|
type:,
|
54
38
|
totp_issuer: nil,
|
@@ -68,14 +52,6 @@ module WorkOS
|
|
68
52
|
# rubocop:enable Metrics/CyclomaticComplexity
|
69
53
|
# rubocop:enable Metrics/PerceivedComplexity
|
70
54
|
|
71
|
-
sig do
|
72
|
-
params(
|
73
|
-
type: String,
|
74
|
-
totp_issuer: T.nilable(String),
|
75
|
-
totp_user: T.nilable(String),
|
76
|
-
phone_number: T.nilable(String),
|
77
|
-
).returns(WorkOS::Factor)
|
78
|
-
end
|
79
55
|
def enroll_factor(
|
80
56
|
type:,
|
81
57
|
totp_issuer: nil,
|
@@ -101,12 +77,6 @@ module WorkOS
|
|
101
77
|
WorkOS::Factor.new(response.body)
|
102
78
|
end
|
103
79
|
|
104
|
-
sig do
|
105
|
-
params(
|
106
|
-
authentication_factor_id: T.nilable(String),
|
107
|
-
sms_template: T.nilable(String),
|
108
|
-
).returns(WorkOS::Challenge)
|
109
|
-
end
|
110
80
|
def challenge_factor(
|
111
81
|
authentication_factor_id: nil,
|
112
82
|
sms_template: nil
|
@@ -127,12 +97,6 @@ module WorkOS
|
|
127
97
|
WorkOS::Challenge.new(response.body)
|
128
98
|
end
|
129
99
|
|
130
|
-
sig do
|
131
|
-
params(
|
132
|
-
authentication_challenge_id: T.nilable(String),
|
133
|
-
code: T.nilable(String),
|
134
|
-
).returns(WorkOS::VerifyChallenge)
|
135
|
-
end
|
136
100
|
def verify_factor(
|
137
101
|
authentication_challenge_id: nil,
|
138
102
|
code: nil
|
@@ -145,12 +109,6 @@ module WorkOS
|
|
145
109
|
)
|
146
110
|
end
|
147
111
|
|
148
|
-
sig do
|
149
|
-
params(
|
150
|
-
authentication_challenge_id: T.nilable(String),
|
151
|
-
code: T.nilable(String),
|
152
|
-
).returns(WorkOS::VerifyChallenge)
|
153
|
-
end
|
154
112
|
def verify_challenge(
|
155
113
|
authentication_challenge_id: nil,
|
156
114
|
code: nil
|