stytch 3.4.0 → 3.7.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: c4e0b5abf60607192bc55481b147a61900f775de4446bb484469a7e9f46ad9eb
4
- data.tar.gz: 997294b0104b0fc95002e2e05f373f69b9fb98b91f1767844eb4bdb8792a527d
3
+ metadata.gz: 1c12f49bd7571d1d7069b19a86c6c8375cd7aee95e8477a86b9a8a811decfae3
4
+ data.tar.gz: 5daf47770391642bb0e526745314ac507300ffc900cfcb3f5954812d8c10ad4f
5
5
  SHA512:
6
- metadata.gz: 9697278039c4a8ab9274f20a89b12f05d07afb7902621b523bbeec20865a72d513aeb3c3aeb360be59e9aec949bdca2d36e2dd6024bc16886db8296759be69f9
7
- data.tar.gz: 8ebdc8a2af442ec66779ed9014f9605f0e40b04ef292f8933379010b3bb3bffad3ab32b5cc1e70e09c695b8e82b45cb583ab3282fb86d01d8640177d7b82e1f4
6
+ metadata.gz: db55a2dc0cf8119ea731c15102282054f1d6f3523ff72b169c9603c882a33e4ace9139c445e97cc499b8048e6546284ab6272fe9eb7b27b3a34bd690c90f1c71
7
+ data.tar.gz: d6a7fb4e31097ea41f9047e661a3ba284c1d298585f9ab692231858cebfd2b92ff7113abc20cfd6a2461fc3cd26d43d781f8951603968d190c4bad5efb01eb84
data/README.md CHANGED
@@ -32,9 +32,10 @@ This client library supports all of Stytch's live products:
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
34
  - [x] [Session Management](https://stytch.com/docs/api/sessions-overview)
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)
37
- - [x] [Crypto wallets (Beta)](https://stytch.com/docs/api/crypto-wallet-overview)
35
+ - [x] [WebAuthn](https://stytch.com/docs/api/webauthn-overview)
36
+ - [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/api/totps-overview)
37
+ - [x] [Crypto wallets](https://stytch.com/docs/api/crypto-wallet-overview)
38
+ - [x] [Passwords (Beta)](https://stytch.com/docs/api/password-overview)
38
39
 
39
40
  ### Example usage
40
41
  Create an API client:
data/lib/stytch/client.rb CHANGED
@@ -8,12 +8,13 @@ require_relative 'sessions'
8
8
  require_relative 'totps'
9
9
  require_relative 'webauthn'
10
10
  require_relative 'crypto_wallets'
11
+ require_relative 'passwords'
11
12
 
12
13
  module Stytch
13
14
  class Client
14
15
  ENVIRONMENTS = %i[live test].freeze
15
16
 
16
- attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn, :crypto_wallets
17
+ attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn, :crypto_wallets, :passwords
17
18
 
18
19
  def initialize(env:, project_id:, secret:, &block)
19
20
  @api_host = api_host(env)
@@ -30,6 +31,7 @@ module Stytch
30
31
  @totps = Stytch::TOTPs.new(@connection)
31
32
  @webauthn = Stytch::WebAuthn.new(@connection)
32
33
  @crypto_wallets = Stytch::CryptoWallets.new(@connection)
34
+ @passwords = Stytch::Passwords.new(@connection)
33
35
  end
34
36
 
35
37
  private
@@ -33,7 +33,8 @@ module Stytch
33
33
  signature:,
34
34
  session_token: nil,
35
35
  session_jwt: nil,
36
- session_duration_minutes: nil
36
+ session_duration_minutes: nil,
37
+ session_custom_claims: nil
37
38
  )
38
39
  request = {
39
40
  crypto_wallet_address: crypto_wallet_address,
@@ -44,6 +45,7 @@ module Stytch
44
45
  request[:session_token] = session_token unless session_token.nil?
45
46
  request[:session_jwt] = session_jwt unless session_jwt.nil?
46
47
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
48
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
47
49
 
48
50
  post_request("#{PATH}/authenticate", request)
49
51
  end
@@ -38,6 +38,7 @@ module Stytch
38
38
  session_token: nil,
39
39
  session_jwt: nil,
40
40
  session_duration_minutes: nil,
41
+ session_custom_claims: nil,
41
42
  code_verifier: nil
42
43
  )
43
44
  request = {
@@ -49,6 +50,7 @@ module Stytch
49
50
  request[:session_token] = session_token unless session_token.nil?
50
51
  request[:session_jwt] = session_jwt unless session_jwt.nil?
51
52
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
53
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
52
54
  request[:code_verifier] = code_verifier unless code_verifier.nil?
53
55
 
54
56
  post_request("#{PATH}/authenticate", request)
data/lib/stytch/oauth.rb CHANGED
@@ -17,6 +17,7 @@ module Stytch
17
17
  session_token: nil,
18
18
  session_jwt: nil,
19
19
  session_duration_minutes: nil,
20
+ session_custom_claims: nil,
20
21
  code_verifier: nil
21
22
  )
22
23
  request = {
@@ -25,6 +26,7 @@ module Stytch
25
26
  request[:session_token] = session_token unless session_token.nil?
26
27
  request[:session_jwt] = session_jwt unless session_jwt.nil?
27
28
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
29
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
28
30
  request[:code_verifier] = code_verifier unless code_verifier.nil?
29
31
 
30
32
  post_request("#{PATH}/authenticate", request)
data/lib/stytch/otps.rb CHANGED
@@ -25,7 +25,8 @@ module Stytch
25
25
  options: {},
26
26
  session_token: nil,
27
27
  session_jwt: nil,
28
- session_duration_minutes: nil
28
+ session_duration_minutes: nil,
29
+ session_custom_claims: nil
29
30
  )
30
31
  request = {
31
32
  method_id: method_id,
@@ -37,6 +38,7 @@ module Stytch
37
38
  request[:session_token] = session_token unless session_token.nil?
38
39
  request[:session_jwt] = session_jwt unless session_jwt.nil?
39
40
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
41
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
40
42
 
41
43
  post_request("#{PATH}/authenticate", request)
42
44
  end
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request_helper'
4
+
5
+ module Stytch
6
+ class Passwords
7
+ include Stytch::RequestHelper
8
+
9
+ attr_reader :email
10
+
11
+ PATH = '/v1/passwords'
12
+
13
+ def initialize(connection)
14
+ @connection = connection
15
+
16
+ @email = Stytch::Passwords::Email.new(@connection)
17
+ end
18
+
19
+ def create(
20
+ email:,
21
+ password:,
22
+ session_duration_minutes: nil,
23
+ session_custom_claims: nil
24
+ )
25
+ request = {
26
+ email: email,
27
+ password: password
28
+ }
29
+
30
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
31
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
32
+
33
+ post_request(PATH.to_s, request)
34
+ end
35
+
36
+ def authenticate(
37
+ email:,
38
+ password:,
39
+ session_token: nil,
40
+ session_jwt: nil,
41
+ session_duration_minutes: nil,
42
+ session_custom_claims: nil
43
+ )
44
+ request = {
45
+ email: email,
46
+ password: password
47
+ }
48
+
49
+ request[:session_token] = session_token unless session_token.nil?
50
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
51
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
52
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
53
+
54
+ post_request("#{PATH}/authenticate", request)
55
+ end
56
+
57
+ def strength_check(
58
+ password:,
59
+ email: nil
60
+ )
61
+ request = {
62
+ password: password
63
+ }
64
+
65
+ request[:email] = email unless email.nil?
66
+
67
+ post_request("#{PATH}/strength_check", request)
68
+ end
69
+
70
+ def migrate(
71
+ email:,
72
+ hash:,
73
+ hash_type:,
74
+ prepend_salt: nil,
75
+ append_salt: nil
76
+ )
77
+ request = {
78
+ email: email,
79
+ hash: hash,
80
+ hash_type: hash_type
81
+ }
82
+
83
+ request[:prepend_salt] = prepend_salt unless prepend_salt.nil?
84
+ request[:append_salt] = append_salt unless append_salt.nil?
85
+
86
+ post_request("#{PATH}/migrate", request)
87
+ end
88
+
89
+ class Email
90
+ include Stytch::RequestHelper
91
+
92
+ PATH = "#{Stytch::Passwords::PATH}/email"
93
+
94
+ def initialize(connection)
95
+ @connection = connection
96
+ end
97
+
98
+ def reset_start(
99
+ email:,
100
+ login_redirect_url: nil,
101
+ reset_password_redirect_url: nil,
102
+ reset_password_expiration_minutes: nil,
103
+ attributes: {},
104
+ code_challenge: nil
105
+ )
106
+ request = {
107
+ email: email
108
+ }
109
+
110
+ request[:login_redirect_url] = login_redirect_url unless login_redirect_url.nil?
111
+ request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil?
112
+ unless reset_password_expiration_minutes.nil?
113
+ request[:reset_password_expiration_minutes] =
114
+ reset_password_expiration_minutes
115
+ end
116
+ request[:attributes] = attributes if attributes != {}
117
+ request[:code_challenge] = code_challenge unless code_challenge.nil?
118
+
119
+ post_request("#{PATH}/reset/start", request)
120
+ end
121
+
122
+ def reset(
123
+ token:,
124
+ password:,
125
+ session_token: nil,
126
+ session_jwt: nil,
127
+ session_duration_minutes: nil,
128
+ session_custom_claims: nil,
129
+ attributes: {},
130
+ options: {},
131
+ code_verifier: nil
132
+ )
133
+ request = {
134
+ token: token,
135
+ password: password
136
+ }
137
+
138
+ request[:session_token] = session_token unless session_token.nil?
139
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
140
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
141
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
142
+ request[:attributes] = attributes if attributes != {}
143
+ request[:options] = options if options != {}
144
+ request[:code_verifier] = code_verifier unless code_verifier.nil?
145
+
146
+ post_request("#{PATH}/reset", request)
147
+ end
148
+ end
149
+ end
150
+ end
@@ -33,13 +33,15 @@ module Stytch
33
33
  def authenticate(
34
34
  session_token: nil,
35
35
  session_jwt: nil,
36
- session_duration_minutes: nil
36
+ session_duration_minutes: nil,
37
+ session_custom_claims: nil
37
38
  )
38
39
  request = {}
39
40
 
40
41
  request[:session_token] = session_token unless session_token.nil?
41
42
  request[:session_jwt] = session_jwt unless session_jwt.nil?
42
43
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
44
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
43
45
 
44
46
  post_request("#{PATH}/authenticate", request)
45
47
  end
@@ -68,12 +70,14 @@ module Stytch
68
70
  def authenticate_jwt(
69
71
  session_jwt,
70
72
  max_token_age_seconds: nil,
71
- session_duration_minutes: nil
73
+ session_duration_minutes: nil,
74
+ session_custom_claims: nil
72
75
  )
73
76
  if max_token_age_seconds == 0
74
77
  return authenticate(
75
78
  session_jwt: session_jwt,
76
79
  session_duration_minutes: session_duration_minutes,
80
+ session_custom_claims: session_custom_claims,
77
81
  )
78
82
  end
79
83
 
@@ -86,6 +90,7 @@ module Stytch
86
90
  return authenticate(
87
91
  session_jwt: session_jwt,
88
92
  session_duration_minutes: session_duration_minutes,
93
+ session_custom_claims: session_custom_claims,
89
94
  )
90
95
  end
91
96
  rescue StandardError
@@ -93,6 +98,7 @@ module Stytch
93
98
  return authenticate(
94
99
  session_jwt: session_jwt,
95
100
  session_duration_minutes: session_duration_minutes,
101
+ session_custom_claims: session_custom_claims,
96
102
  )
97
103
  end
98
104
 
data/lib/stytch/totps.rb CHANGED
@@ -30,7 +30,8 @@ module Stytch
30
30
  totp_code:,
31
31
  session_token: nil,
32
32
  session_jwt: nil,
33
- session_duration_minutes: nil
33
+ session_duration_minutes: nil,
34
+ session_custom_claims: nil
34
35
  )
35
36
  request = {
36
37
  user_id: user_id,
@@ -40,6 +41,7 @@ module Stytch
40
41
  request[:session_token] = session_token unless session_token.nil?
41
42
  request[:session_jwt] = session_jwt unless session_jwt.nil?
42
43
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
44
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
43
45
 
44
46
  post_request("#{PATH}/authenticate", request)
45
47
  end
@@ -59,7 +61,8 @@ module Stytch
59
61
  recovery_code:,
60
62
  session_token: nil,
61
63
  session_jwt: nil,
62
- session_duration_minutes: nil
64
+ session_duration_minutes: nil,
65
+ session_custom_claims: nil
63
66
  )
64
67
  request = {
65
68
  user_id: user_id,
@@ -69,6 +72,7 @@ module Stytch
69
72
  request[:session_token] = session_token unless session_token.nil?
70
73
  request[:session_jwt] = session_jwt unless session_jwt.nil?
71
74
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
75
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
72
76
 
73
77
  post_request("#{PATH}/recover", request)
74
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '3.4.0'
4
+ VERSION = '3.7.0'
5
5
  end
@@ -57,7 +57,8 @@ module Stytch
57
57
  public_key_credential:,
58
58
  session_token: nil,
59
59
  session_jwt: nil,
60
- session_duration_minutes: nil
60
+ session_duration_minutes: nil,
61
+ session_custom_claims: nil
61
62
  )
62
63
  request = {
63
64
  public_key_credential: public_key_credential
@@ -66,6 +67,7 @@ module Stytch
66
67
  request[:session_token] = session_token unless session_token.nil?
67
68
  request[:session_jwt] = session_jwt unless session_jwt.nil?
68
69
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
70
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
69
71
 
70
72
  post_request("#{PATH}/authenticate", request)
71
73
  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: 3.4.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -119,6 +119,7 @@ files:
119
119
  - lib/stytch/middleware.rb
120
120
  - lib/stytch/oauth.rb
121
121
  - lib/stytch/otps.rb
122
+ - lib/stytch/passwords.rb
122
123
  - lib/stytch/request_helper.rb
123
124
  - lib/stytch/sessions.rb
124
125
  - lib/stytch/totps.rb
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.1.6
151
+ rubygems_version: 3.1.4
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: Stytch Ruby Gem