stytch 6.0.0 → 6.2.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: 27d4c3b57b568d2c65e75e95bfa1cf8231e891b2937eeebe14f7675cf6c675f1
4
- data.tar.gz: 1e8cfe7127b66cc0ae61e7a8df420f691793f0ddd85d84c7ca8f06769cc13705
3
+ metadata.gz: f191b11ecf499de4ea27a1eff18ada545ecfa999e46e18c9170d010161c0a08c
4
+ data.tar.gz: 142be9df24b3b26f388407db08647f618d9910db51e25ca88fe11e35cfd28a18
5
5
  SHA512:
6
- metadata.gz: 5e4e3eca324d8b868a9a1b828b0c7ebc7a7e6c8ee5eace9ea92e7f97c91aab6afc52f201d60751e5034880432952789beea63093abee65c1f87ed05ffd31fe3b
7
- data.tar.gz: 6abd1e879e9fe908906604bc287f92986d48faea8dbe985a4408af5f5832cac24a69b8c61659b95c3aad9a5394040cb6afaeb558c296c09548aba03ac54f2fa1
6
+ metadata.gz: a85ad3a934eb36560641c7b37017bf0d3ff981a2df27d18440d8a714a52c9e1b5c6f16f2b4a8f9f261e51c5f1afd7e53175f8f39de18a6ae2bc354faa56e14a8
7
+ data.tar.gz: aca18f76d5c72ae175ef53d92a2ad833cf078934e8ebf49fc3eac96cfb00e66db4295a7569809a294beef8220ba4e895f64edc17577213c283d2029c52036e32
@@ -0,0 +1,29 @@
1
+ name: Check links in README.md
2
+
3
+ on:
4
+ schedule:
5
+ # Every 4 hours at X:00
6
+ - cron: "0 */4 * * *"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ check-links:
11
+ runs-on: ubuntu-latest
12
+ name: Check links in README.md
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - name: Get links
17
+ run: |
18
+ grep -Eo "\[[^][]+]\((https?://stytch.com[^()]+)\)" README.md | grep -Eo "https:[^)]*" | sort -u > links.txt
19
+ found_bad=0
20
+ for link in $(cat links.txt); do
21
+ status_code=$(curl -s -o /dev/null -w "%{http_code}" $link)
22
+ if [[ "$status_code" != "200" ]]; then
23
+ echo "$link -> $status_code"
24
+ found_bad=1
25
+ fi
26
+ done
27
+ if [[ $found_bad == 1 ]]; then
28
+ exit 1
29
+ fi
data/README.md CHANGED
@@ -24,18 +24,18 @@ Or install it yourself as:
24
24
 
25
25
  You can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).
26
26
 
27
- This client library supports all of Stytch's live products:
27
+ This client library supports all Stytch's live products:
28
28
  - [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)
29
- - [x] [Embeddable Magic Links](https://stytch.com/docs/api/create-magic-link-overview)
30
- - [x] [OAuth logins](https://stytch.com/docs/api/oauth-overview)
29
+ - [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)
30
+ - [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)
31
31
  - [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)
32
32
  - [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)
33
33
  - [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)
34
- - [x] [Session Management](https://stytch.com/docs/api/sessions-overview)
35
- - [x] [WebAuthn](https://stytch.com/docs/api/webauthn-overview)
36
- - [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/api/totps-overview)
37
- - [x] [Crypto wallets](https://stytch.com/docs/api/crypto-wallet-overview)
38
- - [x] [Passwords (Beta)](https://stytch.com/docs/api/password-overview)
34
+ - [x] [Session Management](https://stytch.com/docs/guides/sessions/using-sessions)
35
+ - [x] [WebAuthn](https://stytch.com/docs/guides/webauthn/api)
36
+ - [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/guides/totp/api)
37
+ - [x] [Crypto wallets](https://stytch.com/docs/guides/web3/api)
38
+ - [x] [Passwords](https://stytch.com/docs/guides/passwords/api)
39
39
 
40
40
  ### Example usage
41
41
  Create an API client:
@@ -79,7 +79,7 @@ If you've found a bug, [open an issue](https://github.com/stytchauth/stytch-ruby
79
79
 
80
80
  If you have questions or want help troubleshooting, join us in [Slack](https://join.slack.com/t/stytch/shared_invite/zt-nil4wo92-jApJ9Cl32cJbEd9esKkvyg) or email support@stytch.com.
81
81
 
82
- If you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/security).
82
+ If you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).
83
83
 
84
84
  ## Development
85
85
 
@@ -2,16 +2,19 @@
2
2
 
3
3
  require_relative 'b2b_discovery'
4
4
  require_relative 'b2b_magic_links'
5
+ require_relative 'b2b_oauth'
5
6
  require_relative 'b2b_organizations'
7
+ require_relative 'b2b_otp'
6
8
  require_relative 'b2b_passwords'
7
9
  require_relative 'b2b_sessions'
8
10
  require_relative 'b2b_sso'
11
+ require_relative 'm2m'
9
12
 
10
13
  module StytchB2B
11
14
  class Client
12
15
  ENVIRONMENTS = %i[live test].freeze
13
16
 
14
- attr_reader :discovery, :magic_links, :organizations, :passwords, :sso, :sessions
17
+ attr_reader :discovery, :m2m, :magic_links, :oauth, :otps, :organizations, :passwords, :sso, :sessions
15
18
 
16
19
  def initialize(project_id:, secret:, env: nil, &block)
17
20
  @api_host = api_host(env, project_id)
@@ -21,7 +24,10 @@ module StytchB2B
21
24
  create_connection(&block)
22
25
 
23
26
  @discovery = StytchB2B::Discovery.new(@connection)
27
+ @m2m = Stytch::M2M.new(@connection, project_id)
24
28
  @magic_links = StytchB2B::MagicLinks.new(@connection)
29
+ @oauth = StytchB2B::OAuth.new(@connection)
30
+ @otps = StytchB2B::OTPs.new(@connection)
25
31
  @organizations = StytchB2B::Organizations.new(@connection)
26
32
  @passwords = StytchB2B::Passwords.new(@connection)
27
33
  @sso = StytchB2B::SSO.new(@connection)
@@ -32,9 +32,18 @@ module StytchB2B
32
32
  #
33
33
  # This endpoint can be used to accept invites and create new members via domain matching.
34
34
  #
35
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`.
36
+ # The `intermediate_session_token` will not be consumed and instead will be returned in the response.
37
+ # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
38
+ # The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
39
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
40
+ #
35
41
  # == Parameters:
36
42
  # 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.
43
+ # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
44
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
45
+ # the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
46
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
38
47
  # The type of this field is +String+.
39
48
  # organization_id::
40
49
  # 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.
@@ -57,6 +66,16 @@ module StytchB2B
57
66
  # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
58
67
  # Total custom claims size cannot exceed four kilobytes.
59
68
  # The type of this field is nilable +object+.
69
+ # locale::
70
+ # (Coming Soon) If the Member needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
71
+ #
72
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
73
+ #
74
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
75
+ #
76
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
77
+ #
78
+ # The type of this field is nilable +ExchangeRequestLocale+ (string enum).
60
79
  #
61
80
  # == Returns:
62
81
  # An object with the following fields:
@@ -78,17 +97,30 @@ module StytchB2B
78
97
  # organization::
79
98
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
80
99
  # The type of this field is +Organization+ (+object+).
100
+ # member_authenticated::
101
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
102
+ # The type of this field is +Boolean+.
103
+ # intermediate_session_token::
104
+ # The returned Intermediate Session Token is identical to the one that was originally passed in to the request.
105
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
106
+ # It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization,
107
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
108
+ # The type of this field is +String+.
81
109
  # status_code::
82
110
  # 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.
83
111
  # The type of this field is +Integer+.
84
112
  # member_session::
85
113
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
86
114
  # The type of this field is nilable +MemberSession+ (+object+).
115
+ # mfa_required::
116
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
117
+ # The type of this field is nilable +MfaRequired+ (+object+).
87
118
  def exchange(
88
119
  intermediate_session_token:,
89
120
  organization_id:,
90
121
  session_duration_minutes: nil,
91
- session_custom_claims: nil
122
+ session_custom_claims: nil,
123
+ locale: nil
92
124
  )
93
125
  request = {
94
126
  intermediate_session_token: intermediate_session_token,
@@ -96,6 +128,7 @@ module StytchB2B
96
128
  }
97
129
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
98
130
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
131
+ request[:locale] = locale unless locale.nil?
99
132
 
100
133
  post_request('/v1/b2b/discovery/intermediate_sessions/exchange', request)
101
134
  end
@@ -115,9 +148,18 @@ module StytchB2B
115
148
  #
116
149
  # This endpoint can also be used to start an initial session for the newly created member and organization.
117
150
  #
151
+ # (Coming Soon) If the new Organization is created with a `mfa_policy` of `REQUIRED_FOR_ALL`, the newly created Member will need to complete an MFA step to log in to the Organization.
152
+ # The `intermediate_session_token` will not be consumed and instead will be returned in the response.
153
+ # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
154
+ # The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
155
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
156
+ #
118
157
  # == Parameters:
119
158
  # intermediate_session_token::
120
- # 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.
159
+ # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
160
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
161
+ # the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
162
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
121
163
  # The type of this field is +String+.
122
164
  # organization_name::
123
165
  # 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.
@@ -197,6 +239,14 @@ module StytchB2B
197
239
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
198
240
  #
199
241
  # The type of this field is nilable list of +String+.
242
+ # mfa_policy::
243
+ # (Coming Soon) The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
244
+ #
245
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
246
+ #
247
+ # `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
248
+ #
249
+ # The type of this field is nilable +String+.
200
250
  #
201
251
  # == Returns:
202
252
  # An object with the following fields:
@@ -215,6 +265,15 @@ module StytchB2B
215
265
  # member::
216
266
  # The [Member object](https://stytch.com/docs/b2b/api/member-object).
217
267
  # The type of this field is +Member+ (+object+).
268
+ # member_authenticated::
269
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
270
+ # The type of this field is +Boolean+.
271
+ # intermediate_session_token::
272
+ # The returned Intermediate Session Token is identical to the one that was originally passed in to the request.
273
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
274
+ # It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization,
275
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
276
+ # The type of this field is +String+.
218
277
  # status_code::
219
278
  # 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.
220
279
  # The type of this field is +Integer+.
@@ -224,6 +283,9 @@ module StytchB2B
224
283
  # organization::
225
284
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
226
285
  # The type of this field is nilable +Organization+ (+object+).
286
+ # mfa_required::
287
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
288
+ # The type of this field is nilable +MfaRequired+ (+object+).
227
289
  def create(
228
290
  intermediate_session_token:,
229
291
  organization_name:,
@@ -237,7 +299,8 @@ module StytchB2B
237
299
  email_jit_provisioning: nil,
238
300
  email_invites: nil,
239
301
  auth_methods: nil,
240
- allowed_auth_methods: nil
302
+ allowed_auth_methods: nil,
303
+ mfa_policy: nil
241
304
  )
242
305
  request = {
243
306
  intermediate_session_token: intermediate_session_token,
@@ -254,6 +317,7 @@ module StytchB2B
254
317
  request[:email_invites] = email_invites unless email_invites.nil?
255
318
  request[:auth_methods] = auth_methods unless auth_methods.nil?
256
319
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
320
+ request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
257
321
 
258
322
  post_request('/v1/b2b/discovery/organizations/create', request)
259
323
  end
@@ -274,7 +338,10 @@ module StytchB2B
274
338
  #
275
339
  # == Parameters:
276
340
  # intermediate_session_token::
277
- # 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.
341
+ # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
342
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
343
+ # the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
344
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
278
345
  # The type of this field is nilable +String+.
279
346
  # session_token::
280
347
  # A secret token for a given Stytch Session.
@@ -308,6 +375,9 @@ module StytchB2B
308
375
  # status_code::
309
376
  # 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.
310
377
  # The type of this field is +Integer+.
378
+ # organization_id_hint::
379
+ # If the intermediate session token is associated with a specific Organization, that Organization ID will be returned here. The Organization ID will be null if the intermediate session token was generated by a email magic link discovery or OAuth discovery flow. If a session token or session JWT is provided, the Organization ID hint will be null.
380
+ # The type of this field is nilable +String+.
311
381
  def list(
312
382
  intermediate_session_token: nil,
313
383
  session_token: nil,
@@ -20,7 +20,15 @@ module StytchB2B
20
20
  @discovery = StytchB2B::MagicLinks::Discovery.new(@connection)
21
21
  end
22
22
 
23
- # Authenticate a Member with a Magic Link. This endpoint requires a Magic Link token that is not expired or previously used. If the Member’s status is `pending` or `invited`, they will be updated to `active`. Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
23
+ # Authenticate a Member with a Magic Link. This endpoint requires a Magic Link token that is not expired or previously used. If the Member’s status is `pending` or `invited`, they will be updated to `active`.
24
+ # Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
25
+ #
26
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
27
+ # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
28
+ # The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
29
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
30
+ #
31
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
24
32
  #
25
33
  # == Parameters:
26
34
  # magic_links_token::
@@ -57,6 +65,16 @@ module StytchB2B
57
65
  # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
58
66
  # Total custom claims size cannot exceed four kilobytes.
59
67
  # The type of this field is nilable +object+.
68
+ # locale::
69
+ # (Coming Soon) If the Member needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
70
+ #
71
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
72
+ #
73
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
74
+ #
75
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
76
+ #
77
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
60
78
  #
61
79
  # == Returns:
62
80
  # An object with the following fields:
@@ -91,16 +109,29 @@ module StytchB2B
91
109
  # organization::
92
110
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
93
111
  # The type of this field is +Organization+ (+object+).
112
+ # intermediate_session_token::
113
+ # The returned Intermediate Session Token contains an Email Magic Link factor associated with the Member's email address.
114
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
115
+ # It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization that allows login with Email Magic Links,
116
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
117
+ # The type of this field is +String+.
118
+ # member_authenticated::
119
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
120
+ # The type of this field is +Boolean+.
94
121
  # status_code::
95
122
  # 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.
96
123
  # The type of this field is +Integer+.
124
+ # mfa_required::
125
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
126
+ # The type of this field is nilable +MfaRequired+ (+object+).
97
127
  def authenticate(
98
128
  magic_links_token:,
99
129
  pkce_code_verifier: nil,
100
130
  session_token: nil,
101
131
  session_jwt: nil,
102
132
  session_duration_minutes: nil,
103
- session_custom_claims: nil
133
+ session_custom_claims: nil,
134
+ locale: nil
104
135
  )
105
136
  request = {
106
137
  magic_links_token: magic_links_token
@@ -110,6 +141,7 @@ module StytchB2B
110
141
  request[:session_jwt] = session_jwt unless session_jwt.nil?
111
142
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
112
143
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
144
+ request[:locale] = locale unless locale.nil?
113
145
 
114
146
  post_request('/v1/b2b/magic_links/authenticate', request)
115
147
  end
@@ -161,7 +193,7 @@ module StytchB2B
161
193
  #
162
194
  # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
163
195
  #
164
- # The type of this field is nilable +LoginOrSignupRequestLocale+ (+object+).
196
+ # The type of this field is nilable +LoginOrSignupRequestLocale+ (string enum).
165
197
  #
166
198
  # == Returns:
167
199
  # An object with the following fields:
@@ -246,7 +278,7 @@ module StytchB2B
246
278
  #
247
279
  # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
248
280
  #
249
- # The type of this field is nilable +InviteRequestLocale+ (+object+).
281
+ # The type of this field is nilable +InviteRequestLocale+ (string enum).
250
282
  #
251
283
  # == Returns:
252
284
  # An object with the following fields:
@@ -323,7 +355,7 @@ module StytchB2B
323
355
  #
324
356
  # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
325
357
  #
326
- # The type of this field is nilable +SendRequestLocale+ (+object+).
358
+ # The type of this field is nilable +SendRequestLocale+ (string enum).
327
359
  #
328
360
  # == Returns:
329
361
  # An object with the following fields:
@@ -376,7 +408,10 @@ module StytchB2B
376
408
  # 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.
377
409
  # The type of this field is +String+.
378
410
  # intermediate_session_token::
379
- # 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.
411
+ # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
412
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
413
+ # the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
414
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
380
415
  # The type of this field is +String+.
381
416
  # email_address::
382
417
  # The email address.
@@ -0,0 +1,231 @@
1
+ # frozen_string_literal: true
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
+
9
+ require_relative 'request_helper'
10
+
11
+ module StytchB2B
12
+ class OAuth
13
+ include Stytch::RequestHelper
14
+ attr_reader :discovery
15
+
16
+ def initialize(connection)
17
+ @connection = connection
18
+
19
+ @discovery = StytchB2B::OAuth::Discovery.new(@connection)
20
+ end
21
+
22
+ # Authenticate a Member given a `token`. This endpoint verifies that the member completed the OAuth flow by verifying that the token is valid and hasn't expired. Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
23
+ #
24
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
25
+ # The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
26
+ # The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
27
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
28
+ #
29
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
30
+ #
31
+ # == Parameters:
32
+ # oauth_token::
33
+ # The token to authenticate.
34
+ # The type of this field is +String+.
35
+ # session_token::
36
+ # A secret token for a given Stytch Session.
37
+ # The type of this field is nilable +String+.
38
+ # session_duration_minutes::
39
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
40
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
41
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
42
+ #
43
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
44
+ #
45
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
46
+ #
47
+ # 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
48
+ # to use the Stytch session product, you can ignore the session fields in the response.
49
+ # The type of this field is nilable +Integer+.
50
+ # session_jwt::
51
+ # The JSON Web Token (JWT) for a given Stytch Session.
52
+ # The type of this field is nilable +String+.
53
+ # session_custom_claims::
54
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
55
+ # `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
56
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
57
+ # Total custom claims size cannot exceed four kilobytes.
58
+ # The type of this field is nilable +object+.
59
+ # pkce_code_verifier::
60
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
61
+ # The type of this field is nilable +String+.
62
+ # locale::
63
+ # (Coming Soon) If the Member needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
64
+ #
65
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
66
+ #
67
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
68
+ #
69
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
70
+ #
71
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
72
+ #
73
+ # == Returns:
74
+ # An object with the following fields:
75
+ # request_id::
76
+ # 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.
77
+ # The type of this field is +String+.
78
+ # member_id::
79
+ # Globally unique UUID that identifies a specific Member.
80
+ # The type of this field is +String+.
81
+ # provider_subject::
82
+ # The unique identifier for the User within a given OAuth provider. Also commonly called the `sub` or "Subject field" in OAuth protocols.
83
+ # The type of this field is +String+.
84
+ # provider_type::
85
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
86
+ # The type of this field is +String+.
87
+ # session_token::
88
+ # A secret token for a given Stytch Session.
89
+ # The type of this field is +String+.
90
+ # session_jwt::
91
+ # The JSON Web Token (JWT) for a given Stytch Session.
92
+ # The type of this field is +String+.
93
+ # member::
94
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
95
+ # The type of this field is +Member+ (+object+).
96
+ # organization_id::
97
+ # 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.
98
+ # The type of this field is +String+.
99
+ # organization::
100
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
101
+ # The type of this field is +Organization+ (+object+).
102
+ # reset_sessions::
103
+ # (no documentation yet)
104
+ # The type of this field is +Boolean+.
105
+ # member_authenticated::
106
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
107
+ # The type of this field is +Boolean+.
108
+ # intermediate_session_token::
109
+ # The returned Intermediate Session Token contains an OAuth factor associated with the Member's email address.
110
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
111
+ # It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization that allows login with OAuth,
112
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
113
+ # The type of this field is +String+.
114
+ # status_code::
115
+ # 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.
116
+ # The type of this field is +Integer+.
117
+ # member_session::
118
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
119
+ # The type of this field is nilable +MemberSession+ (+object+).
120
+ # provider_values::
121
+ # The `provider_values` object lists relevant identifiers, values, and scopes for a given OAuth provider. For example this object will include a provider's `access_token` that you can use to access the provider's API for a given user.
122
+ #
123
+ # Note that these values will vary based on the OAuth provider in question, e.g. `id_token` is only returned by Microsoft.
124
+ # The type of this field is nilable +ProviderValues+ (+object+).
125
+ # mfa_required::
126
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
127
+ # The type of this field is nilable +MfaRequired+ (+object+).
128
+ def authenticate(
129
+ oauth_token:,
130
+ session_token: nil,
131
+ session_duration_minutes: nil,
132
+ session_jwt: nil,
133
+ session_custom_claims: nil,
134
+ pkce_code_verifier: nil,
135
+ locale: nil
136
+ )
137
+ request = {
138
+ oauth_token: oauth_token
139
+ }
140
+ request[:session_token] = session_token unless session_token.nil?
141
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
142
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
143
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
144
+ request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
145
+ request[:locale] = locale unless locale.nil?
146
+
147
+ post_request('/v1/b2b/oauth/authenticate', request)
148
+ end
149
+
150
+ class Discovery
151
+ include Stytch::RequestHelper
152
+
153
+ def initialize(connection)
154
+ @connection = connection
155
+ end
156
+
157
+ # Authenticates the Discovery OAuth token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
158
+ #
159
+ # == Parameters:
160
+ # discovery_oauth_token::
161
+ # The Discovery OAuth token to authenticate.
162
+ # The type of this field is +String+.
163
+ # session_token::
164
+ # (no documentation yet)
165
+ # The type of this field is nilable +String+.
166
+ # session_duration_minutes::
167
+ # (no documentation yet)
168
+ # The type of this field is nilable +Integer+.
169
+ # session_jwt::
170
+ # (no documentation yet)
171
+ # The type of this field is nilable +String+.
172
+ # session_custom_claims::
173
+ # (no documentation yet)
174
+ # The type of this field is nilable +object+.
175
+ # pkce_code_verifier::
176
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
177
+ # The type of this field is nilable +String+.
178
+ #
179
+ # == Returns:
180
+ # An object with the following fields:
181
+ # request_id::
182
+ # 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.
183
+ # The type of this field is +String+.
184
+ # intermediate_session_token::
185
+ # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
186
+ # The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
187
+ # the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
188
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
189
+ # The type of this field is +String+.
190
+ # email_address::
191
+ # The email address.
192
+ # The type of this field is +String+.
193
+ # discovered_organizations::
194
+ # 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.
195
+ #
196
+ # Note that Organizations will only appear here under any of the following conditions:
197
+ # 1. The end user is already a Member of the Organization.
198
+ # 2. The end user is invited to the Organization.
199
+ # 3. The end user can join the Organization because:
200
+ #
201
+ # a) The Organization allows JIT provisioning.
202
+ #
203
+ # b) The Organizations' allowed domains list contains the Member's email domain.
204
+ #
205
+ # 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).
206
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
207
+ # status_code::
208
+ # 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.
209
+ # The type of this field is +Integer+.
210
+ def authenticate(
211
+ discovery_oauth_token:,
212
+ session_token: nil,
213
+ session_duration_minutes: nil,
214
+ session_jwt: nil,
215
+ session_custom_claims: nil,
216
+ pkce_code_verifier: nil
217
+ )
218
+ request = {
219
+ discovery_oauth_token: discovery_oauth_token
220
+ }
221
+ request[:session_token] = session_token unless session_token.nil?
222
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
223
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
224
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
225
+ request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
226
+
227
+ post_request('/v1/b2b/oauth/discovery/authenticate', request)
228
+ end
229
+ end
230
+ end
231
+ end