@azure/msal-common 1.6.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +180 -0
- package/changelog.md +60 -6
- package/dist/index.es.js +1346 -1034
- package/dist/index.js +1050 -737
- package/dist/src/account/AccountInfo.d.ts +5 -0
- package/dist/src/authority/Authority.d.ts +8 -1
- package/dist/src/cache/CacheManager.d.ts +17 -2
- package/dist/src/cache/entities/AccountEntity.d.ts +15 -2
- package/dist/src/cache/entities/CacheRecord.d.ts +6 -6
- package/dist/src/client/AuthorizationCodeClient.d.ts +8 -2
- package/dist/src/client/BaseClient.d.ts +9 -4
- package/dist/src/client/ClientCredentialClient.d.ts +21 -1
- package/dist/src/client/DeviceCodeClient.d.ts +1 -1
- package/dist/src/client/OnBehalfOfClient.d.ts +30 -1
- package/dist/src/client/RefreshTokenClient.d.ts +2 -2
- package/dist/src/client/SilentFlowClient.d.ts +1 -1
- package/dist/src/client/UsernamePasswordClient.d.ts +28 -0
- package/dist/src/config/ClientConfiguration.d.ts +19 -6
- package/dist/src/error/AuthError.d.ts +2 -2
- package/dist/src/error/ClientAuthError.d.ts +45 -5
- package/dist/src/error/ClientConfigurationError.d.ts +8 -0
- package/dist/src/error/InteractionRequiredAuthError.d.ts +2 -2
- package/dist/src/error/ServerError.d.ts +1 -2
- package/dist/src/index.d.ts +4 -0
- package/dist/src/logger/Logger.d.ts +7 -1
- package/dist/src/request/AuthorizationCodeRequest.d.ts +2 -2
- package/dist/src/request/AuthorizationUrlRequest.d.ts +9 -9
- package/dist/src/request/BaseAuthRequest.d.ts +2 -2
- package/dist/src/request/ClientCredentialRequest.d.ts +1 -1
- package/dist/src/request/EndSessionRequest.d.ts +3 -3
- package/dist/src/request/RefreshTokenRequest.d.ts +1 -1
- package/dist/src/request/RequestParameterBuilder.d.ts +22 -2
- package/dist/src/request/SilentFlowRequest.d.ts +1 -1
- package/dist/src/request/UsernamePasswordRequest.d.ts +16 -0
- package/dist/src/response/AuthenticationResult.d.ts +5 -2
- package/dist/src/response/AuthorizationCodePayload.d.ts +12 -0
- package/dist/src/response/ResponseHandler.d.ts +4 -4
- package/dist/src/response/ServerAuthorizationCodeResponse.d.ts +4 -0
- package/dist/src/url/UrlString.d.ts +1 -0
- package/dist/src/utils/Constants.d.ts +9 -0
- package/dist/src/utils/StringUtils.d.ts +8 -2
- package/package.json +4 -3
|
@@ -4,12 +4,17 @@
|
|
|
4
4
|
* - environment - Entity which issued the token represented by the domain of the issuer (e.g. login.microsoftonline.com)
|
|
5
5
|
* - tenantId - Full tenant or organizational id that this account belongs to
|
|
6
6
|
* - username - preferred_username claim of the id_token that represents this account
|
|
7
|
+
* - localAccountId - Local, tenant-specific account identifer for this account object, usually used in legacy cases
|
|
7
8
|
* - name - Full name for the account, including given name and family name
|
|
9
|
+
* - idTokenClaims - Object contains claims from ID token
|
|
10
|
+
* - localAccountId - The user's account ID
|
|
8
11
|
*/
|
|
9
12
|
export declare type AccountInfo = {
|
|
10
13
|
homeAccountId: string;
|
|
11
14
|
environment: string;
|
|
12
15
|
tenantId: string;
|
|
13
16
|
username: string;
|
|
17
|
+
localAccountId: string;
|
|
14
18
|
name?: string;
|
|
19
|
+
idTokenClaims?: object;
|
|
15
20
|
};
|
|
@@ -69,12 +69,19 @@ export declare class Authority {
|
|
|
69
69
|
* @param openIdConfigurationEndpoint
|
|
70
70
|
*/
|
|
71
71
|
private discoverEndpoints;
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Set the trusted hosts and validate subsequent calls
|
|
74
|
+
*/
|
|
73
75
|
private validateAndSetPreferredNetwork;
|
|
74
76
|
/**
|
|
75
77
|
* Perform endpoint discovery to discover the /authorize, /token and logout endpoints.
|
|
76
78
|
*/
|
|
77
79
|
resolveEndpointsAsync(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Determine if given hostname is alias of this authority
|
|
82
|
+
* @param host
|
|
83
|
+
*/
|
|
84
|
+
isAuthorityAlias(host: string): boolean;
|
|
78
85
|
/**
|
|
79
86
|
* helper function to generate environment from authority object
|
|
80
87
|
* @param authority
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCache, AccountFilter, CredentialFilter, CredentialCache } from "./utils/CacheTypes";
|
|
1
|
+
import { AccountCache, AccountFilter, CredentialFilter, CredentialCache, AppMetadataFilter, AppMetadataCache } from "./utils/CacheTypes";
|
|
2
2
|
import { CacheRecord } from "./entities/CacheRecord";
|
|
3
3
|
import { CredentialEntity } from "./entities/CredentialEntity";
|
|
4
4
|
import { ScopeSet } from "../request/ScopeSet";
|
|
@@ -11,10 +11,14 @@ import { AccountInfo } from "../account/AccountInfo";
|
|
|
11
11
|
import { AppMetadataEntity } from "./entities/AppMetadataEntity";
|
|
12
12
|
import { ServerTelemetryEntity } from "./entities/ServerTelemetryEntity";
|
|
13
13
|
import { ThrottlingEntity } from "./entities/ThrottlingEntity";
|
|
14
|
+
import { ICrypto } from "../crypto/ICrypto";
|
|
14
15
|
/**
|
|
15
16
|
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
|
|
16
17
|
*/
|
|
17
18
|
export declare abstract class CacheManager implements ICacheManager {
|
|
19
|
+
protected clientId: string;
|
|
20
|
+
protected cryptoImpl: ICrypto;
|
|
21
|
+
constructor(clientId: string, cryptoImpl: ICrypto);
|
|
18
22
|
/**
|
|
19
23
|
* fetch the account entity from the platform cache
|
|
20
24
|
* @param accountKey
|
|
@@ -155,6 +159,17 @@ export declare abstract class CacheManager implements ICacheManager {
|
|
|
155
159
|
* @param target
|
|
156
160
|
*/
|
|
157
161
|
private getCredentialsFilteredByInternal;
|
|
162
|
+
/**
|
|
163
|
+
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
|
|
164
|
+
* @param filter
|
|
165
|
+
*/
|
|
166
|
+
getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache;
|
|
167
|
+
/**
|
|
168
|
+
* Support function to help match appMetadata
|
|
169
|
+
* @param environment
|
|
170
|
+
* @param clientId
|
|
171
|
+
*/
|
|
172
|
+
private getAppMetadataFilteredByInternal;
|
|
158
173
|
/**
|
|
159
174
|
* Removes all accounts and related tokens from cache.
|
|
160
175
|
*/
|
|
@@ -216,7 +231,7 @@ export declare abstract class CacheManager implements ICacheManager {
|
|
|
216
231
|
/**
|
|
217
232
|
* Retrieve AppMetadataEntity from cache
|
|
218
233
|
*/
|
|
219
|
-
readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity;
|
|
234
|
+
readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null;
|
|
220
235
|
/**
|
|
221
236
|
* Return the family_id value associated with FOCI
|
|
222
237
|
* @param environment
|
|
@@ -2,6 +2,9 @@ import { Authority } from "../../authority/Authority";
|
|
|
2
2
|
import { AuthToken } from "../../account/AuthToken";
|
|
3
3
|
import { ICrypto } from "../../crypto/ICrypto";
|
|
4
4
|
import { AccountInfo } from "../../account/AccountInfo";
|
|
5
|
+
import { AuthorityType } from "../../authority/AuthorityType";
|
|
6
|
+
import { Logger } from "../../logger/Logger";
|
|
7
|
+
import { TokenClaims } from "../../account/TokenClaims";
|
|
5
8
|
/**
|
|
6
9
|
* Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).
|
|
7
10
|
*
|
|
@@ -22,6 +25,7 @@ import { AccountInfo } from "../../account/AccountInfo";
|
|
|
22
25
|
* lastModificationTime: last time this entity was modified in the cache
|
|
23
26
|
* lastModificationApp:
|
|
24
27
|
* oboAssertion: access token passed in as part of OBO request
|
|
28
|
+
* idTokenClaims: Object containing claims parsed from ID token
|
|
25
29
|
* }
|
|
26
30
|
*/
|
|
27
31
|
export declare class AccountEntity {
|
|
@@ -36,6 +40,9 @@ export declare class AccountEntity {
|
|
|
36
40
|
lastModificationTime?: string;
|
|
37
41
|
lastModificationApp?: string;
|
|
38
42
|
oboAssertion?: string;
|
|
43
|
+
cloudGraphHostName?: string;
|
|
44
|
+
msGraphHost?: string;
|
|
45
|
+
idTokenClaims?: TokenClaims;
|
|
39
46
|
/**
|
|
40
47
|
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
41
48
|
*/
|
|
@@ -64,13 +71,19 @@ export declare class AccountEntity {
|
|
|
64
71
|
* @param idToken
|
|
65
72
|
* @param policy
|
|
66
73
|
*/
|
|
67
|
-
static createAccount(clientInfo: string, authority: Authority, idToken: AuthToken,
|
|
74
|
+
static createAccount(clientInfo: string, homeAccountId: string, authority: Authority, idToken: AuthToken, oboAssertion?: string, cloudGraphHostName?: string, msGraphHost?: string): AccountEntity;
|
|
68
75
|
/**
|
|
69
76
|
* Builds non-AAD/ADFS account.
|
|
70
77
|
* @param authority
|
|
71
78
|
* @param idToken
|
|
72
79
|
*/
|
|
73
|
-
static createGenericAccount(authority: Authority, idToken: AuthToken, oboAssertion?: string): AccountEntity;
|
|
80
|
+
static createGenericAccount(authority: Authority, homeAccountId: string, idToken: AuthToken, oboAssertion?: string, cloudGraphHostName?: string, msGraphHost?: string): AccountEntity;
|
|
81
|
+
/**
|
|
82
|
+
* Generate HomeAccountId from server response
|
|
83
|
+
* @param serverClientInfo
|
|
84
|
+
* @param authType
|
|
85
|
+
*/
|
|
86
|
+
static generateHomeAccountId(serverClientInfo: string, authType: AuthorityType, logger: Logger, cryptoObj: ICrypto, idToken?: AuthToken): string;
|
|
74
87
|
/**
|
|
75
88
|
* Validates an entity: checks for all expected params
|
|
76
89
|
* @param entity
|
|
@@ -4,10 +4,10 @@ import { RefreshTokenEntity } from "./RefreshTokenEntity";
|
|
|
4
4
|
import { AccountEntity } from "./AccountEntity";
|
|
5
5
|
import { AppMetadataEntity } from "./AppMetadataEntity";
|
|
6
6
|
export declare class CacheRecord {
|
|
7
|
-
account: AccountEntity;
|
|
8
|
-
idToken: IdTokenEntity;
|
|
9
|
-
accessToken: AccessTokenEntity;
|
|
10
|
-
refreshToken: RefreshTokenEntity;
|
|
11
|
-
appMetadata: AppMetadataEntity;
|
|
12
|
-
constructor(accountEntity?: AccountEntity, idTokenEntity?: IdTokenEntity, accessTokenEntity?: AccessTokenEntity, refreshTokenEntity?: RefreshTokenEntity, appMetadataEntity?: AppMetadataEntity);
|
|
7
|
+
account: AccountEntity | null;
|
|
8
|
+
idToken: IdTokenEntity | null;
|
|
9
|
+
accessToken: AccessTokenEntity | null;
|
|
10
|
+
refreshToken: RefreshTokenEntity | null;
|
|
11
|
+
appMetadata: AppMetadataEntity | null;
|
|
12
|
+
constructor(accountEntity?: AccountEntity | null, idTokenEntity?: IdTokenEntity | null, accessTokenEntity?: AccessTokenEntity | null, refreshTokenEntity?: RefreshTokenEntity | null, appMetadataEntity?: AppMetadataEntity | null);
|
|
13
13
|
}
|
|
@@ -4,6 +4,7 @@ import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
|
4
4
|
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
5
5
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
6
6
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
7
|
+
import { AuthorizationCodePayload } from "../response/AuthorizationCodePayload";
|
|
7
8
|
/**
|
|
8
9
|
* Oauth2.0 Authorization Code client
|
|
9
10
|
*/
|
|
@@ -25,13 +26,13 @@ export declare class AuthorizationCodeClient extends BaseClient {
|
|
|
25
26
|
* authorization_code_grant
|
|
26
27
|
* @param request
|
|
27
28
|
*/
|
|
28
|
-
acquireToken(request: AuthorizationCodeRequest,
|
|
29
|
+
acquireToken(request: AuthorizationCodeRequest, authCodePayload?: AuthorizationCodePayload): Promise<AuthenticationResult | null>;
|
|
29
30
|
/**
|
|
30
31
|
* Handles the hash fragment response from public client code request. Returns a code response used by
|
|
31
32
|
* the client to exchange for a token in acquireToken.
|
|
32
33
|
* @param hashFragment
|
|
33
34
|
*/
|
|
34
|
-
handleFragmentResponse(hashFragment: string, cachedState: string):
|
|
35
|
+
handleFragmentResponse(hashFragment: string, cachedState: string): AuthorizationCodePayload;
|
|
35
36
|
/**
|
|
36
37
|
* Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
|
|
37
38
|
* Default behaviour is to redirect the user to `window.location.href`.
|
|
@@ -54,4 +55,9 @@ export declare class AuthorizationCodeClient extends BaseClient {
|
|
|
54
55
|
* @param request
|
|
55
56
|
*/
|
|
56
57
|
private createAuthCodeUrlQueryString;
|
|
58
|
+
/**
|
|
59
|
+
* This API validates the `EndSessionRequest` and creates a URL
|
|
60
|
+
* @param request
|
|
61
|
+
*/
|
|
62
|
+
private createLogoutUrlQueryString;
|
|
57
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
1
|
+
import { ClientConfiguration, CommonClientConfiguration } from "../config/ClientConfiguration";
|
|
2
2
|
import { INetworkModule } from "../network/INetworkModule";
|
|
3
3
|
import { NetworkManager, NetworkResponse } from "../network/NetworkManager";
|
|
4
4
|
import { ICrypto } from "../crypto/ICrypto";
|
|
@@ -13,13 +13,13 @@ import { RequestThumbprint } from "../network/RequestThumbprint";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare abstract class BaseClient {
|
|
15
15
|
logger: Logger;
|
|
16
|
-
protected config:
|
|
16
|
+
protected config: CommonClientConfiguration;
|
|
17
17
|
protected cryptoUtils: ICrypto;
|
|
18
18
|
protected cacheManager: CacheManager;
|
|
19
19
|
protected networkClient: INetworkModule;
|
|
20
|
-
protected serverTelemetryManager: ServerTelemetryManager;
|
|
20
|
+
protected serverTelemetryManager: ServerTelemetryManager | null;
|
|
21
21
|
protected networkManager: NetworkManager;
|
|
22
|
-
|
|
22
|
+
authority: Authority;
|
|
23
23
|
protected constructor(configuration: ClientConfiguration);
|
|
24
24
|
/**
|
|
25
25
|
* Creates default headers for requests to token endpoint
|
|
@@ -37,4 +37,9 @@ export declare abstract class BaseClient {
|
|
|
37
37
|
* @param thumbprint
|
|
38
38
|
*/
|
|
39
39
|
protected executePostToTokenEndpoint(tokenEndpoint: string, queryString: string, headers: Record<string, string>, thumbprint: RequestThumbprint): Promise<NetworkResponse<ServerAuthorizationTokenResponse>>;
|
|
40
|
+
/**
|
|
41
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
42
|
+
* @param updatedAuthority
|
|
43
|
+
*/
|
|
44
|
+
updateAuthority(updatedAuthority: Authority): void;
|
|
40
45
|
}
|
|
@@ -8,9 +8,29 @@ import { ClientCredentialRequest } from "../request/ClientCredentialRequest";
|
|
|
8
8
|
export declare class ClientCredentialClient extends BaseClient {
|
|
9
9
|
private scopeSet;
|
|
10
10
|
constructor(configuration: ClientConfiguration);
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Public API to acquire a token with ClientCredential Flow for Confidential clients
|
|
13
|
+
* @param request
|
|
14
|
+
*/
|
|
15
|
+
acquireToken(request: ClientCredentialRequest): Promise<AuthenticationResult | null>;
|
|
16
|
+
/**
|
|
17
|
+
* looks up cache if the tokens are cached already
|
|
18
|
+
*/
|
|
12
19
|
private getCachedAuthenticationResult;
|
|
20
|
+
/**
|
|
21
|
+
* Reads access token from the cache
|
|
22
|
+
* TODO: Move this call to cacheManager instead
|
|
23
|
+
*/
|
|
13
24
|
private readAccessTokenFromCache;
|
|
25
|
+
/**
|
|
26
|
+
* Makes a network call to request the token from the service
|
|
27
|
+
* @param request
|
|
28
|
+
* @param authority
|
|
29
|
+
*/
|
|
14
30
|
private executeTokenRequest;
|
|
31
|
+
/**
|
|
32
|
+
* generate the request to the server in the acceptable format
|
|
33
|
+
* @param request
|
|
34
|
+
*/
|
|
15
35
|
private createTokenRequestBody;
|
|
16
36
|
}
|
|
@@ -12,7 +12,7 @@ export declare class DeviceCodeClient extends BaseClient {
|
|
|
12
12
|
* polls token endpoint to exchange device code for tokens
|
|
13
13
|
* @param request
|
|
14
14
|
*/
|
|
15
|
-
acquireToken(request: DeviceCodeRequest): Promise<AuthenticationResult>;
|
|
15
|
+
acquireToken(request: DeviceCodeRequest): Promise<AuthenticationResult | null>;
|
|
16
16
|
/**
|
|
17
17
|
* Creates device code request and executes http GET
|
|
18
18
|
* @param request
|
|
@@ -8,11 +8,40 @@ import { OnBehalfOfRequest } from "../request/OnBehalfOfRequest";
|
|
|
8
8
|
export declare class OnBehalfOfClient extends BaseClient {
|
|
9
9
|
private scopeSet;
|
|
10
10
|
constructor(configuration: ClientConfiguration);
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Public API to acquire tokens with on behalf of flow
|
|
13
|
+
* @param request
|
|
14
|
+
*/
|
|
15
|
+
acquireToken(request: OnBehalfOfRequest): Promise<AuthenticationResult | null>;
|
|
16
|
+
/**
|
|
17
|
+
* look up cache for tokens
|
|
18
|
+
* @param request
|
|
19
|
+
*/
|
|
12
20
|
private getCachedAuthenticationResult;
|
|
21
|
+
/**
|
|
22
|
+
* read access token from cache TODO: CacheManager API should be used here
|
|
23
|
+
* @param request
|
|
24
|
+
*/
|
|
13
25
|
private readAccessTokenFromCache;
|
|
26
|
+
/**
|
|
27
|
+
* read idtoken from cache TODO: CacheManager API should be used here instead
|
|
28
|
+
* @param request
|
|
29
|
+
*/
|
|
14
30
|
private readIdTokenFromCache;
|
|
31
|
+
/**
|
|
32
|
+
* read account from cache, TODO: CacheManager API should be used here instead
|
|
33
|
+
* @param account
|
|
34
|
+
*/
|
|
15
35
|
private readAccountFromCache;
|
|
36
|
+
/**
|
|
37
|
+
* Make a network call to the server requesting credentials
|
|
38
|
+
* @param request
|
|
39
|
+
* @param authority
|
|
40
|
+
*/
|
|
16
41
|
private executeTokenRequest;
|
|
42
|
+
/**
|
|
43
|
+
* generate a server request in accepable format
|
|
44
|
+
* @param request
|
|
45
|
+
*/
|
|
17
46
|
private createTokenRequestBody;
|
|
18
47
|
}
|
|
@@ -8,12 +8,12 @@ import { SilentFlowRequest } from "../request/SilentFlowRequest";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class RefreshTokenClient extends BaseClient {
|
|
10
10
|
constructor(configuration: ClientConfiguration);
|
|
11
|
-
acquireToken(request: RefreshTokenRequest): Promise<AuthenticationResult>;
|
|
11
|
+
acquireToken(request: RefreshTokenRequest): Promise<AuthenticationResult | null>;
|
|
12
12
|
/**
|
|
13
13
|
* Gets cached refresh token and attaches to request, then calls acquireToken API
|
|
14
14
|
* @param request
|
|
15
15
|
*/
|
|
16
|
-
acquireTokenByRefreshToken(request: SilentFlowRequest): Promise<AuthenticationResult>;
|
|
16
|
+
acquireTokenByRefreshToken(request: SilentFlowRequest): Promise<AuthenticationResult | null>;
|
|
17
17
|
/**
|
|
18
18
|
* makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached
|
|
19
19
|
* @param request
|
|
@@ -9,7 +9,7 @@ export declare class SilentFlowClient extends BaseClient {
|
|
|
9
9
|
* the given token and returns the renewed token
|
|
10
10
|
* @param request
|
|
11
11
|
*/
|
|
12
|
-
acquireToken(request: SilentFlowRequest): Promise<AuthenticationResult>;
|
|
12
|
+
acquireToken(request: SilentFlowRequest): Promise<AuthenticationResult | null>;
|
|
13
13
|
/**
|
|
14
14
|
* Retrieves token from cache or throws an error if it must be refreshed.
|
|
15
15
|
* @param request
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseClient } from "./BaseClient";
|
|
2
|
+
import { ClientConfiguration } from "../config/ClientConfiguration";
|
|
3
|
+
import { UsernamePasswordRequest } from "../request/UsernamePasswordRequest";
|
|
4
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
5
|
+
/**
|
|
6
|
+
* Oauth2.0 Password grant client
|
|
7
|
+
* Note: We are only supporting public clients for password grant and for purely testing purposes
|
|
8
|
+
*/
|
|
9
|
+
export declare class UsernamePasswordClient extends BaseClient {
|
|
10
|
+
constructor(configuration: ClientConfiguration);
|
|
11
|
+
/**
|
|
12
|
+
* API to acquire a token by passing the username and password to the service in exchage of credentials
|
|
13
|
+
* password_grant
|
|
14
|
+
* @param request
|
|
15
|
+
*/
|
|
16
|
+
acquireToken(request: UsernamePasswordRequest): Promise<AuthenticationResult | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Executes POST request to token endpoint
|
|
19
|
+
* @param authority
|
|
20
|
+
* @param request
|
|
21
|
+
*/
|
|
22
|
+
private executeTokenRequest;
|
|
23
|
+
/**
|
|
24
|
+
* Generates a map for all the params to be sent to the service
|
|
25
|
+
* @param request
|
|
26
|
+
*/
|
|
27
|
+
private createTokenRequestBody;
|
|
28
|
+
}
|
|
@@ -29,9 +29,22 @@ export declare type ClientConfiguration = {
|
|
|
29
29
|
cryptoInterface?: ICrypto;
|
|
30
30
|
clientCredentials?: ClientCredentials;
|
|
31
31
|
libraryInfo?: LibraryInfo;
|
|
32
|
-
serverTelemetryManager?: ServerTelemetryManager;
|
|
33
|
-
persistencePlugin?: ICachePlugin;
|
|
34
|
-
serializableCache?: ISerializableTokenCache;
|
|
32
|
+
serverTelemetryManager?: ServerTelemetryManager | null;
|
|
33
|
+
persistencePlugin?: ICachePlugin | null;
|
|
34
|
+
serializableCache?: ISerializableTokenCache | null;
|
|
35
|
+
};
|
|
36
|
+
export declare type CommonClientConfiguration = {
|
|
37
|
+
authOptions: Required<AuthOptions>;
|
|
38
|
+
systemOptions: Required<SystemOptions>;
|
|
39
|
+
loggerOptions: Required<LoggerOptions>;
|
|
40
|
+
storageInterface: CacheManager;
|
|
41
|
+
networkInterface: INetworkModule;
|
|
42
|
+
cryptoInterface: Required<ICrypto>;
|
|
43
|
+
libraryInfo: LibraryInfo;
|
|
44
|
+
serverTelemetryManager: ServerTelemetryManager | null;
|
|
45
|
+
clientCredentials: ClientCredentials;
|
|
46
|
+
persistencePlugin: ICachePlugin | null;
|
|
47
|
+
serializableCache: ISerializableTokenCache | null;
|
|
35
48
|
};
|
|
36
49
|
/**
|
|
37
50
|
* Use this to configure the auth options in the ClientConfiguration object
|
|
@@ -45,7 +58,7 @@ export declare type ClientConfiguration = {
|
|
|
45
58
|
*/
|
|
46
59
|
export declare type AuthOptions = {
|
|
47
60
|
clientId: string;
|
|
48
|
-
authority
|
|
61
|
+
authority: Authority;
|
|
49
62
|
knownAuthorities?: Array<string>;
|
|
50
63
|
cloudDiscoveryMetadata?: string;
|
|
51
64
|
clientCapabilities?: Array<string>;
|
|
@@ -90,7 +103,7 @@ export declare type ClientCredentials = {
|
|
|
90
103
|
assertionType: string;
|
|
91
104
|
};
|
|
92
105
|
};
|
|
93
|
-
export declare const DEFAULT_SYSTEM_OPTIONS: SystemOptions
|
|
106
|
+
export declare const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions>;
|
|
94
107
|
/**
|
|
95
108
|
* Function that sets the default options when not explicitly configured from app developer
|
|
96
109
|
*
|
|
@@ -98,4 +111,4 @@ export declare const DEFAULT_SYSTEM_OPTIONS: SystemOptions;
|
|
|
98
111
|
*
|
|
99
112
|
* @returns Configuration
|
|
100
113
|
*/
|
|
101
|
-
export declare function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache }: ClientConfiguration):
|
|
114
|
+
export declare function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache }: ClientConfiguration): CommonClientConfiguration;
|
|
@@ -13,8 +13,8 @@ export declare const AuthErrorMessage: {
|
|
|
13
13
|
export declare class AuthError extends Error {
|
|
14
14
|
errorCode: string;
|
|
15
15
|
errorMessage: string;
|
|
16
|
-
|
|
17
|
-
constructor(errorCode
|
|
16
|
+
subError: string;
|
|
17
|
+
constructor(errorCode?: string, errorMessage?: string, suberror?: string);
|
|
18
18
|
/**
|
|
19
19
|
* Creates an error that is thrown when something unexpected happens in the library.
|
|
20
20
|
* @param errDesc
|
|
@@ -40,10 +40,18 @@ export declare const ClientAuthErrorMessage: {
|
|
|
40
40
|
code: string;
|
|
41
41
|
desc: string;
|
|
42
42
|
};
|
|
43
|
+
stateNotFoundError: {
|
|
44
|
+
code: string;
|
|
45
|
+
desc: string;
|
|
46
|
+
};
|
|
43
47
|
nonceMismatchError: {
|
|
44
48
|
code: string;
|
|
45
49
|
desc: string;
|
|
46
50
|
};
|
|
51
|
+
nonceNotFoundError: {
|
|
52
|
+
code: string;
|
|
53
|
+
desc: string;
|
|
54
|
+
};
|
|
47
55
|
noTokensFoundError: {
|
|
48
56
|
code: string;
|
|
49
57
|
desc: string;
|
|
@@ -56,6 +64,10 @@ export declare const ClientAuthErrorMessage: {
|
|
|
56
64
|
code: string;
|
|
57
65
|
desc: string;
|
|
58
66
|
};
|
|
67
|
+
multipleMatchingAppMetadata: {
|
|
68
|
+
code: string;
|
|
69
|
+
desc: string;
|
|
70
|
+
};
|
|
59
71
|
tokenRequestCannotBeMade: {
|
|
60
72
|
code: string;
|
|
61
73
|
desc: string;
|
|
@@ -132,6 +144,14 @@ export declare const ClientAuthErrorMessage: {
|
|
|
132
144
|
code: string;
|
|
133
145
|
desc: string;
|
|
134
146
|
};
|
|
147
|
+
tokenClaimsRequired: {
|
|
148
|
+
code: string;
|
|
149
|
+
desc: string;
|
|
150
|
+
};
|
|
151
|
+
noAuthorizationCodeFromServer: {
|
|
152
|
+
code: string;
|
|
153
|
+
desc: string;
|
|
154
|
+
};
|
|
135
155
|
};
|
|
136
156
|
/**
|
|
137
157
|
* Error thrown when there is an error in the client code running on the browser.
|
|
@@ -147,7 +167,7 @@ export declare class ClientAuthError extends AuthError {
|
|
|
147
167
|
* Creates an error thrown if the client info is empty.
|
|
148
168
|
* @param rawClientInfo
|
|
149
169
|
*/
|
|
150
|
-
static createClientInfoEmptyError(
|
|
170
|
+
static createClientInfoEmptyError(): ClientAuthError;
|
|
151
171
|
/**
|
|
152
172
|
* Creates an error thrown when the id token extraction errors out.
|
|
153
173
|
* @param err
|
|
@@ -176,24 +196,36 @@ export declare class ClientAuthError extends AuthError {
|
|
|
176
196
|
* Creates an error thrown when two states do not match.
|
|
177
197
|
*/
|
|
178
198
|
static createStateMismatchError(): ClientAuthError;
|
|
199
|
+
/**
|
|
200
|
+
* Creates an error thrown when the state is not present
|
|
201
|
+
* @param missingState
|
|
202
|
+
*/
|
|
203
|
+
static createStateNotFoundError(missingState: string): ClientAuthError;
|
|
179
204
|
/**
|
|
180
205
|
* Creates an error thrown when the nonce does not match.
|
|
181
206
|
*/
|
|
182
207
|
static createNonceMismatchError(): ClientAuthError;
|
|
208
|
+
/**
|
|
209
|
+
* Creates an error thrown when the mnonce is not present
|
|
210
|
+
* @param missingNonce
|
|
211
|
+
*/
|
|
212
|
+
static createNonceNotFoundError(missingNonce: string): ClientAuthError;
|
|
183
213
|
/**
|
|
184
214
|
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
185
215
|
*/
|
|
186
216
|
static createNoTokensFoundError(): ClientAuthError;
|
|
187
217
|
/**
|
|
188
|
-
* Throws error when multiple tokens are in cache
|
|
189
|
-
* @param scope
|
|
218
|
+
* Throws error when multiple tokens are in cache.
|
|
190
219
|
*/
|
|
191
220
|
static createMultipleMatchingTokensInCacheError(): ClientAuthError;
|
|
192
221
|
/**
|
|
193
|
-
* Throws error when multiple
|
|
194
|
-
* @param scope
|
|
222
|
+
* Throws error when multiple accounts are in cache for the given params
|
|
195
223
|
*/
|
|
196
224
|
static createMultipleMatchingAccountsInCacheError(): ClientAuthError;
|
|
225
|
+
/**
|
|
226
|
+
* Throws error when multiple appMetada are in cache for the given clientId.
|
|
227
|
+
*/
|
|
228
|
+
static createMultipleMatchingAppMetadataInCacheError(): ClientAuthError;
|
|
197
229
|
/**
|
|
198
230
|
* Throws error when no auth code or refresh token is given to ServerTokenRequestParameters.
|
|
199
231
|
*/
|
|
@@ -275,4 +307,12 @@ export declare class ClientAuthError extends AuthError {
|
|
|
275
307
|
* Throws error if token cannot be retrieved from cache due to refresh being required.
|
|
276
308
|
*/
|
|
277
309
|
static createRefreshRequiredError(): ClientAuthError;
|
|
310
|
+
/**
|
|
311
|
+
* Throws error if token claims are not populated for a signed jwt generation
|
|
312
|
+
*/
|
|
313
|
+
static createTokenClaimsRequiredError(): ClientAuthError;
|
|
314
|
+
/**
|
|
315
|
+
* Throws error when the authorization code is missing from the server response
|
|
316
|
+
*/
|
|
317
|
+
static createNoAuthCodeInServerResponseError(): ClientAuthError;
|
|
278
318
|
}
|
|
@@ -75,6 +75,10 @@ export declare const ClientConfigurationErrorMessage: {
|
|
|
75
75
|
code: string;
|
|
76
76
|
desc: string;
|
|
77
77
|
};
|
|
78
|
+
resourceRequestParametersRequired: {
|
|
79
|
+
code: string;
|
|
80
|
+
desc: string;
|
|
81
|
+
};
|
|
78
82
|
};
|
|
79
83
|
/**
|
|
80
84
|
* Error thrown when there is an error in configuration of the MSAL.js library.
|
|
@@ -160,4 +164,8 @@ export declare class ClientConfigurationError extends ClientAuthError {
|
|
|
160
164
|
* Throws error when provided authority is not a member of the trusted host list
|
|
161
165
|
*/
|
|
162
166
|
static createUntrustedAuthorityError(): ClientConfigurationError;
|
|
167
|
+
/**
|
|
168
|
+
* Throws error when resourceRequestMethod or resourceRequestUri is missing
|
|
169
|
+
*/
|
|
170
|
+
static createResourceRequestParametersRequiredError(): ClientConfigurationError;
|
|
163
171
|
}
|
|
@@ -8,6 +8,6 @@ export declare const InteractionRequiredAuthSubErrorMessage: string[];
|
|
|
8
8
|
* Error thrown when user interaction is required at the auth server.
|
|
9
9
|
*/
|
|
10
10
|
export declare class InteractionRequiredAuthError extends ServerError {
|
|
11
|
-
constructor(errorCode
|
|
12
|
-
static isInteractionRequiredError(errorCode
|
|
11
|
+
constructor(errorCode?: string, errorMessage?: string, subError?: string);
|
|
12
|
+
static isInteractionRequiredError(errorCode?: string, errorString?: string, subError?: string): boolean;
|
|
13
13
|
}
|
|
@@ -3,6 +3,5 @@ import { AuthError } from "./AuthError";
|
|
|
3
3
|
* Error thrown when there is an error with the server code, for example, unavailability.
|
|
4
4
|
*/
|
|
5
5
|
export declare class ServerError extends AuthError {
|
|
6
|
-
subError
|
|
7
|
-
constructor(errorCode: string, errorMessage?: string, subError?: string);
|
|
6
|
+
constructor(errorCode?: string, errorMessage?: string, subError?: string);
|
|
8
7
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { RefreshTokenClient } from "./client/RefreshTokenClient";
|
|
|
4
4
|
export { ClientCredentialClient } from "./client/ClientCredentialClient";
|
|
5
5
|
export { OnBehalfOfClient } from "./client/OnBehalfOfClient";
|
|
6
6
|
export { SilentFlowClient } from "./client/SilentFlowClient";
|
|
7
|
+
export { UsernamePasswordClient } from "./client/UsernamePasswordClient";
|
|
7
8
|
export { AuthOptions, SystemOptions, LoggerOptions, DEFAULT_SYSTEM_OPTIONS } from "./config/ClientConfiguration";
|
|
8
9
|
export { ClientConfiguration } from "./config/ClientConfiguration";
|
|
9
10
|
export { AccountInfo } from "./account/AccountInfo";
|
|
@@ -47,8 +48,11 @@ export { OnBehalfOfRequest } from "./request/OnBehalfOfRequest";
|
|
|
47
48
|
export { SilentFlowRequest } from "./request/SilentFlowRequest";
|
|
48
49
|
export { DeviceCodeRequest } from "./request/DeviceCodeRequest";
|
|
49
50
|
export { EndSessionRequest } from "./request/EndSessionRequest";
|
|
51
|
+
export { UsernamePasswordRequest } from "./request/UsernamePasswordRequest";
|
|
50
52
|
export { AuthenticationResult } from "./response/AuthenticationResult";
|
|
53
|
+
export { AuthorizationCodePayload } from "./response/AuthorizationCodePayload";
|
|
51
54
|
export { ServerAuthorizationCodeResponse } from "./response/ServerAuthorizationCodeResponse";
|
|
55
|
+
export { DeviceCodeResponse } from "./response/DeviceCodeResponse";
|
|
52
56
|
export { ILoggerCallback, LogLevel, Logger } from "./logger/Logger";
|
|
53
57
|
export { InteractionRequiredAuthError } from "./error/InteractionRequiredAuthError";
|
|
54
58
|
export { AuthError, AuthErrorMessage } from "./error/AuthError";
|
|
@@ -31,7 +31,13 @@ export declare class Logger {
|
|
|
31
31
|
private level;
|
|
32
32
|
private piiLoggingEnabled;
|
|
33
33
|
private localCallback;
|
|
34
|
-
|
|
34
|
+
private packageName;
|
|
35
|
+
private packageVersion;
|
|
36
|
+
constructor(loggerOptions: LoggerOptions, packageName?: string, packageVersion?: string);
|
|
37
|
+
/**
|
|
38
|
+
* Create new Logger with existing configurations.
|
|
39
|
+
*/
|
|
40
|
+
clone(packageName: string, packageVersion: string): Logger;
|
|
35
41
|
/**
|
|
36
42
|
* Log message with required options.
|
|
37
43
|
*/
|
|
@@ -15,8 +15,8 @@ import { AuthenticationScheme } from "../utils/Constants";
|
|
|
15
15
|
* - resourceRequestUri - URI that token will be used for. Used for proof-of-possession flows.
|
|
16
16
|
*/
|
|
17
17
|
export declare type AuthorizationCodeRequest = BaseAuthRequest & {
|
|
18
|
-
|
|
18
|
+
authenticationScheme: AuthenticationScheme;
|
|
19
19
|
code: string;
|
|
20
|
+
redirectUri: string;
|
|
20
21
|
codeVerifier?: string;
|
|
21
|
-
authenticationScheme?: AuthenticationScheme;
|
|
22
22
|
};
|
|
@@ -31,18 +31,18 @@ import { AccountInfo } from "../account/AccountInfo";
|
|
|
31
31
|
* - resourceRequestUri - URI that token will be used for. Used for proof-of-possession flows.
|
|
32
32
|
*/
|
|
33
33
|
export declare type AuthorizationUrlRequest = BaseAuthRequest & {
|
|
34
|
-
authenticationScheme
|
|
35
|
-
redirectUri
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
authenticationScheme: AuthenticationScheme;
|
|
35
|
+
redirectUri: string;
|
|
36
|
+
responseMode: ResponseMode;
|
|
37
|
+
account?: AccountInfo;
|
|
38
38
|
codeChallenge?: string;
|
|
39
39
|
codeChallengeMethod?: string;
|
|
40
|
-
state?: string;
|
|
41
|
-
prompt?: string;
|
|
42
|
-
account?: AccountInfo;
|
|
43
|
-
loginHint?: string;
|
|
44
40
|
domainHint?: string;
|
|
45
|
-
sid?: string;
|
|
46
41
|
extraQueryParameters?: StringDict;
|
|
42
|
+
extraScopesToConsent?: Array<string>;
|
|
43
|
+
loginHint?: string;
|
|
47
44
|
nonce?: string;
|
|
45
|
+
prompt?: string;
|
|
46
|
+
sid?: string;
|
|
47
|
+
state?: string;
|
|
48
48
|
};
|