workos 4.1.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +37 -0
  3. data/.github/workflows/release.yml +43 -0
  4. data/.rubocop.yml +8 -1
  5. data/Gemfile.lock +22 -69
  6. data/lib/workos/audit_log_export.rb +8 -31
  7. data/lib/workos/audit_logs.rb +0 -26
  8. data/lib/workos/authentication_factor_and_challenge.rb +0 -3
  9. data/lib/workos/authentication_response.rb +3 -6
  10. data/lib/workos/challenge.rb +9 -28
  11. data/lib/workos/client.rb +0 -41
  12. data/lib/workos/configuration.rb +0 -1
  13. data/lib/workos/connection.rb +11 -35
  14. data/lib/workos/directory.rb +10 -37
  15. data/lib/workos/directory_group.rb +9 -36
  16. data/lib/workos/directory_sync.rb +0 -21
  17. data/lib/workos/directory_user.rb +17 -51
  18. data/lib/workos/errors.rb +0 -16
  19. data/lib/workos/event.rb +5 -26
  20. data/lib/workos/events.rb +0 -7
  21. data/lib/workos/factor.rb +9 -28
  22. data/lib/workos/hash_provider.rb +0 -1
  23. data/lib/workos/impersonator.rb +0 -3
  24. data/lib/workos/invitation.rb +12 -37
  25. data/lib/workos/mfa.rb +0 -42
  26. data/lib/workos/organization.rb +8 -31
  27. data/lib/workos/organization_membership.rb +8 -27
  28. data/lib/workos/organizations.rb +0 -26
  29. data/lib/workos/passwordless.rb +0 -14
  30. data/lib/workos/portal.rb +1 -13
  31. data/lib/workos/profile.rb +12 -39
  32. data/lib/workos/profile_and_token.rb +1 -4
  33. data/lib/workos/refresh_authentication_response.rb +2 -5
  34. data/lib/workos/sso.rb +1 -43
  35. data/lib/workos/types/intent.rb +16 -0
  36. data/lib/workos/types/list_struct.rb +8 -5
  37. data/lib/workos/types/passwordless_session_struct.rb +10 -9
  38. data/lib/workos/types/provider.rb +15 -0
  39. data/lib/workos/types.rb +5 -23
  40. data/lib/workos/user.rb +10 -31
  41. data/lib/workos/user_and_token.rb +1 -4
  42. data/lib/workos/user_management.rb +36 -244
  43. data/lib/workos/user_response.rb +0 -3
  44. data/lib/workos/verify_challenge.rb +4 -18
  45. data/lib/workos/version.rb +1 -2
  46. data/lib/workos/webhook.rb +5 -26
  47. data/lib/workos/webhooks.rb +1 -38
  48. data/lib/workos.rb +0 -2
  49. data/spec/lib/workos/audit_logs_spec.rb +2 -3
  50. data/spec/lib/workos/configuration_spec.rb +0 -1
  51. data/spec/lib/workos/directory_sync_spec.rb +0 -1
  52. data/spec/lib/workos/directory_user_spec.rb +0 -1
  53. data/spec/lib/workos/event_spec.rb +0 -1
  54. data/spec/lib/workos/mfa_spec.rb +0 -1
  55. data/spec/lib/workos/organizations_spec.rb +0 -1
  56. data/spec/lib/workos/passwordless_spec.rb +0 -1
  57. data/spec/lib/workos/portal_spec.rb +0 -1
  58. data/spec/lib/workos/sso_spec.rb +0 -1
  59. data/spec/lib/workos/user_management_spec.rb +29 -1
  60. data/spec/lib/workos/webhooks_spec.rb +0 -1
  61. data/spec/spec_helper.rb +0 -9
  62. data/spec/support/fixtures/vcr_cassettes/user_management/revoke_session/not_found.yml +80 -0
  63. data/spec/support/fixtures/vcr_cassettes/user_management/revoke_session/valid.yml +76 -0
  64. data/spec/support/shared_examples/client_spec.rb +0 -1
  65. data/workos.gemspec +1 -6
  66. metadata +15 -129
  67. data/.semaphore/rubygems.yml +0 -24
  68. data/.semaphore/semaphore.yml +0 -51
  69. data/bin/tapioca +0 -29
  70. data/codecov.yml +0 -12
  71. data/devbox.json +0 -18
  72. data/devbox.lock +0 -11
  73. data/lib/workos/types/audit_log_export_struct.rb +0 -17
  74. data/lib/workos/types/challenge_struct.rb +0 -18
  75. data/lib/workos/types/connection_struct.rb +0 -20
  76. data/lib/workos/types/directory_group_struct.rb +0 -19
  77. data/lib/workos/types/directory_struct.rb +0 -19
  78. data/lib/workos/types/directory_user_struct.rb +0 -26
  79. data/lib/workos/types/event_struct.rb +0 -15
  80. data/lib/workos/types/factor_struct.rb +0 -18
  81. data/lib/workos/types/intent_enum.rb +0 -17
  82. data/lib/workos/types/invitation_struct.rb +0 -20
  83. data/lib/workos/types/magic_auth_challenge_struct.rb +0 -12
  84. data/lib/workos/types/organization_membership_struct.rb +0 -16
  85. data/lib/workos/types/organization_struct.rb +0 -17
  86. data/lib/workos/types/profile_struct.rb +0 -21
  87. data/lib/workos/types/provider_enum.rb +0 -16
  88. data/lib/workos/types/user_struct.rb +0 -18
  89. data/lib/workos/types/verify_challenge_struct.rb +0 -13
  90. data/lib/workos/types/webhook_struct.rb +0 -15
  91. data/sorbet/config +0 -2
  92. data/sorbet/rbi/gems/addressable@2.8.0.rbi +0 -290
  93. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -54
  94. data/sorbet/rbi/gems/codecov@0.2.12.rbi +0 -55
  95. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -8
  96. data/sorbet/rbi/gems/crack@0.4.5.rbi +0 -57
  97. data/sorbet/rbi/gems/diff-lcs@1.4.4.rbi +0 -185
  98. data/sorbet/rbi/gems/docile@1.3.5.rbi +0 -54
  99. data/sorbet/rbi/gems/hashdiff@1.0.1.rbi +0 -82
  100. data/sorbet/rbi/gems/json@2.5.1.rbi +0 -109
  101. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -8
  102. data/sorbet/rbi/gems/parallel@1.20.1.rbi +0 -113
  103. data/sorbet/rbi/gems/parser@3.0.1.0.rbi +0 -1187
  104. data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -8
  105. data/sorbet/rbi/gems/public_suffix@4.0.6.rbi +0 -146
  106. data/sorbet/rbi/gems/rainbow@3.0.0.rbi +0 -153
  107. data/sorbet/rbi/gems/rake@13.0.3.rbi +0 -807
  108. data/sorbet/rbi/gems/rbi@0.0.16.rbi +0 -2118
  109. data/sorbet/rbi/gems/regexp_parser@2.1.1.rbi +0 -1117
  110. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -709
  111. data/sorbet/rbi/gems/rspec-core@3.9.3.rbi +0 -2467
  112. data/sorbet/rbi/gems/rspec-expectations@3.9.4.rbi +0 -1569
  113. data/sorbet/rbi/gems/rspec-mocks@3.9.1.rbi +0 -1493
  114. data/sorbet/rbi/gems/rspec-support@3.9.4.rbi +0 -511
  115. data/sorbet/rbi/gems/rspec@3.9.0.rbi +0 -38
  116. data/sorbet/rbi/gems/rubocop-ast@1.4.1.rbi +0 -1881
  117. data/sorbet/rbi/gems/rubocop@0.93.1.rbi +0 -11497
  118. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -405
  119. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -89
  120. data/sorbet/rbi/gems/simplecov@0.21.2.rbi +0 -577
  121. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.2.rbi +0 -8
  122. data/sorbet/rbi/gems/spoom@1.1.15.rbi +0 -1549
  123. data/sorbet/rbi/gems/tapioca@0.7.3.rbi +0 -1718
  124. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -844
  125. data/sorbet/rbi/gems/unicode-display_width@1.7.0.rbi +0 -22
  126. data/sorbet/rbi/gems/unparser@0.6.2.rbi +0 -8
  127. data/sorbet/rbi/gems/vcr@5.0.0.rbi +0 -699
  128. data/sorbet/rbi/gems/webmock@3.12.2.rbi +0 -662
  129. data/sorbet/rbi/gems/yard-sorbet@0.8.0.rbi +0 -268
  130. data/sorbet/rbi/gems/yard@0.9.26.rbi +0 -4048
  131. data/sorbet/tapioca/config.yml +0 -13
  132. data/sorbet/tapioca/require.rb +0 -4
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The Organization class provides a lightweight wrapper around
@@ -7,20 +6,18 @@ module WorkOS
7
6
  # in user space, and is instantiated internally but exposed.
8
7
  class Organization
9
8
  include HashProvider
10
- extend T::Sig
11
9
 
12
10
  attr_accessor :id, :domains, :name, :allow_profiles_outside_organization, :created_at, :updated_at
13
11
 
14
- sig { params(json: String).void }
15
12
  def initialize(json)
16
- raw = parse_json(json)
17
-
18
- @id = T.let(raw.id, String)
19
- @name = T.let(raw.name, String)
20
- @allow_profiles_outside_organization = T.let(raw.allow_profiles_outside_organization, T::Boolean)
21
- @domains = T.let(raw.domains, Array)
22
- @created_at = T.let(raw.created_at, String)
23
- @updated_at = T.let(raw.updated_at, String)
13
+ hash = JSON.parse(json, symbolize_names: true)
14
+
15
+ @id = hash[:id]
16
+ @name = hash[:name]
17
+ @allow_profiles_outside_organization = hash[:allow_profiles_outside_organization]
18
+ @domains = hash[:domains]
19
+ @created_at = hash[:created_at]
20
+ @updated_at = hash[:updated_at]
24
21
  end
25
22
 
26
23
  def to_json(*)
@@ -33,25 +30,5 @@ module WorkOS
33
30
  updated_at: updated_at,
34
31
  }
35
32
  end
