Skip to content

Commit 0b7f97c

Browse files
authored
Merge pull request #1330 from AzureAD/msal-node-account-authority-folders
[msal-common] Create `account` and `authority` folders
2 parents 21bdbb3 + d0ac36d commit 0b7f97c

39 files changed

+198
-198
lines changed

lib/msal-common/src/auth/authority/AadAuthority.ts renamed to lib/msal-common/src/authority/AadAuthority.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import { Authority } from "./Authority";
66
import { OpenIdConfigResponse } from "./OpenIdConfigResponse";
77
import { AuthorityType } from "./AuthorityType";
8-
import { AADTrustedHostList, Constants } from "../../utils/Constants";
9-
import { INetworkModule } from "../../network/INetworkModule";
8+
import { AADTrustedHostList, Constants } from "./../utils/Constants";
9+
import { INetworkModule } from "./../network/INetworkModule";
1010

1111
/**
1212
* The AadAuthority class extends the Authority class and adds functionality specific to the Azure AD OAuth Authority.

lib/msal-common/src/auth/authority/Authority.ts renamed to lib/msal-common/src/authority/Authority.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55
import { AuthorityType } from "./AuthorityType";
66
import { TenantDiscoveryResponse } from "./TenantDiscoveryResponse";
7-
import { UrlString } from "../../url/UrlString";
8-
import { IUri } from "../../url/IUri";
9-
import { ClientAuthError } from "../../error/ClientAuthError";
10-
import { INetworkModule } from "../../network/INetworkModule";
7+
import { UrlString } from "./../url/UrlString";
8+
import { IUri } from "./../url/IUri";
9+
import { ClientAuthError } from "./../error/ClientAuthError";
10+
import { INetworkModule } from "./../network/INetworkModule";
1111

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

108108
/**
109109
* Replaces tenant in url path with current tenant. Defaults to common.
110-
* @param urlString
110+
* @param urlString
111111
*/
112112
private replaceTenant(urlString: string): string {
113113
return urlString.replace("{tenant}", this.tenant);
@@ -136,7 +136,7 @@ export abstract class Authority {
136136

137137
/**
138138
* Gets OAuth endpoints from the given OpenID configuration endpoint.
139-
* @param openIdConfigurationEndpoint
139+
* @param openIdConfigurationEndpoint
140140
*/
141141
private async discoverEndpoints(openIdConfigurationEndpoint: string): Promise<TenantDiscoveryResponse> {
142142
return this.networkInterface.sendGetRequestAsync<TenantDiscoveryResponse>(openIdConfigurationEndpoint);

lib/msal-common/src/auth/authority/AuthorityFactory.ts renamed to lib/msal-common/src/authority/AuthorityFactory.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import { Authority } from "./Authority";
66
import { AadAuthority } from "./AadAuthority";
77
import { AuthorityType } from "./AuthorityType";
8-
import { ClientConfigurationError } from "../../error/ClientConfigurationError";
9-
import { ClientAuthError } from "../../error/ClientAuthError";
10-
import { INetworkModule } from "../../network/INetworkModule";
11-
import { StringUtils } from "../../utils/StringUtils";
12-
import { UrlString } from "../../url/UrlString";
8+
import { ClientConfigurationError } from "../error/ClientConfigurationError";
9+
import { ClientAuthError } from "./../error/ClientAuthError";
10+
import { INetworkModule } from "./../network/INetworkModule";
11+
import { StringUtils } from "./../utils/StringUtils";
12+
import { UrlString } from "./../url/UrlString";
1313

1414
export class AuthorityFactory {
1515

lib/msal-common/src/cache/CacheHelpers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { AccessTokenCacheItem } from "./AccessTokenCacheItem";
66
import { AccessTokenKey } from "./AccessTokenKey";
77
import { AccessTokenValue } from "./AccessTokenValue";
88
import { ICacheStorage } from "./ICacheStorage";
9-
import { Account } from "../auth/Account";
10-
import { Authority } from "../auth/authority/Authority";
9+
import { Account } from "../account/Account";
10+
import { Authority } from "../authority/Authority";
1111
import { ServerCodeRequestParameters } from "../server/ServerCodeRequestParameters";
1212
import { ClientAuthError } from "../error/ClientAuthError";
1313
import { StringUtils } from "../utils/StringUtils";
@@ -44,7 +44,7 @@ export class CacheHelpers {
4444

4545
/**
4646
* Create Nonce key to cache nonce
47-
* @param state
47+
* @param state
4848
*/
4949
generateNonceKey(state: string): string {
5050
return `${TemporaryCacheKeys.NONCE_IDTOKEN}${Constants.RESOURCE_DELIM}${state}`;
@@ -97,7 +97,7 @@ export class CacheHelpers {
9797

9898
/**
9999
* Reset all temporary cache items
100-
* @param state
100+
* @param state
101101
*/
102102
resetTempCacheItems(state?: string): void {
103103
// check state and remove associated cache items

lib/msal-common/src/client/BaseClient.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { ICacheStorage } from "../cache/ICacheStorage";
1111
import { CacheHelpers } from "../cache/CacheHelpers";
1212
import { INetworkModule } from "../network/INetworkModule";
1313
import { ICrypto } from "../crypto/ICrypto";
14-
import { Account } from "../auth/Account";
15-
import { Authority } from "../auth/authority/Authority";
16-
import { IdToken } from "../auth/IdToken";
17-
import { buildClientInfo } from "../auth/ClientInfo";
14+
import { Account } from "../account/Account";
15+
import { Authority } from "../authority/Authority";
16+
import { IdToken } from "../account/IdToken";
17+
import { buildClientInfo } from "../account/ClientInfo";
1818
import { StringUtils } from "../utils/StringUtils";
1919
import { Logger } from "../logger/Logger";
2020
import { PersistentCacheKeys } from "../utils/Constants";

lib/msal-common/src/client/PublicClient.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import { ServerAuthorizationTokenResponse } from "../server/ServerAuthorizationT
1717
import { ClientAuthError } from "../error/ClientAuthError";
1818
import { ClientConfigurationError } from "../error/ClientConfigurationError";
1919
import { AccessTokenCacheItem } from "../cache/AccessTokenCacheItem";
20-
import { AuthorityFactory } from "../auth/authority/AuthorityFactory";
21-
import { IdToken } from "../auth/IdToken";
22-
import { ScopeSet } from "../auth/ScopeSet";
20+
import { AuthorityFactory } from "../authority/AuthorityFactory";
21+
import { IdToken } from "../account/IdToken";
22+
import { ScopeSet } from "../request/ScopeSet";
2323
import { TemporaryCacheKeys, PersistentCacheKeys, AADServerParamKeys, Constants } from "../utils/Constants";
2424
import { TimeUtils } from "../utils/TimeUtils";
2525
import { StringUtils } from "../utils/StringUtils";

lib/msal-common/src/error/ClientAuthError.ts

+26-26
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License.
44
*/
55
import { AuthError } from "./AuthError";
6-
import { IdToken } from "../auth/IdToken";
7-
import { ScopeSet } from "../auth/ScopeSet";
6+
import { IdToken } from "../account/IdToken";
7+
import { ScopeSet } from "../request/ScopeSet";
88

99
/**
1010
* ClientAuthErrorMessage class containing string constants used by error codes and messages.
@@ -105,7 +105,7 @@ export const ClientAuthErrorMessage = {
105105
* Error thrown when there is an error in the client code running on the browser.
106106
*/
107107
export class ClientAuthError extends AuthError {
108-
108+
109109
constructor(errorCode: string, errorMessage?: string) {
110110
super(errorCode, errorMessage);
111111
this.name = "ClientAuthError";
@@ -115,7 +115,7 @@ export class ClientAuthError extends AuthError {
115115

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

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

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

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

152152
/**
153153
* Creates an error thrown when the token request could not be retrieved from the cache
154-
* @param errDetail
154+
* @param errDetail
155155
*/
156156
static createTokenRequestCacheError(errDetail: string): ClientAuthError {
157-
return new ClientAuthError(ClientAuthErrorMessage.tokenRequestCacheError.code,
157+
return new ClientAuthError(ClientAuthErrorMessage.tokenRequestCacheError.code,
158158
`${ClientAuthErrorMessage.tokenRequestCacheError.desc} Error Detail: ${errDetail}`);
159159
}
160160

161161
/**
162162
* Creates an error thrown when the endpoint discovery doesn't complete correctly.
163163
*/
164164
static createEndpointDiscoveryIncompleteError(errDetail: string): ClientAuthError {
165-
return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code,
165+
return new ClientAuthError(ClientAuthErrorMessage.endpointResolutionError.code,
166166
`${ClientAuthErrorMessage.endpointResolutionError.desc} Detail: ${errDetail}`);
167167
}
168168

169169
/**
170170
* Creates an error thrown if authority type is not valid.
171-
* @param invalidAuthorityError
171+
* @param invalidAuthorityError
172172
*/
173173
static createInvalidAuthorityTypeError(givenUrl: string): ClientAuthError {
174-
return new ClientAuthError(ClientAuthErrorMessage.invalidAuthorityType.code,
174+
return new ClientAuthError(ClientAuthErrorMessage.invalidAuthorityType.code,
175175
`${ClientAuthErrorMessage.invalidAuthorityType.desc} Given Url: ${givenUrl}`);
176176
}
177177

178178
/**
179179
* Creates an error thrown when the hash cannot be deserialized.
180-
* @param invalidAuthorityError
180+
* @param invalidAuthorityError
181181
*/
182182
static createHashNotDeserializedError(hashParamObj: string): ClientAuthError {
183-
return new ClientAuthError(ClientAuthErrorMessage.hashNotDeserialized.code,
183+
return new ClientAuthError(ClientAuthErrorMessage.hashNotDeserialized.code,
184184
`${ClientAuthErrorMessage.hashNotDeserialized.desc} Given Object: ${hashParamObj}`);
185185
}
186186

187187
/**
188188
* Creates an error thrown when two states do not match.
189189
*/
190190
static createStateMismatchError(): ClientAuthError {
191-
return new ClientAuthError(ClientAuthErrorMessage.stateMismatchError.code,
191+
return new ClientAuthError(ClientAuthErrorMessage.stateMismatchError.code,
192192
ClientAuthErrorMessage.stateMismatchError.desc);
193193
}
194194

195195
/**
196196
* Creates an error thrown when the nonce does not match.
197197
*/
198198
static createNonceMismatchError(): ClientAuthError {
199-
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code,
199+
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code,
200200
ClientAuthErrorMessage.nonceMismatchError.desc);
201201
}
202202

203-
/**
203+
/**
204204
* Creates an error thrown when the cached account and response account do not match.
205205
*/
206206
static createAccountMismatchError(): ClientAuthError {
207-
return new ClientAuthError(ClientAuthErrorMessage.accountMismatchError.code,
207+
return new ClientAuthError(ClientAuthErrorMessage.accountMismatchError.code,
208208
ClientAuthErrorMessage.accountMismatchError.desc);
209209
}
210210

211211
/**
212212
* Throws error if idToken is not correctly formed
213-
* @param idToken
213+
* @param idToken
214214
*/
215215
static createInvalidIdTokenError(idToken: IdToken) : ClientAuthError {
216216
return new ClientAuthError(ClientAuthErrorMessage.invalidIdToken.code,
@@ -221,15 +221,15 @@ export class ClientAuthError extends AuthError {
221221
* Creates an error thrown when the authorization code required for a token request is null or empty.
222222
*/
223223
static createNoTokensFoundError(scopes: string): ClientAuthError {
224-
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code,
224+
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code,
225225
`${ClientAuthErrorMessage.noTokensFoundError.desc} Scopes: ${scopes}`);
226226
}
227227

228228
/**
229229
* Creates an error in cache parsing.
230230
*/
231231
static createCacheParseError(cacheKey: string): ClientAuthError {
232-
return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code,
232+
return new ClientAuthError(ClientAuthErrorMessage.cacheParseError.code,
233233
`${ClientAuthErrorMessage.cacheParseError.desc} Cache key: ${cacheKey}`);
234234
}
235235

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

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

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

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

276276
/**
277277
* Throws error when attempting to append null or empty ScopeSet.
278-
* @param appendError
278+
* @param appendError
279279
*/
280280
static createAppendScopeSetError(appendError: string): ClientAuthError {
281281
return new ClientAuthError(ClientAuthErrorMessage.appendScopeSetError.code, `${ClientAuthErrorMessage.appendScopeSetError.desc} Detail Error: ${appendError}`);
282282
}
283283

284284
/**
285285
* Throws error if ScopeSet is null or undefined.
286-
* @param givenScopeSet
286+
* @param givenScopeSet
287287
*/
288288
static createEmptyInputScopeSetError(givenScopeSet: ScopeSet): ClientAuthError {
289289
return new ClientAuthError(ClientAuthErrorMessage.emptyInputScopeSetError.code, `${ClientAuthErrorMessage.emptyInputScopeSetError.desc} Given ScopeSet: ${givenScopeSet}`);

lib/msal-common/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ export { PublicClient } from "./client/PublicClient";
33
export { PublicClientConfiguration, AuthOptions } from "./config/PublicClientConfiguration";
44
export { SystemOptions, LoggerOptions, TelemetryOptions } from "./config/Configuration";
55
// Account
6-
export { Account } from "./auth/Account";
6+
export { Account } from "./account/Account";
77
// Authority
8-
export { Authority } from "./auth/authority/Authority";
9-
export { AuthorityFactory } from "./auth/authority/AuthorityFactory";
8+
export { Authority } from "./authority/Authority";
9+
export { AuthorityFactory } from "./authority/AuthorityFactory";
1010
// Cache
1111
export { ICacheStorage } from "./cache/ICacheStorage";
1212
// Network Interface

lib/msal-common/src/request/AuthenticationParameters.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* Licensed under the MIT License.
44
*/
55
import { ClientRequestParameters } from "./ClientRequestParameters";
6-
import { Account } from "../auth/Account";
6+
import { Account } from "../account/Account";
77
import { ClientConfigurationError } from "../error/ClientConfigurationError";
88

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

3434
/**
3535
* Function which validates claims request passed in by the user.
36-
* @param request
36+
* @param request
3737
*/
3838
export function validateClaimsRequest(request: AuthenticationParameters): void {
3939
if (!request.claimsRequest) {

lib/msal-common/src/request/TokenRenewParameters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55
import { ClientRequestParameters } from "./ClientRequestParameters";
6-
import { Account } from "../auth/Account";
6+
import { Account } from "../account/Account";
77

88
/**
99
* AuthenticationParameters passed by user to retrieve a token from the server.

0 commit comments

Comments
 (0)