stytch 5.0.2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/stytch/b2b_client.rb +3 -1
- data/lib/stytch/b2b_discovery.rb +229 -0
- data/lib/stytch/b2b_magic_links.rb +270 -0
- data/lib/stytch/b2b_organizations.rb +474 -50
- data/lib/stytch/b2b_passwords.rb +435 -0
- data/lib/stytch/b2b_sessions.rb +183 -4
- data/lib/stytch/b2b_sso.rb +298 -14
- data/lib/stytch/client.rb +9 -9
- data/lib/stytch/crypto_wallets.rb +112 -13
- data/lib/stytch/errors.rb +16 -16
- data/lib/stytch/magic_links.rb +350 -56
- data/lib/stytch/oauth.rb +129 -22
- data/lib/stytch/otps.rb +454 -71
- data/lib/stytch/passwords.rb +513 -67
- data/lib/stytch/sessions.rb +147 -38
- data/lib/stytch/totps.rb +193 -13
- data/lib/stytch/users.rb +433 -106
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +156 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27d4c3b57b568d2c65e75e95bfa1cf8231e891b2937eeebe14f7675cf6c675f1
|
4
|
+
data.tar.gz: 1e8cfe7127b66cc0ae61e7a8df420f691793f0ddd85d84c7ca8f06769cc13705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4e3eca324d8b868a9a1b828b0c7ebc7a7e6c8ee5eace9ea92e7f97c91aab6afc52f201d60751e5034880432952789beea63093abee65c1f87ed05ffd31fe3b
|
7
|
+
data.tar.gz: 6abd1e879e9fe908906604bc287f92986d48faea8dbe985a4408af5f5832cac24a69b8c61659b95c3aad9a5394040cb6afaeb558c296c09548aba03ac54f2fa1
|
data/.gitignore
CHANGED
data/lib/stytch/b2b_client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'b2b_discovery'
|
3
4
|
require_relative 'b2b_magic_links'
|
4
5
|
require_relative 'b2b_organizations'
|
5
6
|
require_relative 'b2b_passwords'
|
@@ -10,7 +11,7 @@ module StytchB2B
|
|
10
11
|
class Client
|
11
12
|
ENVIRONMENTS = %i[live test].freeze
|
12
13
|
|
13
|
-
attr_reader :magic_links, :organizations, :passwords, :sso, :sessions
|
14
|
+
attr_reader :discovery, :magic_links, :organizations, :passwords, :sso, :sessions
|
14
15
|
|
15
16
|
def initialize(project_id:, secret:, env: nil, &block)
|
16
17
|
@api_host = api_host(env, project_id)
|
@@ -19,6 +20,7 @@ module StytchB2B
|
|
19
20
|
|
20
21
|
create_connection(&block)
|
21
22
|
|
23
|
+
@discovery = StytchB2B::Discovery.new(@connection)
|
22
24
|
@magic_links = StytchB2B::MagicLinks.new(@connection)
|
23
25
|
@organizations = StytchB2B::Organizations.new(@connection)
|
24
26
|
@passwords = StytchB2B::Passwords.new(@connection)
|
data/lib/stytch/b2b_discovery.rb
CHANGED
@@ -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,6 +27,63 @@ 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
|
+
#
|
61
|
+
# == Returns:
|
62
|
+
# An object with the following fields:
|
63
|
+
# request_id::
|
64
|
+
# 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.
|
65
|
+
# The type of this field is +String+.
|
66
|
+
# member_id::
|
67
|
+
# Globally unique UUID that identifies a specific Member.
|
68
|
+
# The type of this field is +String+.
|
69
|
+
# session_token::
|
70
|
+
# A secret token for a given Stytch Session.
|
71
|
+
# The type of this field is +String+.
|
72
|
+
# session_jwt::
|
73
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
74
|
+
# The type of this field is +String+.
|
75
|
+
# member::
|
76
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
77
|
+
# The type of this field is +Member+ (+object+).
|
78
|
+
# organization::
|
79
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
80
|
+
# The type of this field is +Organization+ (+object+).
|
81
|
+
# status_code::
|
82
|
+
# 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
|
+
# The type of this field is +Integer+.
|
84
|
+
# member_session::
|
85
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
86
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
24
87
|
def exchange(
|
25
88
|
intermediate_session_token:,
|
26
89
|
organization_id:,
|
@@ -45,6 +108,122 @@ module StytchB2B
|
|
45
108
|
@connection = connection
|
46
109
|
end
|
47
110
|
|
111
|
+
# 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
|
112
|
+
# [Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object).
|
113
|
+
#
|
114
|
+
# This operation consumes the Intermediate Session.
|
115
|
+
#
|
116
|
+
# This endpoint can also be used to start an initial session for the newly created member and organization.
|
117
|
+
#
|
118
|
+
# == Parameters:
|
119
|
+
# 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.
|
121
|
+
# The type of this field is +String+.
|
122
|
+
# organization_name::
|
123
|
+
# 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.
|
124
|
+
# The type of this field is +String+.
|
125
|
+
# organization_slug::
|
126
|
+
# 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.
|
127
|
+
# The type of this field is +String+.
|
128
|
+
# session_duration_minutes::
|
129
|
+
# Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
|
130
|
+
# returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
|
131
|
+
# five minutes regardless of the underlying session duration, and will need to be refreshed over time.
|
132
|
+
#
|
133
|
+
# This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
|
134
|
+
#
|
135
|
+
# If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
|
136
|
+
#
|
137
|
+
# 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
|
138
|
+
# to use the Stytch session product, you can ignore the session fields in the response.
|
139
|
+
# The type of this field is nilable +Integer+.
|
140
|
+
# session_custom_claims::
|
141
|
+
# Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
|
142
|
+
# `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
|
143
|
+
# delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
|
144
|
+
# Total custom claims size cannot exceed four kilobytes.
|
145
|
+
# The type of this field is nilable +object+.
|
146
|
+
# organization_logo_url::
|
147
|
+
# The image URL of the Organization logo.
|
148
|
+
# The type of this field is nilable +String+.
|
149
|
+
# trusted_metadata::
|
150
|
+
# An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
|
151
|
+
# The type of this field is nilable +object+.
|
152
|
+
# sso_jit_provisioning::
|
153
|
+
# The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
|
154
|
+
#
|
155
|
+
# `ALL_ALLOWED` – new Members will be automatically provisioned upon successful authentication via any of the Organization's `sso_active_connections`.
|
156
|
+
#
|
157
|
+
# `RESTRICTED` – only new Members with SSO logins that comply with `sso_jit_provisioning_allowed_connections` can be provisioned upon authentication.
|
158
|
+
#
|
159
|
+
# `NOT_ALLOWED` – disable JIT provisioning via SSO.
|
160
|
+
#
|
161
|
+
# The type of this field is nilable +String+.
|
162
|
+
# email_allowed_domains::
|
163
|
+
# 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`.
|
164
|
+
#
|
165
|
+
#
|
166
|
+
# 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.
|
167
|
+
# The type of this field is nilable list of +String+.
|
168
|
+
# email_jit_provisioning::
|
169
|
+
# The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
|
170
|
+
#
|
171
|
+
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
|
172
|
+
#
|
173
|
+
# `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
|
174
|
+
#
|
175
|
+
# The type of this field is nilable +String+.
|
176
|
+
# email_invites::
|
177
|
+
# The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:
|
178
|
+
#
|
179
|
+
# `ALL_ALLOWED` – any new Member can be invited to join via email.
|
180
|
+
#
|
181
|
+
# `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be invited via email.
|
182
|
+
#
|
183
|
+
# `NOT_ALLOWED` – disable email invites.
|
184
|
+
#
|
185
|
+
# The type of this field is nilable +String+.
|
186
|
+
# auth_methods::
|
187
|
+
# The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:
|
188
|
+
#
|
189
|
+
# `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
|
190
|
+
#
|
191
|
+
# `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`.
|
192
|
+
#
|
193
|
+
# The type of this field is nilable +String+.
|
194
|
+
# allowed_auth_methods::
|
195
|
+
#
|
196
|
+
# An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
|
197
|
+
# The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
|
198
|
+
#
|
199
|
+
# The type of this field is nilable list of +String+.
|
200
|
+
#
|
201
|
+
# == Returns:
|
202
|
+
# An object with the following fields:
|
203
|
+
# request_id::
|
204
|
+
# 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.
|
205
|
+
# The type of this field is +String+.
|
206
|
+
# member_id::
|
207
|
+
# Globally unique UUID that identifies a specific Member.
|
208
|
+
# The type of this field is +String+.
|
209
|
+
# session_token::
|
210
|
+
# A secret token for a given Stytch Session.
|
211
|
+
# The type of this field is +String+.
|
212
|
+
# session_jwt::
|
213
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
214
|
+
# The type of this field is +String+.
|
215
|
+
# member::
|
216
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
217
|
+
# The type of this field is +Member+ (+object+).
|
218
|
+
# status_code::
|
219
|
+
# 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
|
+
# The type of this field is +Integer+.
|
221
|
+
# member_session::
|
222
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
223
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
224
|
+
# organization::
|
225
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
226
|
+
# The type of this field is nilable +Organization+ (+object+).
|
48
227
|
def create(
|
49
228
|
intermediate_session_token:,
|
50
229
|
organization_name:,
|
@@ -79,6 +258,56 @@ module StytchB2B
|
|
79
258
|
post_request('/v1/b2b/discovery/organizations/create', request)
|
80
259
|
end
|
81
260
|
|
261
|
+
# List all possible organization relationships connected to a [Member Session](https://stytch.com/docs/b2b/api/session-object) or Intermediate Session.
|
262
|
+
#
|
263
|
+
# When a Member Session is passed in, relationships with a type of `active_member`, `pending_member`, or `invited_member`
|
264
|
+
# will be returned, and any membership can be assumed by calling the [Exchange Session](https://stytch.com/docs/b2b/api/exchange-session) endpoint.
|
265
|
+
#
|
266
|
+
# When an Intermediate Session is passed in, all relationship types - `active_member`, `pending_member`, `invited_member`,
|
267
|
+
# and `eligible_to_join_by_email_domain` - will be returned,
|
268
|
+
# and any membership can be assumed by calling the [Exchange Intermediate Session](https://stytch.com/docs/b2b/api/exchange-intermediate-session) endpoint.
|
269
|
+
#
|
270
|
+
# This endpoint requires either an `intermediate_session_token`, `session_jwt` or `session_token` be included in the request.
|
271
|
+
# It will return an error if multiple are present.
|
272
|
+
#
|
273
|
+
# This operation does not consume the Intermediate Session or Session Token passed in.
|
274
|
+
#
|
275
|
+
# == Parameters:
|
276
|
+
# 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.
|
278
|
+
# The type of this field is nilable +String+.
|
279
|
+
# session_token::
|
280
|
+
# A secret token for a given Stytch Session.
|
281
|
+
# The type of this field is nilable +String+.
|
282
|
+
# session_jwt::
|
283
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
284
|
+
# The type of this field is nilable +String+.
|
285
|
+
#
|
286
|
+
# == Returns:
|
287
|
+
# An object with the following fields:
|
288
|
+
# request_id::
|
289
|
+
# 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.
|
290
|
+
# The type of this field is +String+.
|
291
|
+
# email_address::
|
292
|
+
# The email address.
|
293
|
+
# The type of this field is +String+.
|
294
|
+
# discovered_organizations::
|
295
|
+
# 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.
|
296
|
+
#
|
297
|
+
# Note that Organizations will only appear here under any of the following conditions:
|
298
|
+
# 1. The end user is already a Member of the Organization.
|
299
|
+
# 2. The end user is invited to the Organization.
|
300
|
+
# 3. The end user can join the Organization because:
|
301
|
+
#
|
302
|
+
# a) The Organization allows JIT provisioning.
|
303
|
+
#
|
304
|
+
# b) The Organizations' allowed domains list contains the Member's email domain.
|
305
|
+
#
|
306
|
+
# 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).
|
307
|
+
# The type of this field is list of +DiscoveredOrganization+ (+object+).
|
308
|
+
# status_code::
|
309
|
+
# 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
|
+
# The type of this field is +Integer+.
|
82
311
|
def list(
|
83
312
|
intermediate_session_token: nil,
|
84
313
|
session_token: nil,
|
@@ -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
|
@@ -14,6 +20,80 @@ module StytchB2B
|
|
14
20
|
@discovery = StytchB2B::MagicLinks::Discovery.new(@connection)
|
15
21
|
end
|
16
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.
|
24
|
+
#
|
25
|
+
# == Parameters:
|
26
|
+
# magic_links_token::
|
27
|
+
# The Email Magic Link token to authenticate.
|
28
|
+
# The type of this field is +String+.
|
29
|
+
# pkce_code_verifier::
|
30
|
+
# A base64url encoded one time secret used to validate that the request starts and ends on the same device.
|
31
|
+
# The type of this field is nilable +String+.
|
32
|
+
# session_token::
|
33
|
+
# Reuse an existing session instead of creating a new one. If you provide a `session_token`, Stytch will update the session.
|
34
|
+
# If the `session_token` and `magic_links_token` belong to different Members, the `session_token` will be ignored. This endpoint will error if
|
35
|
+
# both `session_token` and `session_jwt` are provided.
|
36
|
+
# The type of this field is nilable +String+.
|
37
|
+
# session_jwt::
|
38
|
+
# Reuse an existing session instead of creating a new one. If you provide a `session_jwt`, Stytch will update the session. If the `session_jwt`
|
39
|
+
# and `magic_links_token` belong to different Members, the `session_jwt` will be ignored. This endpoint will error if both `session_token` and `session_jwt`
|
40
|
+
# are provided.
|
41
|
+
# The type of this field is nilable +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
|
+
#
|
61
|
+
# == Returns:
|
62
|
+
# An object with the following fields:
|
63
|
+
# request_id::
|
64
|
+
# 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.
|
65
|
+
# The type of this field is +String+.
|
66
|
+
# member_id::
|
67
|
+
# Globally unique UUID that identifies a specific Member.
|
68
|
+
# The type of this field is +String+.
|
69
|
+
# method_id::
|
70
|
+
# The email or device involved in the authentication.
|
71
|
+
# The type of this field is +String+.
|
72
|
+
# reset_sessions::
|
73
|
+
# Indicates if all Sessions linked to the Member need to be reset. You should check this field if you aren't using
|
74
|
+
# Stytch's Session product. If you are using Stytch's Session product, we revoke the Member’s other Sessions for you.
|
75
|
+
# The type of this field is +Boolean+.
|
76
|
+
# organization_id::
|
77
|
+
# 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.
|
78
|
+
# The type of this field is +String+.
|
79
|
+
# member::
|
80
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
81
|
+
# The type of this field is +Member+ (+object+).
|
82
|
+
# session_token::
|
83
|
+
# A secret token for a given Stytch Session.
|
84
|
+
# The type of this field is +String+.
|
85
|
+
# session_jwt::
|
86
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
87
|
+
# The type of this field is +String+.
|
88
|
+
# member_session::
|
89
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
90
|
+
# The type of this field is +MemberSession+ (+object+).
|
91
|
+
# organization::
|
92
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
93
|
+
# The type of this field is +Organization+ (+object+).
|
94
|
+
# status_code::
|
95
|
+
# 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
|
+
# The type of this field is +Integer+.
|
17
97
|
def authenticate(
|
18
98
|
magic_links_token:,
|
19
99
|
pkce_code_verifier: nil,
|
@@ -44,6 +124,65 @@ module StytchB2B
|
|
44
124
|
@discovery = StytchB2B::MagicLinks::Email::Discovery.new(@connection)
|
45
125
|
end
|
46
126
|
|
127
|
+
# Send either a login or signup magic link to a Member. A new, pending, or invited Member will receive a signup Email Magic Link. Members will have a `pending` status until they successfully authenticate. An active Member will receive a login Email Magic Link.
|
128
|
+
#
|
129
|
+
# == Parameters:
|
130
|
+
# organization_id::
|
131
|
+
# 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.
|
132
|
+
# The type of this field is +String+.
|
133
|
+
# email_address::
|
134
|
+
# The email address of the Member.
|
135
|
+
# The type of this field is +String+.
|
136
|
+
# login_redirect_url::
|
137
|
+
# The URL that the Member clicks from the login Email Magic Link. This URL should be an endpoint in the backend server that
|
138
|
+
# verifies the request by querying Stytch's authenticate endpoint and finishes the login. If this value is not passed, the default login
|
139
|
+
# redirect URL that you set in your Dashboard is used. If you have not set a default login redirect URL, an error is returned.
|
140
|
+
# The type of this field is nilable +String+.
|
141
|
+
# signup_redirect_url::
|
142
|
+
# The URL the Member clicks from the signup Email Magic Link. This URL should be an endpoint in the backend server that verifies
|
143
|
+
# the request by querying Stytch's authenticate endpoint and finishes the login. If this value is not passed, the default sign-up redirect URL
|
144
|
+
# that you set in your Dashboard is used. If you have not set a default sign-up redirect URL, an error is returned.
|
145
|
+
# The type of this field is nilable +String+.
|
146
|
+
# pkce_code_challenge::
|
147
|
+
# A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
|
148
|
+
# The type of this field is nilable +String+.
|
149
|
+
# login_template_id::
|
150
|
+
# Use a custom template for login emails. By default, it will use your default email template. The template must be from Stytch's
|
151
|
+
# built-in customizations or a custom HTML email for Magic Links - Login.
|
152
|
+
# The type of this field is nilable +String+.
|
153
|
+
# signup_template_id::
|
154
|
+
# Use a custom template for signup emails. By default, it will use your default email template. The template must be from Stytch's
|
155
|
+
# built-in customizations or a custom HTML email for Magic Links - Signup.
|
156
|
+
# The type of this field is nilable +String+.
|
157
|
+
# locale::
|
158
|
+
# Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
159
|
+
#
|
160
|
+
# Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
|
161
|
+
#
|
162
|
+
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
163
|
+
#
|
164
|
+
# The type of this field is nilable +LoginOrSignupRequestLocale+ (+object+).
|
165
|
+
#
|
166
|
+
# == Returns:
|
167
|
+
# An object with the following fields:
|
168
|
+
# request_id::
|
169
|
+
# 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.
|
170
|
+
# The type of this field is +String+.
|
171
|
+
# member_id::
|
172
|
+
# Globally unique UUID that identifies a specific Member.
|
173
|
+
# The type of this field is +String+.
|
174
|
+
# member_created::
|
175
|
+
# A flag indicating `true` if a new Member object was created and `false` if the Member object already existed.
|
176
|
+
# The type of this field is +Boolean+.
|
177
|
+
# member::
|
178
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
179
|
+
# The type of this field is +Member+ (+object+).
|
180
|
+
# organization::
|
181
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
182
|
+
# The type of this field is +Organization+ (+object+).
|
183
|
+
# status_code::
|
184
|
+
# 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.
|
185
|
+
# The type of this field is +Integer+.
|
47
186
|
def login_or_signup(
|
48
187
|
organization_id:,
|
49
188
|
email_address:,
|
@@ -68,6 +207,64 @@ module StytchB2B
|
|
68
207
|
post_request('/v1/b2b/magic_links/email/login_or_signup', request)
|
69
208
|
end
|
70
209
|
|
210
|
+
# Send an invite email to a new Member to join an Organization. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error.
|
211
|
+
#
|
212
|
+
# == Parameters:
|
213
|
+
# organization_id::
|
214
|
+
# 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.
|
215
|
+
# The type of this field is +String+.
|
216
|
+
# email_address::
|
217
|
+
# The email address of the Member.
|
218
|
+
# The type of this field is +String+.
|
219
|
+
# invite_redirect_url::
|
220
|
+
# The URL that the Member clicks from the invite Email Magic Link. This URL should be an endpoint in the backend server that verifies
|
221
|
+
# the request by querying Stytch's authenticate endpoint and finishes the invite flow. If this value is not passed, the default `invite_redirect_url`
|
222
|
+
# that you set in your Dashboard is used. If you have not set a default `invite_redirect_url`, an error is returned.
|
223
|
+
# The type of this field is nilable +String+.
|
224
|
+
# invited_by_member_id::
|
225
|
+
# The `member_id` of the Member who sends the invite.
|
226
|
+
# The type of this field is nilable +String+.
|
227
|
+
# name::
|
228
|
+
# The name of the Member.
|
229
|
+
# The type of this field is nilable +String+.
|
230
|
+
# trusted_metadata::
|
231
|
+
# An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
|
232
|
+
# The type of this field is nilable +object+.
|
233
|
+
# untrusted_metadata::
|
234
|
+
# An arbitrary JSON object of application-specific data. These fields can be edited directly by the
|
235
|
+
# frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
|
236
|
+
# for complete field behavior details.
|
237
|
+
# The type of this field is nilable +object+.
|
238
|
+
# invite_template_id::
|
239
|
+
# Use a custom template for invite emails. By default, it will use your default email template. The template must be a template
|
240
|
+
# using our built-in customizations or a custom HTML email for Magic Links - Invite.
|
241
|
+
# The type of this field is nilable +String+.
|
242
|
+
# locale::
|
243
|
+
# Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
244
|
+
#
|
245
|
+
# Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
|
246
|
+
#
|
247
|
+
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
248
|
+
#
|
249
|
+
# The type of this field is nilable +InviteRequestLocale+ (+object+).
|
250
|
+
#
|
251
|
+
# == Returns:
|
252
|
+
# An object with the following fields:
|
253
|
+
# request_id::
|
254
|
+
# 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.
|
255
|
+
# The type of this field is +String+.
|
256
|
+
# member_id::
|
257
|
+
# Globally unique UUID that identifies a specific Member.
|
258
|
+
# The type of this field is +String+.
|
259
|
+
# member::
|
260
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
261
|
+
# The type of this field is +Member+ (+object+).
|
262
|
+
# organization::
|
263
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
264
|
+
# The type of this field is +Organization+ (+object+).
|
265
|
+
# status_code::
|
266
|
+
# 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.
|
267
|
+
# The type of this field is +Integer+.
|
71
268
|
def invite(
|
72
269
|
organization_id:,
|
73
270
|
email_address:,
|
@@ -101,6 +298,41 @@ module StytchB2B
|
|
101
298
|
@connection = connection
|
102
299
|
end
|
103
300
|
|
301
|
+
# Send a discovery magic link to an email address.
|
302
|
+
#
|
303
|
+
# == Parameters:
|
304
|
+
# email_address::
|
305
|
+
# The email address of the Member.
|
306
|
+
# The type of this field is +String+.
|
307
|
+
# discovery_redirect_url::
|
308
|
+
# The URL that the end user clicks from the discovery Magic Link. This URL should be an endpoint in the backend server that
|
309
|
+
# verifies the request by querying Stytch's discovery authenticate endpoint and continues the flow. If this value is not passed, the default
|
310
|
+
# discovery redirect URL that you set in your Dashboard is used. If you have not set a default discovery redirect URL, an error is returned.
|
311
|
+
# The type of this field is nilable +String+.
|
312
|
+
# pkce_code_challenge::
|
313
|
+
# A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
|
314
|
+
# The type of this field is nilable +String+.
|
315
|
+
# login_template_id::
|
316
|
+
# Use a custom template for discovery emails. By default, it will use your default email template. The template must be from Stytch's
|
317
|
+
# built-in customizations or a custom HTML email for Magic Links - Login.
|
318
|
+
# The type of this field is nilable +String+.
|
319
|
+
# locale::
|
320
|
+
# Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
321
|
+
#
|
322
|
+
# Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
|
323
|
+
#
|
324
|
+
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
325
|
+
#
|
326
|
+
# The type of this field is nilable +SendRequestLocale+ (+object+).
|
327
|
+
#
|
328
|
+
# == Returns:
|
329
|
+
# An object with the following fields:
|
330
|
+
# request_id::
|
331
|
+
# 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.
|
332
|
+
# The type of this field is +String+.
|
333
|
+
# status_code::
|
334
|
+
# 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.
|
335
|
+
# The type of this field is +Integer+.
|
104
336
|
def send(
|
105
337
|
email_address:,
|
106
338
|
discovery_redirect_url: nil,
|
@@ -128,6 +360,44 @@ module StytchB2B
|
|
128
360
|
@connection = connection
|
129
361
|
end
|
130
362
|
|
363
|
+
# Authenticates the Discovery Magic Link 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.
|
364
|
+
#
|
365
|
+
# == Parameters:
|
366
|
+
# discovery_magic_links_token::
|
367
|
+
# The Discovery Email Magic Link token to authenticate.
|
368
|
+
# The type of this field is +String+.
|
369
|
+
# pkce_code_verifier::
|
370
|
+
# A base64url encoded one time secret used to validate that the request starts and ends on the same device.
|
371
|
+
# The type of this field is nilable +String+.
|
372
|
+
#
|
373
|
+
# == Returns:
|
374
|
+
# An object with the following fields:
|
375
|
+
# request_id::
|
376
|
+
# 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
|
+
# The type of this field is +String+.
|
378
|
+
# 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.
|
380
|
+
# The type of this field is +String+.
|
381
|
+
# email_address::
|
382
|
+
# The email address.
|
383
|
+
# The type of this field is +String+.
|
384
|
+
# discovered_organizations::
|
385
|
+
# 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.
|
386
|
+
#
|
387
|
+
# Note that Organizations will only appear here under any of the following conditions:
|
388
|
+
# 1. The end user is already a Member of the Organization.
|
389
|
+
# 2. The end user is invited to the Organization.
|
390
|
+
# 3. The end user can join the Organization because:
|
391
|
+
#
|
392
|
+
# a) The Organization allows JIT provisioning.
|
393
|
+
#
|
394
|
+
# b) The Organizations' allowed domains list contains the Member's email domain.
|
395
|
+
#
|
396
|
+
# 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).
|
397
|
+
# The type of this field is list of +DiscoveredOrganization+ (+object+).
|
398
|
+
# status_code::
|
399
|
+
# 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.
|
400
|
+
# The type of this field is +Integer+.
|
131
401
|
def authenticate(
|
132
402
|
discovery_magic_links_token:,
|
133
403
|
pkce_code_verifier: nil
|