36
-
37
- private
38
-
39
- sig do
40
- params(
41
- json_string: String,
42
- ).returns(WorkOS::Types::OrganizationStruct)
43
- end
44
- def parse_json(json_string)
45
- hash = JSON.parse(json_string, symbolize_names: true)
46
-
47
- WorkOS::Types::OrganizationStruct.new(
48
- id: hash[:id],
49
- name: hash[:name],
50
- allow_profiles_outside_organization: hash[:allow_profiles_outside_organization],
51
- domains: hash[:domains],
52
- created_at: hash[:created_at],
53
- updated_at: hash[:updated_at],
54
- )
55
- end
56
33
  end
57
34
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The OrganizationMembership class provides a lightweight wrapper around a WorkOS OrganizationMembership
@@ -7,20 +6,18 @@ module WorkOS
7
6
  # and is instantiated internally but exposed.
8
7
  class OrganizationMembership
9
8
  include HashProvider
10
- extend T::Sig
11
9
 
12
10
  attr_accessor :id, :user_id, :organization_id, :status, :created_at, :updated_at
13
11
 
14
- sig { params(json: String).void }
15
12
  def initialize(json)
16
- raw = parse_json(json)
17
-
18
- @id = T.let(raw.id, String)
19
- @user_id = T.let(raw.user_id, String)
20
- @organization_id = raw.organization_id
21
- @status = T.let(raw.status, String)
22
- @created_at = T.let(raw.created_at, String)
23
- @updated_at = T.let(raw.updated_at, String)
13
+ hash = JSON.parse(json, symbolize_names: true)
14
+
15
+ @id = hash[:id]
16
+ @user_id = hash[:user_id]
17
+ @organization_id = hash[:organization_id]
18
+ @status = hash[:status]
19
+ @created_at = hash[:created_at]
20
+ @updated_at = hash[:updated_at]
24
21
  end
25
22
 
26
23
  def to_json(*)
@@ -33,21 +30,5 @@ module WorkOS
33
30
  updated_at: updated_at,
34
31
  }
35
32
  end
36
-
37
- private
38
-
39
- sig { params(json_string: String).returns(WorkOS::Types::OrganizationMembershipStruct) }
40
- def parse_json(json_string)
41
- hash = JSON.parse(json_string, symbolize_names: true)
42
-
43
- WorkOS::Types::OrganizationMembershipStruct.new(
44
- id: hash[:id],
45
- user_id: hash[:user_id],
46
- organization_id: hash[:organization_id],
47
- status: hash[:status],
48
- created_at: hash[:created_at],
49
- updated_at: hash[:updated_at],
50
- )
51
- end
52
33
  end
53
34
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  require 'net/http'
5
4
 
@@ -7,7 +6,6 @@ module WorkOS
7
6
  # The Organizations module provides resource methods for working with Organizations
8
7
  module Organizations
9
8
  class << self
10
- extend T::Sig
11
9
  include Client
12
10
 
13
11
  # Retrieve a list of organizations that have connections configured
@@ -22,11 +20,6 @@ module WorkOS
22
20
  # @param [Integer] limit A pagination argument used to limit the number
23
21
  # @param [String] order The order in which to paginate records
24
22
  # of listed Organizations that are returned.
25
- sig do
26
- params(
27
- options: T::Hash[Symbol, String],
28
- ).returns(WorkOS::Types::ListStruct)
29
- end
30
23
  def list_organizations(options = {})
31
24
  options[:order] ||= 'desc'
32
25
  response = execute_request(
@@ -64,7 +57,6 @@ module WorkOS
64
57
  # :domain=>"foo-corp.com"}]>
65
58
  #
66
59
  # @return [WorkOS::Organization]
67
- sig { params(id: String).returns(WorkOS::Organization) }
68
60
  def get_organization(id:)
69
61
  request = get_request(
70
62
  auth: true,
@@ -84,14 +76,6 @@ module WorkOS
84
76
  # @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
85
77
  # within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
86
78
  # @param [String] idempotency_key An idempotency key
87
- sig do
88
- params(
89
- domains: T::Array[String],
90
- name: String,
91
- allow_profiles_outside_organization: T.nilable(T::Boolean),
92
- idempotency_key: T.nilable(String),
93
- ).returns(WorkOS::Organization)
94
- end
95
79
  def create_organization(domains:, name:, allow_profiles_outside_organization: nil, idempotency_key: nil)
96
80
  request = post_request(
97
81
  auth: true,
@@ -118,14 +102,6 @@ module WorkOS
118
102
  # @param [String] name A unique, descriptive name for the organization
119
103
  # @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
120
104
  # within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
121
- sig do
122
- params(
123
- organization: String,
124
- domains: T::Array[String],
125
- name: String,
126
- allow_profiles_outside_organization: T.nilable(T::Boolean),
127
- ).returns(WorkOS::Organization)
128
- end
129
105
  def update_organization(organization:, domains:, name:, allow_profiles_outside_organization: nil)
130
106
  request = put_request(
131
107
  auth: true,
@@ -152,7 +128,6 @@ module WorkOS
152
128
  # => true
153
129
  #
154
130
  # @return [Bool] - returns `true` if successful
155
- sig { params(id: String).returns(T::Boolean) }
156
131
  def delete_organization(id:)
157
132
  request = delete_request(
158
133
  auth: true,
@@ -166,7 +141,6 @@ module WorkOS
166
141
 
167
142
  private
168
143
 
169
- sig { params(response: Net::HTTPResponse).void }
170
144
  def check_and_raise_organization_error(response:)
171
145
  begin
172
146
  body = JSON.parse(response.body)
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  require 'net/http'
5
4
 
@@ -11,7 +10,6 @@ module WorkOS
11
10
  # @see https://workos.com/docs/sso/configuring-magic-link
12
11
  module Passwordless
13
12
  class << self
14
- extend T::Sig
15
13
  include Client
16
14
 
17
15
  # Create a Passwordless Session.
@@ -33,12 +31,6 @@ module WorkOS
33
31
  # configured redirect URI on your WorkOS dashboard.
34
32
  #
35
33
  # @return Hash
36
- sig do
37
- params(
38
- options: Hash,
39
- ).returns(WorkOS::Types::PasswordlessSessionStruct)
40
- end
41
-
42
34
  def create_session(options)
43
35
  response = execute_request(
44
36
  request: post_request(
@@ -64,12 +56,6 @@ module WorkOS
64
56
  # Session to send an email for.
65
57
  #
66
58
  # @return Hash
67
- sig do
68
- params(
69
- session_id: String,
70
- ).returns(T::Hash[String, T::Boolean])
71
- end
72
-
73
59
  def send_session(session_id)
74
60
  response = execute_request(
75
61
  request: post_request(
data/lib/workos/portal.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  require 'net/http'
5
4
 
@@ -8,11 +7,9 @@ module WorkOS
8
7
  # Portal product
9
8
  module Portal
10
9
  class << self
11
- extend T::Sig
12
10
  include Client
13
11
 
14
- GENERATE_LINK_INTENTS = WorkOS::Types::Intent.values.map(&:serialize).
15
- freeze
12
+ GENERATE_LINK_INTENTS = WorkOS::Types::Intent::ALL
16
13
 
17
14
  # Generate a link to grant access to an organization's Admin Portal
18
15
  #
@@ -25,14 +22,6 @@ module WorkOS
25
22
  # redirect link set in your WorkOS Dashboard will be used.
26
23
  # @param [String] The URL to which WorkOS will redirect users to upon
27
24
  # successfully setting up Single Sign On or Directory Sync.
28
- sig do
29
- params(
30
- intent: String,
31
- organization: String,
32
- return_url: T.nilable(String),
33
- success_url: T.nilable(String),
34
- ).returns(String)
35
- end
36
25
  def generate_link(intent:, organization:, return_url: nil, success_url: nil)
37
26
  validate_intent(intent)
38
27
 
@@ -54,7 +43,6 @@ module WorkOS
54
43
 
55
44
  private
56
45
 
57
- sig { params(intent: String).void }
58
46
  def validate_intent(intent)
59
47
  return if GENERATE_LINK_INTENTS.include?(intent)
60
48
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The Profile class provides a lighweight wrapper around
@@ -9,31 +8,25 @@ module WorkOS
9
8
  # is instantiated internally but exposed.
10
9
  class Profile
11
10
  include HashProvider
12
- extend T::Sig
13
11
 
14
- sig { returns(String) }
15
12
  attr_accessor :id, :email, :first_name, :last_name, :groups, :organization_id,
16
13
  :connection_id, :connection_type, :idp_id, :raw_attributes
17
14
 
18
- # rubocop:disable Metrics/AbcSize
19
- sig { params(profile_json: String).void }
20
15
  def initialize(profile_json)
21
- raw = parse_json(profile_json)
22
-
23
- @id = T.let(raw.id, String)
24
- @email = T.let(raw.email, String)
25
- @first_name = raw.first_name
26
- @last_name = raw.last_name
27
- @groups = raw.groups
28
- @organization_id = raw.organization_id
29
- @connection_id = T.let(raw.connection_id, String)
30
- @connection_type = T.let(raw.connection_type, String)
31
- @idp_id = raw.idp_id
32
- @raw_attributes = raw.raw_attributes
16
+ hash = JSON.parse(profile_json, symbolize_names: true)
17
+
18
+ @id = hash[:id]
19
+ @email = hash[:email]
20
+ @first_name = hash[:first_name]
21
+ @last_name = hash[:last_name]
22
+ @groups = hash[:groups]
23
+ @organization_id = hash[:organization_id]
24
+ @connection_id = hash[:connection_id]
25
+ @connection_type = hash[:connection_type]
26
+ @idp_id = hash[:idp_id]
27
+ @raw_attributes = hash[:raw_attributes]
33
28
  end
34
- # rubocop:enable Metrics/AbcSize
35
29
 
36
- sig { returns(String) }
37
30
  def full_name
38
31
  [first_name, last_name].compact.join(' ')
39
32
  end
@@ -52,25 +45,5 @@ module WorkOS
52
45
  raw_attributes: raw_attributes,
53
46
  }
54
47
  end
55
-
56
- private
57
-
58
- sig { params(json_string: String).returns(WorkOS::Types::ProfileStruct) }
59
- def parse_json(json_string)
60
- hash = JSON.parse(json_string, symbolize_names: true)
61
-
62
- WorkOS::Types::ProfileStruct.new(
63
- id: hash[:id],
64
- email: hash[:email],
65
- first_name: hash[:first_name],
66
- last_name: hash[:last_name],
67
- groups: hash[:groups],
68
- organization_id: hash[:organization_id],
69
- connection_id: hash[:connection_id],
70
- connection_type: hash[:connection_type],
71
- idp_id: hash[:idp_id],
72
- raw_attributes: hash[:raw_attributes],
73
- )
74
- end
75
48
  end
76
49
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The ProfileAndToken class represents a Profile and a corresponding
@@ -7,15 +6,13 @@ module WorkOS
7
6
  # is instantiated internally but exposed.
8
7
  class ProfileAndToken
9
8
  include HashProvider
10
- extend T::Sig
11
9
 
12
10
  attr_accessor :access_token, :profile
13
11
 
14
- sig { params(profile_and_token_json: String).void }
15
12
  def initialize(profile_and_token_json)
16
13
  json = JSON.parse(profile_and_token_json, symbolize_names: true)
17
14
 
18
- @access_token = T.let(json[:access_token], String)
15
+ @access_token = json[:access_token]
19
16
  @profile = WorkOS::Profile.new(json[:profile].to_json)
20
17
  end
21
18
 
@@ -1,20 +1,17 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The RefreshAuthenticationResponse contains response data from a successful
6
5
  # `UserManagement.authenticate_with_refresh_token` call
7
6
  class RefreshAuthenticationResponse
8
7
  include HashProvider
9
- extend T::Sig
10
8
 
11
9
  attr_accessor :access_token, :refresh_token
12
10
 
13
- sig { params(authentication_response_json: String).void }
14
11
  def initialize(authentication_response_json)
15
12
  json = JSON.parse(authentication_response_json, symbolize_names: true)
16
- @access_token = T.let(json[:access_token], String)
17
- @refresh_token = T.let(json[:refresh_token], String)
13
+ @access_token = json[:access_token]
14
+ @refresh_token = json[:refresh_token]
18
15
  end
19
16
 
20
17
  def to_json(*)
data/lib/workos/sso.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  require 'net/http'
5
4
  require 'uri'
@@ -12,10 +11,9 @@ module WorkOS
12
11
  # @see https://docs.workos.com/sso/overview
13
12
  module SSO
14
13
  class << self
15
- extend T::Sig
16
14
  include Client
17
15
 
18
- PROVIDERS = WorkOS::Types::Provider.values.map(&:serialize).freeze
16
+ PROVIDERS = WorkOS::Types::Provider::ALL
19
17
 
20
18
  # Generate an Oauth2 authorization URL where your users will
21
19
  # authenticate using the configured SSO Identity Provider.
@@ -55,19 +53,6 @@ module WorkOS
55
53
  #
56
54
  # @return [String]
57
55
  # rubocop:disable Metrics/ParameterLists
58
- sig do
59
- params(
60
- redirect_uri: String,
61
- client_id: T.nilable(String),
62
- domain: T.nilable(String),
63
- domain_hint: T.nilable(String),
64
- login_hint: T.nilable(String),
65
- provider: T.nilable(String),
66
- connection: T.nilable(String),
67
- organization: T.nilable(String),
68
- state: T.nilable(String),
69
- ).returns(String)
70
- end
71
56
  def authorization_url(
72
57
  redirect_uri:,
73
58
  client_id: nil,
@@ -108,11 +93,6 @@ module WorkOS
108
93
  end
109
94
  # rubocop:enable Metrics/ParameterLists
110
95
 
111
- sig do
112
- params(
113
- access_token: String,
114
- ).returns(WorkOS::Profile)
115
- end
116
96
  def get_profile(access_token:)
117
97
  response = execute_request(
118
98
  request: get_request(
@@ -132,12 +112,6 @@ module WorkOS
132
112
  # where you've configured your SSO connection
133
113
  #
134
114
  # @return [WorkOS::ProfileAndToken]
135
- sig do
136
- params(
137
- code: String,
138
- client_id: T.nilable(String),
139
- ).returns(WorkOS::ProfileAndToken)
140
- end
141
115
  def profile_and_token(code:, client_id: nil)
142
116
  body = {
143
117
  client_id: client_id,
@@ -169,11 +143,6 @@ module WorkOS
169
143
  # before a provided Connection ID.
170
144
  #
171
145
  # @return [Hash]
172
- sig do
173
- params(
174
- options: T::Hash[Symbol, String],
175
- ).returns(WorkOS::Types::ListStruct)
176
- end
177
146
  def list_connections(options = {})
178
147
  options[:order] ||= 'desc'
179
148
  response = execute_request(
@@ -211,7 +180,6 @@ module WorkOS
211
180
  # :domain=>"example.com"}]>
212
181
  #
213
182
  # @return [WorkOS::Connection]
214
- sig { params(id: String).returns(WorkOS::Connection) }
215
183
  def get_connection(id:)
216
184
  request = get_request(
217
185
  auth: true,
@@ -232,7 +200,6 @@ module WorkOS
232
200
  # => true
233
201
  #
234
202
  # @return [Bool] - returns `true` if successful
235
- sig { params(id: String).returns(T::Boolean) }
236
203
  def delete_connection(id:)
237
204
  request = delete_request(
238
205
  auth: true,
@@ -246,14 +213,6 @@ module WorkOS
246
213
 
247
214
  private
248
215
 
249
- sig do
250
- params(
251
- domain: T.nilable(String),
252
- provider: T.nilable(String),
253
- connection: T.nilable(String),
254
- organization: T.nilable(String),
255
- ).void
256
- end
257
216
  def validate_authorization_url_arguments(
258
217
  domain:,
259
218
  provider:,
@@ -271,7 +230,6 @@ module WorkOS
271
230
  " `provider` must be in #{PROVIDERS}"
272
231
  end
273
232
 
274
- sig { params(response: Net::HTTPResponse).void }
275
233
  def check_and_raise_profile_and_token_error(response:)
276
234
  begin
277
235
  body = JSON.parse(response.body)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WorkOS
4
+ module Types
5
+ # The Intent constants are declarations of a fixed set of values for
6
+ # intents while generating an Admin Portal link.
7
+ module Intent
8
+ AUDIT_LOGS = 'audit_logs'
9
+ DSYNC = 'dsync'
10
+ LOG_STREAMS = 'log_streams'
11
+ SSO = 'sso'
12
+
13
+ ALL = [AUDIT_LOGS, DSYNC, LOG_STREAMS, SSO].freeze
14
+ end
15
+ end
16
+ end
@@ -1,13 +1,16 @@
1
1
  # frozen_string_literal: true
2
- # typed: strict
3
2
 
4
3
  module WorkOS
5
4
  module Types
6
- # ListStruct acts as a typed interface to expose lists of data and related
5
+ # ListStruct acts as an interface to expose lists of data and related
7
6
  # metadata
8
- class ListStruct < T::Struct
9
- const :data, T::Array[T.untyped]
10
- const :list_metadata, T::Hash[String, T.nilable(String)]
7
+ class ListStruct
8
+ attr_accessor :data, :list_metadata
9
+
10
+ def initialize(data:, list_metadata:)
11
+ @data = data
12
+ @list_metadata = list_metadata
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
- # typed: strict
3
-
4
- require 'date'
5
2
 
6
3
  module WorkOS
7
4
  module Types
8
- # This PasswordlessSessionStruct acts as a typed interface
5
+ # This PasswordlessSessionStruct acts as an interface
9
6
  # for the Passwordless class
10
- class PasswordlessSessionStruct < T::Struct
11
- const :id, String
12
- const :email, String
13
- const :expires_at, Date
14
- const :link, String
7
+ class PasswordlessSessionStruct
8
+ attr_accessor :id, :email, :expires_at, :link
9
+
10
+ def initialize(id:, email:, expires_at:, link:)
11
+ @id = id
12
+ @email = email
13
+ @expires_at = expires_at
14
+ @link = link
15
+ end
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WorkOS
4
+ module Types
5
+ # The Provider constants are declarations of a
6
+ # fixed set of values for SSO Providers.
7
+ module Provider
8
+ GitHub = 'GitHubOAuth'
9
+ Google = 'GoogleOAuth'
10
+ Microsoft = 'MicrosoftOAuth'
11
+
12
+ ALL = [GitHub, Google, Microsoft].freeze
13
+ end
14
+ end
15
+ end
data/lib/workos/types.rb CHANGED
@@ -1,29 +1,11 @@
1
1
  # frozen_string_literal: true
2
- # typed: strong
3
2
 
4
3
  module WorkOS
5
- # WorkOS believes strongly in typed languages,
6
- # so we're using Sorbet throughout this Ruby gem.
4
+ # Types contains a few structs wrapping up common data structures.
7
5
  module Types
8
- require_relative 'types/audit_log_export_struct'
9
- require_relative 'types/challenge_struct'
10
- require_relative 'types/connection_struct'
11
- require_relative 'types/directory_group_struct'
12
- require_relative 'types/directory_struct'
13
- require_relative 'types/directory_user_struct'
14
- require_relative 'types/event_struct'
15
- require_relative 'types/factor_struct'
16
- require_relative 'types/intent_enum'
17
- require_relative 'types/invitation_struct'
18
- require_relative 'types/list_struct'
19
- require_relative 'types/magic_auth_challenge_struct'
20
- require_relative 'types/organization_struct'
21
- require_relative 'types/organization_membership_struct'
22
- require_relative 'types/passwordless_session_struct'
23
- require_relative 'types/profile_struct'
24
- require_relative 'types/provider_enum'
25
- require_relative 'types/user_struct'
26
- require_relative 'types/verify_challenge_struct'
27
- require_relative 'types/webhook_struct'
6
+ autoload :Provider, 'workos/types/provider'
7
+ autoload :Intent, 'workos/types/intent'
8
+ autoload :ListStruct, 'workos/types/list_struct'
9
+ autoload :PasswordlessSessionStruct, 'workos/types/passwordless_session_struct'
28
10
  end
29
11
  end