Skip to content

[msal-common] Create account and authority folders #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { Authority } from "./Authority";
import { OpenIdConfigResponse } from "./OpenIdConfigResponse";
import { AuthorityType } from "./AuthorityType";
import { AADTrustedHostList, Constants } from "../../utils/Constants";
import { INetworkModule } from "../../network/INetworkModule";
import { AADTrustedHostList, Constants } from "./../utils/Constants";
import { INetworkModule } from "./../network/INetworkModule";

/**
* The AadAuthority class extends the Authority class and adds functionality specific to the Azure AD OAuth Authority.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/
import { AuthorityType } from "./AuthorityType";
import { TenantDiscoveryResponse } from "./TenantDiscoveryResponse";
import { UrlString } from "../../url/UrlString";
import { IUri } from "../../url/IUri";
import { ClientAuthError } from "../../error/ClientAuthError";
import { INetworkModule } from "../../network/INetworkModule";
import { UrlString } from "./../url/UrlString";
import { IUri } from "./../url/IUri";
import { ClientAuthError } from "./../error/ClientAuthError";
import { INetworkModule } from "./../network/INetworkModule";

/**
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
Expand Down Expand Up @@ -107,7 +107,7 @@ export abstract class Authority {

/**
* Replaces tenant in url path with current tenant. Defaults to common.
* @param urlString
* @param urlString
*/
private replaceTenant(urlString: string): string {
return urlString.replace("{tenant}", this.tenant);
Expand Down Expand Up @@ -136,7 +136,7 @@ export abstract class Authority {

/**
* Gets OAuth endpoints from the given OpenID configuration endpoint.
* @param openIdConfigurationEndpoint
* @param openIdConfigurationEndpoint
*/
private async discoverEndpoints(openIdConfigurationEndpoint: string): Promise<TenantDiscoveryResponse> {
return this.networkInterface.sendGetRequestAsync<TenantDiscoveryResponse>(openIdConfigurationEndpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import { Authority } from "./Authority";
import { AadAuthority } from "./AadAuthority";
import { AuthorityType } from "./AuthorityType";
import { ClientConfigurationError } from "../../error/ClientConfigurationError";
import { ClientAuthError } from "../../error/ClientAuthError";
import { INetworkModule } from "../../network/INetworkModule";
import { StringUtils } from "../../utils/StringUtils";
import { UrlString } from "../../url/UrlString";
import { ClientConfigurationError } from "../error/ClientConfigurationError";
import { ClientAuthError } from "./../error/ClientAuthError";
import { INetworkModule } from "./../network/INetworkModule";
import { StringUtils } from "./../utils/StringUtils";
import { UrlString } from "./../url/UrlString";

export class AuthorityFactory {

Expand Down
8 changes: 4 additions & 4 deletions lib/msal-common/src/cache/CacheHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { AccessTokenCacheItem } from "./AccessTokenCacheItem";
import { AccessTokenKey } from "./AccessTokenKey";
import { AccessTokenValue } from "./AccessTokenValue";
import { ICacheStorage } from "./ICacheStorage";
import { Account } from "../auth/Account";
import { Authority } from "../auth/authority/Authority";
import { Account } from "../account/Account";
import { Authority } from "../authority/Authority";
import { ServerCodeRequestParameters } from "../server/ServerCodeRequestParameters";
import { ClientAuthError } from "../error/ClientAuthError";
import { StringUtils } from "../utils/StringUtils";
Expand Down Expand Up @@ -44,7 +44,7 @@ export class CacheHelpers {

/**
* Create Nonce key to cache nonce
* @param state
* @param state
*/
generateNonceKey(state: string): string {
return `${TemporaryCacheKeys.NONCE_IDTOKEN}${Constants.RESOURCE_DELIM}${state}`;
Expand Down Expand Up @@ -97,7 +97,7 @@ export class CacheHelpers {

/**
* Reset all temporary cache items
* @param state
* @param state
*/
resetTempCacheItems(state?: string): void {
// check state and remove associated cache items
Expand Down
8 changes: 4 additions & 4 deletions lib/msal-common/src/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { ICacheStorage } from "../cache/ICacheStorage";
import { CacheHelpers } from "../cache/CacheHelpers";
import { INetworkModule } from "../network/INetworkModule";
import { ICrypto } from "../crypto/ICrypto";
import { Account } from "../auth/Account";
import { Authority } from "../auth/authority/Authority";
import { IdToken } from "../auth/IdToken";
import { buildClientInfo } from "../auth/ClientInfo";
import { Account } from "../account/Account";
import { Authority } from "../authority/Authority";
import { IdToken } from "../account/IdToken";
import { buildClientInfo } from "../account/ClientInfo";
import { StringUtils } from "../utils/StringUtils";
import { Logger } from "../logger/Logger";
import { PersistentCacheKeys } from "../utils/Constants";
Expand Down
6 changes: 3 additions & 3 deletions lib/msal-common/src/client/PublicClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { ServerAuthorizationTokenResponse } from "../server/ServerAuthorizationT
import { ClientAuthError } from "../error/ClientAuthError";
import { ClientConfigurationError } from "../error/ClientConfigurationError";
import { AccessTokenCacheItem } from "../cache/AccessTokenCacheItem";
import { AuthorityFactory } from "../auth/authority/AuthorityFactory";
import { IdToken } from "../auth/IdToken";
import { ScopeSet } from "../auth/ScopeSet";
import { AuthorityFactory } from "../authority/AuthorityFactory";
import { IdToken } from "../account/IdToken";
import { ScopeSet } from "../request/ScopeSet";
import { TemporaryCacheKeys, PersistentCacheKeys, AADServerParamKeys, Constants } from "../utils/Constants";
import { TimeUtils } from "../utils/TimeUtils";
import { StringUtils } from "../utils/StringUtils";
Expand Down
52 changes: 26 additions & 26 deletions lib/msal-common/src/error/ClientAuthError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License.
*/
import { AuthError } from "./AuthError";
import { IdToken } from "../auth/IdToken";
import { ScopeSet } from "../auth/ScopeSet";
import { IdToken } from "../account/IdToken";
import { ScopeSet } from "../request/ScopeSet";

/**
* ClientAuthErrorMessage class containing string constants used by error codes and messages.
Expand Down Expand Up @@ -105,7 +105,7 @@ export const ClientAuthErrorMessage = {
* Error thrown when there is an error in the client code running on the browser.
*/
export class ClientAuthError extends AuthError {

constructor(errorCode: string, errorMessage?: string) {
super(errorCode, errorMessage);
this.name = "ClientAuthError";
Expand All @@ -115,7 +115,7 @@ export class ClientAuthError extends AuthError {

/**
* Creates an error thrown when client info object doesn't decode correctly.
* @param caughtError
* @param caughtError
*/
static createClientInfoDecodingError(caughtError: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.clientInfoDecodingError.code,
Expand All @@ -124,7 +124,7 @@ export class ClientAuthError extends AuthError {

/**
* Creates an error thrown if the client info is empty.
* @param rawClientInfo
* @param rawClientInfo
*/
static createClientInfoEmptyError(rawClientInfo: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.clientInfoEmptyError.code,
Expand All @@ -133,7 +133,7 @@ export class ClientAuthError extends AuthError {

/**
* Creates an error thrown when the id token extraction errors out.
* @param err
* @param err
*/
static createIdTokenParsingError(caughtExtractionError: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.idTokenParsingError.code,
Expand All @@ -142,7 +142,7 @@ export class ClientAuthError extends AuthError {

/**
* Creates an error thrown when the id token string is null or empty.
* @param invalidRawTokenString
* @param invalidRawTokenString
*/
static createIdTokenNullOrEmptyError(invalidRawTokenString: string) : ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.nullOrEmptyIdToken.code,
Expand All @@ -151,66 +151,66 @@ export class ClientAuthError extends AuthError {

/**
* Creates an error thrown when the token request could not be retrieved from the cache
* @param errDetail
* @param errDetail
*/
static createTokenRequestCacheError(errDetail: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.tokenRequestCacheError.code,
return new ClientAuthError(ClientAuthErrorMessage.tokenRequestCacheError.code,
`${ClientAuthErrorMessage.tokenRequestCacheError.desc} Error Detail: ${errDetail}`);
}

/**
* Creates an error thrown when the endpoint discovery doesn't complete correctly.
*/
static createEndpointDiscoveryIncompleteError(errDetail: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code,
return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code,
`${ClientAuthErrorMessage.endpointResolutionError.desc} Detail: ${errDetail}`);
}

/**
* Creates an error thrown if authority type is not valid.
* @param invalidAuthorityError
* @param invalidAuthorityError
*/
static createInvalidAuthorityTypeError(givenUrl: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.invalidAuthorityType.code,
return new ClientAuthError(ClientAuthErrorMessage.invalidAuthorityType.code,
`${ClientAuthErrorMessage.invalidAuthorityType.desc} Given Url: ${givenUrl}`);
}

/**
* Creates an error thrown when the hash cannot be deserialized.
* @param invalidAuthorityError
* @param invalidAuthorityError
*/
static createHashNotDeserializedError(hashParamObj: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.hashNotDeserialized.code,
return new ClientAuthError(ClientAuthErrorMessage.hashNotDeserialized.code,
`${ClientAuthErrorMessage.hashNotDeserialized.desc} Given Object: ${hashParamObj}`);
}

/**
* Creates an error thrown when two states do not match.
*/
static createStateMismatchError(): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.stateMismatchError.code,
return new ClientAuthError(ClientAuthErrorMessage.stateMismatchError.code,
ClientAuthErrorMessage.stateMismatchError.desc);
}

/**
* Creates an error thrown when the nonce does not match.
*/
static createNonceMismatchError(): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code,
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code,
ClientAuthErrorMessage.nonceMismatchError.desc);
}

/**
/**
* Creates an error thrown when the cached account and response account do not match.
*/
static createAccountMismatchError(): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.accountMismatchError.code,
return new ClientAuthError(ClientAuthErrorMessage.accountMismatchError.code,
ClientAuthErrorMessage.accountMismatchError.desc);
}

/**
* Throws error if idToken is not correctly formed
* @param idToken
* @param idToken
*/
static createInvalidIdTokenError(idToken: IdToken) : ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.invalidIdToken.code,
Expand All @@ -221,15 +221,15 @@ export class ClientAuthError extends AuthError {
* Creates an error thrown when the authorization code required for a token request is null or empty.
*/
static createNoTokensFoundError(scopes: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code,
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code,
`${ClientAuthErrorMessage.noTokensFoundError.desc} Scopes: ${scopes}`);
}

/**
* Creates an error in cache parsing.
*/
static createCacheParseError(cacheKey: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code,
return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code,
`${ClientAuthErrorMessage.cacheParseError.desc} Cache key: ${cacheKey}`);
}

Expand All @@ -243,7 +243,7 @@ export class ClientAuthError extends AuthError {

/**
* Throws error when multiple tokens are in cache for the given scope.
* @param scope
* @param scope
*/
static createMultipleMatchingTokensInCacheError(scope: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.multipleMatchingTokens.code,
Expand All @@ -259,31 +259,31 @@ export class ClientAuthError extends AuthError {

/**
* Throws error when attempting to append a null, undefined or empty scope to a set
* @param givenScope
* @param givenScope
*/
static createAppendEmptyScopeToSetError(givenScope: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.appendEmptyScopeError.code, `${ClientAuthErrorMessage.appendEmptyScopeError.desc} Given Scope: ${givenScope}`);
}

/**
* Throws error when attempting to append a null, undefined or empty scope to a set
* @param givenScope
* @param givenScope
*/
static createRemoveEmptyScopeFromSetError(givenScope: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.removeEmptyScopeError.code, `${ClientAuthErrorMessage.removeEmptyScopeError.desc} Given Scope: ${givenScope}`);
}

/**
* Throws error when attempting to append null or empty ScopeSet.
* @param appendError
* @param appendError
*/
static createAppendScopeSetError(appendError: string): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.appendScopeSetError.code, `${ClientAuthErrorMessage.appendScopeSetError.desc} Detail Error: ${appendError}`);
}

/**
* Throws error if ScopeSet is null or undefined.
* @param givenScopeSet
* @param givenScopeSet
*/
static createEmptyInputScopeSetError(givenScopeSet: ScopeSet): ClientAuthError {
return new ClientAuthError(ClientAuthErrorMessage.emptyInputScopeSetError.code, `${ClientAuthErrorMessage.emptyInputScopeSetError.desc} Given ScopeSet: ${givenScopeSet}`);
Expand Down
6 changes: 3 additions & 3 deletions lib/msal-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export { PublicClient } from "./client/PublicClient";
export { PublicClientConfiguration, AuthOptions } from "./config/PublicClientConfiguration";
export { SystemOptions, LoggerOptions, TelemetryOptions } from "./config/Configuration";
// Account
export { Account } from "./auth/Account";
export { Account } from "./account/Account";
// Authority
export { Authority } from "./auth/authority/Authority";
export { AuthorityFactory } from "./auth/authority/AuthorityFactory";
export { Authority } from "./authority/Authority";
export { AuthorityFactory } from "./authority/AuthorityFactory";
// Cache
export { ICacheStorage } from "./cache/ICacheStorage";
// Network Interface
Expand Down
6 changes: 3 additions & 3 deletions lib/msal-common/src/request/AuthenticationParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Licensed under the MIT License.
*/
import { ClientRequestParameters } from "./ClientRequestParameters";
import { Account } from "../auth/Account";
import { Account } from "../account/Account";
import { ClientConfigurationError } from "../error/ClientConfigurationError";

/**
* AuthenticationParameters passed by user to retrieve a token from the server.
* - scopes: requested token scopes
* - resource: requested resource uri
* - extraScopesToConsent: additional scopes to consent
* - extraScopesToConsent: additional scopes to consent
* - prompt: the value of the OAuth prompt parameter
* - extraQueryParameters: string to string map of custom query parameters
* - claimsRequest: stringified claims object to request additional claims in a token
Expand All @@ -33,7 +33,7 @@ export type AuthenticationParameters = ClientRequestParameters & {

/**
* Function which validates claims request passed in by the user.
* @param request
* @param request
*/
export function validateClaimsRequest(request: AuthenticationParameters): void {
if (!request.claimsRequest) {
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-common/src/request/TokenRenewParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/
import { ClientRequestParameters } from "./ClientRequestParameters";
import { Account } from "../auth/Account";
import { Account } from "../account/Account";

/**
* AuthenticationParameters passed by user to retrieve a token from the server.
Expand Down
Loading