Skip to content

Commit

Permalink
Fix member status return type for magic links (#135)
Browse files Browse the repository at this point in the history
* fix member status

* Revert "fix member status"

This reverts commit 048da32.

* regenerate

* bump minor version
  • Loading branch information
etaylormcgregor-stytch authored Sep 26, 2024
1 parent 7369506 commit fc1a06c
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 51 deletions.
16 changes: 10 additions & 6 deletions lib/stytch/b2b_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ def initialize(connection)
#
# This endpoint can be used to accept invites and create new members via domain matching.
#
# If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`.
# If the is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`.
# The `intermediate_session_token` will not be consumed and instead will be returned in the response.
# 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.
# 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.
# The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
#
# 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`.
# The `intermediate_session_token` will not be consumed and instead will be returned in the response.
# 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.
#
# == Parameters:
# intermediate_session_token::
# 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.
Expand All @@ -64,7 +68,7 @@ def initialize(connection)
# Total custom claims size cannot exceed four kilobytes.
# The type of this field is nilable +object+.
# locale::
# 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.
# 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.
#
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
#
Expand Down Expand Up @@ -110,7 +114,7 @@ def initialize(connection)
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
# The type of this field is nilable +MfaRequired+ (+object+).
# primary_required::
# (no documentation yet)
# Information about the primary authentication requirements of the Organization.
# The type of this field is nilable +PrimaryRequired+ (+object+).
def exchange(
intermediate_session_token:,
Expand Down Expand Up @@ -139,14 +143,14 @@ def initialize(connection)
@connection = connection
end

# 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
# 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
# [Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object).
#
# This operation consumes the Intermediate Session.
#
# This endpoint will also create an initial Member Session for the newly created Member.
#
# The Member created by this endpoint will automatically be granted the `stytch_admin` Role. See the
# The created by this endpoint will automatically be granted the `stytch_admin` Role. See the
# [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/stytch-default) for more details on this Role.
#
# 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.
Expand Down Expand Up @@ -311,7 +315,7 @@ def initialize(connection)
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
# The type of this field is nilable +MfaRequired+ (+object+).
# primary_required::
# (no documentation yet)
# Information about the primary authentication requirements of the Organization.
# The type of this field is nilable +PrimaryRequired+ (+object+).
def create(
intermediate_session_token:,
Expand Down
14 changes: 7 additions & 7 deletions lib/stytch/b2b_magic_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def initialize(connection)
@discovery = StytchB2B::MagicLinks::Discovery.new(@connection)
end

# 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`.
# Authenticate a 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.
#
# 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.
# If the Member is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
# The `intermediate_session_token` can be passed into 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 the MFA step and acquire a full member session.
# 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.
Expand Down Expand Up @@ -67,7 +67,7 @@ def initialize(connection)
# Total custom claims size cannot exceed four kilobytes.
# The type of this field is nilable +object+.
# locale::
# 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.
# 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.
#
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
#
Expand Down Expand Up @@ -107,9 +107,6 @@ def initialize(connection)
# session_jwt::
# The JSON Web Token (JWT) for a given Stytch Session.
# The type of this field is +String+.
# member_session::
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
# The type of this field is +MemberSession+ (+object+).
# organization::
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
# The type of this field is +Organization+ (+object+).
Expand All @@ -122,6 +119,9 @@ def initialize(connection)
# status_code::
# 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.
# The type of this field is +Integer+.
# member_session::
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
# The type of this field is nilable +MemberSession+ (+object+).
# mfa_required::
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
# The type of this field is nilable +MfaRequired+ (+object+).
Expand Down Expand Up @@ -265,7 +265,7 @@ def login_or_signup(
post_request('/v1/b2b/magic_links/email/login_or_signup', request, headers)
end

# 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.
# Send an invite email to a new to join an. 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.
#
# The magic link invite will be valid for 1 week.
#
Expand Down
13 changes: 8 additions & 5 deletions lib/stytch/b2b_oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ def initialize(connection)
@discovery = StytchB2B::OAuth::Discovery.new(@connection)
end

# 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.
# Authenticate a given a `token`. This endpoint verifies that the member completed the 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.
#
# 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.
# If the Member is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
# 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.
# 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.
# The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
#
# If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
#
# 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`, and an `intermediate_session_token` will be returned.
# 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.
#
# We’re actively accepting requests for new OAuth providers! Please [email us](mailto:[email protected]) or [post in our community](https://stytch.com/docs/b2b/resources) if you are looking for an OAuth provider that is not currently supported.
#
# == Parameters:
Expand Down Expand Up @@ -62,7 +65,7 @@ def initialize(connection)
# A base64url encoded one time secret used to validate that the request starts and ends on the same device.
# The type of this field is nilable +String+.
# locale::
# 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.
# 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.
#
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
#
Expand Down Expand Up @@ -128,7 +131,7 @@ def initialize(connection)
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
# The type of this field is nilable +MfaRequired+ (+object+).
# primary_required::
# (no documentation yet)
# Information about the primary authentication requirements of the Organization.
# The type of this field is nilable +PrimaryRequired+ (+object+).
def authenticate(
oauth_token:,
Expand Down Expand Up @@ -162,7 +165,7 @@ def initialize(connection)
@connection = connection
end

# 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.
# Authenticates the Discovery 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.
#
# == Parameters:
# discovery_oauth_token::
Expand Down
22 changes: 11 additions & 11 deletions lib/stytch/b2b_organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def initialize(connection)
@members = StytchB2B::Organizations::Members.new(@connection)
end

# Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
# Creates an. An `organization_name` and a unique `organization_slug` are required.
#
# By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
#
Expand Down Expand Up @@ -214,7 +214,7 @@ def create(
post_request('/v1/b2b/organizations', request, headers)
end

# Returns an Organization specified by `organization_id`.
# Returns an specified by `organization_id`.
#
# == Parameters:
# organization_id::
Expand All @@ -241,7 +241,7 @@ def get(
get_request(request, headers)
end

# Updates an Organization specified by `organization_id`. An Organization must always have at least one auth setting set to either `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
# Updates an specified by `organization_id`. An Organization must always have at least one auth setting set to either `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
#
# *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
#
Expand Down Expand Up @@ -451,7 +451,7 @@ def update(
put_request("/v1/b2b/organizations/#{organization_id}", request, headers)
end

# Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted.
# Deletes an specified by `organization_id`. All Members of the Organization will also be deleted.
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -712,7 +712,7 @@ def initialize(connection)
@oauth_providers = StytchB2B::Organizations::Members::OAuthProviders.new(@connection)
end

# Updates a Member specified by `organization_id` and `member_id`.
# Updates a specified by `organization_id` and `member_id`.
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -835,7 +835,7 @@ def update(
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request, headers)
end

# Deletes a Member specified by `organization_id` and `member_id`.
# Deletes a specified by `organization_id` and `member_id`.
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -869,7 +869,7 @@ def delete(
delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", headers)
end

# Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`.
# Reactivates a deleted's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`. This endpoint will only work for Members with at least one verified email where their `email_address_verified` is `true`.
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -911,7 +911,7 @@ def reactivate(
put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request, headers)
end

# Delete a Member's MFA phone number.
# Delete a's MFA phone number.
#
# To change a Member's phone number, you must first call this endpoint to delete the existing phone number.
#
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def search(
post_request('/v1/b2b/organizations/members/search', request, headers)
end

# Delete a Member's password.
# Delete a's password.
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def dangerously_get(
get_request(request, headers)
end

# Unlinks a retired email address from a Member specified by their `organization_id` and `member_id`. The email address
# Unlinks a retired email address from a specified by their `organization_id` and `member_id`. The email address
# to be retired can be identified in the request body by either its `email_id`, its `email_address`, or both. If using
# both identifiers they must refer to the same email.
#
Expand Down Expand Up @@ -1199,7 +1199,7 @@ def unlink_retired_email(
post_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/unlink_retired_email", request, headers)
end

# Creates a Member. An `organization_id` and `email_address` are required.
# Creates a. An `organization_id` and `email_address` are required.
#
# == Parameters:
# organization_id::
Expand Down
Loading

0 comments on commit fc1a06c

Please sign in to comment.