authsignal-ruby 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2bf6c96e9f79775fa1d3db3deb5ec5258a8c651e1b4fb8c1c3740c3f5ebd5b6
4
- data.tar.gz: 90124d4aa0b3111cd4b52424c78b16f208d4179991e8dcfc52f48fc735483bba
3
+ metadata.gz: '05993f5ac8d8569efae1a1c17692b90216c135675c922a4ef727124ba4774b5c'
4
+ data.tar.gz: 7f1816f80f7bf7517fda22b2f5d2cc0ad9895431031b06e0dfdf52dc4065c355
5
5
  SHA512:
6
- metadata.gz: 1cb34330978dc710806be016761805b82c7cc442ab58752baf33ff62bff64a4476c7f62fce114e10f3dae144c100ae4fe05d167cd66435d3d38fdcb3adb63612
7
- data.tar.gz: 5dca5b72d6c09fa2bfe78768d451661f6bad5d1188257a6d7523f51f389956c51214af1250c2f318706274b080c9a9ada019ad2f5e246f0daface09e05351096
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 (3.0.1)
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.0)
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.0.6)
32
+ rake (13.2.1)
33
33
  rexml (3.3.8)
34
- rspec (3.11.0)
35
- rspec-core (~> 3.11.0)
36
- rspec-expectations (~> 3.11.0)
37
- rspec-mocks (~> 3.11.0)
38
- rspec-core (3.11.0)
39
- rspec-support (~> 3.11.0)
40
- rspec-expectations (3.11.0)
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.11.0)
43
- rspec-mocks (3.11.1)
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.11.0)
46
- rspec-support (3.11.0)
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.3.21
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 client come with 2 flavors of responses, by default calling the signal APIs will returns payload in hash.
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 signal APIs come with a bang(`!`) counterpart, which will raise `Authsignal::ApiError` when the request is unsuccessful.
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.
@@ -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: { user_id: user_id, token: token, action: action })
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 delete_user_authenticator(user_id:, user_authenticator_id:)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authsignal
4
- VERSION = "3.0.1"
4
+ VERSION = "4.0.0"
5
5
  end
data/lib/authsignal.rb CHANGED
@@ -55,8 +55,8 @@ module Authsignal
55
55
  handle_response(response)
56
56
  end
57
57
 
58
- def delete_user_authenticator(user_id:, user_authenticator_id: )
59
- response = Client.new.delete_user_authenticator(user_id: user_id, user_authenticator_id: user_authenticator_id)
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: 3.0.1
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-15 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday