stytch 9.10.0 → 9.11.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: 4023ae6cace52f9372e689380961ea0720c243425f8ed54b17f56dd24cb5395a
4
- data.tar.gz: 0bd37c0c1b7d57c50ea7150aee027b88dbc59bab2ceafc4b43253b8d7db837d9
3
+ metadata.gz: 5c0d28f978709f9fd734d22ec07b9ead2cff5784bf2236e6f7a814ac6112bd4f
4
+ data.tar.gz: 99d3ef7c666a37a4bdb62717e4f95f10d5e62a5b4acdd30b53b1bc3b8bcc2fa3
5
5
  SHA512:
6
- metadata.gz: 962257a3f4012c7ff59140a8d9adb0b0bdff54a3038b9cf5e9410ec24bfc3361daae2cf0100f21cf3c7b4c7f9bf4ac312082fda641a4f089a2931e75beea8677
7
- data.tar.gz: d2f9fb55899bb104dcd12e34b1c662362490d2c2175607b61ed7a5505051b844df61aaea422bd7fbb5e4ca2aa43b3e436056ab8f4d0affa16016de81ec88a105
6
+ metadata.gz: 5a313477adea0a21456f16ab46658d2cd2a218414a4b36bea7078be9c35b7c703bbab26b3453906ec0e0f3cf718230c002c92335bf43174a82018dd4125a0173
7
+ data.tar.gz: 016de94dc4b6eefac4f061e03f6269088fb5e5936a2fcf43085f96ee278e0859a190a81e8ccee361da8925862509fc9d3f84e5ab46b03fc030a997ae428a8e39
@@ -11,12 +11,13 @@ require_relative 'request_helper'
11
11
  module StytchB2B
12
12
  class OTPs
13
13
  include Stytch::RequestHelper
14
- attr_reader :sms
14
+ attr_reader :sms, :email
15
15
 
16
16
  def initialize(connection)
17
17
  @connection = connection
18
18
 
19
19
  @sms = StytchB2B::OTPs::Sms.new(@connection)
20
+ @email = StytchB2B::OTPs::Email.new(@connection)
20
21
  end
21
22
 
22
23
  class Sms
@@ -237,5 +238,307 @@ module StytchB2B
237
238
  post_request('/v1/b2b/otps/sms/authenticate', request, headers)
238
239
  end
239
240
  end
241
+
242
+ class Email
243
+ include Stytch::RequestHelper
244
+ attr_reader :discovery
245
+
246
+ def initialize(connection)
247
+ @connection = connection
248
+
249
+ @discovery = StytchB2B::OTPs::Email::Discovery.new(@connection)
250
+ end
251
+
252
+ # Send either a login or signup email OTP to a Member. A new, pending, or invited Member will receive a signup email OTP. Non-active members will have a pending status until they successfully authenticate. An active Member will receive a login email OTP.
253
+ #
254
+ # The OTP is valid for 10 minutes. Only the most recently sent OTP is valid: when an OTP is sent, all OTPs previously sent to the same email address are invalidated, even if unused or unexpired.
255
+ #
256
+ # == Parameters:
257
+ # organization_id::
258
+ # 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.
259
+ # The type of this field is +String+.
260
+ # email_address::
261
+ # The email address of the Member.
262
+ # The type of this field is +String+.
263
+ # login_template_id::
264
+ # Use a custom template for login emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for OTP - Login.
265
+ # The type of this field is nilable +String+.
266
+ # signup_template_id::
267
+ # Use a custom template for signup emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for OTP - Signup.
268
+ # The type of this field is nilable +String+.
269
+ # locale::
270
+ # 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"`.
271
+ #
272
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
273
+ #
274
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
275
+ #
276
+ # The type of this field is nilable +LoginOrSignupRequestLocale+ (string enum).
277
+ #
278
+ # == Returns:
279
+ # An object with the following fields:
280
+ # request_id::
281
+ # 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.
282
+ # The type of this field is +String+.
283
+ # member_id::
284
+ # Globally unique UUID that identifies a specific Member.
285
+ # The type of this field is +String+.
286
+ # member_created::
287
+ # A flag indicating `true` if a new Member object was created and `false` if the Member object already existed.
288
+ # The type of this field is +Boolean+.
289
+ # member::
290
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
291
+ # The type of this field is +Member+ (+object+).
292
+ # organization::
293
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
294
+ # The type of this field is +Organization+ (+object+).
295
+ # status_code::
296
+ # 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.
297
+ # The type of this field is +Integer+.
298
+ def login_or_signup(
299
+ organization_id:,
300
+ email_address:,
301
+ login_template_id: nil,
302
+ signup_template_id: nil,
303
+ locale: nil
304
+ )
305
+ headers = {}
306
+ request = {
307
+ organization_id: organization_id,
308
+ email_address: email_address
309
+ }
310
+ request[:login_template_id] = login_template_id unless login_template_id.nil?
311
+ request[:signup_template_id] = signup_template_id unless signup_template_id.nil?
312
+ request[:locale] = locale unless locale.nil?
313
+
314
+ post_request('/v1/b2b/otps/email/login_or_signup', request, headers)
315
+ end
316
+
317
+ # Authenticate a with a one-time passcode (OTP). This endpoint requires an OTP that is not expired or previously used.
318
+ # OTPs have a default expiry of 10 minutes. If the Member’s status is `pending` or `invited`, they will be updated to `active`.
319
+ # 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.
320
+ #
321
+ # 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.
322
+ # 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),
323
+ # 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.
324
+ # 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.
325
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
326
+ #
327
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
328
+ #
329
+ # == Parameters:
330
+ # organization_id::
331
+ # 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.
332
+ # The type of this field is +String+.
333
+ # email_address::
334
+ # The email address of the Member.
335
+ # The type of this field is +String+.
336
+ # code::
337
+ # The code to authenticate.
338
+ # The type of this field is +String+.
339
+ # session_token::
340
+ # A secret token for a given Stytch Session.
341
+ # The type of this field is nilable +String+.
342
+ # session_jwt::
343
+ # The JSON Web Token (JWT) for a given Stytch Session.
344
+ # The type of this field is nilable +String+.
345
+ # intermediate_session_token::
346
+ # 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.
347
+ # The type of this field is nilable +String+.
348
+ # session_duration_minutes::
349
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
350
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
351
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
352
+ #
353
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
354
+ #
355
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
356
+ #
357
+ # 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
358
+ # to use the Stytch session product, you can ignore the session fields in the response.
359
+ # The type of this field is nilable +Integer+.
360
+ # session_custom_claims::
361
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
362
+ # `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
363
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
364
+ # Total custom claims size cannot exceed four kilobytes.
365
+ # The type of this field is nilable +object+.
366
+ # locale::
367
+ # 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"`.
368
+ #
369
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
370
+ #
371
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
372
+ #
373
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
374
+ #
375
+ # == Returns:
376
+ # An object with the following fields:
377
+ # request_id::
378
+ # 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.
379
+ # The type of this field is +String+.
380
+ # member_id::
381
+ # Globally unique UUID that identifies a specific Member.
382
+ # The type of this field is +String+.
383
+ # method_id::
384
+ # The email or device involved in the authentication.
385
+ # The type of this field is +String+.
386
+ # organization_id::
387
+ # 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.
388
+ # The type of this field is +String+.
389
+ # member::
390
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
391
+ # The type of this field is +Member+ (+object+).
392
+ # session_token::
393
+ # A secret token for a given Stytch Session.
394
+ # The type of this field is +String+.
395
+ # session_jwt::
396
+ # The JSON Web Token (JWT) for a given Stytch Session.
397
+ # The type of this field is +String+.
398
+ # member_session::
399
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
400
+ # The type of this field is +MemberSession+ (+object+).
401
+ # organization::
402
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
403
+ # The type of this field is +Organization+ (+object+).
404
+ # intermediate_session_token::
405
+ # 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.
406
+ # The type of this field is +String+.
407
+ # member_authenticated::
408
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
409
+ # The type of this field is +Boolean+.
410
+ # status_code::
411
+ # 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.
412
+ # The type of this field is +Integer+.
413
+ # mfa_required::
414
+ # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
415
+ # The type of this field is nilable +MfaRequired+ (+object+).
416
+ def authenticate(
417
+ organization_id:,
418
+ email_address:,
419
+ code:,
420
+ session_token: nil,
421
+ session_jwt: nil,
422
+ intermediate_session_token: nil,
423
+ session_duration_minutes: nil,
424
+ session_custom_claims: nil,
425
+ locale: nil
426
+ )
427
+ headers = {}
428
+ request = {
429
+ organization_id: organization_id,
430
+ email_address: email_address,
431
+ code: code
432
+ }
433
+ request[:session_token] = session_token unless session_token.nil?
434
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
435
+ request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
436
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
437
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
438
+ request[:locale] = locale unless locale.nil?
439
+
440
+ post_request('/v1/b2b/otps/email/authenticate', request, headers)
441
+ end
442
+
443
+ class Discovery
444
+ include Stytch::RequestHelper
445
+
446
+ def initialize(connection)
447
+ @connection = connection
448
+ end
449
+
450
+ # Send a discovery OTP to an email address. The OTP is valid for 10 minutes. Only the most recently sent OTP is valid: when an OTP is sent, all OTPs previously sent to the same email address are invalidated, even if unused or unexpired.
451
+ #
452
+ # == Parameters:
453
+ # email_address::
454
+ # The email address to start the discovery flow for.
455
+ # The type of this field is +String+.
456
+ # login_template_id::
457
+ # Use a custom template for login emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for OTP - Login.
458
+ # The type of this field is nilable +String+.
459
+ # locale::
460
+ # 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"`.
461
+ #
462
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
463
+ #
464
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
465
+ #
466
+ # The type of this field is nilable +SendRequestLocale+ (string enum).
467
+ #
468
+ # == Returns:
469
+ # An object with the following fields:
470
+ # request_id::
471
+ # 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.
472
+ # The type of this field is +String+.
473
+ # status_code::
474
+ # 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.
475
+ # The type of this field is +Integer+.
476
+ def send(
477
+ email_address:,
478
+ login_template_id: nil,
479
+ locale: nil
480
+ )
481
+ headers = {}
482
+ request = {
483
+ email_address: email_address
484
+ }
485
+ request[:login_template_id] = login_template_id unless login_template_id.nil?
486
+ request[:locale] = locale unless locale.nil?
487
+
488
+ post_request('/v1/b2b/otps/email/discovery/send', request, headers)
489
+ end
490
+
491
+ # Authenticates the OTP and returns an intermediate session token. Intermediate session tokens can be used for various Discovery login flows and are valid for 10 minutes.
492
+ #
493
+ # == Parameters:
494
+ # email_address::
495
+ # The email address of the Member.
496
+ # The type of this field is +String+.
497
+ # code::
498
+ # The code to authenticate.
499
+ # The type of this field is +String+.
500
+ #
501
+ # == Returns:
502
+ # An object with the following fields:
503
+ # request_id::
504
+ # 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.
505
+ # The type of this field is +String+.
506
+ # intermediate_session_token::
507
+ # 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.
508
+ # The type of this field is +String+.
509
+ # email_address::
510
+ # The email address.
511
+ # The type of this field is +String+.
512
+ # discovered_organizations::
513
+ # 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.
514
+ #
515
+ # Note that Organizations will only appear here under any of the following conditions:
516
+ # 1. The end user is already a Member of the Organization.
517
+ # 2. The end user is invited to the Organization.
518
+ # 3. The end user can join the Organization because:
519
+ #
520
+ # a) The Organization allows JIT provisioning.
521
+ #
522
+ # b) The Organizations' allowed domains list contains the Member's email domain.
523
+ #
524
+ # 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).
525
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
526
+ # status_code::
527
+ # 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.
528
+ # The type of this field is +Integer+.
529
+ def authenticate(
530
+ email_address:,
531
+ code:
532
+ )
533
+ headers = {}
534
+ request = {
535
+ email_address: email_address,
536
+ code: code
537
+ }
538
+
539
+ post_request('/v1/b2b/otps/email/discovery/authenticate', request, headers)
540
+ end
541
+ end
542
+ end
240
543
  end
241
544
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '9.10.0'
4
+ VERSION = '9.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stytch
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.10.0
4
+ version: 9.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday