stytch 3.3.0 → 3.6.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: c8df42027eb062c7be0ddfbe1f1ee11eece832c7ca442391421f7355a072c77e
4
- data.tar.gz: 8df5887ad55b4f1c32efdcccf1873ffd371c4d2df3278ffbf290b1868cc56dad
3
+ metadata.gz: 4b0df049845701e13ae486eaf2031c118115588171ff8e486c7c5a7e0c6adc58
4
+ data.tar.gz: 7532843bccf0d29542b3a2358969085fc8faf9800010770b8d288d624713a0bf
5
5
  SHA512:
6
- metadata.gz: fec2e73072c90bfc9d5d8c0ff7c29ccbb41e9979d117b1f5a91f2492a83a1f576390debf250a4e17d767a65d708799f48a4222ec79d4bddf27b79d3788f5670a
7
- data.tar.gz: 77e7d520386a75d66b9aefc5052a93094d297d0764c5d7dc0c08757e9234c63ed0ead8cc17d9dd9160b404ea11c62ace810896e9b8c7dc98fa1a965bf0b7e6b6
6
+ metadata.gz: 0777de15b4986e805daf9640e178b479e28f5954d133dc2ed11e8c21c1ab192d3eb7917bde055dc7a23836ba112f8d446f4877c7fdbb6af711ae17f974352cda
7
+ data.tar.gz: d2ae3531f577256dceecd0d7e1326f65ceda2176bc27cb301409d6bf2a87cb5a5d9740ced383d7fafe83ba9673299db714e36d745e82e859e4badb48b2b4d324
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
@@ -40,8 +42,11 @@ module Stytch
40
42
  'https://api.stytch.com'
41
43
  when :test
42
44
  'https://test.stytch.com'
45
+ when /\Ahttps?:\/\//
46
+ # If this is a string that looks like a URL, assume it's an internal development URL.
47
+ env
43
48
  else
44
- raise ArgumentError, "Invalid value for env (#{@env}): should be live or test"
49
+ raise ArgumentError, "Invalid value for env (#{env}): should be :live or :test"
45
50
  end
46
51
  end
47
52
 
@@ -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,152 @@
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
+ login_expiration_minutes: nil,
103
+ reset_password_expiration_minutes: nil,
104
+ attributes: {},
105
+ code_challenge: nil
106
+ )
107
+ request = {
108
+ email: email
109
+ }
110
+
111
+ request[:login_redirect_url] = login_redirect_url unless login_redirect_url.nil?
112
+ request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil?
113
+ request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil?
114
+ unless reset_password_expiration_minutes.nil?
115
+ request[:reset_password_expiration_minutes] =
116
+ reset_password_expiration_minutes
117
+ end
118
+ request[:attributes] = attributes if attributes != {}
119
+ request[:code_challenge] = code_challenge unless code_challenge.nil?
120
+
121
+ post_request("#{PATH}/reset/start", request)
122
+ end
123
+
124
+ def reset(
125
+ token:,
126
+ password:,
127
+ session_token: nil,
128
+ session_jwt: nil,
129
+ session_duration_minutes: nil,
130
+ session_custom_claims: nil,
131
+ attributes: {},
132
+ options: {},
133
+ code_verifier: nil
134
+ )
135
+ request = {
136
+ token: token,
137
+ password: password
138
+ }
139
+
140
+ request[:session_token] = session_token unless session_token.nil?
141
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
142
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
143
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
144
+ request[:attributes] = attributes if attributes != {}
145
+ request[:options] = options if options != {}
146
+ request[:code_verifier] = code_verifier unless code_verifier.nil?
147
+
148
+ post_request("#{PATH}/reset", request)
149
+ end
150
+ end
151
+ end
152
+ 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.3.0'
4
+ VERSION = '3.6.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.3.0
4
+ version: 3.6.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: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -92,7 +92,7 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 3.5.3
95
- description:
95
+ description:
96
96
  email:
97
97
  - support@stytch.com
98
98
  executables: []
@@ -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
@@ -132,7 +133,7 @@ licenses:
132
133
  metadata:
133
134
  homepage_uri: https://stytch.com
134
135
  source_code_uri: https://github.com/stytchauth/stytch-ruby
135
- post_install_message:
136
+ post_install_message:
136
137
  rdoc_options: []
137
138
  require_paths:
138
139
  - lib
@@ -147,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.0.3.1
151
- signing_key:
151
+ rubygems_version: 3.1.4
152
+ signing_key:
152
153
  specification_version: 4
153
154
  summary: Stytch Ruby Gem
154
155
  test_files: []