authsignal-ruby 3.0.1 → 4.0.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 +10 -6
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +2 -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: '05993f5ac8d8569efae1a1c17692b90216c135675c922a4ef727124ba4774b5c'
|
4
|
+
data.tar.gz: 7f1816f80f7bf7517fda22b2f5d2cc0ad9895431031b06e0dfdf52dc4065c355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb669c48e8fcb98f9241b0cde59c9aba13b4f1991f83f2e6ca0b127338af6d31c123cac2d3a9dec0cafc19142fb0fe9c5a212f792fb2c5655f22d13757f1dee6
|
7
|
+
data.tar.gz: 1e2622b946b9979010eb0f34a7de0b76eda3197242d441807b1bde5a038fe6cbd6a70a9e94ef54cdad4c23d1298f5d49f3f3a6ec2a11bd47a594775467c48342
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
authsignal-ruby (
|
4
|
+
authsignal-ruby (4.0.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,8 +65,9 @@ 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)
|
@@ -83,16 +84,12 @@ module Authsignal
|
|
83
84
|
make_request(:post, "users/#{url_encode(user_id)}/authenticators", body: authenticator)
|
84
85
|
end
|
85
86
|
|
86
|
-
def
|
87
|
+
def delete_authenticator(user_id:, user_authenticator_id:)
|
87
88
|
make_request(:delete, "users/#{url_encode(user_id)}/authenticators/#{url_encode(user_authenticator_id)}")
|
88
89
|
end
|
89
90
|
|
90
91
|
private
|
91
92
|
|
92
|
-
def make_request(method, path, body: nil, headers: nil)
|
93
|
-
@client.public_send(method, path, body, headers)
|
94
|
-
end
|
95
|
-
|
96
93
|
def url_encode(s)
|
97
94
|
ERB::Util.url_encode(s)
|
98
95
|
end
|
@@ -108,5 +105,12 @@ module Authsignal
|
|
108
105
|
def require_api_key
|
109
106
|
Authsignal.configuration.api_secret_key || print_api_key_warning
|
110
107
|
end
|
108
|
+
|
109
|
+
def make_request(method, path, body: nil, headers: nil)
|
110
|
+
if body.is_a?(Hash)
|
111
|
+
body = body.reject { |_, v| v.nil? }
|
112
|
+
end
|
113
|
+
@client.public_send(method, path, body, headers)
|
114
|
+
end
|
111
115
|
end
|
112
116
|
end
|
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
@@ -55,8 +55,8 @@ module Authsignal
|
|
55
55
|
handle_response(response)
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
response = Client.new.
|
58
|
+
def delete_authenticator(user_id:, user_authenticator_id: )
|
59
|
+
response = Client.new.delete_authenticator(user_id: user_id, user_authenticator_id: user_authenticator_id)
|
60
60
|
|
61
61
|
handle_response(response)
|
62
62
|
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.0.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-10-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|