Skip to content

Commit e5e9664

Browse files
committed
create resolve helper
1 parent d91a159 commit e5e9664

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎oidc-client.js‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ function rand() {
3333
return ((Date.now() + Math.random()) * Math.random()).toString().replace(".", "");
3434
}
3535

36+
function resolve(param) {
37+
return _promiseFactory.resolve(param);
38+
}
39+
3640
function error(message) {
3741
return _promiseFactory.reject(Error(message));
3842
}
@@ -141,7 +145,7 @@ OidcClient.prototype.loadMetadataAsync = function () {
141145
var settings = this._settings;
142146

143147
if (settings.metadata) {
144-
return _promiseFactory.resolve(settings.metadata);
148+
return resolve(settings.metadata);
145149
}
146150

147151
if (!settings.authority) {
@@ -176,7 +180,7 @@ OidcClient.prototype.loadX509SigningKeyAsync = function () {
176180
return error("RSA keys empty");
177181
}
178182

179-
return _promiseFactory.resolve(key.x5c[0]);
183+
return resolve(key.x5c[0]);
180184
}
181185

182186
if (settings.jwks) {
@@ -214,7 +218,7 @@ OidcClient.prototype.loadAuthorizationEndpoint = function () {
214218
log("OidcClient.loadAuthorizationEndpoint");
215219

216220
if (this._settings.authorization_endpoint) {
217-
return _promiseFactory.resolve(this._settings.authorization_endpoint);
221+
return resolve(this._settings.authorization_endpoint);
218222
}
219223

220224
if (!this._settings.authority) {
@@ -373,7 +377,7 @@ OidcClient.prototype.validateAccessTokenAsync = function (id_token_contents, acc
373377
return error("at_hash failed to validate");
374378
}
375379

376-
return _promiseFactory.resolve();
380+
return resolve();
377381
};
378382

379383
OidcClient.prototype.validateIdTokenAndAccessTokenAsync = function (id_token, nonce, access_token) {
@@ -451,7 +455,7 @@ OidcClient.prototype.processResponseAsync = function (queryString) {
451455
}
452456
}
453457

454-
var promise = _promiseFactory.resolve();
458+
var promise = resolve();
455459
if (request_state.oidc && request_state.oauth) {
456460
promise = client.validateIdTokenAndAccessTokenAsync(result.id_token, request_state.nonce, result.access_token);
457461
}

0 commit comments

Comments
 (0)