ruby-safenet 0.5.5 → 0.5.6
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/lib/safenet.rb +20 -16
- data/lib/safenet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 198d957bb43bfcba30cbc1839fb488bc999a030b
|
4
|
+
data.tar.gz: 5678f5f43a3dbfb937c5342edc55b8f77467559e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ca589ba67befd4d746c63e7d9002f155034b72ac5d605688374856542b0cbc9f85df9088b9af6aa8964a59290a9c15dd9da54b4a9a8a9e935fac21292c270f
|
7
|
+
data.tar.gz: 2b996a4d1e0dcecedcd854179c41960dd864f33604c6ab9773f34352a0c9e476f477f4e157b9ce8ee856c478c8c10ef4ef41105f12c34cd8e28e862c4008dea3
|
data/lib/safenet.rb
CHANGED
@@ -2,13 +2,17 @@ require "safenet/version"
|
|
2
2
|
require "net/http"
|
3
3
|
require "base64"
|
4
4
|
require "json"
|
5
|
-
require "cgi" #
|
5
|
+
require "cgi" # SafeNet.escape method
|
6
6
|
|
7
7
|
API_VERSION = 0.5
|
8
8
|
API_ENDPOINT = "http://localhost:8100/"
|
9
9
|
|
10
10
|
module SafeNet
|
11
11
|
|
12
|
+
def self.escape(str)
|
13
|
+
CGI.escape(str).gsub(/\+/, '%20')
|
14
|
+
end
|
15
|
+
|
12
16
|
class Client
|
13
17
|
attr_reader :auth, :nfs, :dns, :sd, :ad, :immutable, :cipher, :data_id, :app_info, :key_helper
|
14
18
|
|
@@ -210,7 +214,7 @@ module SafeNet
|
|
210
214
|
options[:is_private] = true if ! options.has_key?(:is_private)
|
211
215
|
|
212
216
|
# Entry point
|
213
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{
|
217
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{SafeNet.escape(dir_path)}"
|
214
218
|
|
215
219
|
# Payload
|
216
220
|
payload = {
|
@@ -259,7 +263,7 @@ module SafeNet
|
|
259
263
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
260
264
|
|
261
265
|
# Entry point
|
262
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{
|
266
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{SafeNet.escape(dir_path)}"
|
263
267
|
|
264
268
|
# API call
|
265
269
|
uri = URI(url)
|
@@ -288,11 +292,11 @@ module SafeNet
|
|
288
292
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
289
293
|
|
290
294
|
# Entry point
|
291
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{
|
295
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{SafeNet.escape(dir_path)}"
|
292
296
|
|
293
297
|
# Optional payload
|
294
298
|
payload = {}
|
295
|
-
payload["name"] =
|
299
|
+
payload["name"] = SafeNet.escape(options[:name]) if options.has_key?(:name)
|
296
300
|
payload["metadata"] = Base64.strict_encode64(options[:meta]) if options.has_key?(:meta)
|
297
301
|
|
298
302
|
# API call
|
@@ -329,7 +333,7 @@ module SafeNet
|
|
329
333
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
330
334
|
|
331
335
|
# Entry point
|
332
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{
|
336
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/directory/#{options[:root_path]}/#{SafeNet.escape(dir_path)}"
|
333
337
|
|
334
338
|
# API call
|
335
339
|
uri = URI(url)
|
@@ -359,7 +363,7 @@ module SafeNet
|
|
359
363
|
contents ||= ""
|
360
364
|
|
361
365
|
# Entry point
|
362
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{
|
366
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{SafeNet.escape(file_path)}"
|
363
367
|
|
364
368
|
# API call
|
365
369
|
uri = URI(url)
|
@@ -393,7 +397,7 @@ module SafeNet
|
|
393
397
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
394
398
|
|
395
399
|
# Entry point
|
396
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{
|
400
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{SafeNet.escape(file_path)}"
|
397
401
|
|
398
402
|
# API call
|
399
403
|
uri = URI(url)
|
@@ -429,7 +433,7 @@ module SafeNet
|
|
429
433
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
430
434
|
|
431
435
|
# Entry point
|
432
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{
|
436
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{SafeNet.escape(file_path)}?"
|
433
437
|
|
434
438
|
# Query params
|
435
439
|
query = []
|
@@ -468,11 +472,11 @@ module SafeNet
|
|
468
472
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
469
473
|
|
470
474
|
# Entry point
|
471
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/metadata/#{options[:root_path]}/#{
|
475
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/metadata/#{options[:root_path]}/#{SafeNet.escape(file_path)}"
|
472
476
|
|
473
477
|
# Optional payload
|
474
478
|
payload = {}
|
475
|
-
payload["name"] =
|
479
|
+
payload["name"] = SafeNet.escape(options[:name]) if options.has_key?(:name)
|
476
480
|
payload["metadata"] = Base64.strict_encode64(options[:meta]) if options.has_key?(:meta)
|
477
481
|
|
478
482
|
# API call
|
@@ -535,7 +539,7 @@ module SafeNet
|
|
535
539
|
options[:root_path] = 'app' if ! options.has_key?(:root_path)
|
536
540
|
|
537
541
|
# Entry point
|
538
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{
|
542
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/nfs/file/#{options[:root_path]}/#{SafeNet.escape(file_path)}"
|
539
543
|
|
540
544
|
# API call
|
541
545
|
uri = URI(url)
|
@@ -566,7 +570,7 @@ module SafeNet
|
|
566
570
|
#
|
567
571
|
def create_long_name(long_name)
|
568
572
|
# entry point
|
569
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{
|
573
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{SafeNet.escape(long_name)}"
|
570
574
|
|
571
575
|
# api call
|
572
576
|
uri = URI(url)
|
@@ -671,7 +675,7 @@ module SafeNet
|
|
671
675
|
# https://maidsafe.readme.io/docs/dns-list-services
|
672
676
|
def list_services(long_name)
|
673
677
|
# entry point
|
674
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{
|
678
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{SafeNet.escape(long_name)}"
|
675
679
|
|
676
680
|
# api call
|
677
681
|
uri = URI(url)
|
@@ -687,7 +691,7 @@ module SafeNet
|
|
687
691
|
# https://maidsafe.readme.io/docs/dns-get-home-dir
|
688
692
|
def get_home_dir(long_name, service_name)
|
689
693
|
# entry point
|
690
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{
|
694
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{SafeNet.escape(service_name)}/#{SafeNet.escape(long_name)}"
|
691
695
|
|
692
696
|
# api call
|
693
697
|
uri = URI(url)
|
@@ -704,7 +708,7 @@ module SafeNet
|
|
704
708
|
# get_file_unauth("thegoogle", "www", "index.html")
|
705
709
|
def get_file_unauth(long_name, service_name, file_path)
|
706
710
|
# entry point
|
707
|
-
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{
|
711
|
+
url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{SafeNet.escape(service_name)}/#{SafeNet.escape(long_name)}/#{SafeNet.escape(file_path)}"
|
708
712
|
|
709
713
|
# api call
|
710
714
|
uri = URI(url)
|
data/lib/safenet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-safenet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Loureiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|