stytch 2.5.0 → 2.9.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: 96a3001aced4c8717890e94108fa8ab11c8272f3dff64a271ec16e04fa86853d
4
- data.tar.gz: ac4224acb1e5242c783728bdfa6ce87e5349a6488d6aee789017870e0caa9749
3
+ metadata.gz: 8b1b869e6182a03431f7159bcfde6544be7d21819449f95cb53a69cc6534a433
4
+ data.tar.gz: b54b8ca4edc62df234546d6f681562b053a1b31677aa090b2ffa7577bbff318f
5
5
  SHA512:
6
- metadata.gz: fd8d2138c34c2e4d595d6c92d6c51a0df43bd8f0709b55f5fb1536274a0b6827d2ba93e5a46d2dd843352460cd6bc4e8f321255efc8ffd649867056981f4158f
7
- data.tar.gz: a86d8be0624be63f7be3748641962e10019a729f311c7d5579e577184e099b03bd3cdae5dea761c61bac5d6c3033a6453c9e09dccddba3cd1d3411c965c42ab5
6
+ metadata.gz: cb5bda40dc3bf05a2e09b0637723febf156c443587d82286fe9112739aa747f2572d9884aeed8b95a05f79d6ef16cdd9d84da50fc5bd6d7228a4a05d9e288cd9
7
+ data.tar.gz: 0ab2ec0d82e2d5cd0b1056d02209e0b4c248d2e63ce2b9820cee56fd100381b80eae0ec3e962e92f0c4b8f86725707faa750c9b3f7ce6dd87847da4cb601f7b1
data/README.md CHANGED
@@ -24,6 +24,18 @@ Or install it yourself as:
24
24
 
25
25
  You can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).
26
26
 
