OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Implements a sign handler using USB gnubbies. | 6 * @fileoverview Implements a sign handler using USB gnubbies. |
7 */ | 7 */ |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 var CORRUPT_sign = false; | 10 var CORRUPT_sign = false; |
11 | 11 |
12 /** | 12 /** |
13 * @param {!SignHelperRequest} request The sign request. | 13 * @param {!SignHelperRequest} request The sign request. |
14 * @constructor | 14 * @constructor |
15 * @implements {RequestHandler} | 15 * @implements {RequestHandler} |
16 */ | 16 */ |
17 function UsbSignHandler(request) { | 17 function UsbSignHandler(request) { |
18 /** @private {!SignHelperRequest} */ | 18 /** @private {!SignHelperRequest} */ |
19 this.request_ = request; | 19 this.request_ = request; |
20 | 20 |
21 /** @private {boolean} */ | 21 /** @private {boolean} */ |
22 this.notified_ = false; | 22 this.notified_ = false; |
23 /** @private {boolean} */ | 23 /** @private {boolean} */ |
24 this.anyGnubbiesFound_ = false; | 24 this.anyGnubbiesFound_ = false; |
25 /** @private {!Array.<!Gnubby>} */ | 25 /** @private {!Array<!Gnubby>} */ |
26 this.notEnrolledGnubbies_ = []; | 26 this.notEnrolledGnubbies_ = []; |
27 } | 27 } |
28 | 28 |
29 /** | 29 /** |
30 * Default timeout value in case the caller never provides a valid timeout. | 30 * Default timeout value in case the caller never provides a valid timeout. |
31 * @const | 31 * @const |
32 */ | 32 */ |
33 UsbSignHandler.DEFAULT_TIMEOUT_MILLIS = 30 * 1000; | 33 UsbSignHandler.DEFAULT_TIMEOUT_MILLIS = 30 * 1000; |
34 | 34 |
35 /** | 35 /** |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 case Gnubby.U2F_V1: | 160 case Gnubby.U2F_V1: |
161 enrollChallenge = UsbSignHandler.BOGUS_CHALLENGE_V1; | 161 enrollChallenge = UsbSignHandler.BOGUS_CHALLENGE_V1; |
162 break; | 162 break; |
163 case Gnubby.U2F_V2: | 163 case Gnubby.U2F_V2: |
164 enrollChallenge = UsbSignHandler.BOGUS_CHALLENGE_V2; | 164 enrollChallenge = UsbSignHandler.BOGUS_CHALLENGE_V2; |
165 break; | 165 break; |
166 default: | 166 default: |
167 self.notifyError_(DeviceStatusCodes.INVALID_DATA_STATUS); | 167 self.notifyError_(DeviceStatusCodes.INVALID_DATA_STATUS); |
168 } | 168 } |
169 gnubby.enroll( | 169 gnubby.enroll( |
170 /** @type {Array.<number>} */ (enrollChallenge), | 170 /** @type {Array<number>} */ (enrollChallenge), |
171 UsbSignHandler.BOGUS_APP_ID_HASH, | 171 UsbSignHandler.BOGUS_APP_ID_HASH, |
172 self.enrollCallback_.bind(self, gnubby)); | 172 self.enrollCallback_.bind(self, gnubby)); |
173 }); | 173 }); |
174 }; | 174 }; |
175 | 175 |
176 /** | 176 /** |
177 * Called with the result of the (bogus, tap capturing) enroll command. | 177 * Called with the result of the (bogus, tap capturing) enroll command. |
178 * @param {Gnubby} gnubby The gnubby "enrolled". | 178 * @param {Gnubby} gnubby The gnubby "enrolled". |
179 * @param {number} code The result of the enroll command. | 179 * @param {number} code The result of the enroll command. |
180 * @param {ArrayBuffer=} infoArray Returned data. | 180 * @param {ArrayBuffer=} infoArray Returned data. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 UsbSignHandler.prototype.close = function() { | 253 UsbSignHandler.prototype.close = function() { |
254 while (this.notEnrolledGnubbies_.length != 0) { | 254 while (this.notEnrolledGnubbies_.length != 0) { |
255 var gnubby = this.notEnrolledGnubbies_.shift(); | 255 var gnubby = this.notEnrolledGnubbies_.shift(); |
256 gnubby.closeWhenIdle(); | 256 gnubby.closeWhenIdle(); |
257 } | 257 } |
258 if (this.signer_) { | 258 if (this.signer_) { |
259 this.signer_.close(); | 259 this.signer_.close(); |
260 this.signer_ = null; | 260 this.signer_ = null; |
261 } | 261 } |
262 }; | 262 }; |
OLD | NEW |