m2m_keygen 0.4.2 → 0.4.3
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 +4 -4
- data/CHANGELOG.md +10 -1
- data/Gemfile +22 -22
- data/Gemfile.lock +30 -29
- data/Guardfile +2 -2
- data/Rakefile +1 -1
- data/docs/M2mKeygen/Error.html +1 -1
- data/docs/M2mKeygen/ParamsEncoder.html +4 -4
- data/docs/M2mKeygen/RackValidator.html +12 -12
- data/docs/M2mKeygen/Signature.html +9 -9
- data/docs/M2mKeygen/Types.html +2 -2
- data/docs/M2mKeygen.html +2 -2
- data/docs/_index.html +1 -1
- data/docs/file.README.html +1 -1
- data/docs/index.html +1 -1
- data/docs/top-level-namespace.html +1 -1
- data/lib/m2m_keygen/params_encoder.rb +6 -6
- data/lib/m2m_keygen/rack_validator.rb +8 -8
- data/lib/m2m_keygen/signature.rb +9 -9
- data/lib/m2m_keygen/types/params_type.rb +1 -1
- data/lib/m2m_keygen/version.rb +1 -1
- data/lib/m2m_keygen.rb +2 -2
- data/m2m_keygen.gemspec +22 -22
- data/yarn.lock +3 -3
- 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: 97b919ad7e666502842c42a4722d99e10237288033a561943798c317fd73cbf8
|
4
|
+
data.tar.gz: 0a70ea67255c9b67dad4a07141aa7d403104edfb2dc8db4b6c82613c7565e101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a085c056d0c3ab39fef8c2d36f17b782aa5dbef6a2af6e7b7083198b72949730141e5fc20624bd757c2452aecaba5365a907b22cd88e274984605b5aaa3e46a
|
7
|
+
data.tar.gz: 7de0d94e000a63f99a0a3ee31446531fbf470b2edc769b4f320cd979c21b5b5953f573e89497658b817de9c820c34b621cdfaad20e12ab5dec22459645640557
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.4.3] - 2022-10-12
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Updated all gems + prettier
|
15
|
+
|
10
16
|
## [0.4.2] - 2022-09-05
|
11
17
|
|
12
18
|
### Changed
|
@@ -49,7 +55,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
49
55
|
|
50
56
|
- Basic skeleton for gem
|
51
57
|
|
52
|
-
[unreleased]: https://github.com/Billcorporate/m2m_keygen_ruby/compare/v0.4.
|
58
|
+
[unreleased]: https://github.com/Billcorporate/m2m_keygen_ruby/compare/v0.4.3...HEAD
|
59
|
+
[0.4.3]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.4.3
|
60
|
+
[0.4.2]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.4.2
|
61
|
+
[0.4.1]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.4.1
|
53
62
|
[0.4.0]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.4.0
|
54
63
|
[0.3.0]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.3.0
|
55
64
|
[0.2.1]: https://github.com/Billcorporate/m2m_keygen_ruby/releases/tag/v0.2.1
|
data/Gemfile
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in m2m_keygen.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
group :development do
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem
|
19
|
-
gem
|
20
|
-
gem
|
21
|
-
gem
|
22
|
-
gem
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
26
|
-
gem
|
27
|
-
gem
|
28
|
-
gem
|
29
|
-
gem
|
9
|
+
gem 'bundler'
|
10
|
+
gem 'bundler-audit', '> 0.6.0', require: false
|
11
|
+
gem 'dotenv'
|
12
|
+
gem 'faker'
|
13
|
+
gem 'guard-rspec', require: false
|
14
|
+
gem 'overcommit', require: false
|
15
|
+
gem 'prettier', require: false
|
16
|
+
gem 'pry-byebug'
|
17
|
+
gem 'rake', '~> 13.0'
|
18
|
+
gem 'rspec', '~> 3.0'
|
19
|
+
gem 'rspec_in_context', '> 1'
|
20
|
+
gem 'rubocop', '> 0.58', require: false
|
21
|
+
gem 'rubocop-faker', require: false
|
22
|
+
gem 'rubocop-performance', require: false
|
23
|
+
gem 'rubocop-sorbet', require: false
|
24
|
+
gem 'simplecov', require: false
|
25
|
+
gem 'solargraph', require: false
|
26
|
+
gem 'sorbet', require: false
|
27
|
+
gem 'tapioca', require: false
|
28
|
+
gem 'yard', require: false
|
29
|
+
gem 'yard-sorbet', require: false
|
30
30
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
m2m_keygen (0.4.
|
4
|
+
m2m_keygen (0.4.3)
|
5
5
|
rack
|
6
6
|
sorbet-runtime
|
7
7
|
zeitwerk (~> 2.6)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (7.0.
|
12
|
+
activesupport (7.0.4)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 1.6, < 2)
|
15
15
|
minitest (>= 5.1)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
docile (1.4.0)
|
29
29
|
dotenv (2.8.1)
|
30
30
|
e2mmap (0.1.0)
|
31
|
-
faker (2.
|
31
|
+
faker (2.23.0)
|
32
32
|
i18n (>= 1.8.11, < 2)
|
33
33
|
ffi (1.15.5)
|
34
34
|
formatador (1.1.0)
|
@@ -46,8 +46,9 @@ GEM
|
|
46
46
|
guard (~> 2.1)
|
47
47
|
guard-compat (~> 1.1)
|
48
48
|
rspec (>= 2.99.0, < 4.0)
|
49
|
-
haml (
|
50
|
-
temple (>= 0.8.
|
49
|
+
haml (6.0.6)
|
50
|
+
temple (>= 0.8.2)
|
51
|
+
thor
|
51
52
|
tilt
|
52
53
|
i18n (1.12.0)
|
53
54
|
concurrent-ruby (~> 1.0)
|
@@ -80,7 +81,7 @@ GEM
|
|
80
81
|
parallel (1.22.1)
|
81
82
|
parser (3.1.2.1)
|
82
83
|
ast (~> 2.4.1)
|
83
|
-
prettier (3.2.
|
84
|
+
prettier (3.2.2)
|
84
85
|
syntax_tree (>= 2.7.1)
|
85
86
|
syntax_tree-haml (>= 1.1.0)
|
86
87
|
syntax_tree-rbs (>= 0.2.0)
|
@@ -92,19 +93,19 @@ GEM
|
|
92
93
|
byebug (~> 11.0)
|
93
94
|
pry (>= 0.13, < 0.15)
|
94
95
|
racc (1.6.0)
|
95
|
-
rack (
|
96
|
+
rack (3.0.0)
|
96
97
|
rainbow (3.1.1)
|
97
98
|
rake (13.0.6)
|
98
99
|
rb-fsevent (0.11.2)
|
99
100
|
rb-inotify (0.10.1)
|
100
101
|
ffi (~> 1.0)
|
101
|
-
rbi (0.0.
|
102
|
+
rbi (0.0.16)
|
102
103
|
ast
|
103
104
|
parser (>= 2.6.4.0)
|
104
105
|
sorbet-runtime (>= 0.5.9204)
|
105
106
|
unparser
|
106
|
-
rbs (2.
|
107
|
-
regexp_parser (2.
|
107
|
+
rbs (2.7.0)
|
108
|
+
regexp_parser (2.6.0)
|
108
109
|
reverse_markdown (2.1.1)
|
109
110
|
nokogiri
|
110
111
|
rexml (3.2.5)
|
@@ -114,17 +115,17 @@ GEM
|
|
114
115
|
rspec-mocks (~> 3.11.0)
|
115
116
|
rspec-core (3.11.0)
|
116
117
|
rspec-support (~> 3.11.0)
|
117
|
-
rspec-expectations (3.11.
|
118
|
+
rspec-expectations (3.11.1)
|
118
119
|
diff-lcs (>= 1.2.0, < 2.0)
|
119
120
|
rspec-support (~> 3.11.0)
|
120
121
|
rspec-mocks (3.11.1)
|
121
122
|
diff-lcs (>= 1.2.0, < 2.0)
|
122
123
|
rspec-support (~> 3.11.0)
|
123
|
-
rspec-support (3.11.
|
124
|
+
rspec-support (3.11.1)
|
124
125
|
rspec_in_context (1.1.0.3)
|
125
126
|
activesupport (> 2.0)
|
126
127
|
rspec (> 3.0)
|
127
|
-
rubocop (1.
|
128
|
+
rubocop (1.36.0)
|
128
129
|
json (~> 2.3)
|
129
130
|
parallel (~> 1.10)
|
130
131
|
parser (>= 3.1.2.1)
|
@@ -139,7 +140,7 @@ GEM
|
|
139
140
|
rubocop-faker (1.1.0)
|
140
141
|
faker (>= 2.12.0)
|
141
142
|
rubocop (>= 0.82.0)
|
142
|
-
rubocop-performance (1.
|
143
|
+
rubocop-performance (1.15.0)
|
143
144
|
rubocop (>= 1.7.0, < 2.0)
|
144
145
|
rubocop-ast (>= 0.4.0)
|
145
146
|
rubocop-sorbet (0.6.11)
|
@@ -152,7 +153,7 @@ GEM
|
|
152
153
|
simplecov_json_formatter (~> 0.1)
|
153
154
|
simplecov-html (0.12.3)
|
154
155
|
simplecov_json_formatter (0.1.4)
|
155
|
-
solargraph (0.
|
156
|
+
solargraph (0.47.2)
|
156
157
|
backport (~> 1.2)
|
157
158
|
benchmark
|
158
159
|
bundler (>= 1.17.2)
|
@@ -167,29 +168,29 @@ GEM
|
|
167
168
|
thor (~> 1.0)
|
168
169
|
tilt (~> 2.0)
|
169
170
|
yard (~> 0.9, >= 0.9.24)
|
170
|
-
sorbet (0.5.
|
171
|
-
sorbet-static (= 0.5.
|
172
|
-
sorbet-runtime (0.5.
|
173
|
-
sorbet-static (0.5.
|
174
|
-
sorbet-static (0.5.
|
175
|
-
sorbet-static-and-runtime (0.5.
|
176
|
-
sorbet (= 0.5.
|
177
|
-
sorbet-runtime (= 0.5.
|
171
|
+
sorbet (0.5.10484)
|
172
|
+
sorbet-static (= 0.5.10484)
|
173
|
+
sorbet-runtime (0.5.10484)
|
174
|
+
sorbet-static (0.5.10484-universal-darwin-21)
|
175
|
+
sorbet-static (0.5.10484-x86_64-linux)
|
176
|
+
sorbet-static-and-runtime (0.5.10484)
|
177
|
+
sorbet (= 0.5.10484)
|
178
|
+
sorbet-runtime (= 0.5.10484)
|
178
179
|
spoom (1.1.12)
|
179
180
|
sorbet (>= 0.5.9204)
|
180
181
|
sorbet-runtime (>= 0.5.9204)
|
181
182
|
thor (>= 0.19.2)
|
182
|
-
syntax_tree (3.
|
183
|
+
syntax_tree (3.6.3)
|
183
184
|
prettier_print
|
184
|
-
syntax_tree-haml (1.3.
|
185
|
+
syntax_tree-haml (1.3.2)
|
185
186
|
haml (>= 5.2)
|
186
187
|
prettier_print
|
187
188
|
syntax_tree (>= 2.0.1)
|
188
|
-
syntax_tree-rbs (0.5.
|
189
|
+
syntax_tree-rbs (0.5.1)
|
189
190
|
prettier_print
|
190
191
|
rbs
|
191
192
|
syntax_tree (>= 2.0.1)
|
192
|
-
tapioca (0.
|
193
|
+
tapioca (0.10.2)
|
193
194
|
bundler (>= 1.17.3)
|
194
195
|
netrc (>= 0.11.0)
|
195
196
|
parallel (>= 1.21.0)
|
@@ -204,7 +205,7 @@ GEM
|
|
204
205
|
tilt (2.0.11)
|
205
206
|
tzinfo (2.0.5)
|
206
207
|
concurrent-ruby (~> 1.0)
|
207
|
-
unicode-display_width (2.
|
208
|
+
unicode-display_width (2.3.0)
|
208
209
|
unparser (0.6.5)
|
209
210
|
diff-lcs (~> 1.3)
|
210
211
|
parser (>= 3.1.0)
|
@@ -214,7 +215,7 @@ GEM
|
|
214
215
|
yard-sorbet (0.7.0)
|
215
216
|
sorbet-runtime (>= 0.5)
|
216
217
|
yard (>= 0.9)
|
217
|
-
zeitwerk (2.6.
|
218
|
+
zeitwerk (2.6.1)
|
218
219
|
|
219
220
|
PLATFORMS
|
220
221
|
arm64-darwin-21
|
data/Guardfile
CHANGED
@@ -24,8 +24,8 @@
|
|
24
24
|
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
25
|
# * 'just' rspec: 'rspec'
|
26
26
|
|
27
|
-
guard :rspec, cmd:
|
28
|
-
require
|
27
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
28
|
+
require 'guard/rspec/dsl'
|
29
29
|
dsl = Guard::RSpec::Dsl.new(self)
|
30
30
|
|
31
31
|
# Feel free to open issues for suggestions and improvements
|
data/Rakefile
CHANGED
data/docs/M2mKeygen/Error.html
CHANGED
@@ -125,7 +125,7 @@
|
|
125
125
|
</div>
|
126
126
|
|
127
127
|
<div id="footer">
|
128
|
-
Generated on
|
128
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
129
129
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
130
130
|
0.9.28 (ruby-3.1.2).
|
131
131
|
</div>
|
@@ -294,12 +294,12 @@
|
|
294
294
|
<pre class="code"><span class="info file"># File 'lib/m2m_keygen/params_encoder.rb', line 14</span>
|
295
295
|
|
296
296
|
<span class='kw'>def</span> <span class='id identifier rubyid_encode'>encode</span>
|
297
|
-
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'
|
297
|
+
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='ivar'>@params</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='ivar'>@params</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
298
298
|
<span class='ivar'>@params</span>
|
299
299
|
<span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='rbrace'>}</span>
|
300
|
-
<span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'
|
300
|
+
<span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span>
|
301
301
|
<span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_jsonify_value'>jsonify_value</span><span class='lparen'>(</span><span class='id identifier rubyid_encode_value'>encode_value</span><span class='lparen'>(</span><span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_must'>must</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
302
|
-
<span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'
|
302
|
+
<span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>&</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
303
303
|
<span class='kw'>end</span></pre>
|
304
304
|
</td>
|
305
305
|
</tr>
|
@@ -311,7 +311,7 @@
|
|
311
311
|
</div>
|
312
312
|
|
313
313
|
<div id="footer">
|
314
|
-
Generated on
|
314
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
315
315
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
316
316
|
0.9.28 (ruby-3.1.2).
|
317
317
|
</div>
|
@@ -181,7 +181,7 @@
|
|
181
181
|
<li class="public ">
|
182
182
|
<span class="summary_signature">
|
183
183
|
|
184
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(secret, algorithm:
|
184
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(secret, algorithm: 'sha512', header_name: 'X-Signature') ⇒ void </a>
|
185
185
|
|
186
186
|
|
187
187
|
|
@@ -234,7 +234,7 @@
|
|
234
234
|
<div class="method_details first">
|
235
235
|
<h3 class="signature first" id="initialize-instance_method">
|
236
236
|
|
237
|
-
#<strong>initialize</strong>(secret, algorithm:
|
237
|
+
#<strong>initialize</strong>(secret, algorithm: 'sha512', header_name: 'X-Signature') ⇒ <tt>void</tt>
|
238
238
|
|
239
239
|
|
240
240
|
|
@@ -269,7 +269,7 @@
|
|
269
269
|
<span class='type'>(<tt>String</tt>)</span>
|
270
270
|
|
271
271
|
|
272
|
-
<em class="default">(defaults to: <tt
|
272
|
+
<em class="default">(defaults to: <tt>'sha512'</tt>)</em>
|
273
273
|
|
274
274
|
|
275
275
|
</li>
|
@@ -282,7 +282,7 @@
|
|
282
282
|
<span class='type'>(<tt>String</tt>)</span>
|
283
283
|
|
284
284
|
|
285
|
-
<em class="default">(defaults to: <tt
|
285
|
+
<em class="default">(defaults to: <tt>'X-Signature'</tt>)</em>
|
286
286
|
|
287
287
|
|
288
288
|
</li>
|
@@ -304,8 +304,8 @@
|
|
304
304
|
<td>
|
305
305
|
<pre class="code"><span class="info file"># File 'lib/m2m_keygen/rack_validator.rb', line 16</span>
|
306
306
|
|
307
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='label'>algorithm:</span> <span class='tstring'><span class='tstring_beg'
|
308
|
-
<span class='ivar'>@header_name</span> <span class='op'>=</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_let'>let</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>HTTP_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_header_name'>header_name</span><span class='period'>.</span><span class='id identifier rubyid_tr'>tr</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'
|
307
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='label'>algorithm:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sha512</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>header_name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>X-Signature</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
308
|
+
<span class='ivar'>@header_name</span> <span class='op'>=</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_let'>let</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>HTTP_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_header_name'>header_name</span><span class='period'>.</span><span class='id identifier rubyid_tr'>tr</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>_</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='const'>String</span><span class='rparen'>)</span>
|
309
309
|
<span class='ivar'>@signature</span> <span class='op'>=</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_let'>let</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Signature.html" title="M2mKeygen::Signature (class)">Signature</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Signature.html#initialize-instance_method" title="M2mKeygen::Signature#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='label'>algorithm:</span> <span class='id identifier rubyid_algorithm'>algorithm</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="Signature.html" title="M2mKeygen::Signature (class)">Signature</a></span></span><span class='rparen'>)</span>
|
310
310
|
<span class='kw'>end</span></pre>
|
311
311
|
</td>
|
@@ -505,11 +505,11 @@
|
|
505
505
|
</span> <span class='id identifier rubyid_req'>req</span> <span class='op'>=</span> <span class='const'>Rack</span><span class='op'>::</span><span class='const'>Request</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
506
506
|
<span class='ivar'>@signature</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span>
|
507
507
|
<span class='label'>params:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
508
|
-
<span class='label'>verb:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_request_method'>request_method</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'
|
509
|
-
<span class='label'>path:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'
|
510
|
-
<span class='label'>signature:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'
|
511
|
-
<span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'
|
512
|
-
<span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'
|
508
|
+
<span class='label'>verb:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_request_method'>request_method</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>get</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
509
|
+
<span class='label'>path:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
510
|
+
<span class='label'>signature:</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>HTTP_X_SIGNATURE</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
511
|
+
<span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>expiry</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>expiry</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>></span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>&&</span>
|
512
|
+
<span class='id identifier rubyid_req'>req</span><span class='period'>.</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>expiry</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'><</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='int'>120</span>
|
513
513
|
<span class='kw'>end</span></pre>
|
514
514
|
</td>
|
515
515
|
</tr>
|
@@ -521,7 +521,7 @@
|
|
521
521
|
</div>
|
522
522
|
|
523
523
|
<div id="footer">
|
524
|
-
Generated on
|
524
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
525
525
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
526
526
|
0.9.28 (ruby-3.1.2).
|
527
527
|
</div>
|
@@ -181,7 +181,7 @@
|
|
181
181
|
<li class="public ">
|
182
182
|
<span class="summary_signature">
|
183
183
|
|
184
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(secret, algorithm:
|
184
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(secret, algorithm: 'sha512') ⇒ void </a>
|
185
185
|
|
186
186
|
|
187
187
|
|
@@ -256,7 +256,7 @@
|
|
256
256
|
<div class="method_details first">
|
257
257
|
<h3 class="signature first" id="initialize-instance_method">
|
258
258
|
|
259
|
-
#<strong>initialize</strong>(secret, algorithm:
|
259
|
+
#<strong>initialize</strong>(secret, algorithm: 'sha512') ⇒ <tt>void</tt>
|
260
260
|
|
261
261
|
|
262
262
|
|
@@ -291,7 +291,7 @@
|
|
291
291
|
<span class='type'>(<tt>String</tt>)</span>
|
292
292
|
|
293
293
|
|
294
|
-
<em class="default">(defaults to: <tt
|
294
|
+
<em class="default">(defaults to: <tt>'sha512'</tt>)</em>
|
295
295
|
|
296
296
|
|
297
297
|
</li>
|
@@ -314,10 +314,10 @@
|
|
314
314
|
<td>
|
315
315
|
<pre class="code"><span class="info file"># File 'lib/m2m_keygen/signature.rb', line 17</span>
|
316
316
|
|
317
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='label'>algorithm:</span> <span class='tstring'><span class='tstring_beg'
|
317
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='label'>algorithm:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sha512</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
318
318
|
<span class='ivar'>@secret</span> <span class='op'>=</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_let'>let</span><span class='lparen'>(</span><span class='id identifier rubyid_secret'>secret</span><span class='comma'>,</span> <span class='const'>String</span><span class='rparen'>)</span>
|
319
319
|
<span class='ivar'>@algorithm</span> <span class='op'>=</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_let'>let</span><span class='lparen'>(</span><span class='id identifier rubyid_algorithm'>algorithm</span><span class='comma'>,</span> <span class='const'>String</span><span class='rparen'>)</span>
|
320
|
-
<span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>HMAC</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='ivar'>@algorithm</span><span class='comma'>,</span> <span class='ivar'>@secret</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'
|
320
|
+
<span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>HMAC</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='ivar'>@algorithm</span><span class='comma'>,</span> <span class='ivar'>@secret</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
321
321
|
<span class='kw'>end</span></pre>
|
322
322
|
</td>
|
323
323
|
</tr>
|
@@ -533,7 +533,7 @@
|
|
533
533
|
<span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>HMAC</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span>
|
534
534
|
<span class='ivar'>@algorithm</span><span class='comma'>,</span>
|
535
535
|
<span class='ivar'>@secret</span><span class='comma'>,</span>
|
536
|
-
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_verb'>verb</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="ParamsEncoder.html" title="M2mKeygen::ParamsEncoder (class)">ParamsEncoder</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ParamsEncoder.html#initialize-instance_method" title="M2mKeygen::ParamsEncoder#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_encode'>encode</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
536
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_verb'>verb</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="ParamsEncoder.html" title="M2mKeygen::ParamsEncoder (class)">ParamsEncoder</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ParamsEncoder.html#initialize-instance_method" title="M2mKeygen::ParamsEncoder#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_encode'>encode</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
537
537
|
<span class='rparen'>)</span>
|
538
538
|
<span class='kw'>end</span></pre>
|
539
539
|
</td>
|
@@ -649,12 +649,12 @@
|
|
649
649
|
<span class='kw'>if</span> <span class='const'>OpenSSL</span><span class='period'>.</span><span class='id identifier rubyid_methods'>methods</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='symbol'>:fixed_length_secure_compare</span><span class='rparen'>)</span>
|
650
650
|
<span class='const'>OpenSSL</span><span class='period'>.</span><span class='id identifier rubyid_fixed_length_secure_compare'>fixed_length_secure_compare</span><span class='lparen'>(</span>
|
651
651
|
<span class='id identifier rubyid_sign'>sign</span><span class='lparen'>(</span><span class='label'>params:</span> <span class='id identifier rubyid_params'>params</span><span class='comma'>,</span> <span class='label'>verb:</span> <span class='id identifier rubyid_verb'>verb</span><span class='comma'>,</span> <span class='label'>path:</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='comma'>,</span>
|
652
|
-
<span class='id identifier rubyid_signature'>signature</span>
|
652
|
+
<span class='id identifier rubyid_signature'>signature</span><span class='comma'>,</span>
|
653
653
|
<span class='rparen'>)</span>
|
654
654
|
<span class='kw'>else</span>
|
655
655
|
<span class='id identifier rubyid_fallback_fixed_length_secure_compare'>fallback_fixed_length_secure_compare</span><span class='lparen'>(</span>
|
656
656
|
<span class='id identifier rubyid_sign'>sign</span><span class='lparen'>(</span><span class='label'>params:</span> <span class='id identifier rubyid_params'>params</span><span class='comma'>,</span> <span class='label'>verb:</span> <span class='id identifier rubyid_verb'>verb</span><span class='comma'>,</span> <span class='label'>path:</span> <span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='comma'>,</span>
|
657
|
-
<span class='id identifier rubyid_signature'>signature</span>
|
657
|
+
<span class='id identifier rubyid_signature'>signature</span><span class='comma'>,</span>
|
658
658
|
<span class='rparen'>)</span>
|
659
659
|
<span class='kw'>end</span>
|
660
660
|
<span class='kw'>rescue</span> <span class='const'>StandardError</span>
|
@@ -670,7 +670,7 @@
|
|
670
670
|
</div>
|
671
671
|
|
672
672
|
<div id="footer">
|
673
|
-
Generated on
|
673
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
674
674
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
675
675
|
0.9.28 (ruby-3.1.2).
|
676
676
|
</div>
|
data/docs/M2mKeygen/Types.html
CHANGED
@@ -118,7 +118,7 @@
|
|
118
118
|
<span class='const'>String</span><span class='comma'>,</span>
|
119
119
|
<span class='const'>Symbol</span><span class='comma'>,</span>
|
120
120
|
<span class='const'>T</span><span class='op'>::</span><span class='const'>Array</span><span class='lbracket'>[</span><span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_untyped'>untyped</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
121
|
-
<span class='const'>T</span><span class='op'>::</span><span class='const'>Hash</span><span class='lbracket'>[</span><span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_untyped'>untyped</span><span class='comma'>,</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_untyped'>untyped</span><span class='rbracket'>]</span>
|
121
|
+
<span class='const'>T</span><span class='op'>::</span><span class='const'>Hash</span><span class='lbracket'>[</span><span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_untyped'>untyped</span><span class='comma'>,</span> <span class='const'>T</span><span class='period'>.</span><span class='id identifier rubyid_untyped'>untyped</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
122
122
|
<span class='rparen'>)</span>
|
123
123
|
<span class='kw'>end</span></pre></dd>
|
124
124
|
|
@@ -137,7 +137,7 @@
|
|
137
137
|
</div>
|
138
138
|
|
139
139
|
<div id="footer">
|
140
|
-
Generated on
|
140
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
141
141
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
142
142
|
0.9.28 (ruby-3.1.2).
|
143
143
|
</div>
|
data/docs/M2mKeygen.html
CHANGED
@@ -131,7 +131,7 @@
|
|
131
131
|
|
132
132
|
</div>
|
133
133
|
</dt>
|
134
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'
|
134
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.4.3</span><span class='tstring_end'>'</span></span></pre></dd>
|
135
135
|
|
136
136
|
</dl>
|
137
137
|
|
@@ -147,7 +147,7 @@
|
|
147
147
|
</div>
|
148
148
|
|
149
149
|
<div id="footer">
|
150
|
-
Generated on
|
150
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
151
151
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
152
152
|
0.9.28 (ruby-3.1.2).
|
153
153
|
</div>
|
data/docs/_index.html
CHANGED
@@ -172,7 +172,7 @@
|
|
172
172
|
</div>
|
173
173
|
|
174
174
|
<div id="footer">
|
175
|
-
Generated on
|
175
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
176
176
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
177
177
|
0.9.28 (ruby-3.1.2).
|
178
178
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -220,7 +220,7 @@ The receiver will generate the same signature from the HTTP request it has recei
|
|
220
220
|
</div></div>
|
221
221
|
|
222
222
|
<div id="footer">
|
223
|
-
Generated on
|
223
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
224
224
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
225
225
|
0.9.28 (ruby-3.1.2).
|
226
226
|
</div>
|
data/docs/index.html
CHANGED
@@ -220,7 +220,7 @@ The receiver will generate the same signature from the HTTP request it has recei
|
|
220
220
|
</div></div>
|
221
221
|
|
222
222
|
<div id="footer">
|
223
|
-
Generated on
|
223
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
224
224
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
225
225
|
0.9.28 (ruby-3.1.2).
|
226
226
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Wed Oct 12 11:55:54 2022 by
|
104
104
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.28 (ruby-3.1.2).
|
106
106
|
</div>
|
@@ -12,19 +12,19 @@ module M2mKeygen
|
|
12
12
|
|
13
13
|
sig { returns(String) }
|
14
14
|
def encode
|
15
|
-
return
|
15
|
+
return '' if @params.nil? || @params.empty?
|
16
16
|
@params
|
17
17
|
.sort_by { |k, _| k.to_s }
|
18
|
-
.reject { |_, v| (v.is_a?(String) && v ==
|
18
|
+
.reject { |_, v| (v.is_a?(String) && v == '') || v.nil? }
|
19
19
|
.map { |k, v| "#{k}=#{jsonify_value(encode_value(T.must(v)))}" }
|
20
|
-
.join(
|
20
|
+
.join('&')
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
25
|
sig do
|
26
26
|
params(value: Types::ParamsValueType).returns(
|
27
|
-
T.any(String, Symbol, Integer)
|
27
|
+
T.any(String, Symbol, Integer),
|
28
28
|
)
|
29
29
|
end
|
30
30
|
def jsonify_value(value)
|
@@ -42,13 +42,13 @@ module M2mKeygen
|
|
42
42
|
|
43
43
|
sig do
|
44
44
|
params(value: Types::ParamsHashNotNilType).returns(
|
45
|
-
T::Hash[String, Types::ParamsValueType]
|
45
|
+
T::Hash[String, Types::ParamsValueType],
|
46
46
|
)
|
47
47
|
end
|
48
48
|
def encode_hash_value(value)
|
49
49
|
value
|
50
50
|
.sort_by { |k, _| k.to_s }
|
51
|
-
.reject { |_, v| (v.is_a?(String) && v ==
|
51
|
+
.reject { |_, v| (v.is_a?(String) && v == '') || v.nil? }
|
52
52
|
.map { |k, v| [k.to_s, encode_value(v)] }
|
53
53
|
.to_h
|
54
54
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# typed: strict
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rack'
|
4
4
|
|
5
5
|
module M2mKeygen
|
6
6
|
class RackValidator
|
@@ -13,8 +13,8 @@ module M2mKeygen
|
|
13
13
|
attr_reader :header_name
|
14
14
|
|
15
15
|
sig { params(secret: String, algorithm: String, header_name: String).void }
|
16
|
-
def initialize(secret, algorithm:
|
17
|
-
@header_name = T.let("HTTP_#{header_name.tr(
|
16
|
+
def initialize(secret, algorithm: 'sha512', header_name: 'X-Signature')
|
17
|
+
@header_name = T.let("HTTP_#{header_name.tr('-', '_').upcase}", String)
|
18
18
|
@signature = T.let(Signature.new(secret, algorithm: algorithm), Signature)
|
19
19
|
end
|
20
20
|
|
@@ -24,11 +24,11 @@ module M2mKeygen
|
|
24
24
|
req = Rack::Request.new(req.env)
|
25
25
|
@signature.validate(
|
26
26
|
params: req.params || {},
|
27
|
-
verb: req.request_method ||
|
28
|
-
path: req.path ||
|
29
|
-
signature: req.env[
|
30
|
-
) && req.params[
|
31
|
-
req.params[
|
27
|
+
verb: req.request_method || 'get',
|
28
|
+
path: req.path || '/',
|
29
|
+
signature: req.env['HTTP_X_SIGNATURE'] || '',
|
30
|
+
) && req.params['expiry'] && req.params['expiry'].to_i > Time.now.to_i &&
|
31
|
+
req.params['expiry'].to_i < Time.now.to_i + 120
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/m2m_keygen/signature.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'openssl'
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
module M2mKeygen
|
7
7
|
class Signature
|
@@ -14,24 +14,24 @@ module M2mKeygen
|
|
14
14
|
attr_reader :algorithm
|
15
15
|
|
16
16
|
sig { params(secret: String, algorithm: String).void }
|
17
|
-
def initialize(secret, algorithm:
|
17
|
+
def initialize(secret, algorithm: 'sha512')
|
18
18
|
@secret = T.let(secret, String)
|
19
19
|
@algorithm = T.let(algorithm, String)
|
20
|
-
OpenSSL::HMAC.hexdigest(@algorithm, @secret,
|
20
|
+
OpenSSL::HMAC.hexdigest(@algorithm, @secret, '')
|
21
21
|
end
|
22
22
|
|
23
23
|
sig do
|
24
24
|
params(
|
25
25
|
params: Types::ParamsType,
|
26
26
|
verb: T.any(String, Symbol),
|
27
|
-
path: String
|
27
|
+
path: String,
|
28
28
|
).returns(String)
|
29
29
|
end
|
30
30
|
def sign(params:, verb:, path:)
|
31
31
|
OpenSSL::HMAC.hexdigest(
|
32
32
|
@algorithm,
|
33
33
|
@secret,
|
34
|
-
"#{verb.to_s.upcase}#{path}#{ParamsEncoder.new(params).encode}"
|
34
|
+
"#{verb.to_s.upcase}#{path}#{ParamsEncoder.new(params).encode}",
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
@@ -40,19 +40,19 @@ module M2mKeygen
|
|
40
40
|
params: Types::ParamsType,
|
41
41
|
verb: T.any(String, Symbol),
|
42
42
|
path: String,
|
43
|
-
signature: String
|
43
|
+
signature: String,
|
44
44
|
).returns(T::Boolean)
|
45
45
|
end
|
46
46
|
def validate(params:, verb:, path:, signature:)
|
47
47
|
if OpenSSL.methods.include?(:fixed_length_secure_compare)
|
48
48
|
OpenSSL.fixed_length_secure_compare(
|
49
49
|
sign(params: params, verb: verb, path: path),
|
50
|
-
signature
|
50
|
+
signature,
|
51
51
|
)
|
52
52
|
else
|
53
53
|
fallback_fixed_length_secure_compare(
|
54
54
|
sign(params: params, verb: verb, path: path),
|
55
|
-
signature
|
55
|
+
signature,
|
56
56
|
)
|
57
57
|
end
|
58
58
|
rescue StandardError
|
data/lib/m2m_keygen/version.rb
CHANGED
data/lib/m2m_keygen.rb
CHANGED
data/m2m_keygen.gemspec
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/m2m_keygen/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'm2m_keygen'
|
7
7
|
spec.version = M2mKeygen::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['Denis <Zaratan> Pasin']
|
9
|
+
spec.email = ['zaratan@hey.com']
|
10
10
|
|
11
|
-
spec.summary =
|
11
|
+
spec.summary = 'Secure M2M key generator'
|
12
12
|
spec.description =
|
13
|
-
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
16
|
-
spec.required_ruby_version =
|
13
|
+
'Secure M2M key generator for Ruby. Generates secure keys for M2M communication in REST APIs.'
|
14
|
+
spec.homepage = 'https://github.com/Billcorporate/m2m_keygen_ruby'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.required_ruby_version = '>= 2.7.0'
|
17
17
|
|
18
|
-
spec.metadata[
|
19
|
-
spec.metadata[
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
20
20
|
spec.metadata[
|
21
|
-
|
22
|
-
] =
|
21
|
+
'changelog_uri'
|
22
|
+
] = 'https://github.com/Billcorporate/m2m_keygen_ruby/blob/main/CHANGELOG.md'
|
23
23
|
spec.metadata[
|
24
|
-
|
25
|
-
] =
|
26
|
-
spec.metadata = {
|
24
|
+
'documentation_uri'
|
25
|
+
] = 'https://billcorporate.github.io/m2m_keygen_ruby'
|
26
|
+
spec.metadata = { 'rubygems_mfa_required' => 'true' }
|
27
27
|
|
28
28
|
# Specify which files should be added to the gem when it is released.
|
29
29
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -33,15 +33,15 @@ Gem::Specification.new do |spec|
|
|
33
33
|
.reject do |f|
|
34
34
|
(f == __FILE__) ||
|
35
35
|
f.match(
|
36
|
-
%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}
|
36
|
+
%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)},
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
spec.bindir =
|
40
|
+
spec.bindir = 'exe'
|
41
41
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
42
|
-
spec.require_paths = [
|
42
|
+
spec.require_paths = ['lib']
|
43
43
|
|
44
|
-
spec.add_dependency
|
45
|
-
spec.add_dependency
|
46
|
-
spec.add_dependency
|
44
|
+
spec.add_dependency 'rack'
|
45
|
+
spec.add_dependency 'sorbet-runtime'
|
46
|
+
spec.add_dependency 'zeitwerk', '~> 2.6'
|
47
47
|
end
|
data/yarn.lock
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
"@prettier/plugin-ruby@^3.2.0":
|
6
|
-
version "3.2.
|
7
|
-
resolved "https://registry.yarnpkg.com/@prettier/plugin-ruby/-/plugin-ruby-3.2.
|
8
|
-
integrity sha512-
|
6
|
+
version "3.2.2"
|
7
|
+
resolved "https://registry.yarnpkg.com/@prettier/plugin-ruby/-/plugin-ruby-3.2.2.tgz#43c9d85349032f74d34c4f57e6a77487d5c5bdc1"
|
8
|
+
integrity sha512-Vc7jVE39Fgswl517ET4kPtpnoRWE6XTi1Sivd84rZyomYnHYUmvUsEeoOf6tVhzTuIXE5XVQB1YCG2hulrwR3Q==
|
9
9
|
dependencies:
|
10
10
|
prettier ">=2.3.0"
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m2m_keygen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis <Zaratan> Pasin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|