authsignal-ruby 3.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -15
- data/README.md +6 -3
- data/lib/authsignal/client.rb +15 -6
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c4fa986346960144f15616720f21828275ffabdf16a817e05cadb4ee3c33565
|
4
|
+
data.tar.gz: 0b748a47e76e7af70786179cfde9fa037188da9c6beee9d25194e47f61adf98e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dfcbd7a4ef015d250e33eebf556f1c651d440de45df9155791748d77f9668e57a40d0e27fb5091290fe178130c3dd70c09cc8aa85829855e317ab263637c5af
|
7
|
+
data.tar.gz: 9ed3d53d1cd3772b2c6744dfacf1ff1471f09e743e1b9ba102f3d731b0c39e185533bad167ceb6f536c0b77c2be49b79094e46fafca8840542dc5b73fd1eb31d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
authsignal-ruby (
|
4
|
+
authsignal-ruby (4.1.0)
|
5
5
|
faraday (>= 2)
|
6
6
|
faraday-retry (~> 2.2)
|
7
7
|
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
crack (1.0.0)
|
15
15
|
bigdecimal
|
16
16
|
rexml
|
17
|
-
diff-lcs (1.5.
|
17
|
+
diff-lcs (1.5.1)
|
18
18
|
faraday (2.12.0)
|
19
19
|
faraday-net_http (>= 2.0, < 3.4)
|
20
20
|
json
|
@@ -29,21 +29,21 @@ GEM
|
|
29
29
|
net-http (0.4.1)
|
30
30
|
uri
|
31
31
|
public_suffix (6.0.1)
|
32
|
-
rake (13.
|
32
|
+
rake (13.2.1)
|
33
33
|
rexml (3.3.8)
|
34
|
-
rspec (3.
|
35
|
-
rspec-core (~> 3.
|
36
|
-
rspec-expectations (~> 3.
|
37
|
-
rspec-mocks (~> 3.
|
38
|
-
rspec-core (3.
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-expectations (3.
|
34
|
+
rspec (3.13.0)
|
35
|
+
rspec-core (~> 3.13.0)
|
36
|
+
rspec-expectations (~> 3.13.0)
|
37
|
+
rspec-mocks (~> 3.13.0)
|
38
|
+
rspec-core (3.13.2)
|
39
|
+
rspec-support (~> 3.13.0)
|
40
|
+
rspec-expectations (3.13.3)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-mocks (3.
|
42
|
+
rspec-support (~> 3.13.0)
|
43
|
+
rspec-mocks (3.13.2)
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-support (3.
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-support (3.13.1)
|
47
47
|
uri (0.13.1)
|
48
48
|
webmock (3.24.0)
|
49
49
|
addressable (>= 2.8.0)
|
@@ -51,6 +51,7 @@ GEM
|
|
51
51
|
hashdiff (>= 0.4.0, < 2.0.0)
|
52
52
|
|
53
53
|
PLATFORMS
|
54
|
+
arm64-darwin-24
|
54
55
|
ruby
|
55
56
|
|
56
57
|
DEPENDENCIES
|
@@ -60,4 +61,4 @@ DEPENDENCIES
|
|
60
61
|
webmock (~> 3.14)
|
61
62
|
|
62
63
|
BUNDLED WITH
|
63
|
-
2.
|
64
|
+
2.5.16
|
data/README.md
CHANGED
@@ -64,6 +64,7 @@ Authsignal's server side signal API has four main api calls `track`, `get_action
|
|
64
64
|
For more details on these api calls, refer to our [official Ruby SDK docs](https://docs.authsignal.com/sdks/server/ruby#track).
|
65
65
|
|
66
66
|
Example:
|
67
|
+
|
67
68
|
```ruby
|
68
69
|
Authsignal.track user_id: 'AS_001', action: 'withdraw', idempotency_key: 'a_random_hash'
|
69
70
|
|
@@ -78,9 +79,10 @@ Authsignal.track user_id: 'AS_001', action: 'withdraw', idempotency_key: 'a_rand
|
|
78
79
|
|
79
80
|
### Response & Error handling
|
80
81
|
|
81
|
-
Authsignal
|
82
|
+
The Authsignal SDK offers two response formats. By default, its methods return the payload in hash format.
|
82
83
|
|
83
84
|
Example:
|
85
|
+
|
84
86
|
```ruby
|
85
87
|
Authsignal.enroll_verified_authenticator user_id: 'AS_001',
|
86
88
|
authenticator: {
|
@@ -96,10 +98,10 @@ Authsignal.enroll_verified_authenticator user_id: 'AS_001',
|
|
96
98
|
# }
|
97
99
|
```
|
98
100
|
|
99
|
-
All
|
100
|
-
|
101
|
+
All methods have a bang (!) counterpart that raises an Authsignal::ApiError if the request fails.
|
101
102
|
|
102
103
|
Example:
|
104
|
+
|
103
105
|
```ruby
|
104
106
|
Authsignal.enroll_verified_authenticator! user_id: 'AS_001',
|
105
107
|
authenticator: {
|
@@ -109,6 +111,7 @@ Authsignal.enroll_verified_authenticator! user_id: 'AS_001',
|
|
109
111
|
# raise:
|
110
112
|
# <Authsignal::ApiError: invalid_request status: 400, error: invalid_request, description: /body/oobChannel must be equal to one o...
|
111
113
|
```
|
114
|
+
|
112
115
|
## Development
|
113
116
|
|
114
117
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` or `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/authsignal/client.rb
CHANGED
@@ -65,14 +65,20 @@ module Authsignal
|
|
65
65
|
|
66
66
|
def validate_challenge(user_id: nil, token:, action: nil)
|
67
67
|
path = "validate"
|
68
|
+
body = { user_id: user_id, token: token, action: action }
|
68
69
|
|
69
|
-
make_request(:post, path, body:
|
70
|
+
make_request(:post, path, body: body)
|
70
71
|
end
|
71
72
|
|
72
73
|
def get_action(user_id, action, idempotency_key)
|
73
74
|
make_request(:get, "users/#{url_encode(user_id)}/actions/#{action}/#{url_encode(idempotency_key)}")
|
74
75
|
end
|
75
76
|
|
77
|
+
def update_action_state(user_id:, action:, idempotency_key:, state:)
|
78
|
+
body = { state: state }
|
79
|
+
make_request(:patch, "users/#{url_encode(user_id)}/actions/#{action}/#{url_encode(idempotency_key)}", body: body)
|
80
|
+
end
|
81
|
+
|
76
82
|
##
|
77
83
|
# TODO: delete identify?
|
78
84
|
def identify(user_id, user_payload)
|
@@ -83,16 +89,12 @@ module Authsignal
|
|
83
89
|
make_request(:post, "users/#{url_encode(user_id)}/authenticators", body: authenticator)
|
84
90
|
end
|
85
91
|
|
86
|
-
def
|
92
|
+
def delete_authenticator(user_id:, user_authenticator_id:)
|
87
93
|
make_request(:delete, "users/#{url_encode(user_id)}/authenticators/#{url_encode(user_authenticator_id)}")
|
88
94
|
end
|
89
95
|
|
90
96
|
private
|
91
97
|
|
92
|
-
def make_request(method, path, body: nil, headers: nil)
|
93
|
-
@client.public_send(method, path, body, headers)
|
94
|
-
end
|
95
|
-
|
96
98
|
def url_encode(s)
|
97
99
|
ERB::Util.url_encode(s)
|
98
100
|
end
|
@@ -108,5 +110,12 @@ module Authsignal
|
|
108
110
|
def require_api_key
|
109
111
|
Authsignal.configuration.api_secret_key || print_api_key_warning
|
110
112
|
end
|
113
|
+
|
114
|
+
def make_request(method, path, body: nil, headers: nil)
|
115
|
+
if body.is_a?(Hash)
|
116
|
+
body = body.reject { |_, v| v.nil? }
|
117
|
+
end
|
118
|
+
@client.public_send(method, path, body, headers)
|
119
|
+
end
|
111
120
|
end
|
112
121
|
end
|
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
@@ -49,14 +49,21 @@ module Authsignal
|
|
49
49
|
handle_response(response)
|
50
50
|
end
|
51
51
|
|
52
|
+
def update_action_state(user_id:, action:, idempotency_key:, state:)
|
53
|
+
# NOTE: Rely on API to respond when given invalid state
|
54
|
+
response = Client.new.update_action_state(user_id: user_id, action: action, idempotency_key: idempotency_key, state: state)
|
55
|
+
|
56
|
+
handle_response(response)
|
57
|
+
end
|
58
|
+
|
52
59
|
def enroll_verified_authenticator(user_id:, authenticator:)
|
53
60
|
response = Client.new.enroll_verified_authenticator(user_id, authenticator)
|
54
61
|
|
55
62
|
handle_response(response)
|
56
63
|
end
|
57
64
|
|
58
|
-
def
|
59
|
-
response = Client.new.
|
65
|
+
def delete_authenticator(user_id:, user_authenticator_id: )
|
66
|
+
response = Client.new.delete_authenticator(user_id: user_id, user_authenticator_id: user_authenticator_id)
|
60
67
|
|
61
68
|
handle_response(response)
|
62
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authsignal-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- justinsoong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|