truelayer-signing 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +12 -2
  4. data/examples/webhook-server/Gemfile +1 -0
  5. data/examples/webhook-server/Gemfile.lock +28 -3
  6. data/examples/webhook-server/main.rb +15 -14
  7. data/lib/truelayer-signing/verifier.rb +72 -20
  8. data/lib/truelayer-signing.rb +9 -1
  9. data/test/resources/missing-zero-padding-test-jwks.json +19 -0
  10. data/test/resources/missing-zero-padding-test-payload.json +22 -0
  11. data/test/resources/missing-zero-padding-test-signature.txt +1 -0
  12. data/test/test-truelayer-signing.rb +118 -6
  13. data/truelayer-signing.gemspec +2 -2
  14. metadata +9 -75
  15. data/doc/CHANGELOG_md.html +0 -132
  16. data/doc/JWT/Decode.html +0 -97
  17. data/doc/JWT/Encode.html +0 -97
  18. data/doc/JWT/JWK/EC.html +0 -169
  19. data/doc/JWT/JWK.html +0 -91
  20. data/doc/JWT.html +0 -95
  21. data/doc/LICENSE-APACHE.html +0 -177
  22. data/doc/LICENSE-MIT.html +0 -105
  23. data/doc/README_md.html +0 -197
  24. data/doc/Rakefile.html +0 -106
  25. data/doc/TrueLayerSigning/Config.html +0 -211
  26. data/doc/TrueLayerSigning/Error.html +0 -97
  27. data/doc/TrueLayerSigning/JwsBase.html +0 -317
  28. data/doc/TrueLayerSigning/JwsHeader.html +0 -268
  29. data/doc/TrueLayerSigning/Signer.html +0 -186
  30. data/doc/TrueLayerSigning/Verifier.html +0 -327
  31. data/doc/TrueLayerSigning.html +0 -226
  32. data/doc/TrueLayerSigningExamples.html +0 -217
  33. data/doc/created.rid +0 -21
  34. data/doc/css/fonts.css +0 -167
  35. data/doc/css/rdoc.css +0 -662
  36. data/doc/examples/sign-request/Gemfile.html +0 -99
  37. data/doc/examples/sign-request/Gemfile_lock.html +0 -143
  38. data/doc/examples/sign-request/README_md.html +0 -138
  39. data/doc/examples/webhook-server/Gemfile.html +0 -99
  40. data/doc/examples/webhook-server/Gemfile_lock.html +0 -142
  41. data/doc/examples/webhook-server/README_md.html +0 -139
  42. data/doc/fonts/Lato-Light.ttf +0 -0
  43. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  44. data/doc/fonts/Lato-Regular.ttf +0 -0
  45. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  46. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  47. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  48. data/doc/images/add.png +0 -0
  49. data/doc/images/arrow_up.png +0 -0
  50. data/doc/images/brick.png +0 -0
  51. data/doc/images/brick_link.png +0 -0
  52. data/doc/images/bug.png +0 -0
  53. data/doc/images/bullet_black.png +0 -0
  54. data/doc/images/bullet_toggle_minus.png +0 -0
  55. data/doc/images/bullet_toggle_plus.png +0 -0
  56. data/doc/images/date.png +0 -0
  57. data/doc/images/delete.png +0 -0
  58. data/doc/images/find.png +0 -0
  59. data/doc/images/loadingAnimation.gif +0 -0
  60. data/doc/images/macFFBgHack.png +0 -0
  61. data/doc/images/package.png +0 -0
  62. data/doc/images/page_green.png +0 -0
  63. data/doc/images/page_white_text.png +0 -0
  64. data/doc/images/page_white_width.png +0 -0
  65. data/doc/images/plugin.png +0 -0
  66. data/doc/images/ruby.png +0 -0
  67. data/doc/images/tag_blue.png +0 -0
  68. data/doc/images/tag_green.png +0 -0
  69. data/doc/images/transparent.png +0 -0
  70. data/doc/images/wrench.png +0 -0
  71. data/doc/images/wrench_orange.png +0 -0
  72. data/doc/images/zoom.png +0 -0
  73. data/doc/index.html +0 -118
  74. data/doc/js/darkfish.js +0 -84
  75. data/doc/js/navigation.js +0 -105
  76. data/doc/js/navigation.js.gz +0 -0
  77. data/doc/js/search.js +0 -110
  78. data/doc/js/search_index.js +0 -1
  79. data/doc/js/search_index.js.gz +0 -0
  80. data/doc/js/searcher.js +0 -229
  81. data/doc/js/searcher.js.gz +0 -0
  82. data/doc/table_of_contents.html +0 -269
  83. data/examples/sign-request/Gemfile.lock +0 -40
