@azure/msal-browser 3.14.0 → 3.16.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/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts +17 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +37 -9
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +3 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -1
- package/dist/app/PublicClientNext.mjs +4 -1
- package/dist/app/PublicClientNext.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.d.ts +49 -0
- package/dist/cache/AccountManager.d.ts.map +1 -0
- package/dist/cache/AccountManager.mjs +131 -0
- package/dist/cache/AccountManager.mjs.map +1 -0
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +9 -2
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/config/Configuration.d.ts +3 -1
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +10 -11
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +118 -10
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +227 -83
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +85 -118
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.mjs +1 -1
- package/dist/crypto/CryptoOps.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +4 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +5 -3
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +1 -1
- package/dist/interaction_client/RedirectClient.mjs +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeAccountContext.d.ts +13 -0
- package/dist/naa/BridgeAccountContext.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +1 -1
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.d.ts +3 -2
- package/dist/naa/BridgeProxy.d.ts.map +1 -1
- package/dist/naa/BridgeProxy.mjs +9 -7
- package/dist/naa/BridgeProxy.mjs.map +1 -1
- package/dist/naa/BridgeRequestEnvelope.d.ts +1 -1
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/IBridgeProxy.d.ts +2 -2
- package/dist/naa/IBridgeProxy.d.ts.map +1 -1
- package/dist/naa/InitContext.d.ts +2 -0
- package/dist/naa/InitContext.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +12 -2
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +43 -6
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/{TeamsAppOperatingContext.d.ts → NestedAppOperatingContext.d.ts} +8 -6
- package/dist/operatingcontext/NestedAppOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/{TeamsAppOperatingContext.mjs → NestedAppOperatingContext.mjs} +17 -30
- package/dist/operatingcontext/NestedAppOperatingContext.mjs.map +1 -0
- package/dist/operatingcontext/StandardOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +5 -5
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +8 -8
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +12412 -12117
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +12412 -12117
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +69 -69
- package/package.json +6 -4
- package/src/app/PublicClientApplication.ts +43 -8
- package/src/app/PublicClientNext.ts +3 -0
- package/src/cache/AccountManager.ts +184 -0
- package/src/cache/BrowserCacheManager.ts +11 -2
- package/src/config/Configuration.ts +3 -1
- package/src/controllers/ControllerFactory.ts +9 -11
- package/src/controllers/NestedAppAuthController.ts +375 -82
- package/src/controllers/StandardController.ts +138 -170
- package/src/index.ts +5 -1
- package/src/interaction_client/NativeInteractionClient.ts +8 -2
- package/src/naa/BridgeAccountContext.ts +17 -0
- package/src/naa/BridgeCapabilities.ts +2 -1
- package/src/naa/BridgeProxy.ts +11 -6
- package/src/naa/BridgeRequestEnvelope.ts +1 -6
- package/src/naa/IBridgeProxy.ts +2 -2
- package/src/naa/InitContext.ts +2 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +68 -2
- package/src/operatingcontext/{TeamsAppOperatingContext.ts → NestedAppOperatingContext.ts} +15 -29
- package/src/operatingcontext/StandardOperatingContext.ts +1 -0
- package/src/operatingcontext/UnknownOperatingContext.ts +8 -7
- package/src/packageMetadata.ts +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +0 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +0 -1
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": "3.
|
|
13
|
+
"version": "3.16.0",
|
|
14
14
|
"description": "Microsoft Authentication Library for js",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"implicit",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"build": "npm run clean && npm run build:modules",
|
|
70
70
|
"prepack": "npm run build:all",
|
|
71
71
|
"format:check": "prettier --ignore-path .gitignore --check src test",
|
|
72
|
-
"format:fix": "prettier --ignore-path .gitignore --write src test"
|
|
72
|
+
"format:fix": "prettier --ignore-path .gitignore --write src test",
|
|
73
|
+
"apiExtractor": "api-extractor run"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"@azure/storage-blob": "^12.2.1",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
|
|
79
80
|
"@babel/preset-env": "^7.7.1",
|
|
80
81
|
"@babel/preset-typescript": "^7.7.2",
|
|
82
|
+
"@microsoft/api-extractor": "^7.43.4",
|
|
81
83
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
82
84
|
"@rollup/plugin-terser": "^0.4.0",
|
|
83
85
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
@@ -90,7 +92,7 @@
|
|
|
90
92
|
"jest": "^29.5.0",
|
|
91
93
|
"jest-environment-jsdom": "^29.5.0",
|
|
92
94
|
"msal-test-utils": "file:../../shared-test-utils",
|
|
93
|
-
"prettier": "2.8.7",
|
|
95
|
+
"prettier": "^2.8.7",
|
|
94
96
|
"rimraf": "^3.0.0",
|
|
95
97
|
"rollup": "^3.14.0",
|
|
96
98
|
"shx": "^0.3.2",
|
|
@@ -101,6 +103,6 @@
|
|
|
101
103
|
"typescript": "^4.9.5"
|
|
102
104
|
},
|
|
103
105
|
"dependencies": {
|
|
104
|
-
"@azure/msal-common": "14.
|
|
106
|
+
"@azure/msal-common": "14.11.0"
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -28,6 +28,8 @@ import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
|
28
28
|
import { EventCallbackFunction } from "../event/EventMessage";
|
|
29
29
|
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
30
30
|
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
31
|
+
import { NestedAppAuthController } from "../controllers/NestedAppAuthController";
|
|
32
|
+
import { NestedAppOperatingContext } from "../operatingcontext/NestedAppOperatingContext";
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* The PublicClientApplication class is the object exposed by the library to perform authentication and authorization functions in Single Page Applications
|
|
@@ -36,6 +38,7 @@ import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
|
36
38
|
export class PublicClientApplication implements IPublicClientApplication {
|
|
37
39
|
protected controller: IController;
|
|
38
40
|
|
|
41
|
+
// creates StandardController and passes it to the PublicClientApplication
|
|
39
42
|
public static async createPublicClientApplication(
|
|
40
43
|
configuration: Configuration
|
|
41
44
|
): Promise<IPublicClientApplication> {
|
|
@@ -70,14 +73,9 @@ export class PublicClientApplication implements IPublicClientApplication {
|
|
|
70
73
|
* @param IController Optional parameter to explictly set the controller. (Will be removed when we remove public constructor)
|
|
71
74
|
*/
|
|
72
75
|
public constructor(configuration: Configuration, controller?: IController) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const standardOperatingContext = new StandardOperatingContext(
|
|
77
|
-
configuration
|
|
78
|
-
);
|
|
79
|
-
this.controller = new StandardController(standardOperatingContext);
|
|
80
|
-
}
|
|
76
|
+
this.controller =
|
|
77
|
+
controller ||
|
|
78
|
+
new StandardController(new StandardOperatingContext(configuration));
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
/**
|
|
@@ -417,3 +415,40 @@ export class PublicClientApplication implements IPublicClientApplication {
|
|
|
417
415
|
return this.controller.clearCache(logoutRequest);
|
|
418
416
|
}
|
|
419
417
|
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* creates NestedAppAuthController and passes it to the PublicClientApplication,
|
|
421
|
+
* falls back to StandardController if NestedAppAuthController is not available
|
|
422
|
+
*
|
|
423
|
+
* @param configuration
|
|
424
|
+
* @returns IPublicClientApplication
|
|
425
|
+
*
|
|
426
|
+
*/
|
|
427
|
+
export async function createNestablePublicClientApplication(
|
|
428
|
+
configuration: Configuration
|
|
429
|
+
): Promise<IPublicClientApplication> {
|
|
430
|
+
const nestedAppAuth = new NestedAppOperatingContext(configuration);
|
|
431
|
+
await nestedAppAuth.initialize();
|
|
432
|
+
|
|
433
|
+
if (nestedAppAuth.isAvailable()) {
|
|
434
|
+
const controller = new NestedAppAuthController(nestedAppAuth);
|
|
435
|
+
return new PublicClientApplication(configuration, controller);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return createStandardPublicClientApplication(configuration);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* creates PublicClientApplication using StandardController
|
|
443
|
+
*
|
|
444
|
+
* @param configuration
|
|
445
|
+
* @returns IPublicClientApplication
|
|
446
|
+
*
|
|
447
|
+
*/
|
|
448
|
+
export async function createStandardPublicClientApplication(
|
|
449
|
+
configuration: Configuration
|
|
450
|
+
): Promise<IPublicClientApplication> {
|
|
451
|
+
const pca = new PublicClientApplication(configuration);
|
|
452
|
+
await pca.initialize();
|
|
453
|
+
return pca;
|
|
454
|
+
}
|
|
@@ -35,6 +35,9 @@ import { UnknownOperatingContext } from "../operatingcontext/UnknownOperatingCon
|
|
|
35
35
|
* The goals of these changes are to provide a clean separation of behavior between different operating contexts (Nested App Auth, Platform Brokers, Plain old Browser, etc.)
|
|
36
36
|
* while still providing a consistent API surface for developers.
|
|
37
37
|
*
|
|
38
|
+
* Please use PublicClientApplication for any prod/real-world scenarios.
|
|
39
|
+
* Note: PublicClientNext is experimental and subject to breaking changes without following semver
|
|
40
|
+
*
|
|
38
41
|
*/
|
|
39
42
|
export class PublicClientNext implements IPublicClientApplication {
|
|
40
43
|
/*
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AccountInfo, AccountFilter, Logger } from "@azure/msal-common";
|
|
7
|
+
import { BrowserCacheManager } from "./BrowserCacheManager";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
|
|
11
|
+
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
12
|
+
* @returns Array of AccountInfo objects in cache
|
|
13
|
+
*/
|
|
14
|
+
export function getAllAccounts(
|
|
15
|
+
logger: Logger,
|
|
16
|
+
browserStorage: BrowserCacheManager,
|
|
17
|
+
isInBrowser: boolean,
|
|
18
|
+
accountFilter?: AccountFilter
|
|
19
|
+
): AccountInfo[] {
|
|
20
|
+
logger.verbose("getAllAccounts called");
|
|
21
|
+
return isInBrowser ? browserStorage.getAllAccounts(accountFilter) : [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns the first account found in the cache that matches the account filter passed in.
|
|
26
|
+
* @param accountFilter
|
|
27
|
+
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
28
|
+
*/
|
|
29
|
+
export function getAccount(
|
|
30
|
+
accountFilter: AccountFilter,
|
|
31
|
+
logger: Logger,
|
|
32
|
+
browserStorage: BrowserCacheManager
|
|
33
|
+
): AccountInfo | null {
|
|
34
|
+
logger.trace("getAccount called");
|
|
35
|
+
if (Object.keys(accountFilter).length === 0) {
|
|
36
|
+
logger.warning("getAccount: No accountFilter provided");
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const account: AccountInfo | null =
|
|
41
|
+
browserStorage.getAccountInfoFilteredBy(accountFilter);
|
|
42
|
+
|
|
43
|
+
if (account) {
|
|
44
|
+
logger.verbose(
|
|
45
|
+
"getAccount: Account matching provided filter found, returning"
|
|
46
|
+
);
|
|
47
|
+
return account;
|
|
48
|
+
} else {
|
|
49
|
+
logger.verbose("getAccount: No matching account found, returning null");
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the signed in account matching username.
|
|
56
|
+
* (the account object is created at the time of successful login)
|
|
57
|
+
* or null when no matching account is found.
|
|
58
|
+
* This API is provided for convenience but getAccountById should be used for best reliability
|
|
59
|
+
* @param username
|
|
60
|
+
* @returns The account object stored in MSAL
|
|
61
|
+
*/
|
|
62
|
+
export function getAccountByUsername(
|
|
63
|
+
username: string,
|
|
64
|
+
logger: Logger,
|
|
65
|
+
browserStorage: BrowserCacheManager
|
|
66
|
+
): AccountInfo | null {
|
|
67
|
+
logger.trace("getAccountByUsername called");
|
|
68
|
+
if (!username) {
|
|
69
|
+
logger.warning("getAccountByUsername: No username provided");
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const account = browserStorage.getAccountInfoFilteredBy({
|
|
74
|
+
username,
|
|
75
|
+
});
|
|
76
|
+
if (account) {
|
|
77
|
+
logger.verbose(
|
|
78
|
+
"getAccountByUsername: Account matching username found, returning"
|
|
79
|
+
);
|
|
80
|
+
logger.verbosePii(
|
|
81
|
+
`getAccountByUsername: Returning signed-in accounts matching username: ${username}`
|
|
82
|
+
);
|
|
83
|
+
return account;
|
|
84
|
+
} else {
|
|
85
|
+
logger.verbose(
|
|
86
|
+
"getAccountByUsername: No matching account found, returning null"
|
|
87
|
+
);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns the signed in account matching homeAccountId.
|
|
94
|
+
* (the account object is created at the time of successful login)
|
|
95
|
+
* or null when no matching account is found
|
|
96
|
+
* @param homeAccountId
|
|
97
|
+
* @returns The account object stored in MSAL
|
|
98
|
+
*/
|
|
99
|
+
export function getAccountByHomeId(
|
|
100
|
+
homeAccountId: string,
|
|
101
|
+
logger: Logger,
|
|
102
|
+
browserStorage: BrowserCacheManager
|
|
103
|
+
): AccountInfo | null {
|
|
104
|
+
logger.trace("getAccountByHomeId called");
|
|
105
|
+
if (!homeAccountId) {
|
|
106
|
+
logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const account = browserStorage.getAccountInfoFilteredBy({
|
|
111
|
+
homeAccountId,
|
|
112
|
+
});
|
|
113
|
+
if (account) {
|
|
114
|
+
logger.verbose(
|
|
115
|
+
"getAccountByHomeId: Account matching homeAccountId found, returning"
|
|
116
|
+
);
|
|
117
|
+
logger.verbosePii(
|
|
118
|
+
`getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`
|
|
119
|
+
);
|
|
120
|
+
return account;
|
|
121
|
+
} else {
|
|
122
|
+
logger.verbose(
|
|
123
|
+
"getAccountByHomeId: No matching account found, returning null"
|
|
124
|
+
);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Returns the signed in account matching localAccountId.
|
|
131
|
+
* (the account object is created at the time of successful login)
|
|
132
|
+
* or null when no matching account is found
|
|
133
|
+
* @param localAccountId
|
|
134
|
+
* @returns The account object stored in MSAL
|
|
135
|
+
*/
|
|
136
|
+
export function getAccountByLocalId(
|
|
137
|
+
localAccountId: string,
|
|
138
|
+
logger: Logger,
|
|
139
|
+
browserStorage: BrowserCacheManager
|
|
140
|
+
): AccountInfo | null {
|
|
141
|
+
logger.trace("getAccountByLocalId called");
|
|
142
|
+
if (!localAccountId) {
|
|
143
|
+
logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const account = browserStorage.getAccountInfoFilteredBy({
|
|
148
|
+
localAccountId,
|
|
149
|
+
});
|
|
150
|
+
if (account) {
|
|
151
|
+
logger.verbose(
|
|
152
|
+
"getAccountByLocalId: Account matching localAccountId found, returning"
|
|
153
|
+
);
|
|
154
|
+
logger.verbosePii(
|
|
155
|
+
`getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`
|
|
156
|
+
);
|
|
157
|
+
return account;
|
|
158
|
+
} else {
|
|
159
|
+
logger.verbose(
|
|
160
|
+
"getAccountByLocalId: No matching account found, returning null"
|
|
161
|
+
);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
|
|
168
|
+
* @param account
|
|
169
|
+
*/
|
|
170
|
+
export function setActiveAccount(
|
|
171
|
+
account: AccountInfo | null,
|
|
172
|
+
browserStorage: BrowserCacheManager
|
|
173
|
+
): void {
|
|
174
|
+
browserStorage.setActiveAccount(account);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Gets the currently active account
|
|
179
|
+
*/
|
|
180
|
+
export function getActiveAccount(
|
|
181
|
+
browserStorage: BrowserCacheManager
|
|
182
|
+
): AccountInfo | null {
|
|
183
|
+
return browserStorage.getActiveAccount();
|
|
184
|
+
}
|
|
@@ -1837,6 +1837,15 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1837
1837
|
if (request.claims) {
|
|
1838
1838
|
claimsHash = await this.cryptoImpl.hashString(request.claims);
|
|
1839
1839
|
}
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* meta data for cache stores time in seconds from epoch
|
|
1843
|
+
* AuthenticationResult returns expiresOn and extExpiresOn in milliseconds (as a Date object which is in ms)
|
|
1844
|
+
* We need to map these for the cache when building tokens from AuthenticationResult
|
|
1845
|
+
*
|
|
1846
|
+
* The next MSAL VFuture should map these both to same value if possible
|
|
1847
|
+
*/
|
|
1848
|
+
|
|
1840
1849
|
const accessTokenEntity = CacheHelpers.createAccessTokenEntity(
|
|
1841
1850
|
result.account?.homeAccountId,
|
|
1842
1851
|
result.account.environment,
|
|
@@ -1844,8 +1853,8 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1844
1853
|
this.clientId,
|
|
1845
1854
|
result.tenantId,
|
|
1846
1855
|
result.scopes.join(" "),
|
|
1847
|
-
result.expiresOn
|
|
1848
|
-
result.extExpiresOn
|
|
1856
|
+
result.expiresOn ? result.expiresOn.getTime() / 1000 : 0,
|
|
1857
|
+
result.extExpiresOn ? result.extExpiresOn.getTime() / 1000 : 0,
|
|
1849
1858
|
base64Decode,
|
|
1850
1859
|
undefined, // refreshOn
|
|
1851
1860
|
result.tokenType as AuthenticationScheme,
|
|
@@ -94,7 +94,9 @@ export type BrowserAuthOptions = {
|
|
|
94
94
|
*/
|
|
95
95
|
skipAuthorityMetadataCache?: boolean;
|
|
96
96
|
/**
|
|
97
|
-
* App supports nested app auth or not; defaults to
|
|
97
|
+
* App supports nested app auth or not; defaults to
|
|
98
|
+
*
|
|
99
|
+
* @deprecated This flag is deprecated and will be removed in the next major version. createNestablePublicClientApplication should be used instead.
|
|
98
100
|
*/
|
|
99
101
|
supportsNestedAppAuth?: boolean;
|
|
100
102
|
};
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { NestedAppOperatingContext } from "../operatingcontext/NestedAppOperatingContext";
|
|
7
7
|
import { StandardOperatingContext } from "../operatingcontext/StandardOperatingContext";
|
|
8
8
|
import { IController } from "./IController";
|
|
9
9
|
import { Configuration } from "../config/Configuration";
|
|
10
|
+
import { StandardController } from "./StandardController";
|
|
11
|
+
import { NestedAppAuthController } from "./NestedAppAuthController";
|
|
10
12
|
|
|
11
13
|
export async function createV3Controller(
|
|
12
14
|
config: Configuration
|
|
@@ -14,27 +16,23 @@ export async function createV3Controller(
|
|
|
14
16
|
const standard = new StandardOperatingContext(config);
|
|
15
17
|
|
|
16
18
|
await standard.initialize();
|
|
17
|
-
|
|
18
|
-
const controller = await import("./StandardController");
|
|
19
|
-
return controller.StandardController.createController(standard);
|
|
19
|
+
return StandardController.createController(standard);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export async function createController(
|
|
23
23
|
config: Configuration
|
|
24
24
|
): Promise<IController | null> {
|
|
25
25
|
const standard = new StandardOperatingContext(config);
|
|
26
|
-
const
|
|
26
|
+
const nestedApp = new NestedAppOperatingContext(config);
|
|
27
27
|
|
|
28
|
-
const operatingContexts = [standard.initialize(),
|
|
28
|
+
const operatingContexts = [standard.initialize(), nestedApp.initialize()];
|
|
29
29
|
|
|
30
30
|
await Promise.all(operatingContexts);
|
|
31
31
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
return controller.NestedAppAuthController.createController(teamsApp);
|
|
32
|
+
if (nestedApp.isAvailable() && config.auth.supportsNestedAppAuth) {
|
|
33
|
+
return NestedAppAuthController.createController(nestedApp);
|
|
35
34
|
} else if (standard.isAvailable()) {
|
|
36
|
-
|
|
37
|
-
return controller.StandardController.createController(standard);
|
|
35
|
+
return StandardController.createController(standard);
|
|
38
36
|
} else {
|
|
39
37
|
// Since neither of the actual operating contexts are available keep the UnknownOperatingContextController
|
|
40
38
|
return null;
|