istox 0.1.59 → 0.1.60

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb2501745dc3c1a95428024656b225b1a2a78f5715716352b86b7677aa317ea6
4
- data.tar.gz: e6fd4f92f1b0f5bd27c91a0793c6d1fa38c27966ee1aacba434d1c09ccae2473
3
+ metadata.gz: 6df187a438469dbdcd93499396e5bd086d7e82fd30b86f2309745017b05e6e85
4
+ data.tar.gz: 0a65c964191f07e0f95afe5801d1ed2ebc5e01bc3b442326a96d2c96f5314cce
5
5
  SHA512:
6
- metadata.gz: a38571a28bcce4b524421cf9abf68a817d44c1b9817cf9f7cd45eee3821be080f8a9847c6061f5a78b1b6c0befbee858b8ea1fd5687ecd5a948be1b3cf39bb40
7
- data.tar.gz: d2a04b4c76da2683686ded3cb877a6c002f924bbd9213ea4fe7a39a5cd558327060c16279882f6f14acefbac69f3af9486a27a424477519b7d9da128723e891b
6
+ metadata.gz: 38877c3c8edd6b2246fc8ffc919fe20319a78b893f9ae022699492351475d2bcc7814364bd67b391fe6a270121352895608b7c2d2d26d9634b69c7a023280379
7
+ data.tar.gz: 92cd75003781fec060f9c7f74a8c4cfa5b76120e9dca70bdc8a8ba1cc3af733cab75776de51399be38c7ac002e42507204c3c5b37861c1c4ad17c5688e8c5e74
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" addBOMForNewFiles="with NO BOM" />
4
+ </project>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.6, RVM: ruby-2.5.3 [global]) [gem]" level="application" />
11
+ </component>
12
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.5.3 [global]" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/istox-gem.iml" filepath="$PROJECT_DIR$/.idea/istox-gem.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,323 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="34535e85-0c20-4dc0-afa1-48a1220ef350" name="Default Changelist" comment="">
5
+ <change afterPath="$PROJECT_DIR$/lib/istox/helpers/vault.rb" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/istox.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/istox.gemspec" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/lib/istox.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox.rb" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/lib/istox/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox/version.rb" afterDir="false" />
10
+ </list>
11
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
12
+ <option name="SHOW_DIALOG" value="false" />
13
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
+ <option name="LAST_RESOLUTION" value="IGNORE" />
16
+ </component>
17
+ <component name="FileEditorManager">
18
+ <leaf>
19
+ <file pinned="false" current-in-tab="false">
20
+ <entry file="file://$PROJECT_DIR$/lib/istox/version.rb">
21
+ <provider selected="true" editor-type-id="text-editor">
22
+ <state relative-caret-position="45">
23
+ <caret line="3" selection-start-line="3" selection-end-line="3" />
24
+ </state>
25
+ </provider>
26
+ </entry>
27
+ </file>
28
+ <file pinned="false" current-in-tab="false">
29
+ <entry file="file://$PROJECT_DIR$/lib/istox.rb">
30
+ <provider selected="true" editor-type-id="text-editor">
31
+ <state relative-caret-position="45">
32
+ <caret line="3" selection-start-line="3" selection-end-line="3" />
33
+ </state>
34
+ </provider>
35
+ </entry>
36
+ </file>
37
+ <file pinned="false" current-in-tab="false">
38
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/grpc_client.rb">
39
+ <provider selected="true" editor-type-id="text-editor">
40
+ <state relative-caret-position="105">
41
+ <caret line="7" selection-start-line="7" selection-end-line="7" />
42
+ </state>
43
+ </provider>
44
+ </entry>
45
+ </file>
46
+ <file pinned="false" current-in-tab="false">
47
+ <entry file="file://$PROJECT_DIR$/lib/istox/models/blockchain_receipt.rb">
48
+ <provider selected="true" editor-type-id="text-editor">
49
+ <state relative-caret-position="165">
50
+ <caret line="11" column="3" selection-start-line="11" selection-start-column="3" selection-end-line="11" selection-end-column="3" />
51
+ </state>
52
+ </provider>
53
+ </entry>
54
+ </file>
55
+ <file pinned="false" current-in-tab="false">
56
+ <entry file="file://$PROJECT_DIR$/Gemfile">
57
+ <provider selected="true" editor-type-id="text-editor">
58
+ <state relative-caret-position="90">
59
+ <caret line="6" selection-start-line="6" selection-end-line="6" />
60
+ </state>
61
+ </provider>
62
+ </entry>
63
+ </file>
64
+ <file pinned="false" current-in-tab="false">
65
+ <entry file="file://$PROJECT_DIR$/README.md">
66
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
67
+ <state split_layout="SPLIT">
68
+ <first_editor relative-caret-position="120">
69
+ <caret line="8" column="52" selection-start-line="8" selection-start-column="19" selection-end-line="8" selection-end-column="52" />
70
+ </first_editor>
71
+ <second_editor />
72
+ </state>
73
+ </provider>
74
+ </entry>
75
+ </file>
76
+ <file pinned="false" current-in-tab="false">
77
+ <entry file="file://$PROJECT_DIR$/istox.gemspec">
78
+ <provider selected="true" editor-type-id="text-editor">
79
+ <state relative-caret-position="735">
80
+ <caret line="49" selection-start-line="49" selection-end-line="49" />
81
+ </state>
82
+ </provider>
83
+ </entry>
84
+ </file>
85
+ <file pinned="false" current-in-tab="true">
86
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/vault.rb">
87
+ <provider selected="true" editor-type-id="text-editor">
88
+ <state relative-caret-position="-320">
89
+ <caret line="28" column="60" lean-forward="true" selection-start-line="28" selection-start-column="60" selection-end-line="28" selection-end-column="60" />
90
+ </state>
91
+ </provider>
92
+ </entry>
93
+ </file>
94
+ <file pinned="false" current-in-tab="false">
95
+ <entry file="file://$PROJECT_DIR$/Gemfile.lock">
96
+ <provider selected="true" editor-type-id="text-editor" />
97
+ </entry>
98
+ </file>
99
+ </leaf>
100
+ </component>
101
+ <component name="Git.Settings">
102
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
103
+ </component>
104
+ <component name="IdeDocumentHistory">
105
+ <option name="CHANGED_PATHS">
106
+ <list>
107
+ <option value="$PROJECT_DIR$/istox.gemspec" />
108
+ <option value="$PROJECT_DIR$/lib/istox.rb" />
109
+ <option value="$PROJECT_DIR$/README.md" />
110
+ <option value="$PROJECT_DIR$/lib/istox/version.rb" />
111
+ <option value="$PROJECT_DIR$/lib/istox/helpers/vault.rb" />
112
+ </list>
113
+ </option>
114
+ </component>
115
+ <component name="ProjectFrameBounds" extendedState="6">
116
+ <option name="y" value="23" />
117
+ <option name="width" value="1440" />
118
+ <option name="height" value="852" />
119
+ </component>
120
+ <component name="ProjectView">
121
+ <navigator proportions="" version="1">
122
+ <foldersAlwaysOnTop value="true" />
123
+ </navigator>
124
+ <panes>
125
+ <pane id="ProjectPane">
126
+ <subPane>
127
+ <expand>
128
+ <path>
129
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
130
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
131
+ </path>
132
+ <path>
133
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
134
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
135
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
136
+ </path>
137
+ <path>
138
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
139
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
140
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
141
+ <item name="istox" type="462c0819:PsiDirectoryNode" />
142
+ </path>
143
+ <path>
144
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
145
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
146
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
147
+ <item name="istox" type="462c0819:PsiDirectoryNode" />
148
+ <item name="helpers" type="462c0819:PsiDirectoryNode" />
149
+ </path>
150
+ <path>
151
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
152
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
153
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
154
+ <item name="istox" type="462c0819:PsiDirectoryNode" />
155
+ <item name="interfaces" type="462c0819:PsiDirectoryNode" />
156
+ </path>
157
+ <path>
158
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
159
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
160
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
161
+ <item name="istox" type="462c0819:PsiDirectoryNode" />
162
+ <item name="models" type="462c0819:PsiDirectoryNode" />
163
+ </path>
164
+ <path>
165
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
166
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
167
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
168
+ <item name="istox" type="462c0819:PsiDirectoryNode" />
169
+ <item name="models" type="462c0819:PsiDirectoryNode" />
170
+ <item name="concerns" type="462c0819:PsiDirectoryNode" />
171
+ </path>
172
+ <path>
173
+ <item name="istox-gem" type="b2602c69:ProjectViewProjectNode" />
174
+ <item name="istox-gem" type="462c0819:PsiDirectoryNode" />
175
+ <item name="spec" type="462c0819:PsiDirectoryNode" />
176
+ </path>
177
+ </expand>
178
+ <select />
179
+ </subPane>
180
+ </pane>
181
+ <pane id="Scope" />
182
+ </panes>
183
+ </component>
184
+ <component name="PropertiesComponent">
185
+ <property name="WebServerToolWindowFactoryState" value="false" />
186
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
187
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
188
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
189
+ </component>
190
+ <component name="RunDashboard">
191
+ <option name="ruleStates">
192
+ <list>
193
+ <RuleState>
194
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
195
+ </RuleState>
196
+ <RuleState>
197
+ <option name="name" value="StatusDashboardGroupingRule" />
198
+ </RuleState>
199
+ </list>
200
+ </option>
201
+ </component>
202
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" />
203
+ <component name="SvnConfiguration">
204
+ <configuration />
205
+ </component>
206
+ <component name="TaskManager">
207
+ <task active="true" id="Default" summary="Default task">
208
+ <changelist id="34535e85-0c20-4dc0-afa1-48a1220ef350" name="Default Changelist" comment="" />
209
+ <created>1560334369924</created>
210
+ <option name="number" value="Default" />
211
+ <option name="presentableId" value="Default" />
212
+ <updated>1560334369924</updated>
213
+ <workItem from="1560334371589" duration="14024000" />
214
+ </task>
215
+ <servers />
216
+ </component>
217
+ <component name="TimeTrackingManager">
218
+ <option name="totallyTimeSpent" value="14024000" />
219
+ </component>
220
+ <component name="ToolWindowManager">
221
+ <frame x="0" y="23" width="1440" height="852" extended-state="6" />
222
+ <editor active="true" />
223
+ <layout>
224
+ <window_info id="Favorites" side_tool="true" />
225
+ <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
226
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
227
+ <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
228
+ <window_info anchor="bottom" id="Database Changes" />
229
+ <window_info anchor="bottom" id="Version Control" />
230
+ <window_info anchor="bottom" id="Messages" visible="true" weight="0.32971507" />
231
+ <window_info anchor="bottom" id="Terminal" />
232
+ <window_info anchor="bottom" id="Event Log" side_tool="true" />
233
+ <window_info anchor="bottom" id="Message" order="0" />
234
+ <window_info anchor="bottom" id="Find" order="1" />
235
+ <window_info anchor="bottom" id="Run" order="2" />
236
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
237
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
238
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
239
+ <window_info anchor="bottom" id="TODO" order="6" />
240
+ <window_info anchor="right" id="Database" />
241
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
242
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
243
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
244
+ </layout>
245
+ </component>
246
+ <component name="TypeScriptGeneratedFilesManager">
247
+ <option name="version" value="1" />
248
+ </component>
249
+ <component name="editorHistoryManager">
250
+ <entry file="file://$PROJECT_DIR$/lib/istox/models/blockchain_receipt.rb">
251
+ <provider selected="true" editor-type-id="text-editor">
252
+ <state relative-caret-position="165">
253
+ <caret line="11" column="3" selection-start-line="11" selection-start-column="3" selection-end-line="11" selection-end-column="3" />
254
+ </state>
255
+ </provider>
256
+ </entry>
257
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/order_book.rb">
258
+ <provider selected="true" editor-type-id="text-editor" />
259
+ </entry>
260
+ <entry file="file://$PROJECT_DIR$/Gemfile">
261
+ <provider selected="true" editor-type-id="text-editor">
262
+ <state relative-caret-position="90">
263
+ <caret line="6" selection-start-line="6" selection-end-line="6" />
264
+ </state>
265
+ </provider>
266
+ </entry>
267
+ <entry file="file://$PROJECT_DIR$/Gemfile.lock">
268
+ <provider selected="true" editor-type-id="text-editor" />
269
+ </entry>
270
+ <entry file="file://$PROJECT_DIR$/istox.gemspec">
271
+ <provider selected="true" editor-type-id="text-editor">
272
+ <state relative-caret-position="735">
273
+ <caret line="49" selection-start-line="49" selection-end-line="49" />
274
+ </state>
275
+ </provider>
276
+ </entry>
277
+ <entry file="file://$PROJECT_DIR$/README.md">
278
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
279
+ <state split_layout="SPLIT">
280
+ <first_editor relative-caret-position="120">
281
+ <caret line="8" column="52" selection-start-line="8" selection-start-column="19" selection-end-line="8" selection-end-column="52" />
282
+ </first_editor>
283
+ <second_editor />
284
+ </state>
285
+ </provider>
286
+ </entry>
287
+ <entry file="file://$PROJECT_DIR$/lib/istox/version.rb">
288
+ <provider selected="true" editor-type-id="text-editor">
289
+ <state relative-caret-position="45">
290
+ <caret line="3" selection-start-line="3" selection-end-line="3" />
291
+ </state>
292
+ </provider>
293
+ </entry>
294
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/message_service.rb">
295
+ <provider selected="true" editor-type-id="text-editor">
296
+ <state relative-caret-position="285">
297
+ <caret line="17" column="74" lean-forward="true" selection-start-line="17" selection-start-column="74" selection-end-line="17" selection-end-column="74" />
298
+ </state>
299
+ </provider>
300
+ </entry>
301
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/grpc_client.rb">
302
+ <provider selected="true" editor-type-id="text-editor">
303
+ <state relative-caret-position="105">
304
+ <caret line="7" selection-start-line="7" selection-end-line="7" />
305
+ </state>
306
+ </provider>
307
+ </entry>
308
+ <entry file="file://$PROJECT_DIR$/lib/istox.rb">
309
+ <provider selected="true" editor-type-id="text-editor">
310
+ <state relative-caret-position="45">
311
+ <caret line="3" selection-start-line="3" selection-end-line="3" />
312
+ </state>
313
+ </provider>
314
+ </entry>
315
+ <entry file="file://$PROJECT_DIR$/lib/istox/helpers/vault.rb">
316
+ <provider selected="true" editor-type-id="text-editor">
317
+ <state relative-caret-position="-320">
318
+ <caret line="28" column="60" lean-forward="true" selection-start-line="28" selection-start-column="60" selection-end-line="28" selection-end-column="60" />
319
+ </state>
320
+ </provider>
321
+ </entry>
322
+ </component>
323
+ </project>
data/README.md CHANGED
@@ -2,6 +2,8 @@ to publish new version
2
2
 
3
3
  1. Change version number in version.rb
4
4
 
5
- 2. gem build istox
5
+ 2. `gem build istox`
6
6
 
7
- 3. gem push istox-<VERSION>.gem
7
+ 3. `gem push istox-<VERSION>.gem`
8
+
9
+ 4. in local repo: `bundle install istox --full-index`
data/istox.gemspec CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency "bunny", ">= 2.12.0"
35
35
  spec.add_dependency "istox_gruf"
36
+ spec.add_dependency "gruf"
37
+ spec.add_dependency 'vault', '~> 0.1'
36
38
  spec.add_dependency "paranoia", "~> 2.2"
37
39
  spec.add_dependency "graphlient"
38
40
  spec.add_dependency 'listen', '~> 3.0.5'
@@ -44,8 +46,6 @@ Gem::Specification.new do |spec|
44
46
  spec.add_development_dependency "faker", "~> 1.7.3"
45
47
  spec.add_development_dependency "bullet", "~> 5.7.5"
46
48
  spec.add_development_dependency "rails", "~> 5.2.1"
47
-
48
49
  spec.add_development_dependency "sqlite3", "~> 1.3.6"
49
50
  spec.add_development_dependency "database_cleaner", "~> 1.6.0"
50
-
51
51
  end
data/lib/istox.rb CHANGED
@@ -15,6 +15,7 @@ module Istox
15
15
  require "istox/interfaces/chainhub/transaction"
16
16
  require "istox/helpers/publisher"
17
17
  require "istox/helpers/bunny_boot"
18
+ require "istox/helpers/vault"
18
19
  require "istox/helpers/order_book"
19
20
  require "istox/helpers/grpc_client"
20
21
  require "istox/helpers/graphql_client"
@@ -0,0 +1,89 @@
1
+ require 'vault'
2
+
3
+ module Istox
4
+ module Vault
5
+ module TOTP
6
+ class << self
7
+
8
+ def create(sid, host)
9
+ Rails.logger.debug { "Generate vault TOTP for key #{totp_key(sid).inspect}" }
10
+
11
+ write_data(totp_key(sid),
12
+ generate: true,
13
+ issuer: host,
14
+ account_name: sid,
15
+ qr_size: 300)
16
+ end
17
+
18
+ def generate_code(sid)
19
+ Rails.logger.debug { "Generate 6-digit OTP code: key #{totp_code_key(sid)}" }
20
+ return read_data(totp_code_key(sid)).data[:code]
21
+ end
22
+
23
+ def validate?(sid, code)
24
+ Rails.logger.debug { "Validate TOTP code: key #{totp_code_key(sid)}, code: #{code}" }
25
+ result = write_data(totp_code_key(sid), code: code).data[:valid]
26
+
27
+ unless result
28
+ code = read_data(totp_code_key(sid)).data[:code]
29
+ Rails.logger.debug { "Code is not valid, it should be #{code}" }
30
+ end
31
+
32
+ result
33
+ end
34
+
35
+ private
36
+
37
+ def read_data(key)
38
+ ::Vault.logical.read(key)
39
+ end
40
+
41
+ def write_data(key, params)
42
+ ::Vault.logical.write(key, params)
43
+ end
44
+
45
+ def totp_key(sid)
46
+ "totp/keys/#{sid}"
47
+ end
48
+
49
+ def totp_code_key(sid)
50
+ "totp/code/#{sid}"
51
+ end
52
+ end
53
+ end
54
+
55
+ class << self
56
+
57
+ def logical
58
+ ::Vault.logical
59
+ end
60
+
61
+ def initialize(secret_key, file_location)
62
+ ::Vault.configure do |config|
63
+ config.address = secret_key
64
+
65
+ if File.exist?(file_location)
66
+ token = File.read(file_location).strip
67
+ config.token = token
68
+ config.ssl_verify = false
69
+ config.timeout = 60
70
+ else
71
+ Rails.logger.info 'Vault token not found, OTP will not be able to use'
72
+ end
73
+ end
74
+ end
75
+
76
+ def get_otp(sid, host)
77
+ ::Istox::Vault::TOTP.create(sid, host)
78
+ Istox::Vault::TOTP.generate_code(sid)
79
+ end
80
+
81
+ def validate_otp(sid, otp)
82
+ return ::Istox::Vault::TOTP.validate?(sid, otp)
83
+ rescue => e
84
+ raise e
85
+ false
86
+ end
87
+ end
88
+ end
89
+ end
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = "0.1.59"
2
+ VERSION = "0.1.60"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.59
4
+ version: 0.1.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-15 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: gruf
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vault
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: paranoia
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -228,6 +256,14 @@ extensions: []
228
256
  extra_rdoc_files: []
229
257
  files:
230
258
  - ".gitignore"
259
+ - ".idea/.rakeTasks"
260
+ - ".idea/encodings.xml"
261
+ - ".idea/inspectionProfiles/Project_Default.xml"
262
+ - ".idea/istox-gem.iml"
263
+ - ".idea/misc.xml"
264
+ - ".idea/modules.xml"
265
+ - ".idea/vcs.xml"
266
+ - ".idea/workspace.xml"
231
267
  - CODE_OF_CONDUCT.md
232
268
  - Gemfile
233
269
  - Gemfile.lock
@@ -247,6 +283,7 @@ files:
247
283
  - lib/istox/helpers/message_service.rb
248
284
  - lib/istox/helpers/order_book.rb
249
285
  - lib/istox/helpers/publisher.rb
286
+ - lib/istox/helpers/vault.rb
250
287
  - lib/istox/interfaces/chainhub/transaction.rb
251
288
  - lib/istox/migrations/create_blockchain_receipts.rb
252
289
  - lib/istox/models/blockchain_receipt.rb
@@ -271,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
308
  version: '0'
272
309
  requirements: []
273
310
  rubyforge_project:
274
- rubygems_version: 2.7.9
311
+ rubygems_version: 2.7.8
275
312
  signing_key:
276
313
  specification_version: 4
277
314
  summary: istox backend shared gem