stytch 0.1.19 → 1.0.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 +18 -33
- data/lib/stytch/endpoints/otp.rb +56 -0
- data/lib/stytch/endpoints/user.rb +26 -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: f31f4c1727653f8dbdd402bb9e97d31ed7893f537c7f98923b3abfa6d1bbcc14
|
4
|
+
data.tar.gz: a3cdadaa143fcfc4e0d72b1d0f0e35246a254ff8482c56627fa6d7cb6cb2e898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56aec4b2699da311092641a43150259a8315ff6c53a460377910dddebffb8c5f02986481a8ef9b8851bb40e25dfb46805b058055bef59b68d6a1d1b688c438fc
|
7
|
+
data.tar.gz: 07c8003263f90593c7c9e86920b8d866621e2890fb477e4d3b05eeb80c56b23c2cfab5913db80b76fe0b4be8d6260e26ce877f2000e8e3686515fce6a5867e5b
|
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
|
|
@@ -3,37 +3,22 @@ module Stytch
|
|
3
3
|
module Magic
|
4
4
|
PATH = "/v1/magic_links".freeze
|
5
5
|
|
6
|
-
def send_magic(
|
7
|
-
method_id:,
|
8
|
-
user_id:,
|
9
|
-
magic_link_url:,
|
10
|
-
expiration_minutes:,
|
11
|
-
attributes: {}
|
12
|
-
)
|
13
|
-
request = {
|
14
|
-
method_id: method_id,
|
15
|
-
user_id: user_id,
|
16
|
-
magic_link_url: magic_link_url,
|
17
|
-
expiration_minutes: expiration_minutes,
|
18
|
-
}
|
19
|
-
|
20
|
-
request[:attributes] = attributes if attributes != {}
|
21
|
-
|
22
|
-
post("#{PATH}/send", request)
|
23
|
-
end
|
24
|
-
|
25
6
|
def send_magic_by_email(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
7
|
+
email:,
|
8
|
+
login_magic_link_url:,
|
9
|
+
signup_magic_link_url:,
|
10
|
+
login_expiration_minutes: nil,
|
11
|
+
signup_expiration_minutes: nil,
|
12
|
+
attributes: {}
|
30
13
|
)
|
31
14
|
request = {
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
email: email,
|
16
|
+
login_magic_link_url: login_magic_link_url,
|
17
|
+
signup_magic_link_url: signup_magic_link_url,
|
35
18
|
}
|
36
19
|
|
20
|
+
request[:login_expiration_minutes] = login_expiration_minutes if login_expiration_minutes != nil
|
21
|
+
request[:signup_expiration_minutes] = signup_expiration_minutes if signup_expiration_minutes != nil
|
37
22
|
request[:attributes] = attributes if attributes != {}
|
38
23
|
|
39
24
|
post("#{PATH}/send_by_email", request)
|
@@ -65,18 +50,18 @@ module Stytch
|
|
65
50
|
|
66
51
|
def invite_by_email(
|
67
52
|
email:,
|
68
|
-
|
69
|
-
|
53
|
+
invite_magic_link_url:,
|
54
|
+
invite_expiration_minutes: nil,
|
70
55
|
attributes: {},
|
71
56
|
name: {}
|
72
57
|
)
|
73
58
|
|
74
59
|
request = {
|
75
60
|
email: email,
|
76
|
-
|
61
|
+
invite_magic_link_url: invite_magic_link_url,
|
77
62
|
}
|
78
63
|
|
79
|
-
request[:
|
64
|
+
request[:invite_expiration_minutes] = invite_expiration_minutes if invite_expiration_minutes != nil
|
80
65
|
request[:attributes] = attributes if attributes != {}
|
81
66
|
request[:name] = name if name != {}
|
82
67
|
|
@@ -95,9 +80,9 @@ module Stytch
|
|
95
80
|
end
|
96
81
|
|
97
82
|
def authenticate_magic(
|
98
|
-
|
99
|
-
|
100
|
-
|
83
|
+
token:,
|
84
|
+
attributes: {},
|
85
|
+
options: {}
|
101
86
|
)
|
102
87
|
request = {}
|
103
88
|
|
@@ -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,16 @@ module Stytch
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_user(
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
email: nil,
|
26
|
+
phone_number: nil,
|
27
|
+
name: {},
|
28
|
+
create_user_as_pending: false,
|
29
|
+
attributes: {}
|
28
30
|
)
|
29
31
|
request = {
|
30
32
|
email: email,
|
33
|
+
phone_number: phone_number,
|
34
|
+
create_user_as_pending: create_user_as_pending
|
31
35
|
}
|
32
36
|
|
33
37
|
request[:name] = name if name != {}
|
@@ -40,10 +44,12 @@ module Stytch
|
|
40
44
|
user_id:,
|
41
45
|
name: {},
|
42
46
|
emails: [],
|
47
|
+
phone_numbers: [],
|
43
48
|
attributes: {}
|
44
49
|
)
|
45
50
|
request = {
|
46
|
-
|
51
|
+
emails: format_emails(emails),
|
52
|
+
phone_numbers: format_phone_numbers(phone_numbers),
|
47
53
|
}
|
48
54
|
|
49
55
|
request[:name] = name if name != {}
|
@@ -57,10 +63,15 @@ module Stytch
|
|
57
63
|
end
|
58
64
|
|
59
65
|
def delete_user_email(
|
60
|
-
|
61
|
-
|
66
|
+
email_id:
|
67
|
+
)
|
68
|
+
delete("#{PATH}/emails/#{email_id}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def delete_user_phone_number(
|
72
|
+
phone_id:
|
62
73
|
)
|
63
|
-
delete("#{PATH}
|
74
|
+
delete("#{PATH}/phone_numbers/#{phone_id}")
|
64
75
|
end
|
65
76
|
|
66
77
|
private
|
@@ -70,6 +81,12 @@ module Stytch
|
|
70
81
|
emails.each { |email| e << { email: email} }
|
71
82
|
e
|
72
83
|
end
|
84
|
+
|
85
|
+
def format_phone_numbers(phone_numbers)
|
86
|
+
p = []
|
87
|
+
phone_numbers.each { |phone_number| p << { phone_number: phone_number} }
|
88
|
+
p
|
89
|
+
end
|
73
90
|
end
|
74
91
|
end
|
75
92
|
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: 1.0.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-06-01 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: []
|