stytch 2.4.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 +4 -4
- data/README.md +12 -0
- data/lib/stytch/client.rb +7 -1
- data/lib/stytch/oauth.rb +31 -0
- data/lib/stytch/totps.rb +67 -0
- data/lib/stytch/users.rb +12 -0
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +71 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36749a9c6ff78b4d5b5bbd59b4377171835c851055bddd5ba5fe71f0942aa7fc
|
4
|
+
data.tar.gz: 256e703ab279e1cb28a3492cefce9dcfc3646d16d2b7bd535230de47340a6ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa0b9db68ee99ac7113e04866cb50804dbc7a7b261ea515284d9ac8ff0455d8046908e700836c5452aea1eb35943c9f3aa044371b59d28eeca7a424304f1a51d
|
7
|
+
data.tar.gz: fdbdcd0555beb34785ca5ed05b7b07e48a62309908e7576192a125cdcb94245c47bb3e760e13b7feb20531cca414136f9719be1c6501c899996b31e513b8b108
|
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
@@ -2,14 +2,17 @@
|
|
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 'totps'
|
9
|
+
require_relative 'webauthn'
|
7
10
|
|
8
11
|
module Stytch
|
9
12
|
class Client
|
10
13
|
ENVIRONMENTS = %i[live test].freeze
|
11
14
|
|
12
|
-
attr_reader :users, :magic_links, :otps, :sessions
|
15
|
+
attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn
|
13
16
|
|
14
17
|
def initialize(env:, project_id:, secret:, &block)
|
15
18
|
@api_host = api_host(env)
|
@@ -20,8 +23,11 @@ module Stytch
|
|
20
23
|
|
21
24
|
@users = Stytch::Users.new(@connection)
|
22
25
|
@magic_links = Stytch::MagicLinks.new(@connection)
|
26
|
+
@oauth = Stytch::OAuth.new(@connection)
|
23
27
|
@otps = Stytch::OTPs.new(@connection)
|
24
28
|
@sessions = Stytch::Sessions.new(@connection)
|
29
|
+
@totps = Stytch::TOTPs.new(@connection)
|
30
|
+
@webauthn = Stytch::WebAuthn.new(@connection)
|
25
31
|
end
|
26
32
|
|
27
33
|
private
|
data/lib/stytch/oauth.rb
ADDED
@@ -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/totps.rb
ADDED
@@ -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)
|
data/lib/stytch/version.rb
CHANGED
@@ -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.
|
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:
|
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: []
|
@@ -73,11 +73,14 @@ 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
|
80
|
+
- lib/stytch/totps.rb
|
79
81
|
- lib/stytch/users.rb
|
80
82
|
- lib/stytch/version.rb
|
83
|
+
- lib/stytch/webauthn.rb
|
81
84
|
- stytch.gemspec
|
82
85
|
homepage: https://stytch.com
|
83
86
|
licenses:
|
@@ -85,7 +88,7 @@ licenses:
|
|
85
88
|
metadata:
|
86
89
|
homepage_uri: https://stytch.com
|
87
90
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
88
|
-
post_install_message:
|
91
|
+
post_install_message:
|
89
92
|
rdoc_options: []
|
90
93
|
require_paths:
|
91
94
|
- lib
|
@@ -100,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
103
|
- !ruby/object:Gem::Version
|
101
104
|
version: '0'
|
102
105
|
requirements: []
|
103
|
-
rubygems_version: 3.1
|
104
|
-
signing_key:
|
106
|
+
rubygems_version: 3.0.3.1
|
107
|
+
signing_key:
|
105
108
|
specification_version: 4
|
106
109
|
summary: Stytch Ruby Gem
|
107
110
|
test_files: []
|