stytch 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 471f88289d40496c784ae4c59b23460ed0db628e98106e50dddb324a311f9957
4
- data.tar.gz: 9292dbede554e351d20dbccf5dd62b4d4f4266a60f3a30fc7636b59c7164e905
3
+ metadata.gz: 36749a9c6ff78b4d5b5bbd59b4377171835c851055bddd5ba5fe71f0942aa7fc
4
+ data.tar.gz: 256e703ab279e1cb28a3492cefce9dcfc3646d16d2b7bd535230de47340a6ff1
5
5
  SHA512:
6
- metadata.gz: 86c1f5fedf5dfa62e807ce98bf960330de3dbe02b06fc750a9eeee4196e13e0b0d996589d33dec08f5aa4d4dcd64cd6388eced50fd9064c709b758c377bf5c64
7
- data.tar.gz: bcb083e45706ccdc855db519a781c2f9254ccf639a72a91f65b034d119160b2c080959efc70587913b9dcae0c62d5402f73a69611e5e6f8095e1aac2329dc349
6
+ metadata.gz: fa0b9db68ee99ac7113e04866cb50804dbc7a7b261ea515284d9ac8ff0455d8046908e700836c5452aea1eb35943c9f3aa044371b59d28eeca7a424304f1a51d
7
+ data.tar.gz: fdbdcd0555beb34785ca5ed05b7b07e48a62309908e7576192a125cdcb94245c47bb3e760e13b7feb20531cca414136f9719be1c6501c899996b31e513b8b108
data/README.md CHANGED
@@ -31,8 +31,9 @@ This client library supports all of Stytch's live products:
31
31
  - [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)
32
32
  - [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)
33
33
  - [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)
34
- - [x] [Session Management (Beta)](https://stytch.com/docs/api/sessions-overview)
34
+ - [x] [Session Management](https://stytch.com/docs/api/sessions-overview)
35
35
  - [x] [WebAuthn (Beta)](https://stytch.com/docs/api/webauthn-overview)
36
+ - [x] [Time-based one-time passcodes (TOTPs) (Beta)](https://stytch.com/docs/api/totps-overview)
36
37
 
37
38
  ### Example usage
38
39
  Create an API client:
data/lib/stytch/client.rb CHANGED
@@ -5,13 +5,14 @@ require_relative 'magic_links'
5
5
  require_relative 'oauth'
6
6
  require_relative 'otps'
7
7
  require_relative 'sessions'
8
+ require_relative 'totps'
8
9
  require_relative 'webauthn'
9
10
 
10
11
  module Stytch
11
12
  class Client
12
13
  ENVIRONMENTS = %i[live test].freeze
13
14
 
14
- attr_reader :users, :magic_links, :oauth, :otps, :sessions, :webauthn
15
+ attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn
15
16
 
16
17
  def initialize(env:, project_id:, secret:, &block)
17
18
  @api_host = api_host(env)
@@ -25,6 +26,7 @@ module Stytch
25
26
  @oauth = Stytch::OAuth.new(@connection)
26
27
  @otps = Stytch::OTPs.new(@connection)
27
28
  @sessions = Stytch::Sessions.new(@connection)
29
+ @totps = Stytch::TOTPs.new(@connection)
28
30
  @webauthn = Stytch::WebAuthn.new(@connection)
29
31
  end
30
32
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request_helper'
4
+
5
+ module Stytch
6
+ class TOTPs
7
+ include Stytch::RequestHelper
8
+
9
+ PATH = '/v1/totps'
10
+
11
+ def initialize(connection)
12
+ @connection = connection
13
+ end
14
+
15
+ def create(
16
+ user_id:,
17
+ expiration_minutes: nil
18
+ )
19
+ request = {
20
+ user_id: user_id,
21
+ }
22
+
23
+ request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
24
+
25
+ post_request("#{PATH}", request)
26
+ end
27
+
28
+ def authenticate(
29
+ user_id:,
30
+ totp_code:,
31
+ session_token: nil,
32
+ session_duration_minutes: nil
33
+ )
34
+ request = {
35
+ user_id: user_id,
36
+ totp_code: totp_code
37
+ }
38
+
39
+ request[:session_token] = session_token unless session_token.nil?
40
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
41
+
42
+ post_request("#{PATH}/authenticate", request)
43
+ end
44
+
45
+ def recovery_codes(
46
+ user_id:
47
+ )
48
+ request = {
49
+ user_id: user_id,
50
+ }
51
+
52
+ post_request("#{PATH}/recovery_codes", request)
53
+ end
54
+
55
+ def recover(
56
+ user_id:,
57
+ recovery_code:
58
+ )
59
+ request = {
60
+ user_id: user_id,
61
+ recovery_code: recovery_code,
62
+ }
63
+
64
+ post_request("#{PATH}/recover", request)
65
+ end
66
+ end
67
+ end
data/lib/stytch/users.rb CHANGED
@@ -89,6 +89,12 @@ module Stytch
89
89
  delete_request("#{PATH}/webauthn_registrations/#{webauthn_registration_id}")
90
90
  end
91
91
 
92
+ def delete_totp(
93
+ totp_id:
94
+ )
95
+ delete_request("#{PATH}/totps/#{totp_id}")
96
+ end
97
+
92
98
  private
93
99
 
94
100
  def format_emails(emails)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.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: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -50,7 +50,7 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '2.0'
53
- description:
53
+ description:
54
54
  email:
55
55
  - support@stytch.com
56
56
  executables: []
@@ -77,6 +77,7 @@ files:
77
77
  - lib/stytch/otps.rb
78
78
  - lib/stytch/request_helper.rb
79
79
  - lib/stytch/sessions.rb
80
+ - lib/stytch/totps.rb
80
81
  - lib/stytch/users.rb
81
82
  - lib/stytch/version.rb
82
83
  - lib/stytch/webauthn.rb
@@ -87,7 +88,7 @@ licenses:
87
88
  metadata:
88
89
  homepage_uri: https://stytch.com
89
90
  source_code_uri: https://github.com/stytchauth/stytch-ruby
90
- post_install_message:
91
+ post_install_message:
91
92
  rdoc_options: []
92
93
  require_paths:
93
94
  - lib
@@ -102,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubygems_version: 3.1.4
106
- signing_key:
106
+ rubygems_version: 3.0.3.1
107
+ signing_key:
107
108
  specification_version: 4
108
109
  summary: Stytch Ruby Gem
109
110
  test_files: []