stytch 0.1.20 → 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/lib/stytch/client.rb +2 -0
- data/lib/stytch/endpoints/otp.rb +56 -0
- data/lib/stytch/endpoints/user.rb +16 -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: 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/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
|
|
@@ -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
|
@@ -23,11 +23,13 @@ module Stytch
|
|
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04
|
11
|
+
date: 2021-05-04 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: []
|