touchpass 0.0.8.1 → 0.0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +27 -12
- data/Rakefile +20 -1
- data/app/assets/images/touchpass/buttons/cancelling.png +0 -0
- data/app/assets/images/touchpass/buttons/unverified.png +0 -0
- data/app/assets/images/touchpass/buttons/verified.png +0 -0
- data/app/assets/images/touchpass/buttons/verify.png +0 -0
- data/app/assets/images/touchpass/buttons/verifying.png +0 -0
- data/app/assets/images/touchpass/cross.png +0 -0
- data/app/assets/images/touchpass/loading.gif +0 -0
- data/app/assets/images/touchpass/tick.png +0 -0
- data/app/assets/images/touchpass/touchpass-logo.jpg +0 -0
- data/app/assets/javascripts/touchpass/index.js +1 -0
- data/app/assets/javascripts/touchpass/jquery.touchpass-0.0.1.js +199 -0
- data/app/assets/stylesheets/touchpass/index.css +1 -0
- data/app/assets/stylesheets/touchpass/widget.css +17 -0
- data/app/controllers/touchpass/verifications_controller.rb +10 -6
- data/bin/tpcli.rb +29 -21
- data/bin/tpcrypt.rb +38 -0
- data/config/routes.rb +2 -2
- data/lib/touchpass/client.rb +33 -81
- data/lib/touchpass/crypt.rb +29 -6
- data/lib/touchpass/prp.rb +9 -6
- data/lib/touchpass/{device.rb → rp/device.rb} +5 -2
- data/lib/touchpass/rp/response.rb +34 -0
- data/lib/touchpass/rp/verification.rb +53 -0
- data/lib/touchpass/verification.rb +119 -86
- data/lib/touchpass/version.rb +1 -1
- data/lib/touchpass.rb +27 -5
- data/spec/curl.touchpass_client_spec-workingcontent.txt +268 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/touchpass_client_spec.rb +42 -48
- data/spec/touchpass_crypt_spec.rb +27 -0
- data/spec/touchpass_rp_verification_spec.rb +52 -0
- data/spec/touchpass_spec.rb +12 -0
- data/spec/touchpass_verification_spec.rb +26 -0
- metadata +66 -14
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,38 +1,53 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
configatron (2.9.1)
|
5
|
+
yamler (>= 0.1.0)
|
6
|
+
cover_me (1.2.0)
|
7
|
+
configatron
|
8
|
+
hashie
|
4
9
|
diff-lcs (1.1.3)
|
5
10
|
ffi (1.0.11)
|
6
11
|
geocoder (1.1.1)
|
7
12
|
growl (1.0.3)
|
8
|
-
guard (1.0.
|
13
|
+
guard (1.0.2)
|
9
14
|
ffi (>= 0.5.0)
|
10
15
|
thor (~> 0.14.6)
|
11
|
-
guard-rspec (0.
|
16
|
+
guard-rspec (0.7.2)
|
12
17
|
guard (>= 0.10.0)
|
13
|
-
|
14
|
-
|
18
|
+
hashie (1.2.0)
|
19
|
+
httparty (0.8.3)
|
20
|
+
multi_json (~> 1.0)
|
15
21
|
multi_xml
|
16
|
-
json (1.6.
|
17
|
-
multi_json (1.
|
18
|
-
multi_xml (0.
|
19
|
-
rspec
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
json (1.6.7)
|
23
|
+
multi_json (1.3.5)
|
24
|
+
multi_xml (0.5.1)
|
25
|
+
rspec (2.10.0)
|
26
|
+
rspec-core (~> 2.10.0)
|
27
|
+
rspec-expectations (~> 2.10.0)
|
28
|
+
rspec-mocks (~> 2.10.0)
|
29
|
+
rspec-core (2.10.0)
|
30
|
+
rspec-expectations (2.10.0)
|
31
|
+
diff-lcs (~> 1.1.3)
|
32
|
+
rspec-mocks (2.10.1)
|
23
33
|
thor (0.14.6)
|
34
|
+
xml-simple (1.1.1)
|
35
|
+
yamler (0.1.0)
|
24
36
|
|
25
37
|
PLATFORMS
|
26
38
|
ruby
|
27
39
|
|
28
40
|
DEPENDENCIES
|
41
|
+
cover_me
|
29
42
|
geocoder (~> 1.1.0)
|
30
43
|
growl
|
31
44
|
guard
|
32
45
|
guard-rspec
|
33
46
|
httparty (~> 0.8.0)
|
34
|
-
json
|
47
|
+
json (~> 1.6.5)
|
48
|
+
rspec
|
35
49
|
rspec-core
|
36
50
|
rspec-expectations
|
37
51
|
rspec-mocks
|
38
52
|
thor (~> 0.14.6)
|
53
|
+
xml-simple (~> 1.1.1)
|
data/Rakefile
CHANGED
@@ -1 +1,20 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
+
t.pattern = 'spec/*_spec.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :cover_me do
|
9
|
+
|
10
|
+
desc "Generates and opens code coverage report."
|
11
|
+
task :report do
|
12
|
+
require 'cover_me'
|
13
|
+
CoverMe.complete!
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
task :spec do
|
19
|
+
Rake::Task['cover_me:report'].invoke
|
20
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require touchpass/jquery.touchpass-0.0.1.js
|
@@ -0,0 +1,199 @@
|
|
1
|
+
// Geodica Touchpass
|
2
|
+
// (C) Copyright 2009-2012 Geodica, a Carpadium Pty Ltd Venture
|
3
|
+
// All rights reserved
|
4
|
+
|
5
|
+
touchpass = {
|
6
|
+
|
7
|
+
options: {
|
8
|
+
sub_uri: "",
|
9
|
+
verifications_path: "/touchpass/verifications",
|
10
|
+
resolution: "LOCAL",
|
11
|
+
location_verification: false,
|
12
|
+
address_fields: {address:'address', city:'city', postcode:'postcode', state:'state', country:'country'},
|
13
|
+
message: null,
|
14
|
+
post_verification_message: null,
|
15
|
+
|
16
|
+
defaultMessage: "Enter your TouchPass ID and click Verify to confirm this transaction using your TouchPass enabled smartphone. <a href='http://geodica.com/faq' target='new'>Tell me more about TouchPass</a>.",
|
17
|
+
verifyingMessage: "TouchPass is verifying this transaction. You will receive notification via your smartphone shortly. <a href='http://geodica.com/faq' target='new'>Tell me more about TouchPass</a>.",
|
18
|
+
verifiedMessage: "Enter your TouchPass ID and click Verify to confirm this transaction using your TouchPass enabled smartphone. <a href='http://geodica.com/faq' target='new'>Tell me more about TouchPass</a>.",
|
19
|
+
unverifiedMessage: "TouchPass could not verify this transaction. <a href='http://geodica.com/faq' target='new'>Tell me more about TouchPass</a>.",
|
20
|
+
errorMessage: "TouchPass was unable to verifiy this transaction. A server error occurred. Please try again later.",
|
21
|
+
},
|
22
|
+
|
23
|
+
Verification: function() {
|
24
|
+
this.to_user = "";
|
25
|
+
this.messages = [];
|
26
|
+
|
27
|
+
this.add_message = function(message, options) {
|
28
|
+
if(!message) return;
|
29
|
+
//console.log("message = " + message + ", to_user: " + this.to_user);
|
30
|
+
this.messages.push( $.extend({ message: message }, options || {}) );
|
31
|
+
};
|
32
|
+
},
|
33
|
+
|
34
|
+
initTouchpass: function() {
|
35
|
+
var tpLayout = "<div id='tp-widget-container'><div id='tp-widget-logo'></div><div id='tp-widget-form'></div><div class='tp-widget-clear'></div></div>";
|
36
|
+
var tpForm = "<form action=''><table><tr><td class='tp-widget-input'><input type='text' placeholder='@TouchPass ID' id='tp-widget-username' name='tp-widget-username'/></td>";
|
37
|
+
tpForm += "<td id='tp-widget-verify-action'><input id='tp-widget-verify-btn' type='image' src='/assets/touchpass/buttons/verify.png' value='Verify'/></td></tr></table></form>"
|
38
|
+
tpForm += "<p class='tp-widget-message'>"+this.options.defaultMessage+"</p>";
|
39
|
+
$("#touchpass-widget").html(tpLayout);
|
40
|
+
$("#touchpass-widget #tp-widget-logo").html("<img src='/assets/touchpass/touchpass-logo.jpg'/>");
|
41
|
+
$("#touchpass-widget #tp-widget-form").html(tpForm);
|
42
|
+
},
|
43
|
+
|
44
|
+
launchVerification: function() {
|
45
|
+
var verification = new this.Verification();
|
46
|
+
verification.to_user = $("#tp-widget-username").val();
|
47
|
+
|
48
|
+
if (!verification.to_user) {
|
49
|
+
alert("Please enter your TouchPass Id");
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
|
53
|
+
if (this.options.location_verification) {
|
54
|
+
var addressFields = this.options.address_fields;
|
55
|
+
verification.address = { address: $("#"+addressFields.address).val(), city: $("#"+addressFields.city).val(), state: $("#"+addressFields.state).val(), postcode: $("#"+addressFields.postcode).val(), country: $("#"+addressFields.country).val() };
|
56
|
+
}
|
57
|
+
|
58
|
+
if (this.options.message) {
|
59
|
+
verification.add_message(this.options.message);
|
60
|
+
}
|
61
|
+
if (this.options.post_verification_message) {
|
62
|
+
verification.add_message(this.options.post_verification_message, {requires_verification: true});
|
63
|
+
}
|
64
|
+
|
65
|
+
this.createVerification(verification);
|
66
|
+
return false;
|
67
|
+
},
|
68
|
+
|
69
|
+
ajaxErrorHandler: function(tpass) {
|
70
|
+
$("p.tp-widget-message").html(tpass.options.errorMessage);
|
71
|
+
$("#tp-widget-username").removeClass("loading");
|
72
|
+
$("#tp-widget-username").addClass("unverified");
|
73
|
+
$("#tp-widget-username").attr("disabled", false);
|
74
|
+
$("#tp-widget-username").attr("readonly", true);
|
75
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/unverified.png'/> <a href='#' style='position:relative; top:-10px; color:#ca0638;' id='tp-widget-reload'>Try again</a>");
|
76
|
+
},
|
77
|
+
|
78
|
+
preVerificationHandler: function() {},
|
79
|
+
postVerificationHandler: function() {},
|
80
|
+
|
81
|
+
createVerification: function(verification) {
|
82
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/verifying.png'/>");
|
83
|
+
$("#tp-widget-username").attr('disabled', true);
|
84
|
+
$("#tp-widget-username").addClass('loading');
|
85
|
+
$("p.tp-widget-message").html(this.options.verifyingMessage);
|
86
|
+
|
87
|
+
var _this = this;
|
88
|
+
|
89
|
+
// run pre-verification handlers
|
90
|
+
this.preVerificationHandler(verification);
|
91
|
+
|
92
|
+
$.ajax({type:'POST', url:this.options.sub_uri + this.options.verifications_path+ ".json",
|
93
|
+
data: verification, dataType:'json',
|
94
|
+
success: function(data) {
|
95
|
+
var errors = data.errors;
|
96
|
+
var verificationId = data.uuid;
|
97
|
+
var reference = data.reference;
|
98
|
+
|
99
|
+
if (errors) {
|
100
|
+
$("p.tp-widget-message").html(_this.options.unverifiedMessage);
|
101
|
+
$("#tp-widget-username").removeClass("loading");
|
102
|
+
$("#tp-widget-username").addClass("unverified");
|
103
|
+
$("#tp-widget-username").attr("disabled", false);
|
104
|
+
$("#tp-widget-username").attr("readonly", true);
|
105
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/unverified.png'/> <a href='#' style='position:relative; top:-10px; color:#ca0638;' id='tp-widget-reload'>Try again</a>");
|
106
|
+
console.log(errors);
|
107
|
+
} else {
|
108
|
+
$("#tp-widget-username").attr('value', "Ref: "+reference);
|
109
|
+
}
|
110
|
+
if (verificationId) {
|
111
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/verifying.png'/> <a href='#' id='tp-widget-cancel-verification-"+verificationId+"' class='tp-widget-cancel-verification'>Cancel</a>");
|
112
|
+
_this.requestVerificationStatus(verificationId);
|
113
|
+
}
|
114
|
+
},
|
115
|
+
error: function() { _this.ajaxErrorHandler(_this) }
|
116
|
+
});
|
117
|
+
// console.log("data:"+data);
|
118
|
+
},
|
119
|
+
|
120
|
+
requestVerificationStatus: function(verificationId) {
|
121
|
+
var _this = this;
|
122
|
+
|
123
|
+
$.ajax({
|
124
|
+
type: "GET",
|
125
|
+
url: this.options.sub_uri + this.options.verifications_path + "/" + verificationId + ".json",
|
126
|
+
async: true,
|
127
|
+
cache: false,
|
128
|
+
timeout: 50000, /* Timeout in ms */
|
129
|
+
dataType: 'json',
|
130
|
+
error: function() { _this.ajaxErrorHandler(_this); },
|
131
|
+
success: function(data) {
|
132
|
+
var status = data.state;
|
133
|
+
var completed = true;
|
134
|
+
|
135
|
+
$("#tp-widget-username").attr("disabled", false);
|
136
|
+
$("#tp-widget-username").attr("readonly", true);
|
137
|
+
$("#tp-widget-username").removeClass("loading");
|
138
|
+
|
139
|
+
if (status=="verified") {
|
140
|
+
$("p.tp-widget-message").html(_this.options.verifiedMessage);
|
141
|
+
$("#tp-widget-username").addClass("verified");
|
142
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/verified.png'/>");
|
143
|
+
} else if (status=="unverified") {
|
144
|
+
$("p.tp-widget-message").html(_this.options.unverifiedMessage);
|
145
|
+
$("#tp-widget-username").addClass("unverified");
|
146
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/unverified.png'/> <a href='#' style='position:relative; top:-10px; color:#ca0638;' id='tp-widget-reload'>Try again</a>");
|
147
|
+
} else if (status=="rejected") {
|
148
|
+
$("p.tp-widget-message").html(_this.options.unverifiedMessage);
|
149
|
+
$("#tp-widget-username").addClass("unverified");
|
150
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/unverified.png'/> <a href='#' style='position:relative; top:-10px; color:#ca0638;' id='tp-widget-reload'>Try again</a>");
|
151
|
+
} else if (status=="cancelled") {
|
152
|
+
$("#tp-widget-username").attr('value', "");
|
153
|
+
$("#tp-widget-username").attr("readonly", false);
|
154
|
+
$("p.tp-widget-message").html(_this.options.defaultMessage);
|
155
|
+
$("#tp-widget-verify-action").html("<input id='tp-widget-verify-btn' type='image' src='/assets/touchpass/buttons/verify.png' value='Verify'/>");
|
156
|
+
}
|
157
|
+
else {
|
158
|
+
// request verification status again after 3 seconds
|
159
|
+
completed = false;
|
160
|
+
setTimeout(function() { _this.requestVerificationStatus(verificationId) }, 3000);
|
161
|
+
}
|
162
|
+
|
163
|
+
if(completed) {
|
164
|
+
// run the post verification handler
|
165
|
+
_this.postVerificationHandler(data);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
});
|
169
|
+
},
|
170
|
+
|
171
|
+
cancelVerification: function(verificationId) {
|
172
|
+
$("#tp-widget-verify-action").html("<img src='/assets/touchpass/buttons/cancelling.png'/>");
|
173
|
+
$.ajax({
|
174
|
+
type: "PUT",
|
175
|
+
url: this.options.sub_uri + this.options.verifications_path + "/" + verificationId + "/cancel.json",
|
176
|
+
dataType: "json"
|
177
|
+
});
|
178
|
+
}
|
179
|
+
};
|
180
|
+
|
181
|
+
$(document).ready(function(){
|
182
|
+
touchpass.initTouchpass();
|
183
|
+
|
184
|
+
$('input#tp-widget-verify-btn').live('click', function() {
|
185
|
+
touchpass.launchVerification();
|
186
|
+
return false;
|
187
|
+
});
|
188
|
+
|
189
|
+
$('a#tp-widget-reload').live('click', function() {
|
190
|
+
touchpass.initTouchpass();
|
191
|
+
return false;
|
192
|
+
});
|
193
|
+
|
194
|
+
$('a.tp-widget-cancel-verification').live('click', function() {
|
195
|
+
var id = $(this).attr('id').split("tp-widget-cancel-verification-")[1];
|
196
|
+
touchpass.cancelVerification(id);
|
197
|
+
return false;
|
198
|
+
});
|
199
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require touchpass/widget.css
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#touchpass-widget { width:600px; margin:10px 0; border:solid 5px #e7e5e2; }
|
2
|
+
#touchpass-widget #tp-widget-container { padding:20px; background:#fff; }
|
3
|
+
#touchpass-widget .tp-widget-clear { clear:both; }
|
4
|
+
#touchpass-widget #tp-widget-container #tp-widget-logo { float:left; width:132px; border:none; padding-right:20px; }
|
5
|
+
#touchpass-widget #tp-widget-container #tp-widget-form { float:left; width:408px; min-height:50px; text-align:left; }
|
6
|
+
#touchpass-widget #tp-widget-container #tp-widget-form table { padding:0; margin-bottom:10px; border:0; }
|
7
|
+
#touchpass-widget #tp-widget-container #tp-widget-form table td { padding:0; border:0; }
|
8
|
+
#touchpass-widget #tp-widget-container #tp-widget-form table td.tp-widget-input { width:220px; }
|
9
|
+
#touchpass-widget #tp-widget-container #tp-widget-form input#tp-widget-username { display:inline-block; width:200px; height:22px; padding:4px; font-size:13px; line-height:18px; color:#808080; border:1px solid #ccc; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px; -webkit-transition:border linear 0.2s, box-shadow linear 0.2s; -moz-transition:border linear 0.2s, box-shadow linear 0.2s; -ms-transition: border linear 0.2s, box-shadow linear 0.2s; -o-transition: border linear 0.2s, box-shadow linear 0.2s; transition: border linear 0.2s, box-shadow linear 0.2s; -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); }
|
10
|
+
#touchpass-widget #tp-widget-container #tp-widget-form input#tp-widget-username.loading { background-image:url('/assets/touchpass/loading.gif'); background-repeat:no-repeat; background-position:95% center; }
|
11
|
+
#touchpass-widget #tp-widget-container #tp-widget-form input#tp-widget-username.verified { background-image:url('/assets/touchpass/tick.png'); background-repeat:no-repeat; background-position:95% center; }
|
12
|
+
#touchpass-widget #tp-widget-container #tp-widget-form input#tp-widget-username.unverified { background-image:url('/assets/touchpass/cross.png'); background-repeat:no-repeat; background-position:95% center; }
|
13
|
+
#touchpass-widget #tp-widget-container #tp-widget-form a.tp-widget-cancel-verification { color:#ca0638; position:relative; top:-10px; color:#ca0638; }
|
14
|
+
#touchpass-widget #tp-widget-container #tp-widget-form #tp-widget-verify-action { height:32px; vertical-align:middle; }
|
15
|
+
#touchpass-widget #tp-widget-container #tp-widget-form #tp-widget-verify-action input#tp-widget-verify-btn { width:109px; height:32px; border:none; padding:0; -webkit-border-radius:0; -moz-border-radius:0; border-radius:0; }
|
16
|
+
#touchpass-widget #tp-widget-container p.tp-widget-message { font-size:11px; color:#666; font-weight:bold; }
|
17
|
+
#touchpass-widget #tp-widget-container p.tp-widget-message a { color:#ca0638; font-weight:normal; }
|
@@ -2,28 +2,32 @@ module Touchpass
|
|
2
2
|
class VerificationsController < ApplicationController
|
3
3
|
|
4
4
|
unloadable
|
5
|
+
respond_to :json
|
5
6
|
|
6
7
|
def create
|
7
8
|
verification = Touchpass::Rp::Verification.new
|
8
|
-
response = verification.create
|
9
|
+
response = verification.create(params[:to_user], params)
|
10
|
+
|
9
11
|
respond_to do |format|
|
10
|
-
format.
|
12
|
+
format.json { render :json => response.to_json, :status => response.http_status_code }
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
def show
|
15
17
|
verification = Touchpass::Rp::Verification.new
|
16
|
-
response = verification.show
|
18
|
+
response = verification.show(params[:id])
|
19
|
+
|
17
20
|
respond_to do |format|
|
18
|
-
format.
|
21
|
+
format.json { render :json => response.to_json, :status => response.http_status_code }
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
25
|
def cancel
|
23
26
|
verification = Touchpass::Rp::Verification.new
|
24
|
-
response = verification.cancel
|
27
|
+
response = verification.cancel(params[:id])
|
28
|
+
|
25
29
|
respond_to do |format|
|
26
|
-
format.
|
30
|
+
format.json { render :json => response.to_json, :status => response.http_status_code }
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/bin/tpcli.rb
CHANGED
@@ -30,7 +30,7 @@ class TpCLI < Thor
|
|
30
30
|
method_option :password, :aliases => "-p", :required => true
|
31
31
|
method_option :hostname, :aliases => "-h"
|
32
32
|
method_option :output, :aliases => "-o"
|
33
|
-
method_option :debug, :aliases => "-d"
|
33
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
34
34
|
def register_party
|
35
35
|
setup(options)
|
36
36
|
output @touchpass_client.register_party(options)
|
@@ -41,7 +41,7 @@ class TpCLI < Thor
|
|
41
41
|
method_option :password, :aliases => "-p", :required => true
|
42
42
|
method_option :hostname, :aliases => "-h"
|
43
43
|
method_option :output, :aliases => "-o"
|
44
|
-
method_option :debug, :aliases => "-d"
|
44
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
45
45
|
def authenticate_party
|
46
46
|
setup(options)
|
47
47
|
output @touchpass_client.authenticate_party(options)
|
@@ -53,7 +53,7 @@ class TpCLI < Thor
|
|
53
53
|
method_option :api_key, :required => true, :default => DFT_API_KEY
|
54
54
|
method_option :hostname, :aliases => "-h"
|
55
55
|
method_option :output, :aliases => "-o"
|
56
|
-
method_option :debug, :aliases => "-d"
|
56
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
57
57
|
def show_party
|
58
58
|
setup(options)
|
59
59
|
output @touchpass_client.get_party(options)
|
@@ -68,7 +68,7 @@ class TpCLI < Thor
|
|
68
68
|
method_option :api_key, :required => true
|
69
69
|
method_option :hostname, :aliases => "-h"
|
70
70
|
method_option :output, :aliases => "-o"
|
71
|
-
method_option :debug, :aliases => "-d"
|
71
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
72
72
|
def update_party
|
73
73
|
setup(options)
|
74
74
|
output @touchpass_client.update_party(options)
|
@@ -78,12 +78,13 @@ class TpCLI < Thor
|
|
78
78
|
method_option :username, :aliases => "-u", :required => true
|
79
79
|
method_option :udid, :required => true
|
80
80
|
method_option :name, :aliases => "-n", :required => true
|
81
|
+
method_option :app_id, :aliases => '-a', :required => true
|
81
82
|
method_option :messaging_type, :aliases => "-mt"
|
82
83
|
method_option :messaging_value, :aliases => "-mv"
|
83
84
|
method_option :api_key, :required => true
|
84
85
|
method_option :hostname, :aliases => "-h"
|
85
86
|
method_option :output, :aliases => "-o"
|
86
|
-
method_option :debug, :aliases => "-d"
|
87
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
87
88
|
def register_device
|
88
89
|
setup(options)
|
89
90
|
output @touchpass_client.register_device(options)
|
@@ -94,7 +95,7 @@ class TpCLI < Thor
|
|
94
95
|
method_option :api_key, :required => true, :default => DFT_API_KEY
|
95
96
|
method_option :hostname, :aliases => "-h"
|
96
97
|
method_option :output, :aliases => "-o"
|
97
|
-
method_option :debug, :aliases => "-d"
|
98
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
98
99
|
def show_devices
|
99
100
|
setup(options)
|
100
101
|
output @touchpass_client.get_devices(options)
|
@@ -106,7 +107,7 @@ class TpCLI < Thor
|
|
106
107
|
method_option :api_key, :required => true, :default => DFT_API_KEY
|
107
108
|
method_option :hostname, :aliases => "-h"
|
108
109
|
method_option :output, :aliases => "-o"
|
109
|
-
method_option :debug, :aliases => "-d"
|
110
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
110
111
|
def show_device
|
111
112
|
setup(options)
|
112
113
|
output @touchpass_client.get_device(options)
|
@@ -119,10 +120,10 @@ class TpCLI < Thor
|
|
119
120
|
method_option :messaging_type, :aliases => "-mt"
|
120
121
|
method_option :messaging_value, :aliases => "-mv"
|
121
122
|
method_option :update_pub_key
|
122
|
-
method_option :api_key, :required => true
|
123
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
123
124
|
method_option :hostname, :aliases => "-h"
|
124
125
|
method_option :output, :aliases => "-o"
|
125
|
-
method_option :debug, :aliases => "-d"
|
126
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
126
127
|
def update_device
|
127
128
|
setup(options)
|
128
129
|
output @touchpass_client.update_device(options)
|
@@ -131,10 +132,10 @@ class TpCLI < Thor
|
|
131
132
|
desc "remove_device", "Remove Device"
|
132
133
|
method_option :username, :aliases => "-u", :required => true
|
133
134
|
method_option :id, :required => true
|
134
|
-
method_option :api_key, :required => true
|
135
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
135
136
|
method_option :hostname, :aliases => "-h"
|
136
137
|
method_option :output, :aliases => "-o"
|
137
|
-
method_option :debug, :aliases => "-d"
|
138
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
138
139
|
def remove_device
|
139
140
|
setup(options)
|
140
141
|
output @touchpass_client.remove_device(options)
|
@@ -143,25 +144,32 @@ class TpCLI < Thor
|
|
143
144
|
desc "create_verification", "Create new Verification"
|
144
145
|
method_option :to_party, :aliases => "-t", :required => true
|
145
146
|
method_option :to_device_id, :aliases => "-D"
|
147
|
+
method_option :to_app_id, :aliases => "-A"
|
146
148
|
method_option :message, :aliases => "-m"
|
149
|
+
method_option :message_post_verification, :aliases => "-M"
|
150
|
+
method_option :message_post_verification_location, :aliases => "-L"
|
151
|
+
method_option :scratch_to_reveal, :type => :boolean, :aliases => "-S"
|
147
152
|
method_option :address, :aliases => "-a" # Required for location verfication
|
148
153
|
method_option :resolution, :aliases => "-r"
|
149
|
-
method_option :api_key, :required => true
|
154
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
150
155
|
method_option :hostname, :aliases => "-h"
|
151
156
|
method_option :output, :aliases => "-o"
|
152
|
-
method_option :debug, :aliases => "-d"
|
157
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
153
158
|
def create_verification
|
154
159
|
setup(options)
|
160
|
+
if options[:message_post_verification_location] && !options[:address]
|
161
|
+
warn "WARNING: post verification location message (-L) ignored as address (-a) not given"
|
162
|
+
end
|
155
163
|
output @touchpass_client.create_verification(options)
|
156
164
|
end
|
157
165
|
|
158
166
|
desc "show_verifications", "Show Verifications"
|
159
167
|
method_option :username, :aliases => "-u"
|
160
168
|
method_option :party_id
|
161
|
-
method_option :api_key, :required => true
|
169
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
162
170
|
method_option :hostname, :aliases => "-h"
|
163
171
|
method_option :output, :aliases => "-o"
|
164
|
-
method_option :debug, :aliases => "-d"
|
172
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
165
173
|
def show_verifications
|
166
174
|
setup(options)
|
167
175
|
output @touchpass_client.get_verifications(options)
|
@@ -170,10 +178,10 @@ class TpCLI < Thor
|
|
170
178
|
desc "show_verification", "Show Verification details"
|
171
179
|
method_option :id, :aliases => "-i", :required => true
|
172
180
|
method_option :device_id # For decrypting message (optional)
|
173
|
-
method_option :api_key, :required => true
|
181
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
174
182
|
method_option :hostname, :aliases => "-h"
|
175
183
|
method_option :output, :aliases => "-o"
|
176
|
-
method_option :debug, :aliases => "-d"
|
184
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
177
185
|
def show_verification
|
178
186
|
setup(options)
|
179
187
|
output @touchpass_client.get_verification(options)
|
@@ -183,10 +191,10 @@ class TpCLI < Thor
|
|
183
191
|
method_option :id, :required => true
|
184
192
|
method_option :device_id, :required => true, :aliases => "-d"
|
185
193
|
method_option :address, :aliases => "-a"
|
186
|
-
method_option :api_key, :required => true
|
194
|
+
method_option :api_key, :required => true, :default => DFT_API_KEY
|
187
195
|
method_option :hostname, :aliases => "-h"
|
188
196
|
method_option :output, :aliases => "-o"
|
189
|
-
method_option :debug, :aliases => "-d"
|
197
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
190
198
|
def update_verification
|
191
199
|
setup(options)
|
192
200
|
output @touchpass_client.update_verification(options)
|
@@ -197,7 +205,7 @@ class TpCLI < Thor
|
|
197
205
|
method_option :api_key, :required => true, :default => DFT_API_KEY
|
198
206
|
method_option :hostname, :aliases => "-h"
|
199
207
|
method_option :output, :aliases => "-o"
|
200
|
-
method_option :debug, :aliases => "-d"
|
208
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
201
209
|
def cancel_verification
|
202
210
|
setup(options)
|
203
211
|
output @touchpass_client.cancel_verification(options)
|
@@ -208,7 +216,7 @@ class TpCLI < Thor
|
|
208
216
|
method_option :api_key, :required => true, :default => DFT_API_KEY
|
209
217
|
method_option :hostname, :aliases => "-h"
|
210
218
|
method_option :output, :aliases => "-o"
|
211
|
-
method_option :debug, :aliases => "-d"
|
219
|
+
method_option :debug, :aliases => "-d", :type => :boolean
|
212
220
|
def reject_verification
|
213
221
|
setup(options)
|
214
222
|
output @touchpass_client.reject_verification(options)
|
data/bin/tpcrypt.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "/../lib"))
|
4
|
+
require "touchpass"
|
5
|
+
|
6
|
+
def usage(message)
|
7
|
+
puts "usage: tpcrypt " + message
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
# usage: tpcrypt operation key data
|
13
|
+
|
14
|
+
operation, data, key = ARGV
|
15
|
+
|
16
|
+
case operation
|
17
|
+
when 'encrypt'
|
18
|
+
usage "encrypt data" unless ARGV.length == 2
|
19
|
+
|
20
|
+
key = Touchpass::Crypt.generate_encryption_key
|
21
|
+
p key
|
22
|
+
result = Touchpass::Crypt.encrypt(data, key)
|
23
|
+
|
24
|
+
puts "result: " + Base64.strict_encode64(result)
|
25
|
+
puts "key: " + Base64.strict_encode64(key)
|
26
|
+
|
27
|
+
when 'decrypt'
|
28
|
+
usage "decrypt data key" unless ARGV.length == 3
|
29
|
+
|
30
|
+
key = Base64.strict_decode64(key)
|
31
|
+
data = Base64.strict_decode64(data)
|
32
|
+
result = Touchpass::Crypt.decrypt(data, key)
|
33
|
+
puts "result: " + result
|
34
|
+
else
|
35
|
+
puts "unknown operation '#{operation}'"
|
36
|
+
usage "operation data [key]"
|
37
|
+
end
|
38
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#config/routes.rb
|
2
|
-
Rails.application.routes.draw do
|
2
|
+
Rails.application.routes.draw do
|
3
3
|
scope :module => 'touchpass' do
|
4
4
|
get "touchpass/verifications/:id" => 'verifications#show'
|
5
5
|
post "touchpass/verifications" => 'verifications#create'
|
6
6
|
put "touchpass/verifications/:id/cancel" => 'verifications#cancel'
|
7
7
|
end
|
8
|
-
end
|
8
|
+
end
|