@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.
Files changed (42) hide show
  1. package/CHANGELOG.json +180 -0
  2. package/changelog.md +60 -6
  3. package/dist/index.es.js +1346 -1034
  4. package/dist/index.js +1050 -737
  5. package/dist/src/account/AccountInfo.d.ts +5 -0
  6. package/dist/src/authority/Authority.d.ts +8 -1
  7. package/dist/src/cache/CacheManager.d.ts +17 -2
  8. package/dist/src/cache/entities/AccountEntity.d.ts +15 -2
  9. package/dist/src/cache/entities/CacheRecord.d.ts +6 -6
  10. package/dist/src/client/AuthorizationCodeClient.d.ts +8 -2
  11. package/dist/src/client/BaseClient.d.ts +9 -4
  12. package/dist/src/client/ClientCredentialClient.d.ts +21 -1
  13. package/dist/src/client/DeviceCodeClient.d.ts +1 -1
  14. package/dist/src/client/OnBehalfOfClient.d.ts +30 -1
  15. package/dist/src/client/RefreshTokenClient.d.ts +2 -2
  16. package/dist/src/client/SilentFlowClient.d.ts +1 -1
  17. package/dist/src/client/UsernamePasswordClient.d.ts +28 -0
  18. package/dist/src/config/ClientConfiguration.d.ts +19 -6
  19. package/dist/src/error/AuthError.d.ts +2 -2
  20. package/dist/src/error/ClientAuthError.d.ts +45 -5
  21. package/dist/src/error/ClientConfigurationError.d.ts +8 -0
  22. package/dist/src/error/InteractionRequiredAuthError.d.ts +2 -2
  23. package/dist/src/error/ServerError.d.ts +1 -2
  24. package/dist/src/index.d.ts +4 -0
  25. package/dist/src/logger/Logger.d.ts +7 -1
  26. package/dist/src/request/AuthorizationCodeRequest.d.ts +2 -2
  27. package/dist/src/request/AuthorizationUrlRequest.d.ts +9 -9
  28. package/dist/src/request/BaseAuthRequest.d.ts +2 -2
  29. package/dist/src/request/ClientCredentialRequest.d.ts +1 -1
  30. package/dist/src/request/EndSessionRequest.d.ts +3 -3
  31. package/dist/src/request/RefreshTokenRequest.d.ts +1 -1
  32. package/dist/src/request/RequestParameterBuilder.d.ts +22 -2
  33. package/dist/src/request/SilentFlowRequest.d.ts +1 -1
  34. package/dist/src/request/UsernamePasswordRequest.d.ts +16 -0
  35. package/dist/src/response/AuthenticationResult.d.ts +5 -2
  36. package/dist/src/response/AuthorizationCodePayload.d.ts +12 -0
  37. package/dist/src/response/ResponseHandler.d.ts +4 -4
  38. package/dist/src/response/ServerAuthorizationCodeResponse.d.ts +4 -0
  39. package/dist/src/url/UrlString.d.ts +1 -0
  40. package/dist/src/utils/Constants.d.ts +9 -0
  41. package/dist/src/utils/StringUtils.d.ts +8 -2
  42. package/package.json +4 -3
@@ -8,10 +8,10 @@
8
8
  * - resourceRequestUri - URI that token will be used for. Used for proof-of-possession flows.
9
9
  */
10
10
  export declare type BaseAuthRequest = {
11
+ authority: string;
12
+ correlationId: string;
11
13
  scopes: Array<string>;
12
14
  claims?: string;
13
- authority?: string;
14
- correlationId?: string;
15
15
  resourceRequestMethod?: string;
16
16
  resourceRequestUri?: string;
17
17
  };
@@ -1,6 +1,6 @@
1
1
  import { BaseAuthRequest } from "./BaseAuthRequest";
2
2
  /**
3
- * RefreshTokenRequest
3
+ * ClientCredentialRequest
4
4
  * - scopes - Array of scopes the application is requesting access to.
5
5
  * - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
6
6
  * - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
@@ -3,12 +3,12 @@ import { AccountInfo } from "../account/AccountInfo";
3
3
  * EndSessionRequest
4
4
  * - account - Account object that will be logged out of. All tokens tied to this account will be cleared.
5
5
  * - postLogoutRedirectUri - URI to navigate to after logout page.
6
- * - authority - Authority to send logout request to.
7
6
  * - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
7
+ * - idTokenHint - ID Token used by B2C to validate logout if required by the policy
8
8
  */
9
9
  export declare type EndSessionRequest = {
10
+ correlationId: string;
10
11
  account?: AccountInfo;
11
12
  postLogoutRedirectUri?: string;
12
- authority?: string;
13
- correlationId?: string;
13
+ idTokenHint?: string;
14
14
  };
@@ -12,5 +12,5 @@ import { AuthenticationScheme } from "../utils/Constants";
12
12
  */
13
13
  export declare type RefreshTokenRequest = BaseAuthRequest & {
14
14
  refreshToken: string;
15
- authenticationScheme?: AuthenticationScheme;
15
+ authenticationScheme: AuthenticationScheme;
16
16
  };
@@ -29,6 +29,16 @@ export declare class RequestParameterBuilder {
29
29
  * @param redirectUri
30
30
  */
31
31
  addRedirectUri(redirectUri: string): void;
32
+ /**
33
+ * add post logout redirectUri
34
+ * @param redirectUri
35
+ */
36
+ addPostLogoutRedirectUri(redirectUri: string): void;
37
+ /**
38
+ * add id_token_hint to logout request
39
+ * @param idTokenHint
40
+ */
41
+ addIdTokenHint(idTokenHint: string): void;
32
42
  /**
33
43
  * add domain_hint
34
44
  * @param domainHint
@@ -48,7 +58,7 @@ export declare class RequestParameterBuilder {
48
58
  * add claims
49
59
  * @param claims
50
60
  */
51
- addClaims(claims: string, clientCapabilities: Array<string>): void;
61
+ addClaims(claims?: string, clientCapabilities?: Array<string>): void;
52
62
  /**
53
63
  * add correlationId
54
64
  * @param correlationId
@@ -141,7 +151,17 @@ export declare class RequestParameterBuilder {
141
151
  * @param eQparams
142
152
  */
143
153
  addExtraQueryParameters(eQparams: StringDict): void;
144
- addClientCapabilitiesToClaims(claims: string, clientCapabilities: Array<string>): string;
154
+ addClientCapabilitiesToClaims(claims?: string, clientCapabilities?: Array<string>): string;
155
+ /**
156
+ * adds `username` for Password Grant flow
157
+ * @param username
158
+ */
159
+ addUsername(username: string): void;
160
+ /**
161
+ * adds `password` for Password Grant flow
162
+ * @param password
163
+ */
164
+ addPassword(password: string): void;
145
165
  /**
146
166
  * add pop_jwk to query params
147
167
  * @param cnfString
@@ -13,5 +13,5 @@ import { BaseAuthRequest } from "./BaseAuthRequest";
13
13
  */
14
14
  export declare type SilentFlowRequest = BaseAuthRequest & {
15
15
  account: AccountInfo;
16
- forceRefresh?: boolean;
16
+ forceRefresh: boolean;
17
17
  };
@@ -0,0 +1,16 @@
1
+ import { BaseAuthRequest } from "./BaseAuthRequest";
2
+ /**
3
+ * UsernamePassword parameters passed by the user to retrieve credentials
4
+ * Note: The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely. This flow is added for internal testing.
5
+ *
6
+ * - scopes - Array of scopes the application is requesting access to.
7
+ * - claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
8
+ * - authority - Url of the authority which the application acquires tokens from.
9
+ * - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
10
+ * - username - username of the client
11
+ * - password - credentials
12
+ */
13
+ export declare type UsernamePasswordRequest = BaseAuthRequest & {
14
+ username: string;
15
+ password: string;
16
+ };
@@ -15,17 +15,20 @@ import { AccountInfo } from "../account/AccountInfo";
15
15
  * - familyId - Family ID identifier, usually only used for refresh tokens
16
16
  */
17
17
  export declare type AuthenticationResult = {
18
+ authority: string;
18
19
  uniqueId: string;
19
20
  tenantId: string;
20
21
  scopes: Array<string>;
21
- account: AccountInfo;
22
+ account: AccountInfo | null;
22
23
  idToken: string;
23
24
  idTokenClaims: object;
24
25
  accessToken: string;
25
26
  fromCache: boolean;
26
- expiresOn: Date;
27
+ expiresOn: Date | null;
27
28
  tokenType: string;
28
29
  extExpiresOn?: Date;
29
30
  state?: string;
30
31
  familyId?: string;
32
+ cloudGraphHostName?: string;
33
+ msGraphHost?: string;
31
34
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Response returned after processing the code response query string or fragment.
3
+ */
4
+ export declare type AuthorizationCodePayload = {
5
+ code: string;
6
+ cloud_instance_name?: string;
7
+ cloud_instance_host_name?: string;
8
+ cloud_graph_host_name?: string;
9
+ msgraph_host?: string;
10
+ state?: string;
11
+ nonce?: string;
12
+ };
@@ -10,6 +10,7 @@ import { CacheManager } from "../cache/CacheManager";
10
10
  import { RequestStateObject } from "../utils/ProtocolUtils";
11
11
  import { ICachePlugin } from "../cache/interface/ICachePlugin";
12
12
  import { ISerializableTokenCache } from "../cache/interface/ISerializableTokenCache";
13
+ import { AuthorizationCodePayload } from "./AuthorizationCodePayload";
13
14
  /**
14
15
  * Class that handles response parsing.
15
16
  */
@@ -18,11 +19,10 @@ export declare class ResponseHandler {
18
19
  private cacheStorage;
19
20
  private cryptoObj;
20
21
  private logger;
21
- private clientInfo;
22
22
  private homeAccountIdentifier;
23
23
  private serializableCache;
24
24
  private persistencePlugin;
25
- constructor(clientId: string, cacheStorage: CacheManager, cryptoObj: ICrypto, logger: Logger, serializableCache?: ISerializableTokenCache, persistencePlugin?: ICachePlugin);
25
+ constructor(clientId: string, cacheStorage: CacheManager, cryptoObj: ICrypto, logger: Logger, serializableCache: ISerializableTokenCache | null, persistencePlugin: ICachePlugin | null);
26
26
  /**
27
27
  * Function which validates server authorization code response.
28
28
  * @param serverResponseHash
@@ -40,7 +40,7 @@ export declare class ResponseHandler {
40
40
  * @param serverTokenResponse
41
41
  * @param authority
42
42
  */
43
- handleServerTokenResponse(serverTokenResponse: ServerAuthorizationTokenResponse, authority: Authority, resourceRequestMethod?: string, resourceRequestUri?: string, cachedNonce?: string, cachedState?: string, requestScopes?: string[], oboAssertion?: string, handlingRefreshTokenResponse?: boolean): Promise<AuthenticationResult>;
43
+ handleServerTokenResponse(serverTokenResponse: ServerAuthorizationTokenResponse, authority: Authority, resourceRequestMethod?: string, resourceRequestUri?: string, authCodePayload?: AuthorizationCodePayload, requestScopes?: string[], oboAssertion?: string, handlingRefreshTokenResponse?: boolean): Promise<AuthenticationResult | null>;
44
44
  /**
45
45
  * Generates CacheRecord
46
46
  * @param serverTokenResponse
@@ -65,5 +65,5 @@ export declare class ResponseHandler {
65
65
  * @param fromTokenCache
66
66
  * @param stateString
67
67
  */
68
- static generateAuthenticationResult(cryptoObj: ICrypto, cacheRecord: CacheRecord, idTokenObj: AuthToken, fromTokenCache: boolean, requestState?: RequestStateObject, resourceRequestMethod?: string, resourceRequestUri?: string): Promise<AuthenticationResult>;
68
+ static generateAuthenticationResult(cryptoObj: ICrypto, authority: Authority, cacheRecord: CacheRecord, fromTokenCache: boolean, idTokenObj?: AuthToken, requestState?: RequestStateObject, resourceRequestMethod?: string, resourceRequestUri?: string): Promise<AuthenticationResult>;
69
69
  }
@@ -10,6 +10,10 @@ export declare type ServerAuthorizationCodeResponse = {
10
10
  code?: string;
11
11
  client_info?: string;
12
12
  state?: string;
13
+ cloud_instance_name?: string;
14
+ cloud_instance_host_name?: string;
15
+ cloud_graph_host_name?: string;
16
+ msgraph_host?: string;
13
17
  error?: string;
14
18
  error_description?: string;
15
19
  suberror?: string;
@@ -39,6 +39,7 @@ export declare class UrlString {
39
39
  */
40
40
  getUrlComponents(): IUri;
41
41
  static getDomainFromUrl(url: string): string;
42
+ static getAbsoluteUrl(relativeUrl: string, baseUrl: string): string;
42
43
  /**
43
44
  * Parses hash string from given string. Returns empty string if no hash symbol is found.
44
45
  * @param hashString
@@ -22,6 +22,7 @@ export declare const Constants: {
22
22
  AUTHORIZATION_PENDING: string;
23
23
  NOT_DEFINED: string;
24
24
  EMPTY_STRING: string;
25
+ FORWARD_SLASH: string;
25
26
  };
26
27
  /**
27
28
  * Request header names
@@ -84,6 +85,7 @@ export declare enum AADServerParamKeys {
84
85
  X_CLIENT_OS = "x-client-OS",
85
86
  X_CLIENT_CPU = "x-client-CPU",
86
87
  POST_LOGOUT_URI = "post_logout_redirect_uri",
88
+ ID_TOKEN_HINT = "id_token_hint",
87
89
  DEVICE_CODE = "device_code",
88
90
  CLIENT_SECRET = "client_secret",
89
91
  CLIENT_ASSERTION = "client_assertion",
@@ -252,3 +254,10 @@ export declare const Errors: {
252
254
  INVALID_GRANT_ERROR: string;
253
255
  CLIENT_MISMATCH_ERROR: string;
254
256
  };
257
+ /**
258
+ * Password grant parameters
259
+ */
260
+ export declare enum PasswordGrantConstants {
261
+ username = "username",
262
+ password = "password"
263
+ }
@@ -14,7 +14,7 @@ export declare class StringUtils {
14
14
  *
15
15
  * @param str
16
16
  */
17
- static isEmpty(str: string): boolean;
17
+ static isEmpty(str?: string): boolean;
18
18
  static startsWith(str: string, search: string): boolean;
19
19
  static endsWith(str: string, search: string): boolean;
20
20
  /**
@@ -38,5 +38,11 @@ export declare class StringUtils {
38
38
  * Attempts to parse a string into JSON
39
39
  * @param str
40
40
  */
41
- static jsonParseHelper<T>(str: string): T;
41
+ static jsonParseHelper<T>(str: string): T | null;
42
+ /**
43
+ * Tests if a given string matches a given pattern, with support for wildcards.
44
+ * @param pattern Wildcard pattern to string match. Supports "*" for wildcards
45
+ * @param input String to match against
46
+ */
47
+ static matchPattern(pattern: string, input: string): boolean;
42
48
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
12
12
  },
13
- "version": "1.6.3",
13
+ "version": "2.0.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -48,11 +48,12 @@
48
48
  "lint": "cd ../../ && npm run lint:common",
49
49
  "lint:fix": "npm run lint -- -- --fix",
50
50
  "test": "mocha",
51
- "test:coverage": "nyc --reporter=text mocha --exit",
51
+ "test:coverage": "nyc mocha",
52
52
  "test:coverage:only": "npm run clean:coverage && npm run test:coverage",
53
53
  "build:modules": "rollup -c",
54
54
  "build:modules:watch": "rollup -cw",
55
55
  "build": "npm run clean && npm run build:modules",
56
+ "build:all": "npm run build",
56
57
  "prepack": "npm run build"
57
58
  },
58
59
  "devDependencies": {
@@ -77,7 +78,7 @@
77
78
  "gh-pages": "^3.1.0",
78
79
  "husky": "^3.0.9",
79
80
  "mocha": "^6.2.2",
80
- "nyc": "^14.1.1",
81
+ "nyc": "^15.0.0",
81
82
  "rimraf": "^3.0.2",
82
83
  "rollup": "^1.24.0",
83
84
  "rollup-plugin-typescript2": "^0.24.3",