stytch 0.1.17 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/stytch/client.rb +2 -0
- data/lib/stytch/endpoints/magic.rb +25 -21
- data/lib/stytch/endpoints/otp.rb +56 -0
- data/lib/stytch/endpoints/user.rb +24 -9
- 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: d64be302698661b1c67aa6bc25276bf60e3963f686eb8f82788652ab765c62c8
|
4
|
+
data.tar.gz: 1073eeb1593ed3289cbb86105f44785eb35f803c36a0f89a7882bdef43161e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20322948ece90536400226cf146b60695986217c9757b9cd6b786551d7d4c2d111740390a68dd447549463d55eaa46b39d1cd2f71d93b8f88784726b88193eb3
|
7
|
+
data.tar.gz: 1f736fbdd2c71ba191544e9d3ee18dc0b5468e7cd38f088a7979d5ee351fc31df32f2b366a7202f7a726900faa48036019b1deb8ad821ec69ad9b0faf2f39ec6
|
data/README.md
CHANGED
@@ -41,4 +41,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
41
|
|
42
42
|
## Code of Conduct
|
43
43
|
|
44
|
-
Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
44
|
+
Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/stytchauth/stytch-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/stytch/client.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require_relative 'endpoints/user'
|
2
2
|
require_relative 'endpoints/magic'
|
3
|
+
require_relative 'endpoints/otp'
|
3
4
|
|
4
5
|
module Stytch
|
5
6
|
class Client
|
6
7
|
include Stytch::Endpoints::User
|
7
8
|
include Stytch::Endpoints::Magic
|
9
|
+
include Stytch::Endpoints::OTP
|
8
10
|
|
9
11
|
ENVIRONMENTS = %i[live test].freeze
|
10
12
|
|
@@ -4,36 +4,36 @@ module Stytch
|
|
4
4
|
PATH = "/v1/magic_links".freeze
|
5
5
|
|
6
6
|
def send_magic(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
method_id:,
|
8
|
+
user_id:,
|
9
|
+
magic_link_url:,
|
10
|
+
expiration_minutes: nil,
|
11
|
+
attributes: {}
|
12
12
|
)
|
13
13
|
request = {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
expiration_minutes: expiration_minutes,
|
14
|
+
method_id: method_id,
|
15
|
+
user_id: user_id,
|
16
|
+
magic_link_url: magic_link_url,
|
18
17
|
}
|
19
18
|
|
19
|
+
request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
|
20
20
|
request[:attributes] = attributes if attributes != {}
|
21
21
|
|
22
22
|
post("#{PATH}/send", request)
|
23
23
|
end
|
24
24
|
|
25
25
|
def send_magic_by_email(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
email:,
|
27
|
+
magic_link_url:,
|
28
|
+
expiration_minutes: nil,
|
29
|
+
attributes: {}
|
30
30
|
)
|
31
31
|
request = {
|
32
|
-
|
33
|
-
|
34
|
-
expiration_minutes: expiration_minutes,
|
32
|
+
email: email,
|
33
|
+
magic_link_url: magic_link_url,
|
35
34
|
}
|
36
35
|
|
36
|
+
request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
|
37
37
|
request[:attributes] = attributes if attributes != {}
|
38
38
|
|
39
39
|
post("#{PATH}/send_by_email", request)
|
@@ -45,13 +45,15 @@ module Stytch
|
|
45
45
|
signup_magic_link_url:,
|
46
46
|
login_expiration_minutes: nil,
|
47
47
|
signup_expiration_minutes: nil,
|
48
|
-
attributes: {}
|
48
|
+
attributes: {},
|
49
|
+
create_user_as_pending: false
|
49
50
|
)
|
50
51
|
|
51
52
|
request = {
|
52
53
|
email: email,
|
53
54
|
login_magic_link_url: login_magic_link_url,
|
54
55
|
signup_magic_link_url: signup_magic_link_url,
|
56
|
+
create_user_as_pending: create_user_as_pending,
|
55
57
|
}
|
56
58
|
|
57
59
|
request[:login_expiration_minutes] = login_expiration_minutes if login_expiration_minutes != nil
|
@@ -65,7 +67,8 @@ module Stytch
|
|
65
67
|
email:,
|
66
68
|
magic_link_url:,
|
67
69
|
expiration_minutes: nil,
|
68
|
-
attributes: {}
|
70
|
+
attributes: {},
|
71
|
+
name: {}
|
69
72
|
)
|
70
73
|
|
71
74
|
request = {
|
@@ -75,6 +78,7 @@ module Stytch
|
|
75
78
|
|
76
79
|
request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
|
77
80
|
request[:attributes] = attributes if attributes != {}
|
81
|
+
request[:name] = name if name != {}
|
78
82
|
|
79
83
|
post("#{PATH}/invite_by_email", request)
|
80
84
|
end
|
@@ -91,9 +95,9 @@ module Stytch
|
|
91
95
|
end
|
92
96
|
|
93
97
|
def authenticate_magic(
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
token:,
|
99
|
+
attributes: {},
|
100
|
+
options: {}
|
97
101
|
)
|
98
102
|
request = {}
|
99
103
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Stytch
|
2
|
+
module Endpoints
|
3
|
+
module OTP
|
4
|
+
PATH = "/v1/otp".freeze
|
5
|
+
|
6
|
+
def send_otp_by_sms(
|
7
|
+
phone_number:,
|
8
|
+
expiration_minutes: nil,
|
9
|
+
attributes: {}
|
10
|
+
)
|
11
|
+
request = {
|
12
|
+
phone_number: phone_number,
|
13
|
+
expiration_minutes: expiration_minutes,
|
14
|
+
}
|
15
|
+
|
16
|
+
request[:attributes] = attributes if attributes != {}
|
17
|
+
|
18
|
+
post("#{PATH}/send_by_sms", request)
|
19
|
+
end
|
20
|
+
|
21
|
+
def login_or_create_user_by_sms(
|
22
|
+
phone_number:,
|
23
|
+
expiration_minutes: nil,
|
24
|
+
attributes: {},
|
25
|
+
create_user_as_pending: false
|
26
|
+
)
|
27
|
+
request = {
|
28
|
+
phone_number: phone_number,
|
29
|
+
expiration_minutes: expiration_minutes,
|
30
|
+
create_user_as_pending: create_user_as_pending
|
31
|
+
}
|
32
|
+
|
33
|
+
request[:attributes] = attributes if attributes != {}
|
34
|
+
|
35
|
+
post("#{PATH}/login_or_create", request)
|
36
|
+
end
|
37
|
+
|
38
|
+
def authenticate_otp(
|
39
|
+
method_id:,
|
40
|
+
code:,
|
41
|
+
attributes: {},
|
42
|
+
options: {}
|
43
|
+
)
|
44
|
+
request = {
|
45
|
+
method_id: method_id,
|
46
|
+
code: code,
|
47
|
+
}
|
48
|
+
|
49
|
+
request[:attributes] = attributes if attributes != {}
|
50
|
+
request[:options] = options if options != {}
|
51
|
+
|
52
|
+
post("#{PATH}/authenticate", request)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -8,8 +8,8 @@ module Stytch
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def get_pending_users(
|
11
|
-
|
12
|
-
|
11
|
+
limit: nil,
|
12
|
+
starting_after_id: nil
|
13
13
|
)
|
14
14
|
query_params = {
|
15
15
|
limit: limit,
|
@@ -22,12 +22,14 @@ module Stytch
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_user(
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
email:,
|
26
|
+
phone_number: nil,
|
27
|
+
name: {},
|
28
|
+
attributes: {}
|
28
29
|
)
|
29
30
|
request = {
|
30
31
|
email: email,
|
32
|
+
phone_number: phone_number
|
31
33
|
}
|
32
34
|
|
33
35
|
request[:name] = name if name != {}
|
@@ -40,10 +42,12 @@ module Stytch
|
|
40
42
|
user_id:,
|
41
43
|
name: {},
|
42
44
|
emails: [],
|
45
|
+
phone_numbers: [],
|
43
46
|
attributes: {}
|
44
47
|
)
|
45
48
|
request = {
|
46
|
-
|
49
|
+
emails: format_emails(emails),
|
50
|
+
phone_numbers: format_phone_numbers(phone_numbers),
|
47
51
|
}
|
48
52
|
|
49
53
|
request[:name] = name if name != {}
|
@@ -57,10 +61,15 @@ module Stytch
|
|
57
61
|
end
|
58
62
|
|
59
63
|
def delete_user_email(
|
60
|
-
|
61
|
-
|
64
|
+
email_id:
|
65
|
+
)
|
66
|
+
delete("#{PATH}/emails/#{email_id}")
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete_user_phone_number(
|
70
|
+
phone_id:
|
62
71
|
)
|
63
|
-
delete("#{PATH}
|
72
|
+
delete("#{PATH}/phone_numbers/#{phone_id}")
|
64
73
|
end
|
65
74
|
|
66
75
|
private
|
@@ -70,6 +79,12 @@ module Stytch
|
|
70
79
|
emails.each { |email| e << { email: email} }
|
71
80
|
e
|
72
81
|
end
|
82
|
+
|
83
|
+
def format_phone_numbers(phone_numbers)
|
84
|
+
p = []
|
85
|
+
phone_numbers.each { |phone_number| p << { phone_number: phone_number} }
|
86
|
+
p
|
87
|
+
end
|
73
88
|
end
|
74
89
|
end
|
75
90
|
end
|
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: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alex-stytch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-06 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
|
- alex@stytch.com
|
56
56
|
executables: []
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/stytch.rb
|
71
71
|
- lib/stytch/client.rb
|
72
72
|
- lib/stytch/endpoints/magic.rb
|
73
|
+
- lib/stytch/endpoints/otp.rb
|
73
74
|
- lib/stytch/endpoints/user.rb
|
74
75
|
- lib/stytch/middleware.rb
|
75
76
|
- lib/stytch/version.rb
|
@@ -80,7 +81,7 @@ licenses:
|
|
80
81
|
metadata:
|
81
82
|
homepage_uri: https://stytch.com
|
82
83
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
83
|
-
post_install_message:
|
84
|
+
post_install_message:
|
84
85
|
rdoc_options: []
|
85
86
|
require_paths:
|
86
87
|
- lib
|
@@ -95,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
99
|
-
signing_key:
|
99
|
+
rubygems_version: 3.1.4
|
100
|
+
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: Stytch Ruby Gem
|
102
103
|
test_files: []
|