silkey-sdk 0.0.1 → 0.0.2
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/.yardopts +14 -0
- data/CHANGELOG.md +11 -1
- data/DEVELOPMENT.md +1 -1
- data/Gemfile.lock +3 -1
- data/README.md +16 -10
- data/lib/silkey/sdk.rb +51 -44
- data/lib/silkey/version.rb +1 -1
- data/silkey-sdk.gemspec +14 -1
- metadata +18 -63
- data/doc/CHANGELOG_md.html +0 -112
- data/doc/LICENSE_txt.html +0 -99
- data/doc/Object.html +0 -117
- data/doc/README_md.html +0 -144
- data/doc/Silkey.html +0 -269
- data/doc/Silkey/ClientFactory.html +0 -106
- data/doc/Silkey/Configuration.html +0 -217
- data/doc/Silkey/Contract.html +0 -106
- data/doc/Silkey/Contract/FrozenArray.html +0 -106
- data/doc/Silkey/ContractFactory.html +0 -106
- data/doc/Silkey/LoggerService.html +0 -106
- data/doc/Silkey/Models.html +0 -99
- data/doc/Silkey/Models/JwtPayload.html +0 -622
- data/doc/Silkey/RegistryContract.html +0 -106
- data/doc/Silkey/SDK.html +0 -356
- data/doc/Silkey/Utils.html +0 -709
- data/doc/created.rid +0 -23
- data/doc/css/fonts.css +0 -167
- data/doc/css/rdoc.css +0 -619
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -112
- data/doc/js/darkfish.js +0 -84
- data/doc/js/navigation.js +0 -105
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +0 -110
- data/doc/js/search_index.js +0 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +0 -229
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +0 -318
@@ -1,106 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Silkey::RegistryContract - 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
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="class">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="../index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
<div id="parent-class-section" class="nav-section">
|
63
|
-
<h3>Parent</h3>
|
64
|
-
|
65
|
-
|
66
|
-
<p class="link"><a href="../Object.html">Object</a>
|
67
|
-
|
68
|
-
</div>
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
</div>
|
74
|
-
</nav>
|
75
|
-
|
76
|
-
<main role="main" aria-labelledby="class-Silkey::RegistryContract">
|
77
|
-
<h1 id="class-Silkey::RegistryContract" class="class">
|
78
|
-
class Silkey::RegistryContract
|
79
|
-
</h1>
|
80
|
-
|
81
|
-
<section class="description">
|
82
|
-
|
83
|
-
</section>
|
84
|
-
|
85
|
-
|
86
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
</section>
|
97
|
-
|
98
|
-
</main>
|
99
|
-
|
100
|
-
|
101
|
-
<footer id="validator-badges" role="contentinfo">
|
102
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
103
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
|
104
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
105
|
-
</footer>
|
106
|
-
|
data/doc/Silkey/SDK.html
DELETED
@@ -1,356 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Silkey::SDK - 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
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="class">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="../index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
<div id="parent-class-section" class="nav-section">
|
63
|
-
<h3>Parent</h3>
|
64
|
-
|
65
|
-
|
66
|
-
<p class="link"><a href="../Object.html">Object</a>
|
67
|
-
|
68
|
-
</div>
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
<!-- Method Quickref -->
|
73
|
-
<div id="method-list-section" class="nav-section">
|
74
|
-
<h3>Methods</h3>
|
75
|
-
|
76
|
-
<ul class="link-list" role="directory">
|
77
|
-
|
78
|
-
<li ><a href="#method-c-fetch_silkey_public_key">::fetch_silkey_public_key</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-c-generate_sso_request_params">::generate_sso_request_params</a>
|
81
|
-
|
82
|
-
<li ><a href="#method-c-message_to_sign">::message_to_sign</a>
|
83
|
-
|
84
|
-
<li ><a href="#method-c-token_payload_verifier">::token_payload_verifier</a>
|
85
|
-
|
86
|
-
</ul>
|
87
|
-
</div>
|
88
|
-
|
89
|
-
</div>
|
90
|
-
</nav>
|
91
|
-
|
92
|
-
<main role="main" aria-labelledby="class-Silkey::SDK">
|
93
|
-
<h1 id="class-Silkey::SDK" class="class">
|
94
|
-
class Silkey::SDK
|
95
|
-
</h1>
|
96
|
-
|
97
|
-
<section class="description">
|
98
|
-
|
99
|
-
</section>
|
100
|
-
|
101
|
-
|
102
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
113
|
-
<header>
|
114
|
-
<h3>Public Class Methods</h3>
|
115
|
-
</header>
|
116
|
-
|
117
|
-
|
118
|
-
<div id="method-c-fetch_silkey_public_key" class="method-detail ">
|
119
|
-
|
120
|
-
<div class="method-heading">
|
121
|
-
<span class="method-name">fetch_silkey_public_key</span><span
|
122
|
-
class="method-args">()</span>
|
123
|
-
|
124
|
-
<span class="method-click-advice">click to toggle source</span>
|
125
|
-
|
126
|
-
</div>
|
127
|
-
|
128
|
-
|
129
|
-
<div class="method-description">
|
130
|
-
|
131
|
-
<p>Fetches public ethereum <a href="../Silkey.html"><code>Silkey</code></a> address (directly from blockchain). This address can be used for token verification</p>
|
132
|
-
|
133
|
-
<p>@param [string] providerUri ie: '<a href="https://infura.io/v3/:infuraId">infura.io/v3/:infuraId</a>' register to infura.io to get infuraId</p>
|
134
|
-
|
135
|
-
<p>@param [string] address of silkey smart contract registry</p>
|
136
|
-
|
137
|
-
<p>@return [string] public ethereum address of silkey signer</p>
|
138
|
-
|
139
|
-
<p>@see List of <a href="../Silkey.html"><code>Silkey</code></a> contracts addresses: <a href="https://github.com/Silkey-Team/silkey-sdk#silkey-sdk">github.com/Silkey-Team/silkey-sdk#silkey-sdk</a></p>
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
<div class="method-source-code" id="fetch_silkey_public_key-source">
|
145
|
-
<pre><span class="ruby-comment"># File lib/silkey/sdk.rb, line 119</span>
|
146
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_silkey_public_key</span>
|
147
|
-
<span class="ruby-identifier">public_key</span> = <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">RegistryContract</span>.<span class="ruby-identifier">get_address</span>(<span class="ruby-string">'Hades'</span>)
|
148
|
-
|
149
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Invalid public key: #{public_key}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">ethereum_address?</span>(<span class="ruby-identifier">public_key</span>)
|
150
|
-
|
151
|
-
<span class="ruby-identifier">public_key</span>
|
152
|
-
<span class="ruby-keyword">end</span></pre>
|
153
|
-
</div>
|
154
|
-
|
155
|
-
</div>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
</div>
|
161
|
-
|
162
|
-
|
163
|
-
<div id="method-c-generate_sso_request_params" class="method-detail ">
|
164
|
-
|
165
|
-
<div class="method-heading">
|
166
|
-
<span class="method-name">generate_sso_request_params</span><span
|
167
|
-
class="method-args">(private_key, hash)</span>
|
168
|
-
|
169
|
-
<span class="method-click-advice">click to toggle source</span>
|
170
|
-
|
171
|
-
</div>
|
172
|
-
|
173
|
-
|
174
|
-
<div class="method-description">
|
175
|
-
|
176
|
-
<p>Generates all needed parameters (including signature) for requesting <a href="../Silkey.html"><code>Silkey</code></a> SSO</p>
|
177
|
-
|
178
|
-
<p>@param [string] private key of domain owner</p>
|
179
|
-
|
180
|
-
<p>@param [Hash] Hash with data: {redirectUrl*, cancelUrl*, refId, scope, ssoTimestamp*} marked with * are required by <a href="../Silkey.html"><code>Silkey</code></a> SSO</p>
|
181
|
-
|
182
|
-
<p>@return [Hash] {{signature, ssoTimestamp, redirectUrl, refId, scope}}</p>
|
183
|
-
|
184
|
-
<p>@example</p>
|
185
|
-
|
186
|
-
<pre class="ruby"><span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span>.<span class="ruby-identifier">generate_sso_request_params</span>(<span class="ruby-identifier">private_key</span>, <span class="ruby-identifier">data</span>)
|
187
|
-
</pre>
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
<div class="method-source-code" id="generate_sso_request_params-source">
|
193
|
-
<pre><span class="ruby-comment"># File lib/silkey/sdk.rb, line 49</span>
|
194
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_sso_request_params</span>(<span class="ruby-identifier">private_key</span>, <span class="ruby-identifier">hash</span>)
|
195
|
-
<span class="ruby-identifier">redirect_url</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value">:redirectUrl</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
196
|
-
<span class="ruby-identifier">cancel_url</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value">:cancelUrl</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
197
|
-
<span class="ruby-identifier">sso_timestamp</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value">:ssoTimestamp</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">current_timestamp</span>
|
198
|
-
<span class="ruby-identifier">ref_id</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value">:refId</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
199
|
-
<span class="ruby-identifier">scope</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value">:scope</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
200
|
-
|
201
|
-
<span class="ruby-identifier">message</span> = <span class="ruby-identifier">message_to_sign</span>({
|
202
|
-
<span class="ruby-value">redirectUrl:</span> <span class="ruby-identifier">redirect_url</span>,
|
203
|
-
<span class="ruby-value">cancelUrl:</span> <span class="ruby-identifier">cancel_url</span>,
|
204
|
-
<span class="ruby-value">ssoTimestamp:</span> <span class="ruby-identifier">sso_timestamp</span>,
|
205
|
-
<span class="ruby-value">refId:</span> <span class="ruby-identifier">ref_id</span>,
|
206
|
-
<span class="ruby-value">scope:</span> <span class="ruby-identifier">scope</span>
|
207
|
-
})
|
208
|
-
|
209
|
-
{
|
210
|
-
<span class="ruby-value">signature:</span> <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">sign_message</span>(<span class="ruby-identifier">private_key</span>, <span class="ruby-identifier">message</span>),
|
211
|
-
<span class="ruby-value">ssoTimestamp:</span> <span class="ruby-identifier">sso_timestamp</span>,
|
212
|
-
<span class="ruby-value">redirectUrl:</span> <span class="ruby-identifier">redirect_url</span>,
|
213
|
-
<span class="ruby-value">cancelUrl:</span> <span class="ruby-identifier">cancel_url</span>,
|
214
|
-
<span class="ruby-value">refId:</span> <span class="ruby-identifier">ref_id</span>,
|
215
|
-
<span class="ruby-value">scope:</span> <span class="ruby-identifier">scope</span>
|
216
|
-
}
|
217
|
-
<span class="ruby-keyword">end</span></pre>
|
218
|
-
</div>
|
219
|
-
|
220
|
-
</div>
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
</div>
|
226
|
-
|
227
|
-
|
228
|
-
<div id="method-c-message_to_sign" class="method-detail ">
|
229
|
-
|
230
|
-
<div class="method-heading">
|
231
|
-
<span class="method-name">message_to_sign</span><span
|
232
|
-
class="method-args">(hash = {})</span>
|
233
|
-
|
234
|
-
<span class="method-click-advice">click to toggle source</span>
|
235
|
-
|
236
|
-
</div>
|
237
|
-
|
238
|
-
|
239
|
-
<div class="method-description">
|
240
|
-
|
241
|
-
<p>Generates message to sign based on plain object data (keys => values)</p>
|
242
|
-
|
243
|
-
<p>@param [Hash]</p>
|
244
|
-
|
245
|
-
<p>@return [string]</p>
|
246
|
-
|
247
|
-
<p>@example:</p>
|
248
|
-
|
249
|
-
<pre class="ruby"><span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span>.<span class="ruby-identifier">message_to_sign</span>({ <span class="ruby-value">redirectUrl:</span> <span class="ruby-string">'http://silkey.io'</span>, <span class="ruby-value">refId:</span> <span class="ruby-value">1</span> });
|
250
|
-
</pre>
|
251
|
-
|
252
|
-
<p>returns</p>
|
253
|
-
|
254
|
-
<pre class="ruby"><span class="ruby-string">'redirectUrl=http://silkey.io::refId=1'</span>
|
255
|
-
</pre>
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
<div class="method-source-code" id="message_to_sign-source">
|
261
|
-
<pre><span class="ruby-comment"># File lib/silkey/sdk.rb, line 22</span>
|
262
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">message_to_sign</span>(<span class="ruby-identifier">hash</span> = {})
|
263
|
-
<span class="ruby-identifier">msg</span> = []
|
264
|
-
<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
265
|
-
<span class="ruby-keyword">if</span> <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">empty?</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">k</span>])
|
266
|
-
<span class="ruby-identifier">msg</span>.<span class="ruby-identifier">push</span>(<span class="ruby-node">"#{k}="</span>)
|
267
|
-
<span class="ruby-keyword">else</span>
|
268
|
-
<span class="ruby-identifier">msg</span>.<span class="ruby-identifier">push</span>(<span class="ruby-node">"#{k}=#{hash[k]}"</span>)
|
269
|
-
<span class="ruby-keyword">end</span>
|
270
|
-
<span class="ruby-keyword">end</span>
|
271
|
-
|
272
|
-
<span class="ruby-identifier">msg</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">'::'</span>)
|
273
|
-
<span class="ruby-keyword">end</span></pre>
|
274
|
-
</div>
|
275
|
-
|
276
|
-
</div>
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
</div>
|
282
|
-
|
283
|
-
|
284
|
-
<div id="method-c-token_payload_verifier" class="method-detail ">
|
285
|
-
|
286
|
-
<div class="method-heading">
|
287
|
-
<span class="method-name">token_payload_verifier</span><span
|
288
|
-
class="method-args">(token, silkey_public_key = nil)</span>
|
289
|
-
|
290
|
-
<span class="method-click-advice">click to toggle source</span>
|
291
|
-
|
292
|
-
</div>
|
293
|
-
|
294
|
-
|
295
|
-
<div class="method-description">
|
296
|
-
|
297
|
-
<p>Verifies JWT token payload</p>
|
298
|
-
|
299
|
-
<p>@see <a href="https://jwt.io">jwt.io</a>/ for details about token payload data</p>
|
300
|
-
|
301
|
-
<p>@param [string] JWT token returned by <a href="../Silkey.html"><code>Silkey</code></a></p>
|
302
|
-
|
303
|
-
<p>@param [string] silkeyPublicKey public ethereum address of <a href="../Silkey.html"><code>Silkey</code></a></p>
|
304
|
-
|
305
|
-
<p>@return [JwtPayload|null] null when signature(s) are invalid, otherwise token payload</p>
|
306
|
-
|
307
|
-
<p>@throws when token is invalid or data are corrupted</p>
|
308
|
-
|
309
|
-
<p>@example</p>
|
310
|
-
|
311
|
-
<pre class="ruby"><span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span>.<span class="ruby-identifier">token_payload_verifier</span>(
|
312
|
-
<span class="ruby-string">'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'</span>,
|
313
|
-
<span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span>.<span class="ruby-identifier">fetch_silkey_public_key</span>
|
314
|
-
)
|
315
|
-
</pre>
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
<div class="method-source-code" id="token_payload_verifier-source">
|
321
|
-
<pre><span class="ruby-comment"># File lib/silkey/sdk.rb, line 94</span>
|
322
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">token_payload_verifier</span>(<span class="ruby-identifier">token</span>, <span class="ruby-identifier">silkey_public_key</span> = <span class="ruby-keyword">nil</span>)
|
323
|
-
<span class="ruby-identifier">payload</span> = <span class="ruby-identifier">token_payload</span>(<span class="ruby-identifier">token</span>)
|
324
|
-
|
325
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">silkey_signature_valid?</span>(<span class="ruby-identifier">payload</span>, <span class="ruby-identifier">silkey_public_key</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">&&</span>
|
326
|
-
<span class="ruby-identifier">user_signature_valid?</span>(<span class="ruby-identifier">payload</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">false</span>
|
327
|
-
<span class="ruby-keyword">return</span> <span class="ruby-constant">Silkey</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">JwtPayload</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">import</span>(<span class="ruby-identifier">payload</span>)
|
328
|
-
<span class="ruby-keyword">end</span>
|
329
|
-
|
330
|
-
<span class="ruby-keyword">nil</span>
|
331
|
-
<span class="ruby-keyword">rescue</span>
|
332
|
-
<span class="ruby-keyword">nil</span>
|
333
|
-
<span class="ruby-keyword">end</span></pre>
|
334
|
-
</div>
|
335
|
-
|
336
|
-
</div>
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
</div>
|
342
|
-
|
343
|
-
|
344
|
-
</section>
|
345
|
-
|
346
|
-
</section>
|
347
|
-
|
348
|
-
</main>
|
349
|
-
|
350
|
-
|
351
|
-
<footer id="validator-badges" role="contentinfo">
|
352
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
353
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
|
354
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
355
|
-
</footer>
|
356
|
-
|