bitid 0.0.2 → 0.0.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.
- data/README.md +18 -2
- data/lib/bitid.rb +8 -2
- data/lib/bitid/version.rb +1 -1
- data/test/test_bitid.rb +7 -1
- metadata +7 -1
data/README.md
CHANGED
@@ -28,7 +28,15 @@ bitid = Bitid.new(nonce:@nonce, callback:@callback)
|
|
28
28
|
```
|
29
29
|
|
30
30
|
`nonce` is an random string associated with the user's session id.
|
31
|
-
`callback` is the url where the wallet will post the challenge's signature.
|
31
|
+
`callback` is the url without the scheme where the wallet will post the challenge's signature.
|
32
|
+
|
33
|
+
One example of callback could be `www.site.com/callback`. A callback cannot have parameters. By
|
34
|
+
default the POST call will be done using `https`. If you need to tell the wallet to POST on
|
35
|
+
`http` then you need to add `unsecure:true`.
|
36
|
+
|
37
|
+
```
|
38
|
+
bitid = Bitid.new(nonce:@nonce, callback:@callback, unsecure:true)
|
39
|
+
```
|
32
40
|
|
33
41
|
Once the `Bitid` object is initialized, you have access to the following methods :
|
34
42
|
|
@@ -42,11 +50,19 @@ This is the uri which will trigger the wallet when clicked (or scanned as QRcode
|
|
42
50
|
bitid://bitid-demo.herokuapp.com/callback?x=987f20277c015ce7
|
43
51
|
```
|
44
52
|
|
53
|
+
If you added `unsecure:true` when initializing the object then uri will be like :
|
54
|
+
|
55
|
+
```
|
56
|
+
bitid://bitid-demo.herokuapp.com/callback?x=987f20277c015ce7&u=1
|
57
|
+
```
|
58
|
+
|
59
|
+
To get the uri as QRcode :
|
60
|
+
|
45
61
|
```
|
46
62
|
bitid.qrcode
|
47
63
|
```
|
48
64
|
|
49
|
-
|
65
|
+
This is actualy an URL pointing to the QRcode image.
|
50
66
|
|
51
67
|
### Verification
|
52
68
|
|
data/lib/bitid.rb
CHANGED
@@ -6,14 +6,16 @@ class Bitid
|
|
6
6
|
|
7
7
|
SCHEME = 'bitid'
|
8
8
|
PARAM_NONCE = 'x'
|
9
|
+
PARAM_UNSECURE = 'u'
|
9
10
|
|
10
|
-
attr_accessor :nonce, :callback, :signature, :uri
|
11
|
+
attr_accessor :nonce, :callback, :signature, :uri, :unsecure
|
11
12
|
|
12
13
|
def initialize hash={}
|
13
14
|
@nonce = hash[:nonce]
|
14
15
|
@callback = URI(hash[:callback])
|
15
16
|
@signature = hash[:signature]
|
16
17
|
@address = hash[:address]
|
18
|
+
@unsecure = hash[:unsecure]
|
17
19
|
@uri = hash[:uri].nil? ? build_uri : URI(hash[:uri])
|
18
20
|
end
|
19
21
|
|
@@ -48,7 +50,11 @@ class Bitid
|
|
48
50
|
def build_uri
|
49
51
|
uri = @callback
|
50
52
|
uri.scheme = SCHEME
|
51
|
-
|
53
|
+
params = {PARAM_NONCE => @nonce}
|
54
|
+
if @unsecure
|
55
|
+
params = params.merge({PARAM_UNSECURE => 1})
|
56
|
+
end
|
57
|
+
uri.query = URI.encode_www_form(params)
|
52
58
|
uri
|
53
59
|
end
|
54
60
|
end
|
data/lib/bitid/version.rb
CHANGED
data/test/test_bitid.rb
CHANGED
@@ -34,7 +34,13 @@ class TestBitid < Test::Unit::TestCase
|
|
34
34
|
def test_build_uri
|
35
35
|
bitid = Bitid.new(nonce:@nonce, callback:@callback)
|
36
36
|
|
37
|
-
assert_match /\Abitid\:\/\/localhost\:3000\/callback\?x
|
37
|
+
assert_match /\Abitid\:\/\/localhost\:3000\/callback\?x=[a-z0-9]+\Z/, bitid.uri
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_build_uri_with_unsecure_param
|
41
|
+
bitid = Bitid.new(nonce:@nonce, callback:@callback, unsecure:true)
|
42
|
+
|
43
|
+
assert_match /\Abitid\:\/\/localhost\:3000\/callback\?x=[a-z0-9]+&u=1\Z/, bitid.uri
|
38
44
|
end
|
39
45
|
|
40
46
|
def test_verify_uri
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -88,12 +88,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- - ! '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: 690211457
|
91
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
95
|
none: false
|
93
96
|
requirements:
|
94
97
|
- - ! '>='
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '0'
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
hash: 690211457
|
97
103
|
requirements: []
|
98
104
|
rubyforge_project:
|
99
105
|
rubygems_version: 1.8.25
|