Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: remoting/webapp/base/js/credentials_provider.js

Issue 1397463003: Report the Auth method for me2me connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/base/js/client_session.js ('k') | remoting/webapp/base/js/log_to_server.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'use strict'; 5 'use strict';
6 6
7 var remoting = remoting || {}; 7 var remoting = remoting || {};
8 8
9 /** @typedef {{clientId: string, sharedSecret: string}} */ 9 /** @typedef {{clientId: string, sharedSecret: string}} */
10 remoting.PairingInfo; 10 remoting.PairingInfo;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 */ 43 */
44 remoting.CredentialsProvider = function(args) { 44 remoting.CredentialsProvider = function(args) {
45 /** @private */ 45 /** @private */
46 this.fetchPin_ = (args.accessCode) ? this.getAccessCode_ : args.fetchPin; 46 this.fetchPin_ = (args.accessCode) ? this.getAccessCode_ : args.fetchPin;
47 /** @private */ 47 /** @private */
48 this.pairingInfo_ = args.pairingInfo; 48 this.pairingInfo_ = args.pairingInfo;
49 /** @private */ 49 /** @private */
50 this.accessCode_ = args.accessCode; 50 this.accessCode_ = args.accessCode;
51 /** @private */ 51 /** @private */
52 this.fetchThirdPartyToken_ = args.fetchThirdPartyToken; 52 this.fetchThirdPartyToken_ = args.fetchThirdPartyToken;
53
54 /** @private {?remoting.ChromotingEvent.AuthMethod} */
55 this.authMethod_ = null;
53 }; 56 };
54 57
55 /** @returns {void} */ 58 /** @returns {void} */
56 remoting.CredentialsProvider.prototype.getAccessCode_ = function( 59 remoting.CredentialsProvider.prototype.getAccessCode_ = function(
57 /** boolean */ supportsPairing, /** Function */ callback) { 60 /** boolean */ supportsPairing, /** Function */ callback) {
61 this.authMethod_ = remoting.ChromotingEvent.AuthMethod.ACCESS_CODE;
58 callback(this.accessCode_); 62 callback(this.accessCode_);
59 }; 63 };
60 64
61 /** @returns {remoting.PairingInfo} */ 65 /** @returns {remoting.PairingInfo} */
62 remoting.CredentialsProvider.prototype.getPairingInfo = function() { 66 remoting.CredentialsProvider.prototype.getPairingInfo = function() {
67 if (this.pairingInfo_) {
68 this.authMethod_ = remoting.ChromotingEvent.AuthMethod.PINLESS;
69 }
63 return this.pairingInfo_ || { clientId: '', sharedSecret: ''}; 70 return this.pairingInfo_ || { clientId: '', sharedSecret: ''};
64 }; 71 };
65 72
66 /** 73 /**
67 * @param {boolean} pairingSupported Whether pairing is supported by the host. 74 * @param {boolean} pairingSupported Whether pairing is supported by the host.
68 * @returns {Promise<string>} 75 * @returns {Promise<string>}
69 */ 76 */
70 remoting.CredentialsProvider.prototype.getPIN = function(pairingSupported) { 77 remoting.CredentialsProvider.prototype.getPIN = function(pairingSupported) {
71 var that = this; 78 var that = this;
72 if (!this.fetchPin_) { 79 if (!this.fetchPin_) {
73 Promise.resolve(''); 80 Promise.resolve('');
74 } 81 }
82
83 this.authMethod_ = remoting.ChromotingEvent.AuthMethod.PIN;
75 return new Promise(function(/** function(string) */ resolve) { 84 return new Promise(function(/** function(string) */ resolve) {
76 that.fetchPin_(pairingSupported, resolve); 85 that.fetchPin_(pairingSupported, resolve);
77 }); 86 });
78 }; 87 };
79 88
80 /** 89 /**
81 * @param {string} tokenUrl Token-issue URL received from the host. 90 * @param {string} tokenUrl Token-issue URL received from the host.
82 * @param {string} hostPublicKey Host public key (DER and Base64 encoded). 91 * @param {string} hostPublicKey Host public key (DER and Base64 encoded).
83 * @param {string} scope OAuth scope to request the token for. 92 * @param {string} scope OAuth scope to request the token for.
84 * 93 *
85 * @returns {Promise<remoting.ThirdPartyToken>} 94 * @returns {Promise<remoting.ThirdPartyToken>}
86 */ 95 */
87 remoting.CredentialsProvider.prototype.getThirdPartyToken = function( 96 remoting.CredentialsProvider.prototype.getThirdPartyToken = function(
88 tokenUrl, hostPublicKey, scope) { 97 tokenUrl, hostPublicKey, scope) {
89 var that = this; 98 var that = this;
90 if (!this.fetchThirdPartyToken_) { 99 if (!this.fetchThirdPartyToken_) {
91 Promise.resolve({token: '', secret: ''}); 100 Promise.resolve({token: '', secret: ''});
92 } 101 }
102
103 this.authMethod_ = remoting.ChromotingEvent.AuthMethod.THIRD_PARTY;
93 return new Promise(function(/** Function */ resolve) { 104 return new Promise(function(/** Function */ resolve) {
94 var onTokenFetched = function(/** string */ token, /** string */ secret) { 105 var onTokenFetched = function(/** string */ token, /** string */ secret) {
95 resolve({token: token, secret: secret}); 106 resolve({token: token, secret: secret});
96 }; 107 };
97 that.fetchThirdPartyToken_(tokenUrl, hostPublicKey, scope, onTokenFetched); 108 that.fetchThirdPartyToken_(tokenUrl, hostPublicKey, scope, onTokenFetched);
98 }); 109 });
99 }; 110 };
111
112 /** @return {?remoting.ChromotingEvent.AuthMethod} */
113 remoting.CredentialsProvider.prototype.getAuthMethod = function() {
114 return this.authMethod_;
115 };
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/client_session.js ('k') | remoting/webapp/base/js/log_to_server.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698