bitid 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.
- data/README.md +12 -4
- data/lib/bitid.rb +4 -5
- data/lib/bitid/version.rb +1 -1
- data/test/test_bitid.rb +4 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -33,13 +33,12 @@ bitid = Bitid.new(nonce:@nonce, callback:@callback)
|
|
33
33
|
Once the `Bitid` object is initialized, you have access to the following methods :
|
34
34
|
|
35
35
|
```
|
36
|
-
bitid.
|
36
|
+
bitid.uri
|
37
37
|
```
|
38
38
|
|
39
|
-
This is the
|
39
|
+
This is the uri which will trigger the wallet when clicked (or scanned as QRcode). For instance :
|
40
40
|
|
41
41
|
```
|
42
|
-
Bitcoin Signed Message:
|
43
42
|
bitid://bitid-demo.herokuapp.com/callback?x=987f20277c015ce7
|
44
43
|
```
|
45
44
|
|
@@ -47,7 +46,7 @@ bitid://bitid-demo.herokuapp.com/callback?x=987f20277c015ce7
|
|
47
46
|
bitid.qrcode
|
48
47
|
```
|
49
48
|
|
50
|
-
The same
|
49
|
+
The same uri, but on QRcode format (this is actualy an URL pointing to the QRcode image).
|
51
50
|
|
52
51
|
### Verification
|
53
52
|
|
@@ -80,6 +79,15 @@ If returns `true`, then you can authenticate the user's session with `address` (
|
|
80
79
|
address used to sign the challenge).
|
81
80
|
|
82
81
|
|
82
|
+
## Integration example
|
83
|
+
|
84
|
+
Ruby on Rails application using the bitid gem :
|
85
|
+
https://github.com/bitid/bitid-demo
|
86
|
+
|
87
|
+
Live demonstration :
|
88
|
+
http://bitid-demo.herokuapp.com/
|
89
|
+
|
90
|
+
|
83
91
|
## Author
|
84
92
|
|
85
93
|
Eric Larchevêque
|
data/lib/bitid.rb
CHANGED
@@ -6,7 +6,6 @@ class Bitid
|
|
6
6
|
|
7
7
|
SCHEME = 'bitid'
|
8
8
|
PARAM_NONCE = 'x'
|
9
|
-
SIGNATURE_HEADER = "Bitcoin Signed Message:\n"
|
10
9
|
|
11
10
|
attr_accessor :nonce, :callback, :signature, :uri
|
12
11
|
|
@@ -25,19 +24,19 @@ class Bitid
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def signature_valid?
|
28
|
-
BitcoinCigs.verify_message(@address, @signature,
|
27
|
+
BitcoinCigs.verify_message(@address, @signature, uri)
|
29
28
|
end
|
30
29
|
|
31
30
|
def qrcode
|
32
|
-
"http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=" + CGI::escape(
|
31
|
+
"http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=" + CGI::escape(uri)
|
33
32
|
end
|
34
33
|
|
35
34
|
def nonce
|
36
35
|
CGI::parse(@uri.query)[PARAM_NONCE][0]
|
37
36
|
end
|
38
37
|
|
39
|
-
def
|
40
|
-
|
38
|
+
def uri
|
39
|
+
@uri.to_s
|
41
40
|
end
|
42
41
|
|
43
42
|
def callback
|
data/lib/bitid/version.rb
CHANGED
data/test/test_bitid.rb
CHANGED
@@ -8,7 +8,7 @@ class TestBitid < Test::Unit::TestCase
|
|
8
8
|
@callback = "http://localhost:3000/callback"
|
9
9
|
@uri = "bitid://localhost:3000/callback?x=fe32e61882a71074"
|
10
10
|
@address = "1HpE8571PFRwge5coHiFdSCLcwa7qetcn"
|
11
|
-
@signature = "
|
11
|
+
@signature = "IPKm1/EZ1AKscpwSZI34F5NiEkpdr7QKHeLOPPSGs6TXJHULs7CSNtjurcfg72HNuKvL2YgNXdOetQRyARhX7bg="
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_build_uri
|
@@ -27,14 +27,14 @@ class TestBitid < Test::Unit::TestCase
|
|
27
27
|
def test_build_qrcode
|
28
28
|
bitid = Bitid.new(nonce:@nonce, callback:@callback)
|
29
29
|
|
30
|
-
uri_encoded = CGI::escape(bitid.
|
30
|
+
uri_encoded = CGI::escape(bitid.uri)
|
31
31
|
assert_equal "http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=#{uri_encoded}", bitid.qrcode
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def test_build_uri
|
35
35
|
bitid = Bitid.new(nonce:@nonce, callback:@callback)
|
36
36
|
|
37
|
-
assert_match /\
|
37
|
+
assert_match /\Abitid\:\/\/localhost\:3000\/callback\?x=/, bitid.uri
|
38
38
|
end
|
39
39
|
|
40
40
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bitcoin-cigs
|