@@ -1,186 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class TrueLayerSigning::Signer - RDoc Documentation</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../";
11
- var index_rel_prefix = "../";
12
- </script>
13
-
14
- <script src="../js/navigation.js" defer></script>
15
- <script src="../js/search.js" defer></script>
16
- <script src="../js/search_index.js" defer></script>
17
- <script src="../js/searcher.js" defer></script>
18
- <script src="../js/darkfish.js" defer></script>
19
-
20
- <link href="../css/fonts.css" rel="stylesheet">
21
- <link href="../css/rdoc.css" rel="stylesheet">
22
-
23
-
24
- <body id="top" role="document" class="class">
25
- <nav role="navigation">
26
- <div id="project-navigation">
27
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
- <h2>
29
- <a href="../index.html" rel="home">Home</a>
30
- </h2>
31
-
32
- <div id="table-of-contents-navigation">
33
- <a href="../table_of_contents.html#pages">Pages</a>
34
- <a href="../table_of_contents.html#classes">Classes</a>
35
- <a href="../table_of_contents.html#methods">Methods</a>
36
- </div>
37
- </div>
38
-
39
- <div id="search-section" role="search" class="project-section initially-hidden">
40
- <form action="#" method="get" accept-charset="utf-8">
41
- <div id="search-field-wrapper">
42
- <input id="search-field" role="combobox" aria-label="Search"
43
- aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search" spellcheck="false"
45
- title="Type to search, Up and Down to navigate, Enter to load">
46
- </div>
47
-
48
- <ul id="search-results" aria-label="Search Results"
49
- aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" class="initially-hidden"></ul>
51
- </form>
52
- </div>
53
-
54
- </div>
55
-
56
-
57
-
58
- <div id="class-metadata">
59
-
60
-
61
- <div id="parent-class-section" class="nav-section">
62
- <h3>Parent</h3>
63
-
64
- <p class="link">JwsBase
65
- </div>
66
-
67
-
68
-
69
-
70
- <!-- Method Quickref -->
71
- <div id="method-list-section" class="nav-section">
72
- <h3>Methods</h3>
73
-
74
- <ul class="link-list" role="directory">
75
- <li ><a href="#method-i-set_jku">#set_jku</a>
76
- <li ><a href="#method-i-sign">#sign</a>
77
- </ul>
78
- </div>
79
-
80
- </div>
81
- </nav>
82
-
83
- <main role="main" aria-labelledby="class-TrueLayerSigning::Signer">
84
- <h1 id="class-TrueLayerSigning::Signer" class="class">
85
- class TrueLayerSigning::Signer
86
- </h1>
87
-
88
- <section class="description">
89
-
90
- </section>
91
-
92
- <section id="5Buntitled-5D" class="documentation-section">
93
-
94
-
95
-
96
- <section class="attribute-method-details" class="method-section">
97
- <header>
98
- <h3>Attributes</h3>
99
- </header>
100
-
101
- <div id="attribute-i-jws_jku" class="method-detail">
102
- <div class="method-heading attribute-method-heading">
103
- <span class="method-name">jws_jku</span><span
104
- class="attribute-access-type">[R]</span>
105
- </div>
106
-
107
- <div class="method-description">
108
-
109
- </div>
110
- </div>
111
- </section>
112
-
113
-
114
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
115
- <header>
116
- <h3>Public Instance Methods</h3>
117
- </header>
118
-
119
- <div id="method-i-set_jku" class="method-detail ">
120
- <div class="method-header">
121
- <div class="method-heading">
122
- <span class="method-name">set_jku</span><span
123
- class="method-args">(jku)</span>
124
- <span class="method-click-advice">click to toggle source</span>
125
- </div>
126
- </div>
127
-
128
- <div class="method-description">
129
-
130
-
131
- <div class="method-source-code" id="set_jku-source">
132
- <pre><span class="ruby-comment"># File lib/truelayer-signing/signer.rb, line 18</span>
133
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_jku</span>(<span class="ruby-identifier">jku</span>)
134
- <span class="ruby-ivar">@jws_jku</span> = <span class="ruby-identifier">jku</span>
135
- <span class="ruby-keyword">self</span>
136
- <span class="ruby-keyword">end</span></pre>
137
- </div>
138
- </div>
139
-
140
-
141
- </div>
142
-
143
- <div id="method-i-sign" class="method-detail ">
144
- <div class="method-header">
145
- <div class="method-heading">
146
- <span class="method-name">sign</span><span
147
- class="method-args">()</span>
148
- <span class="method-click-advice">click to toggle source</span>
149
- </div>
150
- </div>
151
-
152
- <div class="method-description">
153
-
154
-
155
- <div class="method-source-code" id="sign-source">
156
- <pre><span class="ruby-comment"># File lib/truelayer-signing/signer.rb, line 5</span>
157
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sign</span>
158
- <span class="ruby-identifier">ensure_signer_config!</span>
159
-
160
- <span class="ruby-identifier">private_key</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span>.<span class="ruby-identifier">read</span>(<span class="ruby-constant">TrueLayerSigning</span>.<span class="ruby-identifier">private_key</span>)
161
- <span class="ruby-identifier">jws_header_args</span> = { <span class="ruby-value">tl_headers:</span> <span class="ruby-identifier">headers</span> }
162
- <span class="ruby-identifier">jws_header_args</span>[<span class="ruby-value">:jku</span>] = <span class="ruby-identifier">jws_jku</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">jws_jku</span>
163
- <span class="ruby-identifier">jws_header</span> = <span class="ruby-constant">TrueLayerSigning</span><span class="ruby-operator">::</span><span class="ruby-constant">JwsHeader</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">jws_header_args</span>).<span class="ruby-identifier">to_h</span>
164
- <span class="ruby-identifier">jwt</span> = <span class="ruby-constant">JWT</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">build_signing_payload</span>, <span class="ruby-identifier">private_key</span>, <span class="ruby-constant">TrueLayerSigning</span>.<span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">jws_header</span>)
165
- <span class="ruby-identifier">header</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">signature</span> = <span class="ruby-identifier">jwt</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;.&quot;</span>)
166
-
167
- <span class="ruby-node">&quot;#{header}..#{signature}&quot;</span>
168
- <span class="ruby-keyword">end</span></pre>
169
- </div>
170
- </div>
171
-
172
-
173
- </div>
174
-
175
- </section>
176
-
177
- </section>
178
- </main>
179
-
180
-
181
- <footer id="validator-badges" role="contentinfo">
182
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
183
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.5.0.
184
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
185
- </footer>
186
-
@@ -1,327 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class TrueLayerSigning::Verifier - RDoc Documentation</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../";
11
- var index_rel_prefix = "../";
12
- </script>
13
-
14
- <script src="../js/navigation.js" defer></script>
15
- <script src="../js/search.js" defer></script>
16
- <script src="../js/search_index.js" defer></script>
17
- <script src="../js/searcher.js" defer></script>
18
- <script src="../js/darkfish.js" defer></script>
19
-
20
- <link href="../css/fonts.css" rel="stylesheet">
21
- <link href="../css/rdoc.css" rel="stylesheet">
22
-
23
-
24
- <body id="top" role="document" class="class">
25
- <nav role="navigation">
26
- <div id="project-navigation">
27
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
- <h2>
29
- <a href="../index.html" rel="home">Home</a>
30
- </h2>
31
-
32
- <div id="table-of-contents-navigation">
33
- <a href="../table_of_contents.html#pages">Pages</a>
34
- <a href="../table_of_contents.html#classes">Classes</a>
35
- <a href="../table_of_contents.html#methods">Methods</a>
36
- </div>
37
- </div>
38
-
39
- <div id="search-section" role="search" class="project-section initially-hidden">
40
- <form action="#" method="get" accept-charset="utf-8">
41
- <div id="search-field-wrapper">
42
- <input id="search-field" role="combobox" aria-label="Search"
43
- aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search" spellcheck="false"
45
- title="Type to search, Up and Down to navigate, Enter to load">
46
- </div>
47
-
48
- <ul id="search-results" aria-label="Search Results"
49
- aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" class="initially-hidden"></ul>
51
- </form>
52
- </div>
53
-
54
- </div>
55
-
56
-
57
-
58
- <div id="class-metadata">
59
-
60
-
61
- <div id="parent-class-section" class="nav-section">
62
- <h3>Parent</h3>
63
-
64
- <p class="link"><a href="JwsBase.html">TrueLayerSigning::JwsBase</a>
65
- </div>
66
-
67
-
68
-
69
-
70
- <!-- Method Quickref -->
71
- <div id="method-list-section" class="nav-section">
72
- <h3>Methods</h3>
73
-
74
- <ul class="link-list" role="directory">
75
- <li class="calls-super" ><a href="#method-c-new">::new</a>
76
- <li ><a href="#method-c-parse_tl_signature">::parse_tl_signature</a>
77
- <li ><a href="#method-i-require_header">#require_header</a>
78
- <li ><a href="#method-i-require_headers">#require_headers</a>
79
- <li ><a href="#method-i-verify">#verify</a>
80
- </ul>
81
- </div>
82
-
83
- </div>
84
- </nav>
85
-
86
- <main role="main" aria-labelledby="class-TrueLayerSigning::Verifier">
87
- <h1 id="class-TrueLayerSigning::Verifier" class="class">
88
- class TrueLayerSigning::Verifier
89
- </h1>
90
-
91
- <section class="description">
92
-
93
- </section>
94
-
95
- <section id="5Buntitled-5D" class="documentation-section">
96
-
97
-
98
-
99
- <section class="attribute-method-details" class="method-section">
100
- <header>
101
- <h3>Attributes</h3>
102
- </header>
103
-
104
- <div id="attribute-i-key_type" class="method-detail">
105
- <div class="method-heading attribute-method-heading">
106
- <span class="method-name">key_type</span><span
107
- class="attribute-access-type">[R]</span>
108
- </div>
109
-
110
- <div class="method-description">
111
-
112
- </div>
113
- </div>
114
- <div id="attribute-i-key_value" class="method-detail">
115
- <div class="method-heading attribute-method-heading">
116
- <span class="method-name">key_value</span><span
117
- class="attribute-access-type">[R]</span>
118
- </div>
119
-
120
- <div class="method-description">
121
-
122
- </div>
123
- </div>
124
- <div id="attribute-i-required_headers" class="method-detail">
125
- <div class="method-heading attribute-method-heading">
126
- <span class="method-name">required_headers</span><span
127
- class="attribute-access-type">[R]</span>
128
- </div>
129
-
130
- <div class="method-description">
131
-
132
- </div>
133
- </div>
134
- </section>
135
-
136
-
137
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
138
- <header>
139
- <h3>Public Class Methods</h3>
140
- </header>
141
-
142
- <div id="method-c-new" class="method-detail ">
143
- <div class="method-header">
144
- <div class="method-heading">
145
- <span class="method-name">new</span><span
146
- class="method-args">(args)</span>
147
- <span class="method-click-advice">click to toggle source</span>
148
- </div>
149
- </div>
150
-
151
- <div class="method-description">
152
-
153
- <div class="method-calls-super">
154
- Calls superclass method
155
- <a href="JwsBase.html#method-c-new"><code>TrueLayerSigning::JwsBase::new</code></a>
156
- </div>
157
-
158
- <div class="method-source-code" id="new-source">
159
- <pre><span class="ruby-comment"># File lib/truelayer-signing/verifier.rb, line 7</span>
160
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">args</span>)
161
- <span class="ruby-keyword">super</span>
162
- <span class="ruby-ivar">@key_type</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:key_type</span>]
163
- <span class="ruby-ivar">@key_value</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:key_value</span>]
164
- <span class="ruby-keyword">end</span></pre>
165
- </div>
166
- </div>
167
-
168
-
169
- </div>
170
-
171
- <div id="method-c-parse_tl_signature" class="method-detail ">
172
- <div class="method-header">
173
- <div class="method-heading">
174
- <span class="method-name">parse_tl_signature</span><span
175
- class="method-args">(tl_signature)</span>
176
- <span class="method-click-advice">click to toggle source</span>
177
- </div>
178
- </div>
179
-
180
- <div class="method-description">
181
-
182
-
183
- <div class="method-source-code" id="parse_tl_signature-source">
184
- <pre><span class="ruby-comment"># File lib/truelayer-signing/verifier.rb, line 59</span>
185
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse_tl_signature</span>(<span class="ruby-identifier">tl_signature</span>)
186
- <span class="ruby-identifier">jws_header_b64</span>, <span class="ruby-identifier">signature_b64</span> = <span class="ruby-identifier">tl_signature</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;..&quot;</span>)
187
-
188
- <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;Invalid signature format&quot;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">signature_b64</span>
189
-
190
- <span class="ruby-keyword">begin</span>
191
- <span class="ruby-identifier">jws_header_raw</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">urlsafe_decode64</span>(<span class="ruby-identifier">jws_header_b64</span>)
192
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">ArgumentError</span>
193
- <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;Invalid base64 for header&quot;</span>)
194
- <span class="ruby-keyword">else</span>
195
- <span class="ruby-identifier">jws_header</span> = <span class="ruby-constant">JwsHeader</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">jws_header_raw</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">true</span>))
196
- <span class="ruby-keyword">end</span>
197
-
198
- [<span class="ruby-identifier">jws_header</span>, <span class="ruby-identifier">jws_header_b64</span>, <span class="ruby-identifier">signature_b64</span>]
199
- <span class="ruby-keyword">end</span></pre>
200
- </div>
201
- </div>
202
-
203
-
204
- </div>
205
-
206
- </section>
207
-
208
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
209
- <header>
210
- <h3>Public Instance Methods</h3>
211
- </header>
212
-
213
- <div id="method-i-require_header" class="method-detail ">
214
- <div class="method-header">
215
- <div class="method-heading">
216
- <span class="method-name">require_header</span><span
217
- class="method-args">(name)</span>
218
- <span class="method-click-advice">click to toggle source</span>
219
- </div>
220
- </div>
221
-
222
- <div class="method-description">
223
-
224
-
225
- <div class="method-source-code" id="require_header-source">
226
- <pre><span class="ruby-comment"># File lib/truelayer-signing/verifier.rb, line 48</span>
227
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">require_header</span>(<span class="ruby-identifier">name</span>)
228
- <span class="ruby-ivar">@required_headers</span> <span class="ruby-operator">||=</span> []
229
- <span class="ruby-ivar">@required_headers</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">name</span>)
230
- <span class="ruby-keyword">self</span>
231
- <span class="ruby-keyword">end</span></pre>
232
- </div>
233
- </div>
234
-
235
-
236
- </div>
237
-
238
- <div id="method-i-require_headers" class="method-detail ">
239
- <div class="method-header">
240
- <div class="method-heading">
241
- <span class="method-name">require_headers</span><span
242
- class="method-args">(names)</span>
243
- <span class="method-click-advice">click to toggle source</span>
244
- </div>
245
- </div>
246
-
247
- <div class="method-description">
248
-
249
-
250
- <div class="method-source-code" id="require_headers-source">
251
- <pre><span class="ruby-comment"># File lib/truelayer-signing/verifier.rb, line 54</span>
252
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">require_headers</span>(<span class="ruby-identifier">names</span>)
253
- <span class="ruby-ivar">@required_headers</span> = <span class="ruby-identifier">names</span>
254
- <span class="ruby-keyword">self</span>
255
- <span class="ruby-keyword">end</span></pre>
256
- </div>
257
- </div>
258
-
259
-
260
- </div>
261
-
262
- <div id="method-i-verify" class="method-detail ">
263
- <div class="method-header">
264
- <div class="method-heading">
265
- <span class="method-name">verify</span><span
266
- class="method-args">(tl_signature)</span>
267
- <span class="method-click-advice">click to toggle source</span>
268
- </div>
269
- </div>
270
-
271
- <div class="method-description">
272
-
273
-
274
- <div class="method-source-code" id="verify-source">
275
- <pre><span class="ruby-comment"># File lib/truelayer-signing/verifier.rb, line 13</span>
276
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">verify</span>(<span class="ruby-identifier">tl_signature</span>)
277
- <span class="ruby-identifier">ensure_verifier_config!</span>
278
-
279
- <span class="ruby-identifier">jws_header</span>, <span class="ruby-identifier">jws_header_b64</span>, <span class="ruby-identifier">signature_b64</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse_tl_signature</span>(<span class="ruby-identifier">tl_signature</span>)
280
- <span class="ruby-identifier">public_key</span> = <span class="ruby-identifier">retrieve_public_key</span>(<span class="ruby-identifier">key_type</span>, <span class="ruby-identifier">key_value</span>, <span class="ruby-identifier">jws_header</span>)
281
-
282
- <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;Unexpected `alg` header value&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">jws_header</span>.<span class="ruby-identifier">alg</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">TrueLayerSigning</span>.<span class="ruby-identifier">algorithm</span>
283
-
284
- <span class="ruby-identifier">ordered_headers</span> = <span class="ruby-identifier">jws_header</span>.<span class="ruby-identifier">filter_headers</span>(<span class="ruby-identifier">headers</span>)
285
- <span class="ruby-identifier">normalised_headers</span> = {}
286
- <span class="ruby-identifier">ordered_headers</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">header</span><span class="ruby-operator">|</span> <span class="ruby-identifier">normalised_headers</span>[<span class="ruby-identifier">header</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">downcase</span>] = <span class="ruby-identifier">header</span>.<span class="ruby-identifier">last</span> }
287
-
288
- <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;Signature missing required header(s)&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">required_headers</span> <span class="ruby-operator">&amp;&amp;</span>
289
- <span class="ruby-identifier">required_headers</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-identifier">normalised_headers</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">downcase</span>) }
290
-
291
- <span class="ruby-identifier">payload_b64</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">urlsafe_encode64</span>(<span class="ruby-identifier">build_signing_payload</span>(<span class="ruby-identifier">ordered_headers</span>), <span class="ruby-value">padding:</span> <span class="ruby-keyword">false</span>)
292
- <span class="ruby-identifier">full_signature</span> = [<span class="ruby-identifier">jws_header_b64</span>, <span class="ruby-identifier">payload_b64</span>, <span class="ruby-identifier">signature_b64</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
293
- <span class="ruby-identifier">jwt_options</span> = { <span class="ruby-value">algorithm:</span> <span class="ruby-constant">TrueLayerSigning</span>.<span class="ruby-identifier">algorithm</span> }
294
-
295
- <span class="ruby-keyword">begin</span>
296
- <span class="ruby-constant">JWT</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">full_signature</span>, <span class="ruby-identifier">public_key</span>, <span class="ruby-keyword">true</span>, <span class="ruby-identifier">jwt_options</span>)
297
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">JWT</span><span class="ruby-operator">::</span><span class="ruby-constant">VerificationError</span>
298
- <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&quot;/&quot;</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;/&quot;</span>
299
- <span class="ruby-identifier">payload_b64</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">urlsafe_encode64</span>(<span class="ruby-identifier">build_signing_payload</span>(<span class="ruby-identifier">ordered_headers</span>),
300
- <span class="ruby-value">padding:</span> <span class="ruby-keyword">false</span>)
301
- <span class="ruby-identifier">full_signature</span> = [<span class="ruby-identifier">jws_header_b64</span>, <span class="ruby-identifier">payload_b64</span>, <span class="ruby-identifier">signature_b64</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>)
302
-
303
- <span class="ruby-keyword">begin</span>
304
- <span class="ruby-constant">JWT</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">full_signature</span>, <span class="ruby-identifier">public_key</span>, <span class="ruby-keyword">true</span>, <span class="ruby-identifier">jwt_options</span>)
305
- <span class="ruby-keyword">rescue</span>
306
- <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;Signature verification failed&quot;</span>)
307
- <span class="ruby-keyword">end</span>
308
- <span class="ruby-keyword">end</span>
309
- <span class="ruby-keyword">end</span></pre>
310
- </div>
311
- </div>
312
-
313
-
314
- </div>
315
-
316
- </section>
317
-
318
- </section>
319
- </main>
320
-
321
-
322
- <footer id="validator-badges" role="contentinfo">
323
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
324
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.5.0.
325
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
326
- </footer>
327
-