stytch 2.7.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/stytch/client.rb +3 -1
- data/lib/stytch/magic_links.rb +13 -13
- data/lib/stytch/totps.rb +72 -0
- data/lib/stytch/users.rb +6 -0
- data/lib/stytch/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e1189f6fb15a13e7eca082c284fd13e96297000dcd4cad735620289a34ac2f
|
4
|
+
data.tar.gz: 922aed7238ccb9f2042afad0c506ca0ceeff30d1cc2905947fec5d3513051eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5786234e98901186751ad3c142365144e1587d83aa827c1f13c4bbbec7f2093a165af5e26aacab9a27069d280885f897c03ea245e8c4dfae03dd60716eaa832
|
7
|
+
data.tar.gz: 32a2c56b4cb0327ed95e0991bbb5dd2db32eb3a3eee4f8c21aba81b540a08a04a14d38931b52b476dfcb4353c7679346c15aafdf8d056532370f02e674bae491
|
data/README.md
CHANGED
@@ -31,8 +31,9 @@ This client library supports all of Stytch's live products:
|
|
31
31
|
- [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)
|
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
|
-
- [x] [Session Management
|
34
|
+
- [x] [Session Management](https://stytch.com/docs/api/sessions-overview)
|
35
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)
|
36
37
|
|
37
38
|
### Example usage
|
38
39
|
Create an API client:
|
@@ -56,7 +57,7 @@ client.magic_links.email.login_or_create(
|
|
56
57
|
Authenticate the token from the magic link:
|
57
58
|
```ruby
|
58
59
|
client.magic_links.authenticate(
|
59
|
-
token: "
|
60
|
+
token: "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4=",
|
60
61
|
)
|
61
62
|
```
|
62
63
|
|
data/lib/stytch/client.rb
CHANGED
@@ -5,13 +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'
|
8
9
|
require_relative 'webauthn'
|
9
10
|
|
10
11
|
module Stytch
|
11
12
|
class Client
|
12
13
|
ENVIRONMENTS = %i[live test].freeze
|
13
14
|
|
14
|
-
attr_reader :users, :magic_links, :oauth, :otps, :sessions, :webauthn
|
15
|
+
attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn
|
15
16
|
|
16
17
|
def initialize(env:, project_id:, secret:, &block)
|
17
18
|
@api_host = api_host(env)
|
@@ -25,6 +26,7 @@ module Stytch
|
|
25
26
|
@oauth = Stytch::OAuth.new(@connection)
|
26
27
|
@otps = Stytch::OTPs.new(@connection)
|
27
28
|
@sessions = Stytch::Sessions.new(@connection)
|
29
|
+
@totps = Stytch::TOTPs.new(@connection)
|
28
30
|
@webauthn = Stytch::WebAuthn.new(@connection)
|
29
31
|
end
|
30
32
|
|
data/lib/stytch/magic_links.rb
CHANGED
@@ -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
|
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/totps.rb
ADDED
@@ -0,0 +1,72 @@
|
|
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
|
+
session_token: nil,
|
59
|
+
session_duration_minutes: nil
|
60
|
+
)
|
61
|
+
request = {
|
62
|
+
user_id: user_id,
|
63
|
+
recovery_code: recovery_code
|
64
|
+
}
|
65
|
+
|
66
|
+
request[:session_token] = session_token unless session_token.nil?
|
67
|
+
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
68
|
+
|
69
|
+
post_request("#{PATH}/recover", request)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/stytch/users.rb
CHANGED
data/lib/stytch/version.rb
CHANGED
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.10.1
|
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-02-17 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: []
|
@@ -77,6 +77,7 @@ 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
|
82
83
|
- lib/stytch/webauthn.rb
|
@@ -87,7 +88,7 @@ licenses:
|
|
87
88
|
metadata:
|
88
89
|
homepage_uri: https://stytch.com
|
89
90
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
90
|
-
post_install_message:
|
91
|
+
post_install_message:
|
91
92
|
rdoc_options: []
|
92
93
|
require_paths:
|
93
94
|
- lib
|
@@ -102,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
106
|
+
rubygems_version: 3.0.3
|
107
|
+
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Stytch Ruby Gem
|
109
110
|
test_files: []
|