stytch 6.4.0 → 9.8.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: 94327b3a992f3e596ec4c0a5a6bad97d2c78041e15f12a470949819aa5c0994d
4
- data.tar.gz: a02935d82c7129002058f425f15d73886b5f373b9f942e35cfb410fd62c7148d
3
+ metadata.gz: e075ae0bbd1a3f639927bcd53fc125ce81856a38ca08af4fda63a5a67c59a8d2
4
+ data.tar.gz: f820f820eff94a0d24e504bc1cb2a31d449124609b37edb60d1f6678acfe19e8
5
5
  SHA512:
6
- metadata.gz: c366e0741c92ecf5ce5413beb57917a01f733ecc231540aebfab19c8a51ee75e7ee9deded5d23453b0580fc3556c90f7e2d1b707dfd79fa6aa6fa6b43cf5e152
7
- data.tar.gz: 9e2540999fa38c50436ea9409859cff663378d7b4a4d21a9ec15bdc8e36b326ed3ae2d681751739adbcecb57b3bd3a1c578394ba6d9dd2b92a1e9b5863f1a84b
6
+ metadata.gz: 392f3723a7fd0e3950a4179da49c49dc2c01d469b6b2c4107c6d6d20b9beabcee3b5741c16f260ad04dc440c42122bd3098e5eb91844133c9cf08a4e30f58443
7
+ data.tar.gz: bb1e40d2bbc571b03215aa94dc40164816fd5559f412c14cb4b9b6b73ef1046a3339005d456ccb294b712d353c17eb53cf08b0fb0bfa030dd061fd11afc92712
@@ -26,3 +26,16 @@ jobs:
26
26
  bundler-cache: true
27
27
 
28
28
  - run: bundle exec rspec
29
+
30
+ lint:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v3
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ # Match the minimum supported Ruby version in the gemspec.
38
+ ruby-version: '2.7'
39
+ bundler-cache: true
40
+
41
+ - run: bundle exec rubocop
data/.gitignore CHANGED
@@ -8,6 +8,8 @@
8
8
  /tmp/
9
9
  *.gem
10
10
  Gemfile.lock
11
+ .idea/
12
+ .envrc
11
13
 
12
14
  # rspec failure tracking
13
15
  .rspec_status
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: disable
6
+ # The target Ruby version must match the one in stytch.gemspec.
7
+ TargetRubyVersion: 2.7
8
+
9
+ Layout/LineLength: { Enabled: false }
10
+ LeadingCommentSpace: { Enabled: false }
11
+
12
+ Metrics: { Enabled: false }
13
+
14
+ Style/Documentation: { Enabled: false }
15
+ Style/For: { Enabled: false }
16
+ Style/FrozenStringLiteralComment: { Enabled: false }
17
+ Style/NumericPredicate: { Enabled: false }
18
+ Style/StringConcatenation: { Enabled: false }
19
+
20
+ RSpec/DescribedClass: { Enabled: false }
21
+ RSpec/ExampleLength: { Enabled: false }
22
+ RSpec/MultipleExpectations: { Enabled: false }
data/DEVELOPMENT.md CHANGED
@@ -5,7 +5,9 @@ Thanks for contributing to Stytch's Ruby library! If you run into trouble, find
5
5
  ## Setup
6
6
 
7
7
  1. Clone this repo.
8
- 2. To test your changes locally, update your GEMFILE with `gem 'stytch', path: '../stytch'` where `../stytch` is the path to your cloned copy of stytch-ruby.
8
+ 2. Install development dependencies using [Bundler]: `bundle install`
9
+
10
+ To test your changes locally in another project, update your `GEMFILE` with `gem 'stytch', path: '../stytch'` where `../stytch` is the path to your cloned copy of stytch-ruby.
9
11
 
10
12
  ## Issues and Pull Requests
11
13
 
@@ -15,4 +17,5 @@ If you have non-trivial changes you'd like us to incorporate, please open an iss
15
17
 
16
18
  When you're ready for someone to look at your issue or PR, assign `@stytchauth/client-libraries` (GitHub should do this automatically). If we don't acknowledge it within one business day, please escalate it by tagging `@stytchauth/engineering` in a comment or letting us know in [Slack].
17
19
 
18
- [Slack]: https://join.slack.com/t/stytch/shared_invite/zt-nil4wo92-jApJ9Cl32cJbEd9esKkvyg
20
+ [Bundler]: https://bundler.io/
21
+ [Slack]: https://stytch.com/docs/resources/support/overview
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Stytch Ruby gem makes it easy to use the Stytch user infrastructure API in Ruby applications.
4
4
 
5
- It pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/stytch-js) or your own custom authentication flow.
5
+ It pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/vanilla-js) or your own custom authentication flow.
6
6
 
7
7
  ## Install
8
8
 
@@ -25,6 +25,9 @@ Or install it yourself as:
25
25
  You can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).
26
26
 
27
27
  This client library supports all Stytch's live products:
28
+
29
+ ### B2C
30
+
28
31
  - [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)
29
32
  - [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)
30
33
  - [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)
@@ -37,7 +40,18 @@ This client library supports all Stytch's live products:
37
40
  - [x] [Crypto wallets](https://stytch.com/docs/guides/web3/api)
38
41
  - [x] [Passwords](https://stytch.com/docs/guides/passwords/api)
39
42
 
40
- ### Example usage
43
+ ### B2B
44
+
45
+ - [x] [Organizations](https://stytch.com/docs/b2b/api/organization-object)
46
+ - [x] [Members](https://stytch.com/docs/b2b/api/member-object)
47
+ - [x] [Email Magic Links](https://stytch.com/docs/b2b/api/send-login-signup-email)
48
+ - [x] [OAuth logins](https://stytch.com/docs/b2b/api/oauth-google-start)
49
+ - [x] [Session Management](https://stytch.com/docs/b2b/api/session-object)
50
+ - [x] [Single-Sign On](https://stytch.com/docs/b2b/api/sso-authenticate-start)
51
+ - [x] [Discovery](https://stytch.com/docs/b2b/api/discovered-organization-object)
52
+ - [x] [Passwords](https://stytch.com/docs/b2b/api/passwords-authenticate)
53
+
54
+ ### Example B2C usage
41
55
  Create an API client:
42
56
  ```ruby
43
57
  client = Stytch::Client.new(
@@ -61,6 +75,41 @@ client.magic_links.authenticate(
61
75
  )
62
76
  ```
63
77
 
78
+ ### Example B2B usage
79
+
80
+ Create an API client:
81
+ ```ruby
82
+ require 'stytch'
83
+
84
+ client = StytchB2B::Client.new(
85
+ project_id: "project-test-uuid",
86
+ secret: "secret-test-uuid"
87
+ )
88
+ ```
89
+
90
+ Create an organization
91
+
92
+ ```ruby
93
+ resp = client.organizations.create(
94
+ organization_name: 'Example Org Inc.',
95
+ organization_slug: 'example-org'
96
+ )
97
+
98
+ puts resp
99
+ ```
100
+
101
+ Log the first user into the organization
102
+
103
+ ```ruby
104
+ resp = client.magic_links.email.login_or_signup(
105
+ organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
106
+ email_address: 'sandbox@stytch.com'
107
+ )
108
+
109
+ puts resp
110
+ ```
111
+
112
+
64
113
  ## Handling Errors
65
114
 
66
115
  When possible the response will contain an `error_type` and an `error_message` that can be used to distinguish errors.
@@ -77,7 +126,7 @@ Follow one of the [integration guides](https://stytch.com/docs/guides) or start
77
126
 
78
127
  If you've found a bug, [open an issue](https://github.com/stytchauth/stytch-ruby/issues/new)!
79
128
 
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.
129
+ If you have questions or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email support@stytch.com.
81
130
 
82
131
  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
132
 
@@ -6,32 +6,47 @@ require_relative 'b2b_oauth'
6
6
  require_relative 'b2b_organizations'
7
7
  require_relative 'b2b_otp'
8
8
  require_relative 'b2b_passwords'
9
+ require_relative 'b2b_rbac'
10
+ require_relative 'b2b_recovery_codes'
11
+ require_relative 'b2b_scim'
9
12
  require_relative 'b2b_sessions'
10
13
  require_relative 'b2b_sso'
14
+ require_relative 'b2b_totps'
11
15
  require_relative 'm2m'
16
+ require_relative 'project'
17
+ require_relative 'rbac_local'
12
18
 
13
19
  module StytchB2B
14
20
  class Client
15
21
  ENVIRONMENTS = %i[live test].freeze
16
22
 
17
- attr_reader :discovery, :m2m, :magic_links, :oauth, :otps, :organizations, :passwords, :sso, :sessions
23
+ attr_reader :discovery, :m2m, :magic_links, :oauth, :otps, :organizations, :passwords, :project, :rbac, :recovery_codes, :scim, :sso, :sessions, :totps
18
24
 
19
25
  def initialize(project_id:, secret:, env: nil, &block)
20
26
  @api_host = api_host(env, project_id)
21
27
  @project_id = project_id
22
28
  @secret = secret
29
+ @is_b2b_client = true
23
30
 
24
31
  create_connection(&block)
25
32
 
33
+ rbac = StytchB2B::RBAC.new(@connection)
34
+ @policy_cache = StytchB2B::PolicyCache.new(rbac_client: rbac)
35
+
26
36
  @discovery = StytchB2B::Discovery.new(@connection)
27
- @m2m = Stytch::M2M.new(@connection, project_id)
37
+ @m2m = Stytch::M2M.new(@connection, @project_id, @is_b2b_client)
28
38
  @magic_links = StytchB2B::MagicLinks.new(@connection)
29
39
  @oauth = StytchB2B::OAuth.new(@connection)
30
40
  @otps = StytchB2B::OTPs.new(@connection)
31
41
  @organizations = StytchB2B::Organizations.new(@connection)
32
42
  @passwords = StytchB2B::Passwords.new(@connection)
43
+ @project = Stytch::Project.new(@connection)
44
+ @rbac = StytchB2B::RBAC.new(@connection)
45
+ @recovery_codes = StytchB2B::RecoveryCodes.new(@connection)
46
+ @scim = StytchB2B::SCIM.new(@connection)
33
47
  @sso = StytchB2B::SSO.new(@connection)
34
- @sessions = StytchB2B::Sessions.new(@connection)
48
+ @sessions = StytchB2B::Sessions.new(@connection, @project_id, @policy_cache)
49
+ @totps = StytchB2B::TOTPs.new(@connection)
35
50
  end
36
51
 
37
52
  private
@@ -32,18 +32,19 @@ module StytchB2B
32
32
  #
33
33
  # This endpoint can be used to accept invites and create new members via domain matching.
34
34
  #
35
- # If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`.
35
+ # If the is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`.
36
36
  # The `intermediate_session_token` will not be consumed and instead will be returned in the response.
37
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
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
39
  # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
40
40
  #
41
+ # If the Member is logging in via an OAuth provider that does not fully verify the email, the returned value of `member_authenticated` will be `false`.
42
+ # The `intermediate_session_token` will not be consumed and instead will be returned in the response.
43
+ # The `primary_required` field details the authentication flow the Member must perform in order to [complete a step-up authentication](https://stytch.com/docs/b2b/guides/oauth/auth-flows) into the organization. The `intermediate_session_token` must be passed into that authentication flow.
44
+ #
41
45
  # == Parameters:
42
46
  # intermediate_session_token::
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.
47
+ # 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. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with 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; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
47
48
  # The type of this field is +String+.
48
49
  # organization_id::
49
50
  # 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.
@@ -67,7 +68,7 @@ module StytchB2B
67
68
  # Total custom claims size cannot exceed four kilobytes.
68
69
  # The type of this field is nilable +object+.
69
70
  # locale::
70
- # 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
+ # If the 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
  #
72
73
  # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
73
74
  #
@@ -101,10 +102,7 @@ module StytchB2B
101
102
  # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
102
103
  # The type of this field is +Boolean+.
103
104
  # 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.
105
+ # The returned Intermediate Session Token is identical to the one that was originally passed in to the request. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with 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; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
108
106
  # The type of this field is +String+.
109
107
  # status_code::
110
108
  # 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.
@@ -115,6 +113,9 @@ module StytchB2B
115
113
  # mfa_required::
116
114
  # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
117
115
  # The type of this field is nilable +MfaRequired+ (+object+).
116
+ # primary_required::
117
+ # Information about the primary authentication requirements of the Organization.
118
+ # The type of this field is nilable +PrimaryRequired+ (+object+).
118
119
  def exchange(
119
120
  intermediate_session_token:,
120
121
  organization_id:,
@@ -122,6 +123,7 @@ module StytchB2B
122
123
  session_custom_claims: nil,
123
124
  locale: nil
124
125
  )
126
+ headers = {}
125
127
  request = {
126
128
  intermediate_session_token: intermediate_session_token,
127
129
  organization_id: organization_id
@@ -130,7 +132,7 @@ module StytchB2B
130
132
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
131
133
  request[:locale] = locale unless locale.nil?
132
134
 
133
- post_request('/v1/b2b/discovery/intermediate_sessions/exchange', request)
135
+ post_request('/v1/b2b/discovery/intermediate_sessions/exchange', request, headers)
134
136
  end
135
137
  end
136
138
 
@@ -141,12 +143,15 @@ module StytchB2B
141
143
  @connection = connection
142
144
  end
143
145
 
144
- # 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
146
+ # If an end user does not want to join any already-existing, or has no possible Organizations to join, this endpoint can be used to create a new
145
147
  # [Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object).
146
148
  #
147
149
  # This operation consumes the Intermediate Session.
148
150
  #
149
- # This endpoint can also be used to start an initial session for the newly created member and organization.
151
+ # This endpoint will also create an initial Member Session for the newly created Member.
152
+ #
153
+ # The created by this endpoint will automatically be granted the `stytch_admin` Role. See the
154
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/stytch-default) for more details on this Role.
150
155
  #
151
156
  # 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
157
  # The `intermediate_session_token` will not be consumed and instead will be returned in the response.
@@ -156,10 +161,7 @@ module StytchB2B
156
161
  #
157
162
  # == Parameters:
158
163
  # intermediate_session_token::
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.
164
+ # 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. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with 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; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
163
165
  # The type of this field is +String+.
164
166
  # organization_name::
165
167
  # 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.
@@ -208,11 +210,11 @@ module StytchB2B
208
210
  # 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.
209
211
  # The type of this field is nilable list of +String+.
210
212
  # email_jit_provisioning::
211
- # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
213
+ # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
212
214
  #
213
- # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
215
+ # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link or OAuth.
214
216
  #
215
- # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
217
+ # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
216
218
  #
217
219
  # The type of this field is nilable +String+.
218
220
  # email_invites::
@@ -234,7 +236,6 @@ module StytchB2B
234
236
  #
235
237
  # The type of this field is nilable +String+.
236
238
  # allowed_auth_methods::
237
- #
238
239
  # An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
239
240
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
240
241
  #
@@ -242,11 +243,41 @@ module StytchB2B
242
243
  # mfa_policy::
243
244
  # The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
244
245
  #
245
- # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
246
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
246
247
  #
247
248
  # `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
  #
249
250
  # The type of this field is nilable +String+.
251
+ # rbac_email_implicit_role_assignments::
252
+ # Implicit role assignments based off of email domains.
253
+ # For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
254
+ # associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
255
+ # for more information about role assignment.
256
+ # The type of this field is nilable list of +EmailImplicitRoleAssignment+ (+object+).
257
+ # mfa_methods::
258
+ # The setting that controls which MFA methods can be used by Members of an Organization. The accepted values are:
259
+ #
260
+ # `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
261
+ #
262
+ # `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
263
+ #
264
+ # The type of this field is nilable +String+.
265
+ # allowed_mfa_methods::
266
+ # An array of allowed MFA authentication methods. This list is enforced when `mfa_methods` is set to `RESTRICTED`.
267
+ # The list's accepted values are: `sms_otp` and `totp`.
268
+ #
269
+ # The type of this field is nilable list of +String+.
270
+ # oauth_tenant_jit_provisioning::
271
+ # The authentication setting that controls how a new Member can JIT provision into an organization by tenant. The accepted values are:
272
+ #
273
+ # `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
274
+ #
275
+ # `NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
276
+ #
277
+ # The type of this field is nilable +String+.
278
+ # allowed_oauth_tenants::
279
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
280
+ # The type of this field is nilable +object+.
250
281
  #
251
282
  # == Returns:
252
283
  # An object with the following fields:
@@ -269,10 +300,7 @@ module StytchB2B
269
300
  # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
270
301
  # The type of this field is +Boolean+.
271
302
  # 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.
303
+ # The returned Intermediate Session Token is identical to the one that was originally passed in to the request. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with 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; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
276
304
  # The type of this field is +String+.
277
305
  # status_code::
278
306
  # 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.
@@ -286,6 +314,9 @@ module StytchB2B
286
314
  # mfa_required::
287
315
  # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
288
316
  # The type of this field is nilable +MfaRequired+ (+object+).
317
+ # primary_required::
318
+ # Information about the primary authentication requirements of the Organization.
319
+ # The type of this field is nilable +PrimaryRequired+ (+object+).
289
320
  def create(
290
321
  intermediate_session_token:,
291
322
  organization_name:,
@@ -300,8 +331,14 @@ module StytchB2B
300
331
  email_invites: nil,
301
332
  auth_methods: nil,
302
333
  allowed_auth_methods: nil,
303
- mfa_policy: nil
334
+ mfa_policy: nil,
335
+ rbac_email_implicit_role_assignments: nil,
336
+ mfa_methods: nil,
337
+ allowed_mfa_methods: nil,
338
+ oauth_tenant_jit_provisioning: nil,
339
+ allowed_oauth_tenants: nil
304
340
  )
341
+ headers = {}
305
342
  request = {
306
343
  intermediate_session_token: intermediate_session_token,
307
344
  organization_name: organization_name,
@@ -318,8 +355,13 @@ module StytchB2B
318
355
  request[:auth_methods] = auth_methods unless auth_methods.nil?
319
356
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
320
357
  request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
358
+ request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
359
+ request[:mfa_methods] = mfa_methods unless mfa_methods.nil?
360
+ request[:allowed_mfa_methods] = allowed_mfa_methods unless allowed_mfa_methods.nil?
361
+ request[:oauth_tenant_jit_provisioning] = oauth_tenant_jit_provisioning unless oauth_tenant_jit_provisioning.nil?
362
+ request[:allowed_oauth_tenants] = allowed_oauth_tenants unless allowed_oauth_tenants.nil?
321
363
 
322
- post_request('/v1/b2b/discovery/organizations/create', request)
364
+ post_request('/v1/b2b/discovery/organizations/create', request, headers)
323
365
  end
324
366
 
325
367
  # List all possible organization relationships connected to a [Member Session](https://stytch.com/docs/b2b/api/session-object) or Intermediate Session.
@@ -338,10 +380,7 @@ module StytchB2B
338
380
  #
339
381
  # == Parameters:
340
382
  # intermediate_session_token::
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.
383
+ # 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. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with 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; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
345
384
  # The type of this field is nilable +String+.
346
385
  # session_token::
347
386
  # A secret token for a given Stytch Session.
@@ -383,12 +422,13 @@ module StytchB2B
383
422
  session_token: nil,
384
423
  session_jwt: nil
385
424
  )
425
+ headers = {}
386
426
  request = {}
387
427
  request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
388
428
  request[:session_token] = session_token unless session_token.nil?
389
429
  request[:session_jwt] = session_jwt unless session_jwt.nil?
390
430
 
391
- post_request('/v1/b2b/discovery/organizations', request)
431
+ post_request('/v1/b2b/discovery/organizations', request, headers)
392
432
  end
393
433
  end
394
434
  end