onfido 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/onfido/resource.rb +9 -5
- data/lib/onfido/resources/document.rb +1 -1
- data/lib/onfido/resources/live_photo.rb +1 -1
- data/lib/onfido/version.rb +1 -1
- data/spec/support/fake_onfido_api.rb +10 -1
- metadata +2 -3
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 601240f564ef7c2e14fa481011fd428d3ee46234e877387f5dee8e369181bde7
|
4
|
+
data.tar.gz: 4d6808f5c9ed80267b73f54907619cc548924d8e62cc36909b8eb6acb1e71226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 458f2220666b891e81034ac34cd49781d950454dbe2ed1e528c5f6a000fa327903cb6b3d49959f0e0c788dfd272770d20a995396b6457c697c04b3f49667f762
|
7
|
+
data.tar.gz: 16c4524637abf578ce72cc66a4e94903d945599d5ccfb8bf2aa057a59763c5ad0f2550dc708cdba85092a3b25117dd3107fb7257148f2665590733f9f161d9cc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,7 @@ onfido = Onfido::API.new(
|
|
76
76
|
|
77
77
|
## Verifying webhooks
|
78
78
|
|
79
|
-
Each webhook endpoint has a secret token, generated automatically and [exposed](https://onfido.com
|
79
|
+
Each webhook endpoint has a secret token, generated automatically and [exposed](https://documentation.onfido.com/#register-webhook) in the API. When sending a request, Onfido includes a signature computed using the request body and this token in the `X-SHA2-Signature` header.
|
80
80
|
|
81
81
|
You should compare this provided signature to one you generate yourself with the token to verify that a webhook is a genuine request from Onfido.
|
82
82
|
|
@@ -90,7 +90,7 @@ else
|
|
90
90
|
end
|
91
91
|
```
|
92
92
|
|
93
|
-
Read more at https://onfido.com/
|
93
|
+
Read more at https://developers.onfido.com/guide/manual-webhook-signature-verification#webhook-security
|
94
94
|
|
95
95
|
## Contributing
|
96
96
|
|
data/lib/onfido/resource.rb
CHANGED
@@ -4,6 +4,7 @@ module Onfido
|
|
4
4
|
class Resource # rubocop:todo Metrics/ClassLength
|
5
5
|
VALID_HTTP_METHODS = %i[get post put delete].freeze
|
6
6
|
REQUEST_TIMEOUT_HTTP_CODE = 408
|
7
|
+
ADDITIONAL_HEADERS = { 'Content-Type' => 'application/json; charset=utf-8' }.freeze
|
7
8
|
|
8
9
|
def initialize(options)
|
9
10
|
@rest_client = options.rest_client
|
@@ -14,19 +15,22 @@ module Onfido
|
|
14
15
|
attr_reader :rest_client
|
15
16
|
|
16
17
|
def get(path:)
|
17
|
-
handle_request { rest_client[path].get }
|
18
|
+
handle_request { rest_client[path].get(ADDITIONAL_HEADERS) }
|
18
19
|
end
|
19
20
|
|
20
|
-
def post(path:, payload: nil)
|
21
|
-
|
21
|
+
def post(path:, payload: nil, send_json: true)
|
22
|
+
parsed_payload = send_json ? payload.to_json : payload
|
23
|
+
additional_headers = send_json ? ADDITIONAL_HEADERS : {}
|
24
|
+
|
25
|
+
handle_request { rest_client[path].post(parsed_payload, additional_headers) }
|
22
26
|
end
|
23
27
|
|
24
28
|
def put(path:, payload: nil)
|
25
|
-
handle_request { rest_client[path].put(payload) }
|
29
|
+
handle_request { rest_client[path].put(payload.to_json, ADDITIONAL_HEADERS) }
|
26
30
|
end
|
27
31
|
|
28
32
|
def delete(path:)
|
29
|
-
handle_request { rest_client[path].delete }
|
33
|
+
handle_request { rest_client[path].delete(ADDITIONAL_HEADERS) }
|
30
34
|
end
|
31
35
|
|
32
36
|
def handle_request
|
data/lib/onfido/version.rb
CHANGED
@@ -9,6 +9,16 @@ RSpec.shared_context 'fake onfido api' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength
|
12
|
+
before do
|
13
|
+
begin
|
14
|
+
if request.content_type == "application/json; charset=utf-8"
|
15
|
+
body_parameters = JSON.parse(request.body.read)
|
16
|
+
params.merge!(body_parameters) if body_parameters
|
17
|
+
end
|
18
|
+
rescue JSON::ParserError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
get '/v3.2/addresses/pick' do
|
13
23
|
json_response(200, 'addresses.json')
|
14
24
|
end
|
@@ -155,7 +165,6 @@ class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength
|
|
155
165
|
end
|
156
166
|
|
157
167
|
delete '/v3.2/webhooks/:id' do
|
158
|
-
content_type 'application/json; charset=utf-8'
|
159
168
|
status 204
|
160
169
|
end
|
161
170
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onfido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onfido
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -122,7 +122,6 @@ files:
|
|
122
122
|
- ".gitignore"
|
123
123
|
- ".rspec"
|
124
124
|
- ".rubocop.yml"
|
125
|
-
- ".travis.yml"
|
126
125
|
- CHANGELOG.md
|
127
126
|
- Gemfile
|
128
127
|
- LICENSE
|