stytch 2.3.0 → 2.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: 95cdc60c0add8eb1aba7e844f54ed5e9c9ed3dc26ad299870a07d897634801b6
4
- data.tar.gz: e88adcfd927ea90cfa200909e95706a765cd22c6153105a2206ee6aaa9840102
3
+ metadata.gz: 471f88289d40496c784ae4c59b23460ed0db628e98106e50dddb324a311f9957
4
+ data.tar.gz: 9292dbede554e351d20dbccf5dd62b4d4f4266a60f3a30fc7636b59c7164e905
5
5
  SHA512:
6
- metadata.gz: 435c13d8d023dc519b00ca38b1c1a3b149cc01530e71b1dedd30a4f60ca0a63064c5c226f5af48a04aff1cf4d57962783d1fa9f15ca439f6b543960b40de9b51
7
- data.tar.gz: da191a50f950473cb38337e867f3732a6263e862aa9a22245c003ecbd4586d009e0d3c5b62147e046e521ddff31e28967f533ee0937a6dddcd9b9adf929a4c6e
6
+ metadata.gz: 86c1f5fedf5dfa62e807ce98bf960330de3dbe02b06fc750a9eeee4196e13e0b0d996589d33dec08f5aa4d4dcd64cd6388eced50fd9064c709b758c377bf5c64
7
+ data.tar.gz: bcb083e45706ccdc855db519a781c2f9254ccf639a72a91f65b034d119160b2c080959efc70587913b9dcae0c62d5402f73a69611e5e6f8095e1aac2329dc349
data/README.md CHANGED
@@ -24,6 +24,17 @@ 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 (Beta)](https://stytch.com/docs/api/sessions-overview)
35
+ - [x] [WebAuthn (Beta)](https://stytch.com/docs/api/webauthn-overview)
36
+
37
+ ### Example usage
27
38
  Create an API client:
28
39
  ```ruby
29
40
  client = Stytch::Client.new(
data/lib/stytch/client.rb CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  require_relative 'users'
4
4
  require_relative 'magic_links'
5
+ require_relative 'oauth'
5
6
  require_relative 'otps'
6
7
  require_relative 'sessions'
8
+ require_relative 'webauthn'
7
9
 
8
10
  module Stytch
9
11
  class Client
10
12
  ENVIRONMENTS = %i[live test].freeze
11
13
 
12
- attr_reader :users, :magic_links, :otps, :sessions
14
+ attr_reader :users, :magic_links, :oauth, :otps, :sessions, :webauthn
13
15
 
14
16
  def initialize(env:, project_id:, secret:, &block)
15
17
  @api_host = api_host(env)
@@ -20,8 +22,10 @@ module Stytch
20
22
 
21
23
  @users = Stytch::Users.new(@connection)
22
24
  @magic_links = Stytch::MagicLinks.new(@connection)
25
+ @oauth = Stytch::OAuth.new(@connection)
23
26
  @otps = Stytch::OTPs.new(@connection)
24
27
  @sessions = Stytch::Sessions.new(@connection)
28
+ @webauthn = Stytch::WebAuthn.new(@connection)
25
29
  end
26
30
 
27
31
  private
@@ -16,6 +16,21 @@ module Stytch
16
16
  @email = Stytch::MagicLinks::Email.new(@connection)
17
17
  end
18
18
 
19
+ def create(
20
+ user_id:,
21
+ expiration_minutes: nil,
22
+ attributes: {}
23
+ )
24
+ request = {
25
+ user_id: user_id
26
+ }
27
+
28
+ request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
29
+ request[:attributes] = attributes if attributes != {}
30
+
31
+ post_request(PATH.to_s, request)
32
+ end
33
+
19
34
  def authenticate(
20
35
  token:,
21
36
  attributes: {},
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request_helper'
4
+
5
+ module Stytch
6
+ class OAuth
7
+ include Stytch::RequestHelper
8
+
9
+ PATH = '/v1/oauth'
10
+
11
+ def initialize(connection)
12
+ @connection = connection
13
+ end
14
+
15
+ def authenticate(
16
+ token:,
17
+ session_management_type: nil,
18
+ session_token: nil,
19
+ session_duration_minutes: nil
20
+ )
21
+ request = {
22
+ token: token
23
+ }
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?
27
+
28
+ post_request("#{PATH}/authenticate", request)
29
+ end
30
+ end
31
+ end
data/lib/stytch/users.rb CHANGED
@@ -83,6 +83,12 @@ 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
+
86
92
  private
87
93
 
88
94
  def format_emails(emails)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '2.3.0'
4
+ VERSION = '2.7.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.3.0
4
+ version: 2.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: 2021-09-01 00:00:00.000000000 Z
11
+ date: 2021-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -73,11 +73,13 @@ files:
73
73
  - lib/stytch/client.rb
74
74
  - lib/stytch/magic_links.rb
75
75
  - lib/stytch/middleware.rb
76
+ - lib/stytch/oauth.rb
76
77
  - lib/stytch/otps.rb
77
78
  - lib/stytch/request_helper.rb
78
79
  - lib/stytch/sessions.rb
79
80
  - lib/stytch/users.rb
80
81
  - lib/stytch/version.rb
82
+ - lib/stytch/webauthn.rb
81
83
  - stytch.gemspec
82
84
  homepage: https://stytch.com
83
85
  licenses: