stytch 0.1.16 → 0.1.21
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 +10 -6
- data/lib/stytch/endpoints/otp.rb +56 -0
- data/lib/stytch/endpoints/user.rb +18 -2
- data/lib/stytch/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f7f81b30c19471d94ea6c9c3dac52b2e50485bedd40429b66e395dd272aa2ee
|
4
|
+
data.tar.gz: 49ea0b78ec5b829011f2d3b2519b5d8abb1327d913ec7eb9bc678edd7bbe1976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 510b3a0466324f2349198f92ebb316e851d059f57f28ea2f349ac72d49b3ba01d721362cd613236b792472ade599bc6b2773d3f5c77f1e6844095a7d846bb3b8
|
7
|
+
data.tar.gz: a260451b3ed384fcec781780bde436699ac4ebb2ea24d8bc55f594cf1bb8982583f22d58dc5fe4dcdf9de6da7adfbb333f4c989f4ed5d0b75dc6c1dca2486df7
|
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
|
|
@@ -7,16 +7,16 @@ module Stytch
|
|
7
7
|
method_id:,
|
8
8
|
user_id:,
|
9
9
|
magic_link_url:,
|
10
|
-
expiration_minutes
|
10
|
+
expiration_minutes: nil,
|
11
11
|
attributes: {}
|
12
12
|
)
|
13
13
|
request = {
|
14
14
|
method_id: method_id,
|
15
15
|
user_id: user_id,
|
16
16
|
magic_link_url: magic_link_url,
|
17
|
-
expiration_minutes: expiration_minutes,
|
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)
|
@@ -25,15 +25,15 @@ module Stytch
|
|
25
25
|
def send_magic_by_email(
|
26
26
|
email:,
|
27
27
|
magic_link_url:,
|
28
|
-
expiration_minutes
|
28
|
+
expiration_minutes: nil,
|
29
29
|
attributes: {}
|
30
30
|
)
|
31
31
|
request = {
|
32
32
|
email: email,
|
33
33
|
magic_link_url: magic_link_url,
|
34
|
-
expiration_minutes: expiration_minutes,
|
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
|
@@ -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
|
@@ -7,7 +7,7 @@ module Stytch
|
|
7
7
|
get("#{PATH}/#{user_id}")
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def get_pending_users(
|
11
11
|
limit: nil,
|
12
12
|
starting_after_id: nil
|
13
13
|
)
|
@@ -16,18 +16,20 @@ module Stytch
|
|
16
16
|
starting_after_id: starting_after_id,
|
17
17
|
}
|
18
18
|
|
19
|
-
request = request_with_query_params("#{PATH}/
|
19
|
+
request = request_with_query_params("#{PATH}/pending", query_params)
|
20
20
|
|
21
21
|
get(request)
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_user(
|
25
25
|
email:,
|
26
|
+
phone_number: nil,
|
26
27
|
name: {},
|
27
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 != {}
|
@@ -63,6 +67,12 @@ module Stytch
|
|
63
67
|
delete("#{PATH}/#{user_id}/emails/#{email}")
|
64
68
|
end
|
65
69
|
|
70
|
+
def delete_user_phone_number(
|
71
|
+
phone_id:
|
72
|
+
)
|
73
|
+
delete("#{PATH}/phone_numbers/#{phone_id}")
|
74
|
+
end
|
75
|
+
|
66
76
|
private
|
67
77
|
|
68
78
|
def format_emails(emails)
|
@@ -70,6 +80,12 @@ module Stytch
|
|
70
80
|
emails.each { |email| e << { email: email} }
|
71
81
|
e
|
72
82
|
end
|
83
|
+
|
84
|
+
def format_phone_numbers(phone_numbers)
|
85
|
+
p = []
|
86
|
+
phone_numbers.each { |phone_number| p << { phone_number: phone_number} }
|
87
|
+
p
|
88
|
+
end
|
73
89
|
end
|
74
90
|
end
|
75
91
|
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.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alex-stytch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -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
|