stytch 5.0.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6ee430e74726ce2a8dd22451dfeec1506301ceabd017c32ef1f58ae7cc25492
4
- data.tar.gz: c796fe06cc8f05fe0ca282531e3faf8d27a034e325119a564c2c80bb410d83ab
3
+ metadata.gz: 734345852cfe96eb50bcbb218b9757310c0f324b1326b96488cff983d4b4cc29
4
+ data.tar.gz: 62be1b92820bf7ef7cba5a0956bcdab696e13aee6f69acb0f68de9ae17f7b134
5
5
  SHA512:
6
- metadata.gz: 294abc2a28d9b4d5836353ceeef68ae834519de7058c399a479e3879012ffd9e71ba82dce1dd7adda34fd0468b3cca6a4c7bf6febc80049763a3b4d7ac14700f
7
- data.tar.gz: 86a961039cc51b22a936f4dd03e6a8eacff65eb9d3e4c4ff13ba224a048c53abfb9569ab24aec5bfc508a9d216278ba961f12c8f69cc348a0b06b7d2cfb64c80
6
+ metadata.gz: 58db37330e6d76f2d95747a678f5de69ce5e831b2e293bf5e316fc5afb130a303399fdf3d64fb2e2ee1efc4f3c219712b9e06a3c3b34ffda7549ebdbac9fedf3
7
+ data.tar.gz: 4cf8c4f8201e6717594a64d68584fd073f18b52674df440c1f53add007ac1a0f8f7867c99b5889984a587fff291ab75231fb5b470037b08ab9600a46307118e8
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  *.gem
10
+ Gemfile.lock
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'b2b_discovery'
3
4
  require_relative 'b2b_magic_links'
5
+ require_relative 'b2b_oauth'
4
6
  require_relative 'b2b_organizations'
7
+ require_relative 'b2b_otp'
5
8
  require_relative 'b2b_passwords'
6
9
  require_relative 'b2b_sessions'
7
10
  require_relative 'b2b_sso'
@@ -10,7 +13,7 @@ module StytchB2B
10
13
  class Client
11
14
  ENVIRONMENTS = %i[live test].freeze
12
15
 
13
- attr_reader :magic_links, :organizations, :passwords, :sso, :sessions
16
+ attr_reader :discovery, :magic_links, :oauth, :otps, :organizations, :passwords, :sso, :sessions
14
17
 
15
18
  def initialize(project_id:, secret:, env: nil, &block)
16
19
  @api_host = api_host(env, project_id)
@@ -19,7 +22,10 @@ module StytchB2B
19
22
 
20
23
  create_connection(&block)
21
24
 
25
+ @discovery = StytchB2B::Discovery.new(@connection)
22
26
  @magic_links = StytchB2B::MagicLinks.new(@connection)
27
+ @oauth = StytchB2B::OAuth.new(@connection)
28
+ @otps = StytchB2B::OTPs.new(@connection)
23
29
  @organizations = StytchB2B::Organizations.new(@connection)
24
30
  @passwords = StytchB2B::Passwords.new(@connection)
25
31
  @sso = StytchB2B::SSO.new(@connection)
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
3
9
  require_relative 'request_helper'
4
10
 
5
11
  module StytchB2B
@@ -21,11 +27,72 @@ module StytchB2B
21
27
  @connection = connection
22
28
  end
23
29
 
30
+ # Exchange an Intermediate Session for a fully realized [Member Session](https://stytch.com/docs/b2b/api/session-object) in a desired [Organization](https://stytch.com/docs/b2b/api/organization-object).
31
+ # This operation consumes the Intermediate Session.
32
+ #
33
+ # This endpoint can be used to accept invites and create new members via domain matching.
34
+ #
35
+ # == Parameters:
36
+ # intermediate_session_token::
37
+ # The Intermediate Session Token. This token does not belong to a specific instance of a member, but may be exchanged for an existing Member Session or used to create a new organization.
38
+ # The type of this field is +String+.
39
+ # organization_id::
40
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
41
+ # The type of this field is +String+.
42
+ # session_duration_minutes::
43
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
44
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
45
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
46
+ #
47
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
48
+ #
49
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
50
+ #
51
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
52
+ # to use the Stytch session product, you can ignore the session fields in the response.
53
+ # The type of this field is nilable +Integer+.
54
+ # session_custom_claims::
55
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
56
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
57
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
58
+ # Total custom claims size cannot exceed four kilobytes.
59
+ # The type of this field is nilable +object+.
60
+ # locale::
61
+ # (no documentation yet)
62
+ # The type of this field is nilable +ExchangeRequestLocale+ (string enum).
63
+ #
64
+ # == Returns:
65
+ # An object with the following fields:
66
+ # request_id::
67
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
68
+ # The type of this field is +String+.
69
+ # member_id::
70
+ # Globally unique UUID that identifies a specific Member.
71
+ # The type of this field is +String+.
72
+ # session_token::
73
+ # A secret token for a given Stytch Session.
74
+ # The type of this field is +String+.
75
+ # session_jwt::
76
+ # The JSON Web Token (JWT) for a given Stytch Session.
77
+ # The type of this field is +String+.
78
+ # member::
79
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
80
+ # The type of this field is +Member+ (+object+).
81
+ # organization::
82
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
83
+ # The type of this field is +Organization+ (+object+).
84
+ # status_code::
85
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
86
+ # The type of this field is +Integer+.
87
+ # member_session::
88
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
89
+ # The type of this field is nilable +MemberSession+ (+object+).
24
90
  def exchange(
25
91
  intermediate_session_token:,
26
92
  organization_id:,
27
93
  session_duration_minutes: nil,
28
- session_custom_claims: nil
94
+ session_custom_claims: nil,
95
+ locale: nil
29
96
  )
30
97
  request = {
31
98
  intermediate_session_token: intermediate_session_token,
@@ -33,6 +100,7 @@ module StytchB2B
33
100
  }
34
101
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
35
102
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
103
+ request[:locale] = locale unless locale.nil?
36
104
 
37
105
  post_request('/v1/b2b/discovery/intermediate_sessions/exchange', request)
38
106
  end
@@ -45,6 +113,125 @@ module StytchB2B
45
113
  @connection = connection
46
114
  end
47
115
 
116
+ # If an end user does not want to join any already-existing organization, or has no possible organizations to join, this endpoint can be used to create a new
117
+ # [Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object).
118
+ #
119
+ # This operation consumes the Intermediate Session.
120
+ #
121
+ # This endpoint can also be used to start an initial session for the newly created member and organization.
122
+ #
123
+ # == Parameters:
124
+ # intermediate_session_token::
125
+ # The Intermediate Session Token. This token does not belong to a specific instance of a member, but may be exchanged for an existing Member Session or used to create a new organization.
126
+ # The type of this field is +String+.
127
+ # organization_name::
128
+ # The name of the Organization. If the name is not specified, a default name will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization name will be generated based on the name portion of the email. Otherwise, the organization name will be generated based on the email domain.
129
+ # The type of this field is +String+.
130
+ # organization_slug::
131
+ # The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. If the slug is not specified, a default slug will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization slug will be generated based on the name portion of the email. Otherwise, the organization slug will be generated based on the email domain.
132
+ # The type of this field is +String+.
133
+ # session_duration_minutes::
134
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
135
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
136
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
137
+ #
138
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
139
+ #
140
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
141
+ #
142
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
143
+ # to use the Stytch session product, you can ignore the session fields in the response.
144
+ # The type of this field is nilable +Integer+.
145
+ # session_custom_claims::
146
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
147
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
148
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
149
+ # Total custom claims size cannot exceed four kilobytes.
150
+ # The type of this field is nilable +object+.
151
+ # organization_logo_url::
152
+ # The image URL of the Organization logo.
153
+ # The type of this field is nilable +String+.
154
+ # trusted_metadata::
155
+ # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
156
+ # The type of this field is nilable +object+.
157
+ # sso_jit_provisioning::
158
+ # The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
159
+ #
160
+ # `ALL_ALLOWED` – new Members will be automatically provisioned upon successful authentication via any of the Organization's `sso_active_connections`.
161
+ #
162
+ # `RESTRICTED` – only new Members with SSO logins that comply with `sso_jit_provisioning_allowed_connections` can be provisioned upon authentication.
163
+ #
164
+ # `NOT_ALLOWED` – disable JIT provisioning via SSO.
165
+ #
166
+ # The type of this field is nilable +String+.
167
+ # email_allowed_domains::
168
+ # An array of email domains that allow invites or JIT provisioning for new Members. This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
169
+ #
170
+ #
171
+ # Common domains such as `gmail.com` are not allowed. See the [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
172
+ # The type of this field is nilable list of +String+.
173
+ # email_jit_provisioning::
174
+ # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
175
+ #
176
+ # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
177
+ #
178
+ # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
179
+ #
180
+ # The type of this field is nilable +String+.
181
+ # email_invites::
182
+ # The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:
183
+ #
184
+ # `ALL_ALLOWED` – any new Member can be invited to join via email.
185
+ #
186
+ # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be invited via email.
187
+ #
188
+ # `NOT_ALLOWED` – disable email invites.
189
+ #
190
+ # The type of this field is nilable +String+.
191
+ # auth_methods::
192
+ # The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:
193
+ #
194
+ # `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
195
+ #
196
+ # `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
197
+ #
198
+ # The type of this field is nilable +String+.
199
+ # allowed_auth_methods::
200
+ #
201
+ # An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
202
+ # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
203
+ #
204
+ # The type of this field is nilable list of +String+.
205
+ # mfa_policy::
206
+ # (no documentation yet)
207
+ # The type of this field is nilable +String+.
208
+ #
209
+ # == Returns:
210
+ # An object with the following fields:
211
+ # request_id::
212
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
213
+ # The type of this field is +String+.
214
+ # member_id::
215
+ # Globally unique UUID that identifies a specific Member.
216
+ # The type of this field is +String+.
217
+ # session_token::
218
+ # A secret token for a given Stytch Session.
219
+ # The type of this field is +String+.
220
+ # session_jwt::
221
+ # The JSON Web Token (JWT) for a given Stytch Session.
222
+ # The type of this field is +String+.
223
+ # member::
224
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
225
+ # The type of this field is +Member+ (+object+).
226
+ # status_code::
227
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
228
+ # The type of this field is +Integer+.
229
+ # member_session::
230
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
231
+ # The type of this field is nilable +MemberSession+ (+object+).
232
+ # organization::
233
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
234
+ # The type of this field is nilable +Organization+ (+object+).
48
235
  def create(
49
236
  intermediate_session_token:,
50
237
  organization_name:,
@@ -58,7 +245,8 @@ module StytchB2B
58
245
  email_jit_provisioning: nil,
59
246
  email_invites: nil,
60
247
  auth_methods: nil,
61
- allowed_auth_methods: nil
248
+ allowed_auth_methods: nil,
249
+ mfa_policy: nil
62
250
  )
63
251
  request = {
64
252
  intermediate_session_token: intermediate_session_token,
@@ -75,16 +263,68 @@ module StytchB2B
75
263
  request[:email_invites] = email_invites unless email_invites.nil?
76
264
  request[:auth_methods] = auth_methods unless auth_methods.nil?
77
265
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
266
+ request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
78
267
 
79
268
  post_request('/v1/b2b/discovery/organizations/create', request)
80
269
  end
81
270
 
271
+ # List all possible organization relationships connected to a [Member Session](https://stytch.com/docs/b2b/api/session-object) or Intermediate Session.
272
+ #
273
+ # When a Member Session is passed in, relationships with a type of `active_member`, `pending_member`, or `invited_member`
274
+ # will be returned, and any membership can be assumed by calling the [Exchange Session](https://stytch.com/docs/b2b/api/exchange-session) endpoint.
275
+ #
276
+ # When an Intermediate Session is passed in, all relationship types - `active_member`, `pending_member`, `invited_member`,
277
+ # and `eligible_to_join_by_email_domain` - will be returned,
278
+ # and any membership can be assumed by calling the [Exchange Intermediate Session](https://stytch.com/docs/b2b/api/exchange-intermediate-session) endpoint.
279
+ #
280
+ # This endpoint requires either an `intermediate_session_token`, `session_jwt` or `session_token` be included in the request.
281
+ # It will return an error if multiple are present.
282
+ #
283
+ # This operation does not consume the Intermediate Session or Session Token passed in.
284
+ #
285
+ # == Parameters:
286
+ # intermediate_session_token::
287
+ # The Intermediate Session Token. This token does not belong to a specific instance of a member, but may be exchanged for an existing Member Session or used to create a new organization.
288
+ # The type of this field is nilable +String+.
289
+ # session_token::
290
+ # A secret token for a given Stytch Session.
291
+ # The type of this field is nilable +String+.
292
+ # session_jwt::
293
+ # The JSON Web Token (JWT) for a given Stytch Session.
294
+ # The type of this field is nilable +String+.
295
+ #
296
+ # == Returns:
297
+ # An object with the following fields:
298
+ # request_id::
299
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
300
+ # The type of this field is +String+.
301
+ # email_address::
302
+ # The email address.
303
+ # The type of this field is +String+.
304
+ # discovered_organizations::
305
+ # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details.
306
+ #
307
+ # Note that Organizations will only appear here under any of the following conditions:
308
+ # 1. The end user is already a Member of the Organization.
309
+ # 2. The end user is invited to the Organization.
310
+ # 3. The end user can join the Organization because:
311
+ #
312
+ # a) The Organization allows JIT provisioning.
313
+ #
314
+ # b) The Organizations' allowed domains list contains the Member's email domain.
315
+ #
316
+ # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks).
317
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
318
+ # status_code::
319
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
320
+ # The type of this field is +Integer+.
82
321
  def list(
83
322
  intermediate_session_token: nil,
84
323
  session_token: nil,
85
324
  session_jwt: nil
86
325
  )
87
- request = {}
326
+ request = {
327
+ }
88
328
  request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
89
329
  request[:session_token] = session_token unless session_token.nil?
90
330
  request[:session_jwt] = session_jwt unless session_jwt.nil?