27
+ This client library supports all of Stytch's live products:
28
+ - [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)
29
+ - [x] [Embeddable Magic Links](https://stytch.com/docs/api/create-magic-link-overview)
30
+ - [x] [OAuth logins](https://stytch.com/docs/api/oauth-overview)
31
+ - [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)
32
+ - [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)
33
+ - [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)
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
+
38
+ ### Example usage
27
39
  Create an API client:
28
40
  ```ruby
29
41
  client = Stytch::Client.new(
data/lib/stytch/client.rb CHANGED
@@ -5,12 +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'
9
+ require_relative 'webauthn'
8
10
 
9
11
  module Stytch
10
12
  class Client
11
13
  ENVIRONMENTS = %i[live test].freeze
12
14
 
13
- attr_reader :users, :magic_links, :oauth, :otps, :sessions
15
+ attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn
14
16
 
15
17
  def initialize(env:, project_id:, secret:, &block)
16
18
  @api_host = api_host(env)
@@ -24,6 +26,8 @@ module Stytch
24
26
  @oauth = Stytch::OAuth.new(@connection)
25
27
  @otps = Stytch::OTPs.new(@connection)
26
28
  @sessions = Stytch::Sessions.new(@connection)
29
+ @totps = Stytch::TOTPs.new(@connection)
30
+ @webauthn = Stytch::WebAuthn.new(@connection)
27
31
  end
28
32
 
29
33
  private
@@ -28,7 +28,7 @@ module Stytch
28
28
  request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
29
29
  request[:attributes] = attributes if attributes != {}
30
30
 
31
- post_request(PATH.to_s, request)
31
+ post_request(PATH, request)
32
32
  end
33
33
 
34
34
  def authenticate(
@@ -61,18 +61,18 @@ module Stytch
61
61
 
62
62
  def send(
63
63
  email:,
64
- login_magic_link_url:,
65
- signup_magic_link_url:,
64
+ login_magic_link_url: nil,
65
+ signup_magic_link_url: nil,
66
66
  login_expiration_minutes: nil,
67
67
  signup_expiration_minutes: nil,
68
68
  attributes: {}
69
69
  )
70
70
  request = {
71
- email: email,
72
- login_magic_link_url: login_magic_link_url,
73
- signup_magic_link_url: signup_magic_link_url
71
+ email: email
74
72
  }
75
73
 
74
+ request[:login_magic_link_url] = login_magic_link_url unless login_magic_link_url.nil?
75
+ request[:signup_magic_link_url] = signup_magic_link_url unless signup_magic_link_url.nil?
76
76
  request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil?
77
77
  request[:signup_expiration_minutes] = signup_expiration_minutes unless signup_expiration_minutes.nil?
78
78
  request[:attributes] = attributes if attributes != {}
@@ -82,8 +82,8 @@ module Stytch
82
82
 
83
83
  def login_or_create(
84
84
  email:,
85
- login_magic_link_url:,
86
- signup_magic_link_url:,
85
+ login_magic_link_url: nil,
86
+ signup_magic_link_url: nil,
87
87
  login_expiration_minutes: nil,
88
88
  signup_expiration_minutes: nil,
89
89
  attributes: {},
@@ -91,11 +91,11 @@ module Stytch
91
91
  )
92
92
  request = {
93
93
  email: email,
94
- login_magic_link_url: login_magic_link_url,
95
- signup_magic_link_url: signup_magic_link_url,
96
94
  create_user_as_pending: create_user_as_pending
97
95
  }
98
96
 
97
+ request[:login_magic_link_url] = login_magic_link_url unless login_magic_link_url.nil?
98
+ request[:signup_magic_link_url] = signup_magic_link_url unless signup_magic_link_url.nil?
99
99
  request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil?
100
100
  request[:signup_expiration_minutes] = signup_expiration_minutes unless signup_expiration_minutes.nil?
101
101
  request[:attributes] = attributes if attributes != {}
@@ -105,16 +105,16 @@ module Stytch
105
105
 
106
106
  def invite(
107
107
  email:,
108
- invite_magic_link_url:,
108
+ invite_magic_link_url: nil,
109
109
  invite_expiration_minutes: nil,
110
110
  attributes: {},
111
111
  name: {}
112
112
  )
113
113
  request = {
114
- email: email,
115
- invite_magic_link_url: invite_magic_link_url
114
+ email: email
116
115
  }
117
116
 
117
+ request[:invite_magic_link_url] = invite_magic_link_url unless invite_magic_link_url.nil?
118
118
  request[:invite_expiration_minutes] = invite_expiration_minutes unless invite_expiration_minutes.nil?
119
119
  request[:attributes] = attributes if attributes != {}
120
120
  request[:name] = name if name != {}
data/lib/stytch/oauth.rb CHANGED
@@ -14,12 +14,16 @@ module Stytch
14
14
 
15
15
  def authenticate(
16
16
  token:,
17
- session_management_type: nil
17
+ session_management_type: nil,
18
+ session_token: nil,
19
+ session_duration_minutes: nil
18
20
  )
19
21
  request = {
20
22
  token: token
21
23
  }
22
24
  request[:session_management_type] = session_management_type unless session_management_type.nil?
25
+ request[:session_token] = session_token unless session_token.nil?
26
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
23
27
 
24
28
  post_request("#{PATH}/authenticate", request)
25
29
  end
@@ -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
@@ -83,6 +83,18 @@ module Stytch
83
83
  delete_request("#{PATH}/phone_numbers/#{phone_id}")
84
84
  end
85
85
 
86
+ def delete_webauthn_registration(
87
+ webauthn_registration_id:
88
+ )
89
+ delete_request("#{PATH}/webauthn_registrations/#{webauthn_registration_id}")
90
+ end
91
+
92
+ def delete_totp(
93
+ totp_id:
94
+ )
95
+ delete_request("#{PATH}/totps/#{totp_id}")
96
+ end
97
+
86
98
  private
87
99
 
88
100
  def format_emails(emails)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '2.5.0'
4
+ VERSION = '2.9.0'
5
5
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request_helper'
4
+
5
+ module Stytch
6
+ class WebAuthn
7
+ include Stytch::RequestHelper
8
+
9
+ PATH = '/v1/webauthn'
10
+
11
+ def initialize(connection)
12
+ @connection = connection
13
+ end
14
+
15
+ def register_start(
16
+ user_id:,
17
+ domain:,
18
+ user_agent: nil,
19
+ authenticator_type: nil
20
+ )
21
+ request = {
22
+ user_id: user_id,
23
+ domain: domain
24
+ }
25
+
26
+ request[:user_agent] = user_agent unless user_agent.nil?
27
+ request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
28
+
29
+ post_request("#{PATH}/register/start", request)
30
+ end
31
+
32
+ def register(
33
+ user_id:,
34
+ public_key_credential:
35
+ )
36
+ request = {
37
+ user_id: user_id,
38
+ public_key_credential: public_key_credential
39
+ }
40
+
41
+ post_request("#{PATH}/register", request)
42
+ end
43
+
44
+ def authenticate_start(
45
+ user_id:,
46
+ domain:
47
+ )
48
+ request = {
49
+ user_id: user_id,
50
+ domain: domain
51
+ }
52
+
53
+ post_request("#{PATH}/authenticate/start", request)
54
+ end
55
+
56
+ def authenticate(
57
+ public_key_credential:,
58
+ session_token: nil,
59
+ session_duration_minutes: nil
60
+ )
61
+ request = {
62
+ public_key_credential: public_key_credential
63
+ }
64
+
65
+ request[:session_token] = session_token unless session_token.nil?
66
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
67
+
68
+ post_request("#{PATH}/authenticate", request)
69
+ end
70
+ end
71
+ 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.5.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-15 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
@@ -77,8 +77,10 @@ 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
83
+ - lib/stytch/webauthn.rb
82
84
  - stytch.gemspec
83
85
  homepage: https://stytch.com
84
86
  licenses: