Commit 3a84cbd5 authored by Ahmet Turan Koçak's avatar Ahmet Turan Koçak
Browse files

Initial commit

parents
{"version":3,"file":"AuthToken.d.ts","sourceRoot":"","sources":["../../src/account/AuthToken.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBAAa,SAAS;IAGlB,QAAQ,EAAE,MAAM,CAAC;IAEjB,MAAM,EAAE,WAAW,CAAC;gBACR,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAS7C;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW;IAgB7E;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAW7D"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { ClientAuthError } from '../error/ClientAuthError.js';
import { StringUtils } from '../utils/StringUtils.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* JWT Token representation class. Parses token string and generates claims object.
*/
var AuthToken = /** @class */ (function () {
function AuthToken(rawToken, crypto) {
if (StringUtils.isEmpty(rawToken)) {
throw ClientAuthError.createTokenNullOrEmptyError(rawToken);
}
this.rawToken = rawToken;
this.claims = AuthToken.extractTokenClaims(rawToken, crypto);
}
/**
* Extract token by decoding the rawToken
*
* @param encodedToken
*/
AuthToken.extractTokenClaims = function (encodedToken, crypto) {
var decodedToken = StringUtils.decodeAuthToken(encodedToken);
// token will be decoded to get the username
try {
var base64TokenPayload = decodedToken.JWSPayload;
// base64Decode() should throw an error if there is an issue
var base64Decoded = crypto.base64Decode(base64TokenPayload);
return JSON.parse(base64Decoded);
}
catch (err) {
throw ClientAuthError.createTokenParsingError(err);
}
};
/**
* Determine if the token's max_age has transpired
*/
AuthToken.checkMaxAge = function (authTime, maxAge) {
/*
* per https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
* To force an immediate re-authentication: If an app requires that a user re-authenticate prior to access,
* provide a value of 0 for the max_age parameter and the AS will force a fresh login.
*/
var fiveMinuteSkew = 300000; // five minutes in milliseconds
if ((maxAge === 0) || ((Date.now() - fiveMinuteSkew) > (authTime + maxAge))) {
throw ClientAuthError.createMaxAgeTranspiredError();
}
};
return AuthToken;
}());
export { AuthToken };
//# sourceMappingURL=AuthToken.js.map
{"version":3,"file":"AuthToken.js","sources":["../../src/account/AuthToken.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TokenClaims } from \"./TokenClaims\";\nimport { DecodedAuthToken } from \"./DecodedAuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ICrypto } from \"../crypto/ICrypto\";\n\n/**\n * JWT Token representation class. Parses token string and generates claims object.\n */\nexport class AuthToken {\n\n // Raw Token string\n rawToken: string;\n // Claims inside token\n claims: TokenClaims;\n constructor(rawToken: string, crypto: ICrypto) {\n if (StringUtils.isEmpty(rawToken)) {\n throw ClientAuthError.createTokenNullOrEmptyError(rawToken);\n }\n\n this.rawToken = rawToken;\n this.claims = AuthToken.extractTokenClaims(rawToken, crypto);\n }\n\n /**\n * Extract token by decoding the rawToken\n *\n * @param encodedToken\n */\n static extractTokenClaims(encodedToken: string, crypto: ICrypto): TokenClaims {\n\n const decodedToken: DecodedAuthToken = StringUtils.decodeAuthToken(encodedToken);\n\n // token will be decoded to get the username\n try {\n const base64TokenPayload = decodedToken.JWSPayload;\n\n // base64Decode() should throw an error if there is an issue\n const base64Decoded = crypto.base64Decode(base64TokenPayload);\n return JSON.parse(base64Decoded) as TokenClaims;\n } catch (err) {\n throw ClientAuthError.createTokenParsingError(err);\n }\n }\n\n /**\n * Determine if the token's max_age has transpired\n */\n static checkMaxAge(authTime: number, maxAge: number): void {\n /*\n * per https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest\n * To force an immediate re-authentication: If an app requires that a user re-authenticate prior to access,\n * provide a value of 0 for the max_age parameter and the AS will force a fresh login.\n */\n const fiveMinuteSkew = 300000; // five minutes in milliseconds\n if ((maxAge === 0) || ((Date.now() - fiveMinuteSkew) > (authTime + maxAge))) {\n throw ClientAuthError.createMaxAgeTranspiredError();\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAQH;;AAEG;AACH,IAAA,SAAA,kBAAA,YAAA;IAMI,SAAY,SAAA,CAAA,QAAgB,EAAE,MAAe,EAAA;AACzC,QAAA,IAAI,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC/B,YAAA,MAAM,eAAe,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AAC/D,SAAA;AAED,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;KAChE;AAED;;;;AAIG;AACI,IAAA,SAAA,CAAA,kBAAkB,GAAzB,UAA0B,YAAoB,EAAE,MAAe,EAAA;QAE3D,IAAM,YAAY,GAAqB,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;;QAGjF,IAAI;AACA,YAAA,IAAM,kBAAkB,GAAG,YAAY,CAAC,UAAU,CAAC;;YAGnD,IAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAC9D,YAAA,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAgB,CAAC;AACnD,SAAA;AAAC,QAAA,OAAO,GAAG,EAAE;AACV,YAAA,MAAM,eAAe,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;AACtD,SAAA;KACJ,CAAA;AAED;;AAEG;AACI,IAAA,SAAA,CAAA,WAAW,GAAlB,UAAmB,QAAgB,EAAE,MAAc,EAAA;AAC/C;;;;AAIG;AACH,QAAA,IAAM,cAAc,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,KAAK,QAAQ,GAAG,MAAM,CAAC,CAAC,EAAE;AACzE,YAAA,MAAM,eAAe,CAAC,2BAA2B,EAAE,CAAC;AACvD,SAAA;KACJ,CAAA;IACL,OAAC,SAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
export declare type CcsCredential = {
credential: string;
type: CcsCredentialType;
};
export declare enum CcsCredentialType {
HOME_ACCOUNT_ID = "home_account_id",
UPN = "UPN"
}
//# sourceMappingURL=CcsCredential.d.ts.map
\ No newline at end of file
{"version":3,"file":"CcsCredential.d.ts","sourceRoot":"","sources":["../../src/account/CcsCredential.ts"],"names":[],"mappings":"AAKA,oBAAY,aAAa,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,iBAAiB,CAAA;CAC1B,CAAC;AAEF,oBAAY,iBAAiB;IACzB,eAAe,oBAAoB;IACnC,GAAG,QAAQ;CACd"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var CcsCredentialType;
(function (CcsCredentialType) {
CcsCredentialType["HOME_ACCOUNT_ID"] = "home_account_id";
CcsCredentialType["UPN"] = "UPN";
})(CcsCredentialType || (CcsCredentialType = {}));
export { CcsCredentialType };
//# sourceMappingURL=CcsCredential.js.map
{"version":3,"file":"CcsCredential.js","sources":["../../src/account/CcsCredential.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type CcsCredential = {\n credential: string,\n type: CcsCredentialType\n};\n\nexport enum CcsCredentialType {\n HOME_ACCOUNT_ID = \"home_account_id\",\n UPN = \"UPN\"\n}\n"],"names":[],"mappings":";;AAAA;;;AAGG;IAOS,kBAGX;AAHD,CAAA,UAAY,iBAAiB,EAAA;AACzB,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,iBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACf,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,GAG5B,EAAA,CAAA,CAAA;;;;"}
\ No newline at end of file
/**
* Client Assertion credential for Confidential Clients
*/
export declare type ClientAssertion = {
assertion: string;
assertionType: string;
};
/**
* Client Credentials set for Confidential Clients
*/
export declare type ClientCredentials = {
clientSecret?: string;
clientAssertion?: ClientAssertion;
};
//# sourceMappingURL=ClientCredentials.d.ts.map
\ No newline at end of file
{"version":3,"file":"ClientCredentials.d.ts","sourceRoot":"","sources":["../../src/account/ClientCredentials.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,eAAe,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAA;CACxB,CAAC;AAEF;;GAEG;AACH,oBAAY,iBAAiB,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAA;CACpC,CAAC"}
\ No newline at end of file
import { ICrypto } from "../crypto/ICrypto";
/**
* Client info object which consists of two IDs. Need to add more info here.
*/
export declare type ClientInfo = {
uid: string;
utid: string;
};
/**
* Function to build a client info object from server clientInfo string
* @param rawClientInfo
* @param crypto
*/
export declare function buildClientInfo(rawClientInfo: string, crypto: ICrypto): ClientInfo;
/**
* Function to build a client info object from cached homeAccountId string
* @param homeAccountId
*/
export declare function buildClientInfoFromHomeAccountId(homeAccountId: string): ClientInfo;
//# sourceMappingURL=ClientInfo.d.ts.map
\ No newline at end of file
{"version":3,"file":"ClientInfo.d.ts","sourceRoot":"","sources":["../../src/account/ClientInfo.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C;;GAEG;AACH,oBAAY,UAAU,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAA;CACf,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,UAAU,CAWlF;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CASlF"}
\ No newline at end of file
/*! @azure/msal-common v9.0.1 2022-12-07 */
'use strict';
import { ClientAuthError } from '../error/ClientAuthError.js';
import { StringUtils } from '../utils/StringUtils.js';
import { Separators, Constants } from '../utils/Constants.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Function to build a client info object from server clientInfo string
* @param rawClientInfo
* @param crypto
*/
function buildClientInfo(rawClientInfo, crypto) {
if (StringUtils.isEmpty(rawClientInfo)) {
throw ClientAuthError.createClientInfoEmptyError();
}
try {
var decodedClientInfo = crypto.base64Decode(rawClientInfo);
return JSON.parse(decodedClientInfo);
}
catch (e) {
throw ClientAuthError.createClientInfoDecodingError(e.message);
}
}
/**
* Function to build a client info object from cached homeAccountId string
* @param homeAccountId
*/
function buildClientInfoFromHomeAccountId(homeAccountId) {
if (StringUtils.isEmpty(homeAccountId)) {
throw ClientAuthError.createClientInfoDecodingError("Home account ID was empty.");
}
var clientInfoParts = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);
return {
uid: clientInfoParts[0],
utid: clientInfoParts.length < 2 ? Constants.EMPTY_STRING : clientInfoParts[1]
};
}
export { buildClientInfo, buildClientInfoFromHomeAccountId };
//# sourceMappingURL=ClientInfo.js.map
{"version":3,"file":"ClientInfo.js","sources":["../../src/account/ClientInfo.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ICrypto } from \"../crypto/ICrypto\";\nimport { Separators, Constants } from \"../utils/Constants\";\n\n/**\n * Client info object which consists of two IDs. Need to add more info here.\n */\nexport type ClientInfo = {\n uid: string,\n utid: string\n};\n\n/**\n * Function to build a client info object from server clientInfo string\n * @param rawClientInfo\n * @param crypto\n */\nexport function buildClientInfo(rawClientInfo: string, crypto: ICrypto): ClientInfo {\n if (StringUtils.isEmpty(rawClientInfo)) {\n throw ClientAuthError.createClientInfoEmptyError();\n }\n\n try {\n const decodedClientInfo: string = crypto.base64Decode(rawClientInfo);\n return JSON.parse(decodedClientInfo) as ClientInfo;\n } catch (e) {\n throw ClientAuthError.createClientInfoDecodingError((e as ClientAuthError).message);\n }\n}\n\n/**\n * Function to build a client info object from cached homeAccountId string\n * @param homeAccountId \n */\nexport function buildClientInfoFromHomeAccountId(homeAccountId: string): ClientInfo {\n if (StringUtils.isEmpty(homeAccountId)) {\n throw ClientAuthError.createClientInfoDecodingError(\"Home account ID was empty.\");\n }\n const clientInfoParts: string[] = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);\n return {\n uid: clientInfoParts[0],\n utid: clientInfoParts.length < 2 ? Constants.EMPTY_STRING : clientInfoParts[1]\n };\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;AAeH;;;;AAIG;AACa,SAAA,eAAe,CAAC,aAAqB,EAAE,MAAe,EAAA;AAClE,IAAA,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;AACpC,QAAA,MAAM,eAAe,CAAC,0BAA0B,EAAE,CAAC;AACtD,KAAA;IAED,IAAI;QACA,IAAM,iBAAiB,GAAW,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;AACrE,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAe,CAAC;AACtD,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;QACR,MAAM,eAAe,CAAC,6BAA6B,CAAE,CAAqB,CAAC,OAAO,CAAC,CAAC;AACvF,KAAA;AACL,CAAC;AAED;;;AAGG;AACG,SAAU,gCAAgC,CAAC,aAAqB,EAAA;AAClE,IAAA,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;AACpC,QAAA,MAAM,eAAe,CAAC,6BAA6B,CAAC,4BAA4B,CAAC,CAAC;AACrF,KAAA;AACD,IAAA,IAAM,eAAe,GAAa,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAC3F,OAAO;AACH,QAAA,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;AACvB,QAAA,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC;KACjF,CAAC;AACN;;;;"}
\ No newline at end of file
{"version":3,"file":"DecodedAuthToken.d.ts","sourceRoot":"","sources":["../../src/account/DecodedAuthToken.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAA;CACjB"}
\ No newline at end of file
{"version":3,"file":"TokenClaims.d.ts","sourceRoot":"","sources":["../../src/account/TokenClaims.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,WAAW,GAAG;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,GAAG,CAAC,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
\ No newline at end of file
import { AuthorityType } from "./AuthorityType";
import { OpenIdConfigResponse } from "./OpenIdConfigResponse";
import { IUri } from "../url/IUri";
import { INetworkModule } from "../network/INetworkModule";
import { ProtocolMode } from "./ProtocolMode";
import { ICacheManager } from "../cache/interface/ICacheManager";
import { AuthorityOptions } from "./AuthorityOptions";
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
import { RegionDiscoveryMetadata } from "./RegionDiscoveryMetadata";
import { AzureCloudOptions } from "../config/ClientConfiguration";
import { Logger } from "../logger/Logger";
/**
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
* endpoint. It will store the pertinent config data in this object for use during token calls.
*/
export declare class Authority {
private _canonicalAuthority;
private _canonicalAuthorityUrlComponents;
protected networkInterface: INetworkModule;
protected cacheManager: ICacheManager;
private authorityOptions;
private metadata;
private regionDiscovery;
regionDiscoveryMetadata: RegionDiscoveryMetadata;
private proxyUrl;
private logger;
constructor(authority: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions, logger: Logger, proxyUrl?: string);
get authorityType(): AuthorityType;
/**
* ProtocolMode enum representing the way endpoints are constructed.
*/
get protocolMode(): ProtocolMode;
/**
* Returns authorityOptions which can be used to reinstantiate a new authority instance
*/
get options(): AuthorityOptions;
/**
* A URL that is the authority set by the developer
*/
get canonicalAuthority(): string;
/**
* Sets canonical authority.
*/
set canonicalAuthority(url: string);
/**
* Get authority components.
*/
get canonicalAuthorityUrlComponents(): IUri;
/**
* Get hostname and port i.e. login.microsoftonline.com
*/
get hostnameAndPort(): string;
/**
* Get tenant for authority.
*/
get tenant(): string;
/**
* OAuth /authorize endpoint for requests
*/
get authorizationEndpoint(): string;
/**
* OAuth /token endpoint for requests
*/
get tokenEndpoint(): string;
get deviceCodeEndpoint(): string;
/**
* OAuth logout endpoint for requests
*/
get endSessionEndpoint(): string;
/**
* OAuth issuer for requests
*/
get selfSignedJwtAudience(): string;
/**
* Jwks_uri for token signing keys
*/
get jwksUri(): string;
/**
* Replaces tenant in url path with current tenant. Defaults to common.
* @param urlString
*/
private replaceTenant;
/**
* Replaces path such as tenant or policy with the current tenant or policy.
* @param urlString
*/
private replacePath;
/**
* The default open id configuration endpoint for any canonical authority.
*/
protected get defaultOpenIdConfigurationEndpoint(): string;
/**
* Boolean that returns whethr or not tenant discovery has been completed.
*/
discoveryComplete(): boolean;
/**
* Perform endpoint discovery to discover aliases, preferred_cache, preferred_network
* and the /authorize, /token and logout endpoints.
*/
resolveEndpointsAsync(): Promise<void>;
/**
* Update AuthorityMetadataEntity with new endpoints and return where the information came from
* @param metadataEntity
*/
private updateEndpointMetadata;
/**
* Compares the number of url components after the domain to determine if the cached
* authority metadata can be used for the requested authority. Protects against same domain different
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
* @param metadataEntity
*/
private isAuthoritySameType;
/**
* Parse authorityMetadata config option
*/
private getEndpointMetadataFromConfig;
/**
* Gets OAuth endpoints from the given OpenID configuration endpoint.
*
* @param hasHardcodedMetadata boolean
*/
private getEndpointMetadataFromNetwork;
/**
* Get OAuth endpoints for common authorities.
*/
private getEndpointMetadataFromHardcodedValues;
/**
* Update the retrieved metadata with regional information.
*/
private updateMetadataWithRegionalInformation;
/**
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
* and returns where the information was retrieved from
* @param cachedMetadata
* @param newMetadata
*/
private updateCloudDiscoveryMetadata;
/**
* Parse cloudDiscoveryMetadata config or check knownAuthorities
*/
private getCloudDiscoveryMetadataFromConfig;
/**
* Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
*
* @param hasHardcodedMetadata boolean
*/
private getCloudDiscoveryMetadataFromNetwork;
/**
* Get cloud discovery metadata for common authorities
*/
private getCloudDiscoveryMetadataFromHarcodedValues;
/**
* Helper function to determine if this host is included in the knownAuthorities config option
*/
private isInKnownAuthorities;
/**
* helper function to populate the authority based on azureCloudOptions
* @param authorityString
* @param azureCloudOptions
*/
static generateAuthority(authorityString: string, azureCloudOptions?: AzureCloudOptions): string;
/**
* Creates cloud discovery metadata object from a given host
* @param host
*/
static createCloudDiscoveryMetadataFromHost(host: string): CloudDiscoveryMetadata;
/**
* Searches instance discovery network response for the entry that contains the host in the aliases list
* @param response
* @param authority
*/
static getCloudDiscoveryMetadataFromNetworkResponse(response: CloudDiscoveryMetadata[], authority: string): CloudDiscoveryMetadata | null;
/**
* helper function to generate environment from authority object
*/
getPreferredCache(): string;
/**
* Returns whether or not the provided host is an alias of this authority instance
* @param host
*/
isAlias(host: string): boolean;
/**
* Checks whether the provided host is that of a public cloud authority
*
* @param authority string
* @returns bool
*/
static isPublicCloudAuthority(host: string): boolean;
/**
* Rebuild the authority string with the region
*
* @param host string
* @param region string
*/
static buildRegionalAuthorityString(host: string, region: string, queryString?: string): string;
/**
* Replace the endpoints in the metadata object with their regional equivalents.
*
* @param metadata OpenIdConfigResponse
* @param azureRegion string
*/
static replaceWithRegionalInformation(metadata: OpenIdConfigResponse, azureRegion: string): OpenIdConfigResponse;
}
//# sourceMappingURL=Authority.d.ts.map
\ No newline at end of file
{"version":3,"file":"Authority.d.ts","sourceRoot":"","sources":["../../src/authority/Authority.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAA0B,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAuB,MAAM,oBAAoB,CAAC;AAG3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C;;;GAGG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,mBAAmB,CAAY;IAEvC,OAAO,CAAC,gCAAgC,CAAc;IAEtD,SAAS,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAE3C,SAAS,CAAC,YAAY,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,gBAAgB,CAAmB;IAE3C,OAAO,CAAC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
import { AuthorityType } from './AuthorityType.js';
import { isOpenIdConfigResponse } from './OpenIdConfigResponse.js';
import { UrlString } from '../url/UrlString.js';
import { ClientAuthError } from '../error/ClientAuthError.js';
import { Constants, AuthorityMetadataSource, RegionDiscoveryOutcomes } from '../utils/Constants.js';
import { EndpointMetadata, InstanceDiscoveryMetadata } from './AuthorityMetadata.js';
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
import { ProtocolMode } from './ProtocolMode.js';
import { AuthorityMetadataEntity } from '../cache/entities/AuthorityMetadataEntity.js';
import { AzureCloudInstance } from './AuthorityOptions.js';
import { isCloudInstanceDiscoveryResponse } from './CloudInstanceDiscoveryResponse.js';
import { isCloudInstanceDiscoveryErrorResponse } from './CloudInstanceDiscoveryErrorResponse.js';
import { RegionDiscovery } from './RegionDiscovery.js';
import { AuthError } from '../error/AuthError.js';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
* endpoint. It will store the pertinent config data in this object for use during token calls.
*/
var Authority = /** @class */ (function () {
function Authority(authority, networkInterface, cacheManager, authorityOptions, logger, proxyUrl) {
this.canonicalAuthority = authority;
this._canonicalAuthority.validateAsUri();
this.networkInterface = networkInterface;
this.cacheManager = cacheManager;
this.authorityOptions = authorityOptions;
this.regionDiscovery = new RegionDiscovery(networkInterface);
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
this.logger = logger;
}
Object.defineProperty(Authority.prototype, "authorityType", {
// See above for AuthorityType
get: function () {
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
if (pathSegments.length) {
switch (pathSegments[0].toLowerCase()) {
case Constants.ADFS:
return AuthorityType.Adfs;
case Constants.DSTS:
return AuthorityType.Dsts;
}
}
return AuthorityType.Default;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "protocolMode", {
/**
* ProtocolMode enum representing the way endpoints are constructed.
*/
get: function () {
return this.authorityOptions.protocolMode;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "options", {
/**
* Returns authorityOptions which can be used to reinstantiate a new authority instance
*/
get: function () {
return this.authorityOptions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "canonicalAuthority", {
/**
* A URL that is the authority set by the developer
*/
get: function () {
return this._canonicalAuthority.urlString;
},
/**
* Sets canonical authority.
*/
set: function (url) {
this._canonicalAuthority = new UrlString(url);
this._canonicalAuthority.validateAsUri();
this._canonicalAuthorityUrlComponents = null;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "canonicalAuthorityUrlComponents", {
/**
* Get authority components.
*/
get: function () {
if (!this._canonicalAuthorityUrlComponents) {
this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();
}
return this._canonicalAuthorityUrlComponents;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "hostnameAndPort", {
/**
* Get hostname and port i.e. login.microsoftonline.com
*/
get: function () {
return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "tenant", {
/**
* Get tenant for authority.
*/
get: function () {
return this.canonicalAuthorityUrlComponents.PathSegments[0];
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "authorizationEndpoint", {
/**
* OAuth /authorize endpoint for requests
*/
get: function () {
if (this.discoveryComplete()) {
var endpoint = this.replacePath(this.metadata.authorization_endpoint);
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "tokenEndpoint", {
/**
* OAuth /token endpoint for requests
*/
get: function () {
if (this.discoveryComplete()) {
var endpoint = this.replacePath(this.metadata.token_endpoint);
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "deviceCodeEndpoint", {
get: function () {
if (this.discoveryComplete()) {
var endpoint = this.replacePath(this.metadata.token_endpoint.replace("/token", "/devicecode"));
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "endSessionEndpoint", {
/**
* OAuth logout endpoint for requests
*/
get: function () {
if (this.discoveryComplete()) {
// ROPC policies may not have end_session_endpoint set
if (!this.metadata.end_session_endpoint) {
throw ClientAuthError.createLogoutNotSupportedError();
}
var endpoint = this.replacePath(this.metadata.end_session_endpoint);
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "selfSignedJwtAudience", {
/**
* OAuth issuer for requests
*/
get: function () {
if (this.discoveryComplete()) {
var endpoint = this.replacePath(this.metadata.issuer);
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Authority.prototype, "jwksUri", {
/**
* Jwks_uri for token signing keys
*/
get: function () {
if (this.discoveryComplete()) {
var endpoint = this.replacePath(this.metadata.jwks_uri);
return this.replaceTenant(endpoint);
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
},
enumerable: false,
configurable: true
});
/**
* Replaces tenant in url path with current tenant. Defaults to common.
* @param urlString
*/
Authority.prototype.replaceTenant = function (urlString) {
return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);
};
/**
* Replaces path such as tenant or policy with the current tenant or policy.
* @param urlString
*/
Authority.prototype.replacePath = function (urlString) {
var endpoint = urlString;
var cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);
var cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
var currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
currentAuthorityParts.forEach(function (currentPart, index) {
var cachedPart = cachedAuthorityParts[index];
if (currentPart !== cachedPart) {
endpoint = endpoint.replace("/" + cachedPart + "/", "/" + currentPart + "/");
}
});
return endpoint;
};
Object.defineProperty(Authority.prototype, "defaultOpenIdConfigurationEndpoint", {
/**
* The default open id configuration endpoint for any canonical authority.
*/
get: function () {
if (this.authorityType === AuthorityType.Adfs ||
this.authorityType === AuthorityType.Dsts ||
this.protocolMode === ProtocolMode.OIDC) {
return this.canonicalAuthority + ".well-known/openid-configuration";
}
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
},
enumerable: false,
configurable: true
});
/**
* Boolean that returns whethr or not tenant discovery has been completed.
*/
Authority.prototype.discoveryComplete = function () {
return !!this.metadata;
};
/**
* Perform endpoint discovery to discover aliases, preferred_cache, preferred_network
* and the /authorize, /token and logout endpoints.
*/
Authority.prototype.resolveEndpointsAsync = function () {
return __awaiter(this, void 0, void 0, function () {
var metadataEntity, cloudDiscoverySource, endpointSource, cacheKey;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
if (!metadataEntity) {
metadataEntity = new AuthorityMetadataEntity();
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
}
return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
case 1:
cloudDiscoverySource = _a.sent();
this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
return [4 /*yield*/, this.updateEndpointMetadata(metadataEntity)];
case 2:
endpointSource = _a.sent();
if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {
// Reset the expiration time unless both values came from a successful cache lookup
metadataEntity.resetExpiresAt();
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
}
cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);
this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);
this.metadata = metadataEntity;
return [2 /*return*/];
}
});
});
};
/**
* Update AuthorityMetadataEntity with new endpoints and return where the information came from
* @param metadataEntity
*/
Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var metadata, harcodedMetadata;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
metadata = this.getEndpointMetadataFromConfig();
if (metadata) {
metadataEntity.updateEndpointMetadata(metadata, false);
return [2 /*return*/, AuthorityMetadataSource.CONFIG];
}
if (this.isAuthoritySameType(metadataEntity) && metadataEntity.endpointsFromNetwork && !metadataEntity.isExpired()) {
// No need to update
return [2 /*return*/, AuthorityMetadataSource.CACHE];
}
harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
case 1:
metadata = _c.sent();
if (!metadata) return [3 /*break*/, 4];
if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
case 2:
metadata = _c.sent();
_c.label = 3;
case 3:
metadataEntity.updateEndpointMetadata(metadata, true);
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
case 4:
if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
case 5:
harcodedMetadata = _c.sent();
_c.label = 6;
case 6:
metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
}
});
});
};
/**
* Compares the number of url components after the domain to determine if the cached
* authority metadata can be used for the requested authority. Protects against same domain different
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
* @param metadataEntity
*/
Authority.prototype.isAuthoritySameType = function (metadataEntity) {
var cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);
var cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
return cachedParts.length === this.canonicalAuthorityUrlComponents.PathSegments.length;
};
/**
* Parse authorityMetadata config option
*/
Authority.prototype.getEndpointMetadataFromConfig = function () {
if (this.authorityOptions.authorityMetadata) {
try {
return JSON.parse(this.authorityOptions.authorityMetadata);
}
catch (e) {
throw ClientConfigurationError.createInvalidAuthorityMetadataError();
}
}
return null;
};
/**
* Gets OAuth endpoints from the given OpenID configuration endpoint.
*
* @param hasHardcodedMetadata boolean
*/
Authority.prototype.getEndpointMetadataFromNetwork = function () {
return __awaiter(this, void 0, void 0, function () {
var options, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
options = {};
if (this.proxyUrl) {
options.proxyUrl = this.proxyUrl;
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.networkInterface.
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
case 2:
response = _a.sent();
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
case 3:
_a.sent();
return [2 /*return*/, null];
case 4: return [2 /*return*/];
}
});
});
};
/**
* Get OAuth endpoints for common authorities.
*/
Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
if (this.canonicalAuthority in EndpointMetadata) {
return EndpointMetadata[this.canonicalAuthority];
}
return null;
};
/**
* Update the retrieved metadata with regional information.
*/
Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function () {
var autodetectedRegionName, azureRegion;
return __generator(this, function (_f) {
switch (_f.label) {
case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
case 1:
autodetectedRegionName = _f.sent();
azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
? autodetectedRegionName
: (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
}
else {
if (autodetectedRegionName) {
this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
}
else {
this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
}
}
if (azureRegion) {
this.regionDiscoveryMetadata.region_used = azureRegion;
return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
}
return [2 /*return*/, metadata];
}
});
});
};
/**
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
* and returns where the information was retrieved from
* @param cachedMetadata
* @param newMetadata
*/
Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
return __awaiter(this, void 0, void 0, function () {
var metadata, metadataEntityExpired, harcodedMetadata;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.logger.verbose("Attempting to get cloud discovery metadata in the config");
this.logger.verbosePii("Known Authorities: " + (this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE));
this.logger.verbosePii("Authority Metadata: " + (this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE));
this.logger.verbosePii("Canonical Authority: " + (metadataEntity.canonical_authority || Constants.NOT_APPLICABLE));
metadata = this.getCloudDiscoveryMetadataFromConfig();
if (metadata) {
this.logger.verbose("Found cloud discovery metadata in the config.");
metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
return [2 /*return*/, AuthorityMetadataSource.CONFIG];
}
// If the cached metadata came from config but that config was not passed to this instance, we must go to the network
this.logger.verbose("Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the cache.");
metadataEntityExpired = metadataEntity.isExpired();
if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntityExpired) {
this.logger.verbose("Found metadata in the cache.");
// No need to update
return [2 /*return*/, AuthorityMetadataSource.CACHE];
}
else if (metadataEntityExpired) {
this.logger.verbose("The metadata entity is expired.");
}
this.logger.verbose("Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.");
return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
case 1:
metadata = _a.sent();
if (metadata) {
this.logger.verbose("cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()");
metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
}
this.logger.verbose("Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.");
harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
this.logger.verbose("Found cloud discovery metadata from hardcoded values.");
metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
}
// Metadata could not be obtained from the config, cache, network or hardcoded values
this.logger.error("Did not find cloud discovery metadata from hardcoded values... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.");
throw ClientConfigurationError.createUntrustedAuthorityError();
}
});
});
};
/**
* Parse cloudDiscoveryMetadata config or check knownAuthorities
*/
Authority.prototype.getCloudDiscoveryMetadataFromConfig = function () {
// Check if network response was provided in config
if (this.authorityOptions.cloudDiscoveryMetadata) {
this.logger.verbose("The cloud discovery metadata has been provided as a network response, in the config.");
try {
this.logger.verbose("Attempting to parse the cloud discovery metadata.");
var parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata);
var metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(parsedResponse.metadata, this.hostnameAndPort);
this.logger.verbose("Parsed the cloud discovery metadata.");
if (metadata) {
this.logger.verbose("There is returnable metadata attached to the parsed cloud discovery metadata.");
return metadata;
}
else {
this.logger.verbose("There is no metadata attached to the parsed cloud discovery metadata.");
}
}
catch (e) {
this.logger.verbose("Unable to parse the cloud discovery metadata. Throwing Invalid Cloud Discovery Metadata Error.");
throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();
}
}
// If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities
if (this.isInKnownAuthorities()) {
this.logger.verbose("The host is included in knownAuthorities. Creating new cloud discovery metadata from the host.");
return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
}
return null;
};
/**
* Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
*
* @param hasHardcodedMetadata boolean
*/
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
return __awaiter(this, void 0, void 0, function () {
var instanceDiscoveryEndpoint, options, match, response, typedResponseBody, metadata, error_1, typedError;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
options = {};
if (this.proxyUrl) {
options.proxyUrl = this.proxyUrl;
}
match = null;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
case 2:
response = _a.sent();
typedResponseBody = void 0;
metadata = void 0;
if (isCloudInstanceDiscoveryResponse(response.body)) {
typedResponseBody = response.body;
metadata = typedResponseBody.metadata;
this.logger.verbosePii("tenant_discovery_endpoint is: " + typedResponseBody.tenant_discovery_endpoint);
}
else if (isCloudInstanceDiscoveryErrorResponse(response.body)) {
this.logger.warning("A CloudInstanceDiscoveryErrorResponse was returned. The cloud instance discovery network request's status code is: " + response.status);
typedResponseBody = response.body;
if (typedResponseBody.error === Constants.INVALID_INSTANCE) {
this.logger.error("The CloudInstanceDiscoveryErrorResponse error is invalid_instance.");
return [2 /*return*/, null];
}
this.logger.warning("The CloudInstanceDiscoveryErrorResponse error is " + typedResponseBody.error);
this.logger.warning("The CloudInstanceDiscoveryErrorResponse error description is " + typedResponseBody.error_description);
this.logger.warning("Setting the value of the CloudInstanceDiscoveryMetadata (returned from the network) to []");
metadata = [];
}
else {
this.logger.error("AAD did not return a CloudInstanceDiscoveryResponse or CloudInstanceDiscoveryErrorResponse");
return [2 /*return*/, null];
}
this.logger.verbose("Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request.");
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
return [3 /*break*/, 4];
case 3:
error_1 = _a.sent();
if (error_1 instanceof AuthError) {
this.logger.error("There was a network error while attempting to get the cloud discovery instance metadata.\nError: " + error_1.errorCode + "\nError Description: " + error_1.errorMessage);
}
else {
typedError = error_1;
this.logger.error("A non-MSALJS error was thrown while attempting to get the cloud instance discovery metadata.\nError: " + typedError.name + "\nError Description: " + typedError.message);
}
return [2 /*return*/, null];
case 4:
// Custom Domain scenario, host is trusted because Instance Discovery call succeeded
if (!match) {
this.logger.warning("The developer's authority was not found within the CloudInstanceDiscoveryMetadata returned from the network request.");
this.logger.verbose("Creating custom Authority for custom domain scenario.");
match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
}
return [2 /*return*/, match];
}
});
});
};
/**
* Get cloud discovery metadata for common authorities
*/
Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
return InstanceDiscoveryMetadata[this.canonicalAuthority];
}
return null;
};
/**
* Helper function to determine if this host is included in the knownAuthorities config option
*/
Authority.prototype.isInKnownAuthorities = function () {
var _this = this;
var matches = this.authorityOptions.knownAuthorities.filter(function (authority) {
return UrlString.getDomainFromUrl(authority).toLowerCase() === _this.hostnameAndPort;
});
return matches.length > 0;
};
/**
* helper function to populate the authority based on azureCloudOptions
* @param authorityString
* @param azureCloudOptions
*/
Authority.generateAuthority = function (authorityString, azureCloudOptions) {
var authorityAzureCloudInstance;
if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {
var tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;
authorityAzureCloudInstance = azureCloudOptions.azureCloudInstance + "/" + tenant + "/";
}
return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;
};
/**
* Creates cloud discovery metadata object from a given host
* @param host
*/
Authority.createCloudDiscoveryMetadataFromHost = function (host) {
return {
preferred_network: host,
preferred_cache: host,
aliases: [host]
};
};
/**
* Searches instance discovery network response for the entry that contains the host in the aliases list
* @param response
* @param authority
*/
Authority.getCloudDiscoveryMetadataFromNetworkResponse = function (response, authority) {
for (var i = 0; i < response.length; i++) {
var metadata = response[i];
if (metadata.aliases.indexOf(authority) > -1) {
return metadata;
}
}
return null;
};
/**
* helper function to generate environment from authority object
*/
Authority.prototype.getPreferredCache = function () {
if (this.discoveryComplete()) {
return this.metadata.preferred_cache;
}
else {
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
}
};
/**
* Returns whether or not the provided host is an alias of this authority instance
* @param host
*/
Authority.prototype.isAlias = function (host) {
return this.metadata.aliases.indexOf(host) > -1;
};
/**
* Checks whether the provided host is that of a public cloud authority
*
* @param authority string
* @returns bool
*/
Authority.isPublicCloudAuthority = function (host) {
return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;
};
/**
* Rebuild the authority string with the region
*
* @param host string
* @param region string
*/
Authority.buildRegionalAuthorityString = function (host, region, queryString) {
// Create and validate a Url string object with the initial authority string
var authorityUrlInstance = new UrlString(host);
authorityUrlInstance.validateAsUri();
var authorityUrlParts = authorityUrlInstance.getUrlComponents();
var hostNameAndPort = region + "." + authorityUrlParts.HostNameAndPort;
if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {
hostNameAndPort = region + "." + Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX;
}
// Include the query string portion of the url
var url = UrlString.constructAuthorityUriFromObject(__assign(__assign({}, authorityUrlInstance.getUrlComponents()), { HostNameAndPort: hostNameAndPort })).urlString;
// Add the query string if a query string was provided
if (queryString)
return url + "?" + queryString;
return url;
};
/**
* Replace the endpoints in the metadata object with their regional equivalents.
*
* @param metadata OpenIdConfigResponse
* @param azureRegion string
*/
Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
if (metadata.end_session_endpoint) {
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
}
return metadata;
};
return Authority;
}());
export { Authority };
//# sourceMappingURL=Authority.js.map
{"version":3,"file":"Authority.js","sources":["../../src/authority/Authority.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthorityType } from \"./AuthorityType\";\nimport { isOpenIdConfigResponse, OpenIdConfigResponse } from \"./OpenIdConfigResponse\";\nimport { UrlString } from \"../url/UrlString\";\nimport { IUri } from \"../url/IUri\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { AuthorityMetadataSource, Constants, RegionDiscoveryOutcomes } from \"../utils/Constants\";\nimport { EndpointMetadata, InstanceDiscoveryMetadata } from \"./AuthorityMetadata\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ProtocolMode } from \"./ProtocolMode\";\nimport { ICacheManager } from \"../cache/interface/ICacheManager\";\nimport { AuthorityMetadataEntity } from \"../cache/entities/AuthorityMetadataEntity\";\nimport { AuthorityOptions , AzureCloudInstance } from \"./AuthorityOptions\";\nimport { CloudInstanceDiscoveryResponse, isCloudInstanceDiscoveryResponse } from \"./CloudInstanceDiscoveryResponse\";\nimport { CloudInstanceDiscoveryErrorResponse, isCloudInstanceDiscoveryErrorResponse } from \"./CloudInstanceDiscoveryErrorResponse\";\nimport { CloudDiscoveryMetadata } from \"./CloudDiscoveryMetadata\";\nimport { RegionDiscovery } from \"./RegionDiscovery\";\nimport { RegionDiscoveryMetadata } from \"./RegionDiscoveryMetadata\";\nimport { ImdsOptions } from \"./ImdsOptions\";\nimport { AzureCloudOptions } from \"../config/ClientConfiguration\";\nimport { Logger } from \"../logger/Logger\";\nimport { AuthError } from \"../error/AuthError\";\n\n/**\n * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the\n * endpoint. It will store the pertinent config data in this object for use during token calls.\n */\nexport class Authority {\n // Canonical authority url string\n private _canonicalAuthority: UrlString;\n // Canonicaly authority url components\n private _canonicalAuthorityUrlComponents: IUri | null;\n // Network interface to make requests with.\n protected networkInterface: INetworkModule;\n // Cache Manager to cache network responses\n protected cacheManager: ICacheManager;\n // Protocol mode to construct endpoints\n private authorityOptions: AuthorityOptions;\n // Authority metadata\n private metadata: AuthorityMetadataEntity;\n // Region discovery service\n private regionDiscovery: RegionDiscovery;\n // Region discovery metadata\n public regionDiscoveryMetadata: RegionDiscoveryMetadata;\n // Proxy url string\n private proxyUrl: string;\n // Logger object\n private logger: Logger;\n\n constructor(\n authority: string,\n networkInterface: INetworkModule,\n cacheManager: ICacheManager,\n authorityOptions: AuthorityOptions,\n logger: Logger,\n proxyUrl?: string\n ) {\n this.canonicalAuthority = authority;\n this._canonicalAuthority.validateAsUri();\n this.networkInterface = networkInterface;\n this.cacheManager = cacheManager;\n this.authorityOptions = authorityOptions;\n this.regionDiscovery = new RegionDiscovery(networkInterface);\n this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };\n this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;\n this.logger = logger;\n }\n\n // See above for AuthorityType\n public get authorityType(): AuthorityType {\n const pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;\n if (pathSegments.length) {\n switch(pathSegments[0].toLowerCase()) {\n case Constants.ADFS:\n return AuthorityType.Adfs;\n case Constants.DSTS:\n return AuthorityType.Dsts;\n default:\n break;\n }\n }\n return AuthorityType.Default;\n }\n\n /**\n * ProtocolMode enum representing the way endpoints are constructed.\n */\n public get protocolMode(): ProtocolMode {\n return this.authorityOptions.protocolMode;\n }\n\n /**\n * Returns authorityOptions which can be used to reinstantiate a new authority instance\n */\n public get options(): AuthorityOptions {\n return this.authorityOptions;\n }\n\n /**\n * A URL that is the authority set by the developer\n */\n public get canonicalAuthority(): string {\n return this._canonicalAuthority.urlString;\n }\n\n /**\n * Sets canonical authority.\n */\n public set canonicalAuthority(url: string) {\n this._canonicalAuthority = new UrlString(url);\n this._canonicalAuthority.validateAsUri();\n this._canonicalAuthorityUrlComponents = null;\n }\n\n /**\n * Get authority components.\n */\n public get canonicalAuthorityUrlComponents(): IUri {\n if (!this._canonicalAuthorityUrlComponents) {\n this._canonicalAuthorityUrlComponents = this._canonicalAuthority.getUrlComponents();\n }\n\n return this._canonicalAuthorityUrlComponents;\n }\n\n /**\n * Get hostname and port i.e. login.microsoftonline.com\n */\n public get hostnameAndPort(): string {\n return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();\n }\n\n /**\n * Get tenant for authority.\n */\n public get tenant(): string {\n return this.canonicalAuthorityUrlComponents.PathSegments[0];\n }\n\n /**\n * OAuth /authorize endpoint for requests\n */\n public get authorizationEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.authorization_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth /token endpoint for requests\n */\n public get tokenEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n public get deviceCodeEndpoint(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.token_endpoint.replace(\"/token\", \"/devicecode\"));\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth logout endpoint for requests\n */\n public get endSessionEndpoint(): string {\n if(this.discoveryComplete()) {\n // ROPC policies may not have end_session_endpoint set\n if (!this.metadata.end_session_endpoint) {\n throw ClientAuthError.createLogoutNotSupportedError();\n }\n const endpoint = this.replacePath(this.metadata.end_session_endpoint);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * OAuth issuer for requests\n */\n public get selfSignedJwtAudience(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.issuer);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Jwks_uri for token signing keys\n */\n public get jwksUri(): string {\n if(this.discoveryComplete()) {\n const endpoint = this.replacePath(this.metadata.jwks_uri);\n return this.replaceTenant(endpoint);\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Replaces tenant in url path with current tenant. Defaults to common.\n * @param urlString\n */\n private replaceTenant(urlString: string): string {\n return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);\n }\n\n /**\n * Replaces path such as tenant or policy with the current tenant or policy.\n * @param urlString\n */\n private replacePath(urlString: string): string {\n let endpoint = urlString;\n const cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);\n const cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;\n\n currentAuthorityParts.forEach((currentPart, index) => {\n const cachedPart = cachedAuthorityParts[index];\n if (currentPart !== cachedPart) {\n endpoint = endpoint.replace(`/${cachedPart}/`, `/${currentPart}/`);\n }\n });\n\n return endpoint;\n }\n\n /**\n * The default open id configuration endpoint for any canonical authority.\n */\n protected get defaultOpenIdConfigurationEndpoint(): string {\n if (\n this.authorityType === AuthorityType.Adfs ||\n this.authorityType === AuthorityType.Dsts ||\n this.protocolMode === ProtocolMode.OIDC\n ) {\n return `${this.canonicalAuthority}.well-known/openid-configuration`;\n }\n return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;\n }\n\n /**\n * Boolean that returns whethr or not tenant discovery has been completed.\n */\n discoveryComplete(): boolean {\n return !!this.metadata;\n }\n\n /**\n * Perform endpoint discovery to discover aliases, preferred_cache, preferred_network\n * and the /authorize, /token and logout endpoints.\n */\n public async resolveEndpointsAsync(): Promise<void> {\n let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);\n if (!metadataEntity) {\n metadataEntity = new AuthorityMetadataEntity();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cloudDiscoverySource = await this.updateCloudDiscoveryMetadata(metadataEntity);\n this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);\n const endpointSource = await this.updateEndpointMetadata(metadataEntity);\n\n if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE && endpointSource !== AuthorityMetadataSource.CACHE) {\n // Reset the expiration time unless both values came from a successful cache lookup\n metadataEntity.resetExpiresAt();\n metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);\n }\n\n const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache);\n this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity);\n this.metadata = metadataEntity;\n }\n\n /**\n * Update AuthorityMetadataEntity with new endpoints and return where the information came from\n * @param metadataEntity\n */\n private async updateEndpointMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n let metadata = this.getEndpointMetadataFromConfig();\n if (metadata) {\n metadataEntity.updateEndpointMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.endpointsFromNetwork && !metadataEntity.isExpired()) {\n // No need to update\n return AuthorityMetadataSource.CACHE;\n }\n\n let harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();\n metadata = await this.getEndpointMetadataFromNetwork();\n if (metadata) {\n // If the user prefers to use an azure region replace the global endpoints with regional information.\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {\n metadata = await this.updateMetadataWithRegionalInformation(metadata);\n }\n\n metadataEntity.updateEndpointMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n } \n\n if (harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache) {\n // If the user prefers to use an azure region replace the global endpoints with regional information.\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {\n harcodedMetadata = await this.updateMetadataWithRegionalInformation(\n harcodedMetadata\n );\n }\n\n metadataEntity.updateEndpointMetadata(harcodedMetadata, false);\n return AuthorityMetadataSource.HARDCODED_VALUES;\n } else {\n throw ClientAuthError.createUnableToGetOpenidConfigError(\n this.defaultOpenIdConfigurationEndpoint\n );\n }\n }\n\n /**\n * Compares the number of url components after the domain to determine if the cached \n * authority metadata can be used for the requested authority. Protects against same domain different \n * authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy\n * @param metadataEntity\n */\n private isAuthoritySameType(metadataEntity: AuthorityMetadataEntity): boolean {\n const cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);\n const cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;\n\n return cachedParts.length === this.canonicalAuthorityUrlComponents.PathSegments.length;\n }\n\n /**\n * Parse authorityMetadata config option\n */\n private getEndpointMetadataFromConfig(): OpenIdConfigResponse | null {\n if (this.authorityOptions.authorityMetadata) {\n try {\n return JSON.parse(this.authorityOptions.authorityMetadata) as OpenIdConfigResponse;\n } catch (e) {\n throw ClientConfigurationError.createInvalidAuthorityMetadataError();\n }\n }\n\n return null;\n }\n\n /**\n * Gets OAuth endpoints from the given OpenID configuration endpoint.\n * \n * @param hasHardcodedMetadata boolean\n */\n private async getEndpointMetadataFromNetwork(): Promise<OpenIdConfigResponse | null> {\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n /*\n * TODO: Add a timeout if the authority exists in our library's \n * hardcoded list of metadata\n */\n\n try {\n const response = await this.networkInterface.\n sendGetRequestAsync<OpenIdConfigResponse>(this.defaultOpenIdConfigurationEndpoint, options);\n return isOpenIdConfigResponse(response.body) ? response.body : null;\n } catch (e) {\n return null;\n }\n }\n\n /**\n * Get OAuth endpoints for common authorities.\n */\n private getEndpointMetadataFromHardcodedValues(): OpenIdConfigResponse | null {\n if (this.canonicalAuthority in EndpointMetadata) {\n return EndpointMetadata[this.canonicalAuthority];\n }\n\n return null;\n }\n\n /**\n * Update the retrieved metadata with regional information.\n */\n private async updateMetadataWithRegionalInformation(metadata: OpenIdConfigResponse): Promise<OpenIdConfigResponse> {\n const autodetectedRegionName = await this.regionDiscovery.detectRegion(\n this.authorityOptions.azureRegionConfiguration?.environmentRegion,\n this.regionDiscoveryMetadata,\n this.proxyUrl\n );\n\n const azureRegion = \n this.authorityOptions.azureRegionConfiguration?.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG\n ? autodetectedRegionName\n : this.authorityOptions.azureRegionConfiguration?.azureRegion;\n\n if (this.authorityOptions.azureRegionConfiguration?.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {\n this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :\n RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;\n } else {\n if (autodetectedRegionName) {\n this.regionDiscoveryMetadata.region_outcome = (\n this.authorityOptions.azureRegionConfiguration?.azureRegion === autodetectedRegionName\n ) ?\n RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :\n RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;\n } else {\n this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;\n }\n }\n\n if (azureRegion) {\n this.regionDiscoveryMetadata.region_used = azureRegion;\n return Authority.replaceWithRegionalInformation(metadata, azureRegion);\n }\n\n return metadata;\n }\n\n /**\n * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache\n * and returns where the information was retrieved from\n * @param cachedMetadata\n * @param newMetadata\n */\n private async updateCloudDiscoveryMetadata(metadataEntity: AuthorityMetadataEntity): Promise<AuthorityMetadataSource> {\n this.logger.verbose(\"Attempting to get cloud discovery metadata in the config\");\n this.logger.verbosePii(`Known Authorities: ${this.authorityOptions.knownAuthorities || Constants.NOT_APPLICABLE}`);\n this.logger.verbosePii(`Authority Metadata: ${this.authorityOptions.authorityMetadata || Constants.NOT_APPLICABLE}`);\n this.logger.verbosePii(`Canonical Authority: ${metadataEntity.canonical_authority || Constants.NOT_APPLICABLE}`);\n let metadata = this.getCloudDiscoveryMetadataFromConfig();\n if (metadata) {\n this.logger.verbose(\"Found cloud discovery metadata in the config.\");\n metadataEntity.updateCloudDiscoveryMetadata(metadata, false);\n return AuthorityMetadataSource.CONFIG;\n }\n\n // If the cached metadata came from config but that config was not passed to this instance, we must go to the network\n this.logger.verbose(\"Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the cache.\");\n const metadataEntityExpired = metadataEntity.isExpired();\n if (this.isAuthoritySameType(metadataEntity) && metadataEntity.aliasesFromNetwork && !metadataEntityExpired) {\n this.logger.verbose(\"Found metadata in the cache.\");\n // No need to update\n return AuthorityMetadataSource.CACHE;\n } else if (metadataEntityExpired) {\n this.logger.verbose(\"The metadata entity is expired.\");\n }\n\n this.logger.verbose(\"Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network.\");\n metadata = await this.getCloudDiscoveryMetadataFromNetwork();\n if (metadata) {\n this.logger.verbose(\"cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork()\");\n metadataEntity.updateCloudDiscoveryMetadata(metadata, true);\n return AuthorityMetadataSource.NETWORK;\n }\n \n this.logger.verbose(\"Did not find cloud discovery metadata from the network... Attempting to get cloud discovery metadata from hardcoded values.\");\n const harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();\n if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {\n this.logger.verbose(\"Found cloud discovery metadata from hardcoded values.\");\n metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);\n return AuthorityMetadataSource.HARDCODED_VALUES;\n }\n \n // Metadata could not be obtained from the config, cache, network or hardcoded values\n this.logger.error(\"Did not find cloud discovery metadata from hardcoded values... Metadata could not be obtained from config, cache, network or hardcoded values. Throwing Untrusted Authority Error.\");\n throw ClientConfigurationError.createUntrustedAuthorityError();\n }\n\n /**\n * Parse cloudDiscoveryMetadata config or check knownAuthorities\n */\n private getCloudDiscoveryMetadataFromConfig(): CloudDiscoveryMetadata | null {\n // Check if network response was provided in config\n if (this.authorityOptions.cloudDiscoveryMetadata) {\n this.logger.verbose(\"The cloud discovery metadata has been provided as a network response, in the config.\");\n try {\n this.logger.verbose(\"Attempting to parse the cloud discovery metadata.\");\n const parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata) as CloudInstanceDiscoveryResponse;\n const metadata = Authority.getCloudDiscoveryMetadataFromNetworkResponse(\n parsedResponse.metadata,\n this.hostnameAndPort\n );\n this.logger.verbose(\"Parsed the cloud discovery metadata.\");\n if (metadata) {\n this.logger.verbose(\"There is returnable metadata attached to the parsed cloud discovery metadata.\");\n return metadata;\n } else {\n this.logger.verbose(\"There is no metadata attached to the parsed cloud discovery metadata.\");\n }\n } catch (e) {\n this.logger.verbose(\"Unable to parse the cloud discovery metadata. Throwing Invalid Cloud Discovery Metadata Error.\");\n throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();\n }\n }\n\n // If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities\n if (this.isInKnownAuthorities()) {\n this.logger.verbose(\"The host is included in knownAuthorities. Creating new cloud discovery metadata from the host.\");\n return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);\n }\n\n return null;\n }\n\n /**\n * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config\n * \n * @param hasHardcodedMetadata boolean\n */\n private async getCloudDiscoveryMetadataFromNetwork(): Promise<CloudDiscoveryMetadata | null> {\n const instanceDiscoveryEndpoint =\n `${Constants.AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;\n const options: ImdsOptions = {};\n if (this.proxyUrl) {\n options.proxyUrl = this.proxyUrl;\n }\n\n /*\n * TODO: Add a timeout if the authority exists in our library's\n * hardcoded list of metadata\n */\n\n let match = null;\n try {\n const response =\n await this.networkInterface.sendGetRequestAsync<CloudInstanceDiscoveryResponse | CloudInstanceDiscoveryErrorResponse>(\n instanceDiscoveryEndpoint,\n options\n );\n \n let typedResponseBody: CloudInstanceDiscoveryResponse | CloudInstanceDiscoveryErrorResponse;\n let metadata: Array<CloudDiscoveryMetadata>;\n if (isCloudInstanceDiscoveryResponse(response.body)) {\n typedResponseBody = response.body as CloudInstanceDiscoveryResponse;\n metadata = typedResponseBody.metadata;\n\n this.logger.verbosePii(`tenant_discovery_endpoint is: ${typedResponseBody.tenant_discovery_endpoint}`);\n } else if (isCloudInstanceDiscoveryErrorResponse(response.body)) {\n this.logger.warning(`A CloudInstanceDiscoveryErrorResponse was returned. The cloud instance discovery network request's status code is: ${response.status}`);\n\n typedResponseBody = response.body as CloudInstanceDiscoveryErrorResponse;\n if (typedResponseBody.error === Constants.INVALID_INSTANCE) {\n this.logger.error(\"The CloudInstanceDiscoveryErrorResponse error is invalid_instance.\");\n return null;\n }\n\n this.logger.warning(`The CloudInstanceDiscoveryErrorResponse error is ${typedResponseBody.error}`);\n this.logger.warning(`The CloudInstanceDiscoveryErrorResponse error description is ${typedResponseBody.error_description}`);\n \n this.logger.warning(\"Setting the value of the CloudInstanceDiscoveryMetadata (returned from the network) to []\");\n metadata = [];\n } else {\n this.logger.error(\"AAD did not return a CloudInstanceDiscoveryResponse or CloudInstanceDiscoveryErrorResponse\");\n return null;\n }\n\n this.logger.verbose(\"Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request.\");\n match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(\n metadata,\n this.hostnameAndPort\n );\n } catch (error) {\n if (error instanceof AuthError) {\n this.logger.error(`There was a network error while attempting to get the cloud discovery instance metadata.\\nError: ${error.errorCode}\\nError Description: ${error.errorMessage}`);\n } else {\n const typedError = error as Error;\n this.logger.error(`A non-MSALJS error was thrown while attempting to get the cloud instance discovery metadata.\\nError: ${typedError.name}\\nError Description: ${typedError.message}`);\n }\n \n return null;\n }\n\n // Custom Domain scenario, host is trusted because Instance Discovery call succeeded\n if (!match) {\n this.logger.warning(\"The developer's authority was not found within the CloudInstanceDiscoveryMetadata returned from the network request.\");\n this.logger.verbose(\"Creating custom Authority for custom domain scenario.\");\n\n match = Authority.createCloudDiscoveryMetadataFromHost(\n this.hostnameAndPort\n );\n }\n return match;\n }\n\n /**\n * Get cloud discovery metadata for common authorities \n */\n private getCloudDiscoveryMetadataFromHarcodedValues(): CloudDiscoveryMetadata | null {\n if (this.canonicalAuthority in InstanceDiscoveryMetadata) {\n return InstanceDiscoveryMetadata[this.canonicalAuthority];\n }\n\n return null;\n }\n\n /**\n * Helper function to determine if this host is included in the knownAuthorities config option\n */\n private isInKnownAuthorities(): boolean {\n const matches = this.authorityOptions.knownAuthorities.filter((authority) => {\n return UrlString.getDomainFromUrl(authority).toLowerCase() === this.hostnameAndPort;\n });\n\n return matches.length > 0;\n }\n\n /**\n * helper function to populate the authority based on azureCloudOptions\n * @param authorityString\n * @param azureCloudOptions\n */\n static generateAuthority(authorityString: string, azureCloudOptions?: AzureCloudOptions): string {\n let authorityAzureCloudInstance;\n\n if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {\n const tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;\n authorityAzureCloudInstance = `${azureCloudOptions.azureCloudInstance}/${tenant}/`;\n }\n\n return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;\n }\n\n /**\n * Creates cloud discovery metadata object from a given host\n * @param host\n */\n static createCloudDiscoveryMetadataFromHost(host: string): CloudDiscoveryMetadata {\n return {\n preferred_network: host,\n preferred_cache: host,\n aliases: [host]\n };\n }\n\n /**\n * Searches instance discovery network response for the entry that contains the host in the aliases list\n * @param response\n * @param authority\n */\n static getCloudDiscoveryMetadataFromNetworkResponse(\n response: CloudDiscoveryMetadata[],\n authority: string\n ): CloudDiscoveryMetadata | null {\n for (let i = 0; i < response.length; i++) {\n const metadata = response[i];\n if (metadata.aliases.indexOf(authority) > -1) {\n return metadata;\n }\n }\n\n return null;\n }\n\n /**\n * helper function to generate environment from authority object\n */\n getPreferredCache(): string {\n if(this.discoveryComplete()) {\n return this.metadata.preferred_cache;\n } else {\n throw ClientAuthError.createEndpointDiscoveryIncompleteError(\"Discovery incomplete.\");\n }\n }\n\n /**\n * Returns whether or not the provided host is an alias of this authority instance\n * @param host\n */\n isAlias(host: string): boolean {\n return this.metadata.aliases.indexOf(host) > -1;\n }\n\n /**\n * Checks whether the provided host is that of a public cloud authority\n *\n * @param authority string\n * @returns bool\n */\n static isPublicCloudAuthority(host: string): boolean {\n return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;\n }\n\n /**\n * Rebuild the authority string with the region\n *\n * @param host string\n * @param region string\n */\n static buildRegionalAuthorityString(host: string, region: string, queryString?: string): string {\n // Create and validate a Url string object with the initial authority string\n const authorityUrlInstance = new UrlString(host);\n authorityUrlInstance.validateAsUri();\n\n const authorityUrlParts = authorityUrlInstance.getUrlComponents();\n\n let hostNameAndPort= `${region}.${authorityUrlParts.HostNameAndPort}`;\n\n if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {\n hostNameAndPort = `${region}.${Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX}`;\n }\n\n // Include the query string portion of the url\n const url = UrlString.constructAuthorityUriFromObject({\n ...authorityUrlInstance.getUrlComponents(),\n HostNameAndPort: hostNameAndPort\n }).urlString;\n\n // Add the query string if a query string was provided\n if (queryString) return `${url}?${queryString}`;\n\n return url;\n }\n\n /**\n * Replace the endpoints in the metadata object with their regional equivalents.\n *\n * @param metadata OpenIdConfigResponse\n * @param azureRegion string\n */\n static replaceWithRegionalInformation(metadata: OpenIdConfigResponse, azureRegion: string): OpenIdConfigResponse {\n metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);\n // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature\n metadata.token_endpoint = Authority.buildRegionalAuthorityString(\n metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING\n );\n\n if (metadata.end_session_endpoint) {\n metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);\n }\n\n return metadata;\n }\n}\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAyBH;;;AAGG;AACH,IAAA,SAAA,kBAAA,YAAA;IAsBI,SACI,SAAA,CAAA,SAAiB,EACjB,gBAAgC,EAChC,YAA2B,EAC3B,gBAAkC,EAClC,MAAc,EACd,QAAiB,EAAA;AAEjB,QAAA,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;AACpC,QAAA,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,CAAC;AACzC,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AACzC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACjC,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC;AAC7D,QAAA,IAAI,CAAC,uBAAuB,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;QAC/G,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAAC,YAAY,CAAC;AACnD,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;KACxB;AAGD,IAAA,MAAA,CAAA,cAAA,CAAW,SAAa,CAAA,SAAA,EAAA,eAAA,EAAA;;AAAxB,QAAA,GAAA,EAAA,YAAA;AACI,YAAA,IAAM,YAAY,GAAG,IAAI,CAAC,+BAA+B,CAAC,YAAY,CAAC;YACvE,IAAI,YAAY,CAAC,MAAM,EAAE;AACrB,gBAAA,QAAO,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;oBAChC,KAAK,SAAS,CAAC,IAAI;wBACf,OAAO,aAAa,CAAC,IAAI,CAAC;oBAC9B,KAAK,SAAS,C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,EAAE,WAAW,CAAC,CAAC;;AAEvH,QAAA,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAC,4BAA4B,CAC5D,QAAQ,CAAC,cAAc,EAAE,WAAW,EAAE,SAAS,CAAC,kCAAkC,CACrF,CAAC;QAEF,IAAI,QAAQ,CAAC,oBAAoB,EAAE;AAC/B,YAAA,QAAQ,CAAC,oBAAoB,GAAG,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;AACtH,SAAA;AAED,QAAA,OAAO,QAAQ,CAAC;KACnB,CAAA;IACL,OAAC,SAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
\ No newline at end of file
import { Authority } from "./Authority";
import { INetworkModule } from "../network/INetworkModule";
import { ICacheManager } from "../cache/interface/ICacheManager";
import { AuthorityOptions } from "./AuthorityOptions";
import { Logger } from "../logger/Logger";
export declare class AuthorityFactory {
/**
* Create an authority object of the correct type based on the url
* Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
*
* Also performs endpoint discovery.
*
* @param authorityUri
* @param networkClient
* @param protocolMode
*/
static createDiscoveredInstance(authorityUri: string, networkClient: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions, logger: Logger, proxyUrl?: string): Promise<Authority>;
/**
* Create an authority object of the correct type based on the url
* Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
*
* Does not perform endpoint discovery.
*
* @param authorityUrl
* @param networkInterface
* @param protocolMode
*/
static createInstance(authorityUrl: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions, logger: Logger, proxyUrl?: string): Authority;
}
//# sourceMappingURL=AuthorityFactory.d.ts.map
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment