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 Provides a client view of a gnubby, aka USB security key. | 6 * @fileoverview Provides a client view of a gnubby, aka USB security key. |
7 */ | 7 */ |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 busyWait.clearTimeout(); | 451 busyWait.clearTimeout(); |
452 cb(rc, rc_data); | 452 cb(rc, rc_data); |
453 } | 453 } |
454 } | 454 } |
455 | 455 |
456 retryBusy(-GnubbyDevice.BUSY, undefined); // Start work. | 456 retryBusy(-GnubbyDevice.BUSY, undefined); // Start work. |
457 }; | 457 }; |
458 | 458 |
459 /** Default callback for commands. Simply logs to console. | 459 /** Default callback for commands. Simply logs to console. |
460 * @param {number} rc Result status code | 460 * @param {number} rc Result status code |
461 * @param {(ArrayBuffer|Uint8Array|Array.<number>|null)} data Result data | 461 * @param {(ArrayBuffer|Uint8Array|Array<number>|null)} data Result data |
462 */ | 462 */ |
463 Gnubby.defaultCallback = function(rc, data) { | 463 Gnubby.defaultCallback = function(rc, data) { |
464 var msg = 'defaultCallback(' + rc; | 464 var msg = 'defaultCallback(' + rc; |
465 if (data) { | 465 if (data) { |
466 if (typeof data == 'string') msg += ', ' + data; | 466 if (typeof data == 'string') msg += ', ' + data; |
467 else msg += ', ' + UTIL_BytesToHex(new Uint8Array(data)); | 467 else msg += ', ' + UTIL_BytesToHex(new Uint8Array(data)); |
468 } | 468 } |
469 msg += ')'; | 469 msg += ')'; |
470 console.log(UTIL_fmt(msg)); | 470 console.log(UTIL_fmt(msg)); |
471 }; | 471 }; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 } | 788 } |
789 } | 789 } |
790 // Warn on errors other than waiting for touch, wrong data, and | 790 // Warn on errors other than waiting for touch, wrong data, and |
791 // unrecognized command. | 791 // unrecognized command. |
792 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) { | 792 if (rc != 0x6985 && rc != 0x6a80 && rc != 0x6d00) { |
793 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16))); | 793 console.warn(UTIL_fmt('apduReply_ fail: ' + rc.toString(16))); |
794 } | 794 } |
795 cb(rc); | 795 cb(rc); |
796 }); | 796 }); |
797 }; | 797 }; |
OLD | NEW |