@azure/msal-browser 2.16.1 → 2.20.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 (163) hide show
  1. package/CHANGELOG.json +283 -0
  2. package/{changelog.md → CHANGELOG.md} +73 -1
  3. package/README.md +12 -4
  4. package/dist/_virtual/_tslib.js +1 -1
  5. package/dist/app/ClientApplication.d.ts +35 -137
  6. package/dist/app/ClientApplication.d.ts.map +1 -1
  7. package/dist/app/ClientApplication.js +178 -883
  8. package/dist/app/ClientApplication.js.map +1 -1
  9. package/dist/app/IPublicClientApplication.d.ts +8 -0
  10. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  11. package/dist/app/IPublicClientApplication.js +16 -1
  12. package/dist/app/IPublicClientApplication.js.map +1 -1
  13. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  14. package/dist/app/PublicClientApplication.js +35 -41
  15. package/dist/app/PublicClientApplication.js.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.d.ts +46 -0
  17. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -0
  18. package/dist/cache/AsyncMemoryStorage.js +195 -0
  19. package/dist/cache/AsyncMemoryStorage.js.map +1 -0
  20. package/dist/cache/BrowserCacheManager.d.ts +19 -2
  21. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  22. package/dist/cache/BrowserCacheManager.js +104 -15
  23. package/dist/cache/BrowserCacheManager.js.map +1 -1
  24. package/dist/cache/BrowserStorage.d.ts +1 -1
  25. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  26. package/dist/cache/BrowserStorage.js +1 -1
  27. package/dist/cache/BrowserStorage.js.map +1 -1
  28. package/dist/cache/DatabaseStorage.d.ts +29 -4
  29. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  30. package/dist/cache/DatabaseStorage.js +151 -45
  31. package/dist/cache/DatabaseStorage.js.map +1 -1
  32. package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
  33. package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
  34. package/dist/cache/ITokenCache.d.ts +8 -0
  35. package/dist/cache/ITokenCache.d.ts.map +1 -0
  36. package/dist/cache/IWindowStorage.d.ts +3 -3
  37. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  38. package/dist/cache/MemoryStorage.d.ts +3 -3
  39. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  40. package/dist/cache/MemoryStorage.js +1 -1
  41. package/dist/cache/MemoryStorage.js.map +1 -1
  42. package/dist/cache/TokenCache.d.ts +48 -0
  43. package/dist/cache/TokenCache.d.ts.map +1 -0
  44. package/dist/cache/TokenCache.js +124 -0
  45. package/dist/cache/TokenCache.js.map +1 -0
  46. package/dist/config/Configuration.js +1 -1
  47. package/dist/crypto/BrowserCrypto.d.ts +3 -1
  48. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  49. package/dist/crypto/BrowserCrypto.js +3 -2
  50. package/dist/crypto/BrowserCrypto.js.map +1 -1
  51. package/dist/crypto/CryptoOps.d.ts +21 -6
  52. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  53. package/dist/crypto/CryptoOps.js +67 -15
  54. package/dist/crypto/CryptoOps.js.map +1 -1
  55. package/dist/crypto/GuidGenerator.js +1 -1
  56. package/dist/crypto/PkceGenerator.js +1 -1
  57. package/dist/crypto/SignedHttpRequest.d.ts +31 -0
  58. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
  59. package/dist/crypto/SignedHttpRequest.js +70 -0
  60. package/dist/crypto/SignedHttpRequest.js.map +1 -0
  61. package/dist/encode/Base64Decode.js +1 -1
  62. package/dist/encode/Base64Encode.js +1 -1
  63. package/dist/error/BrowserAuthError.d.ts +36 -4
  64. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  65. package/dist/error/BrowserAuthError.js +51 -11
  66. package/dist/error/BrowserAuthError.js.map +1 -1
  67. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  68. package/dist/event/EventHandler.d.ts +13 -0
  69. package/dist/event/EventHandler.d.ts.map +1 -1
  70. package/dist/event/EventHandler.js +66 -1
  71. package/dist/event/EventHandler.js.map +1 -1
  72. package/dist/event/EventMessage.d.ts +4 -3
  73. package/dist/event/EventMessage.d.ts.map +1 -1
  74. package/dist/event/EventMessage.js +24 -5
  75. package/dist/event/EventMessage.js.map +1 -1
  76. package/dist/event/EventType.d.ts +5 -0
  77. package/dist/event/EventType.d.ts.map +1 -1
  78. package/dist/event/EventType.js +6 -1
  79. package/dist/event/EventType.js.map +1 -1
  80. package/dist/index.cjs.js +4678 -2996
  81. package/dist/index.cjs.js.map +1 -1
  82. package/dist/index.d.ts +6 -2
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +4 -2
  85. package/dist/index.js.map +1 -1
  86. package/dist/interaction_client/BaseInteractionClient.d.ts +42 -0
  87. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -0
  88. package/dist/interaction_client/BaseInteractionClient.js +131 -0
  89. package/dist/interaction_client/BaseInteractionClient.js.map +1 -0
  90. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +5 -0
  91. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts.map +1 -0
  92. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +21 -0
  93. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -0
  94. package/dist/interaction_client/PopupClient.d.ts +37 -0
  95. package/dist/interaction_client/PopupClient.d.ts.map +1 -0
  96. package/dist/interaction_client/PopupClient.js +234 -0
  97. package/dist/interaction_client/PopupClient.js.map +1 -0
  98. package/dist/interaction_client/RedirectClient.d.ts +42 -0
  99. package/dist/interaction_client/RedirectClient.d.ts.map +1 -0
  100. package/dist/interaction_client/RedirectClient.js +301 -0
  101. package/dist/interaction_client/RedirectClient.js.map +1 -0
  102. package/dist/interaction_client/SilentAuthCodeClient.d.ts +22 -0
  103. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -0
  104. package/dist/interaction_client/SilentAuthCodeClient.js +80 -0
  105. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -0
  106. package/dist/interaction_client/SilentCacheClient.d.ts +22 -0
  107. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -0
  108. package/dist/interaction_client/SilentCacheClient.js +85 -0
  109. package/dist/interaction_client/SilentCacheClient.js.map +1 -0
  110. package/dist/interaction_client/SilentIframeClient.d.ts +29 -0
  111. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -0
  112. package/dist/interaction_client/SilentIframeClient.js +107 -0
  113. package/dist/interaction_client/SilentIframeClient.js.map +1 -0
  114. package/dist/interaction_client/SilentRefreshClient.d.ts +20 -0
  115. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -0
  116. package/dist/interaction_client/SilentRefreshClient.js +76 -0
  117. package/dist/interaction_client/SilentRefreshClient.js.map +1 -0
  118. package/dist/interaction_client/StandardInteractionClient.d.ts +66 -0
  119. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -0
  120. package/dist/interaction_client/StandardInteractionClient.js +249 -0
  121. package/dist/interaction_client/StandardInteractionClient.js.map +1 -0
  122. package/dist/interaction_handler/InteractionHandler.d.ts +11 -2
  123. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  124. package/dist/interaction_handler/InteractionHandler.js +36 -10
  125. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  126. package/dist/interaction_handler/PopupHandler.d.ts +2 -0
  127. package/dist/interaction_handler/PopupHandler.d.ts.map +1 -1
  128. package/dist/interaction_handler/PopupHandler.js +3 -4
  129. package/dist/interaction_handler/PopupHandler.js.map +1 -1
  130. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  131. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  132. package/dist/interaction_handler/RedirectHandler.js +7 -6
  133. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  134. package/dist/interaction_handler/SilentHandler.js +1 -1
  135. package/dist/navigation/NavigationClient.js +1 -1
  136. package/dist/network/FetchClient.js +1 -1
  137. package/dist/network/XhrClient.js +1 -1
  138. package/dist/packageMetadata.d.ts +1 -1
  139. package/dist/packageMetadata.js +2 -2
  140. package/dist/packageMetadata.js.map +1 -1
  141. package/dist/request/AuthorizationCodeRequest.d.ts +8 -0
  142. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -0
  143. package/dist/request/EndSessionPopupRequest.d.ts +3 -0
  144. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  145. package/dist/request/PopupRequest.d.ts +3 -0
  146. package/dist/request/PopupRequest.d.ts.map +1 -1
  147. package/dist/request/RedirectRequest.d.ts.map +1 -1
  148. package/dist/utils/BrowserConstants.d.ts +13 -1
  149. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  150. package/dist/utils/BrowserConstants.js +17 -3
  151. package/dist/utils/BrowserConstants.js.map +1 -1
  152. package/dist/utils/BrowserProtocolUtils.js +1 -1
  153. package/dist/utils/BrowserStringUtils.js +1 -1
  154. package/dist/utils/BrowserUtils.js +1 -1
  155. package/dist/utils/MathUtils.js +1 -1
  156. package/dist/utils/PopupUtils.d.ts +26 -2
  157. package/dist/utils/PopupUtils.d.ts.map +1 -1
  158. package/dist/utils/PopupUtils.js +42 -15
  159. package/dist/utils/PopupUtils.js.map +1 -1
  160. package/lib/msal-browser.js +4678 -2996
  161. package/lib/msal-browser.js.map +1 -1
  162. package/lib/msal-browser.min.js +32 -32
  163. package/package.json +9 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentCacheClient.js","sources":["../../src/interaction_client/SilentCacheClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo } from \"@azure/msal-common\";\nimport { SilentRequest } from \"../request/SilentRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\nimport { BrowserAuthError, BrowserAuthErrorMessage } from \"../error/BrowserAuthError\";\n\nexport class SilentCacheClient extends StandardInteractionClient {\n /**\n * Returns unexpired tokens from the cache, if available\n * @param silentRequest \n */\n async acquireToken(silentRequest: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Telemetry manager only used to increment cacheHits here\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\n const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Silent auth client created\");\n \n try {\n const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, cachedToken);\n return cachedToken;\n } catch (error) {\n if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {\n this.logger.verbose(\"Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.\");\n }\n throw error;\n }\n }\n \n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Creates an Silent Flow Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createSilentFlowClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<SilentFlowClient> {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\n return new SilentFlowClient(clientConfig);\n }\n\n initializeSilentRequest(request: SilentRequest, account: AccountInfo): CommonSilentFlowRequest {\n return {\n ...request,\n ...this.initializeBaseRequest(request),\n account: account,\n forceRefresh: request.forceRefresh || false\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAYuC,qCAAyB;IAAhE;;KAkDC;;;;;IA7CS,wCAAY,GAAlB,UAAmB,aAAsC;;;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AK,IAC7C;KACL;IACL,wBAAC;AAAD,CAlDA,CAAuC,yBAAyB;;;;"}
@@ -0,0 +1,29 @@
1
+ import { AuthenticationResult, ICrypto, Logger } from "@azure/msal-common";
2
+ import { StandardInteractionClient } from "./StandardInteractionClient";
3
+ import { BrowserConfiguration } from "../config/Configuration";
4
+ import { BrowserCacheManager } from "../cache/BrowserCacheManager";
5
+ import { EventHandler } from "../event/EventHandler";
6
+ import { INavigationClient } from "../navigation/INavigationClient";
7
+ import { ApiId } from "../utils/BrowserConstants";
8
+ import { SsoSilentRequest } from "../request/SsoSilentRequest";
9
+ export declare class SilentIframeClient extends StandardInteractionClient {
10
+ private apiId;
11
+ constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, correlationId?: string);
12
+ /**
13
+ * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none
14
+ * @param request
15
+ */
16
+ acquireToken(request: SsoSilentRequest): Promise<AuthenticationResult>;
17
+ /**
18
+ * Currently Unsupported
19
+ */
20
+ logout(): Promise<void>;
21
+ /**
22
+ * Helper which acquires an authorization code silently using a hidden iframe from given url
23
+ * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.
24
+ * @param navigateUrl
25
+ * @param userRequestScopes
26
+ */
27
+ private silentTokenHelper;
28
+ }
29
+ //# sourceMappingURL=SilentIframeClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentIframeClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/SilentIframeClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAgG,MAAM,oBAAoB,CAAC;AACzK,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAmB,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,qBAAa,kBAAmB,SAAQ,yBAAyB;IAC7D,OAAO,CAAC,KAAK,CAAQ;gBAET,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,MAAM;IAKzN;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0C5E;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB;;;;;OAKG;YACW,iBAAiB;CAYlC"}
@@ -0,0 +1,107 @@
1
+ /*! @azure/msal-browser v2.20.0 2021-12-07 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
+ import { AuthError, StringUtils, PromptValue } from '@azure/msal-common';
5
+ import { StandardInteractionClient } from './StandardInteractionClient.js';
6
+ import { BrowserAuthError } from '../error/BrowserAuthError.js';
7
+ import { InteractionType } from '../utils/BrowserConstants.js';
8
+ import { SilentHandler } from '../interaction_handler/SilentHandler.js';
9
+
10
+ /*
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License.
13
+ */
14
+ var SilentIframeClient = /** @class */ (function (_super) {
15
+ __extends(SilentIframeClient, _super);
16
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
17
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
18
+ _this.apiId = apiId;
19
+ return _this;
20
+ }
21
+ /**
22
+ * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none
23
+ * @param request
24
+ */
25
+ SilentIframeClient.prototype.acquireToken = function (request) {
26
+ return __awaiter(this, void 0, void 0, function () {
27
+ var silentRequest, serverTelemetryManager, authCodeRequest, authClient, navigateUrl, e_1;
28
+ return __generator(this, function (_a) {
29
+ switch (_a.label) {
30
+ case 0:
31
+ this.logger.verbose("acquireTokenByIframe called");
32
+ // Check that we have some SSO data
33
+ if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
34
+ this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
35
+ }
36
+ // Check that prompt is set to none, throw error if it is set to anything else.
37
+ if (request.prompt && request.prompt !== PromptValue.NONE) {
38
+ throw BrowserAuthError.createSilentPromptValueError(request.prompt);
39
+ }
40
+ silentRequest = this.initializeAuthorizationRequest(__assign(__assign({}, request), { prompt: PromptValue.NONE }), InteractionType.Silent);
41
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
42
+ _a.label = 1;
43
+ case 1:
44
+ _a.trys.push([1, 6, , 7]);
45
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
46
+ case 2:
47
+ authCodeRequest = _a.sent();
48
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority)];
49
+ case 3:
50
+ authClient = _a.sent();
51
+ this.logger.verbose("Auth code client created");
52
+ return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];
53
+ case 4:
54
+ navigateUrl = _a.sent();
55
+ return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)];
56
+ case 5: return [2 /*return*/, _a.sent()];
57
+ case 6:
58
+ e_1 = _a.sent();
59
+ if (e_1 instanceof AuthError) {
60
+ e_1.setCorrelationId(this.correlationId);
61
+ }
62
+ serverTelemetryManager.cacheFailedRequest(e_1);
63
+ this.browserStorage.cleanRequestByState(silentRequest.state);
64
+ throw e_1;
65
+ case 7: return [2 /*return*/];
66
+ }
67
+ });
68
+ });
69
+ };
70
+ /**
71
+ * Currently Unsupported
72
+ */
73
+ SilentIframeClient.prototype.logout = function () {
74
+ // Synchronous so we must reject
75
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
76
+ };
77
+ /**
78
+ * Helper which acquires an authorization code silently using a hidden iframe from given url
79
+ * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.
80
+ * @param navigateUrl
81
+ * @param userRequestScopes
82
+ */
83
+ SilentIframeClient.prototype.silentTokenHelper = function (navigateUrl, authCodeRequest, authClient, browserRequestLogger) {
84
+ return __awaiter(this, void 0, void 0, function () {
85
+ var silentHandler, msalFrame, hash, state;
86
+ return __generator(this, function (_a) {
87
+ switch (_a.label) {
88
+ case 0:
89
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, browserRequestLogger, this.config.system.navigateFrameWait);
90
+ return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
91
+ case 1:
92
+ msalFrame = _a.sent();
93
+ return [4 /*yield*/, silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout)];
94
+ case 2:
95
+ hash = _a.sent();
96
+ state = this.validateAndExtractStateFromHash(hash, InteractionType.Silent, authCodeRequest.correlationId);
97
+ // Handle response from hash string
98
+ return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ return SilentIframeClient;
104
+ }(StandardInteractionClient));
105
+
106
+ export { SilentIframeClient };
107
+ //# sourceMappingURL=SilentIframeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentIframeClient.js","sources":["../../src/interaction_client/SilentIframeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, ICrypto, Logger, StringUtils, PromptValue, CommonAuthorizationCodeRequest, AuthorizationCodeClient, AuthError } from \"@azure/msal-common\";\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\nimport { SilentHandler } from \"../interaction_handler/SilentHandler\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\n\nexport class SilentIframeClient extends StandardInteractionClient {\n private apiId: ApiId;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, correlationId?: string) {\n super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId);\n this.apiId = apiId;\n }\n \n /**\n * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none\n * @param request \n */\n async acquireToken(request: SsoSilentRequest): Promise<AuthenticationResult> {\n this.logger.verbose(\"acquireTokenByIframe called\");\n // Check that we have some SSO data\n if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {\n this.logger.warning(\"No user hint provided. The authorization server may need more information to complete this request.\");\n }\n\n // Check that prompt is set to none, throw error if it is set to anything else.\n if (request.prompt && request.prompt !== PromptValue.NONE) {\n throw BrowserAuthError.createSilentPromptValueError(request.prompt);\n }\n\n // Create silent request\n const silentRequest: AuthorizationUrlRequest = this.initializeAuthorizationRequest({\n ...request,\n prompt: PromptValue.NONE\n }, InteractionType.Silent);\n\n const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);\n\n try {\n // Create auth code request and generate PKCE params\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(silentRequest);\n\n // Initialize the client\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create authorize request url\n const navigateUrl = await authClient.getAuthCodeUrl(silentRequest);\n\n return await this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger);\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByState(silentRequest.state);\n throw e;\n }\n }\n\n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Helper which acquires an authorization code silently using a hidden iframe from given url\n * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.\n * @param navigateUrl\n * @param userRequestScopes\n */\n private async silentTokenHelper(navigateUrl: string, authCodeRequest: CommonAuthorizationCodeRequest, authClient: AuthorizationCodeClient, browserRequestLogger: Logger): Promise<AuthenticationResult> {\n // Create silent handler\n const silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, browserRequestLogger, this.config.system.navigateFrameWait);\n // Get the frame handle for the silent request\n const msalFrame = await silentHandler.initiateAuthRequest(navigateUrl);\n // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.\n const hash = await silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout);\n const state = this.validateAndExtractStateFromHash(hash, InteractionType.Silent, authCodeRequest.correlationId);\n\n // Handle response from hash string\n return silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAiBwC,sCAAyB;IAG7D,4BAAY,MAA4B,EAAE,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M,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;;wBAGhH,sBAAO,aAAa,CAAC,0BAA0B,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,EAAC;;;;KAC1G;IACL,yBAAC;AAAD,CAhFA,CAAwC,yBAAyB;;;;"}
@@ -0,0 +1,20 @@
1
+ import { StandardInteractionClient } from "./StandardInteractionClient";
2
+ import { CommonSilentFlowRequest, AuthenticationResult, ServerTelemetryManager, RefreshTokenClient } from "@azure/msal-common";
3
+ export declare class SilentRefreshClient extends StandardInteractionClient {
4
+ /**
5
+ * Exchanges the refresh token for new tokens
6
+ * @param request
7
+ */
8
+ acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult>;
9
+ /**
10
+ * Currently Unsupported
11
+ */
12
+ logout(): Promise<void>;
13
+ /**
14
+ * Creates a Refresh Client with the given authority, or the default authority.
15
+ * @param serverTelemetryManager
16
+ * @param authorityUrl
17
+ */
18
+ protected createRefreshTokenClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<RefreshTokenClient>;
19
+ }
20
+ //# sourceMappingURL=SilentRefreshClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentRefreshClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/SilentRefreshClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB,EAAa,MAAM,oBAAoB,CAAC;AAI1I,qBAAa,mBAAoB,SAAQ,yBAAyB;IAC9D;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBnF;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB;;;;OAIG;cACa,wBAAwB,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAK/I"}
@@ -0,0 +1,76 @@
1
+ /*! @azure/msal-browser v2.20.0 2021-12-07 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
+ import { StandardInteractionClient } from './StandardInteractionClient.js';
5
+ import { AuthError, RefreshTokenClient } from '@azure/msal-common';
6
+ import { ApiId } from '../utils/BrowserConstants.js';
7
+ import { BrowserAuthError } from '../error/BrowserAuthError.js';
8
+
9
+ /*
10
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11
+ * Licensed under the MIT License.
12
+ */
13
+ var SilentRefreshClient = /** @class */ (function (_super) {
14
+ __extends(SilentRefreshClient, _super);
15
+ function SilentRefreshClient() {
16
+ return _super !== null && _super.apply(this, arguments) || this;
17
+ }
18
+ /**
19
+ * Exchanges the refresh token for new tokens
20
+ * @param request
21
+ */
22
+ SilentRefreshClient.prototype.acquireToken = function (request) {
23
+ return __awaiter(this, void 0, void 0, function () {
24
+ var silentRequest, serverTelemetryManager, refreshTokenClient;
25
+ var _this = this;
26
+ return __generator(this, function (_a) {
27
+ switch (_a.label) {
28
+ case 0:
29
+ silentRequest = __assign(__assign({}, request), this.initializeBaseRequest(request));
30
+ serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
31
+ return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority)];
32
+ case 1:
33
+ refreshTokenClient = _a.sent();
34
+ this.logger.verbose("Refresh token client created");
35
+ // Send request to renew token. Auth module will throw errors if token cannot be renewed.
36
+ return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(function (e) {
37
+ if (e instanceof AuthError) {
38
+ e.setCorrelationId(_this.correlationId);
39
+ }
40
+ serverTelemetryManager.cacheFailedRequest(e);
41
+ throw e;
42
+ })];
43
+ }
44
+ });
45
+ });
46
+ };
47
+ /**
48
+ * Currently Unsupported
49
+ */
50
+ SilentRefreshClient.prototype.logout = function () {
51
+ // Synchronous so we must reject
52
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
53
+ };
54
+ /**
55
+ * Creates a Refresh Client with the given authority, or the default authority.
56
+ * @param serverTelemetryManager
57
+ * @param authorityUrl
58
+ */
59
+ SilentRefreshClient.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var clientConfig;
62
+ return __generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
65
+ case 1:
66
+ clientConfig = _a.sent();
67
+ return [2 /*return*/, new RefreshTokenClient(clientConfig)];
68
+ }
69
+ });
70
+ });
71
+ };
72
+ return SilentRefreshClient;
73
+ }(StandardInteractionClient));
74
+
75
+ export { SilentRefreshClient };
76
+ //# sourceMappingURL=SilentRefreshClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentRefreshClient.js","sources":["../../src/interaction_client/SilentRefreshClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { CommonSilentFlowRequest, AuthenticationResult, ServerTelemetryManager, RefreshTokenClient, AuthError } from \"@azure/msal-common\";\nimport { ApiId } from \"../utils/BrowserConstants\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\n\nexport class SilentRefreshClient extends StandardInteractionClient {\n /**\n * Exchanges the refresh token for new tokens\n * @param request \n */\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n const silentRequest: CommonSilentFlowRequest = {\n ...request,\n ...this.initializeBaseRequest(request)\n };\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\n const refreshTokenClient = await this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Refresh token client created\");\n \n // Send request to renew token. Auth module will throw errors if token cannot be renewed.\n return refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(e => {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n throw e;\n });\n }\n\n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Creates a Refresh Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createRefreshTokenClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<RefreshTokenClient> {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\n return new RefreshTokenClient(clientConfig);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAUyC,uCAAyB;IAAlE;;KA0CC;;;;;IArCS,0CAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBACzC,aAAa,yBACZ,OAAO,GACP,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CACzC,CAAC;wBACI,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;wBAC/E,qBAAM,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAzG,kBAAkB,GAAG,SAAoF;wBAC/G,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;;wBAGpD,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC;gCACvE,IAAI,CAAC,YAAY,SAAS,EAAE;oCACxB,CAAC,CAAC,gBAAgB,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;iCAC1C;gCACD,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;gCAC7C,MAAM,CAAC,CAAC;6BACX,CAAC,EAAC;;;;KACN;;;;IAKD,oCAAM,GAAN;;QAEI,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kCAAkC,EAAE,CAAC,CAAC;KAChF;;;;;;IAOe,sDAAwB,GAAxC,UAAyC,sBAA8C,EAAE,YAAqB;;;;;4BAErF,qBAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,YAAY,CAAC,EAAA;;wBAAtF,YAAY,GAAG,SAAuE;wBAC5F,sBAAO,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAC;;;;KAC/C;IACL,0BAAC;AAAD,CA1CA,CAAyC,yBAAyB;;;;"}
@@ -0,0 +1,66 @@
1
+ import { ICrypto, Logger, ServerTelemetryManager, CommonAuthorizationCodeRequest, AuthorizationCodeClient, ClientConfiguration, Authority, CommonEndSessionRequest } from "@azure/msal-common";
2
+ import { BaseInteractionClient } from "./BaseInteractionClient";
3
+ import { BrowserConfiguration } from "../config/Configuration";
4
+ import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
5
+ import { BrowserCacheManager } from "../cache/BrowserCacheManager";
6
+ import { EventHandler } from "../event/EventHandler";
7
+ import { InteractionType } from "../utils/BrowserConstants";
8
+ import { EndSessionRequest } from "../request/EndSessionRequest";
9
+ import { INavigationClient } from "../navigation/INavigationClient";
10
+ import { RedirectRequest } from "../request/RedirectRequest";
11
+ import { PopupRequest } from "../request/PopupRequest";
12
+ import { SsoSilentRequest } from "../request/SsoSilentRequest";
13
+ /**
14
+ * Defines the class structure and helper functions used by the "standard", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))
15
+ */
16
+ export declare abstract class StandardInteractionClient extends BaseInteractionClient {
17
+ protected navigationClient: INavigationClient;
18
+ constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, correlationId?: string);
19
+ /**
20
+ * Generates an auth code request tied to the url request.
21
+ * @param request
22
+ */
23
+ protected initializeAuthorizationCodeRequest(request: AuthorizationUrlRequest): Promise<CommonAuthorizationCodeRequest>;
24
+ /**
25
+ * Initializer for the logout request.
26
+ * @param logoutRequest
27
+ */
28
+ protected initializeLogoutRequest(logoutRequest?: EndSessionRequest): CommonEndSessionRequest;
29
+ /**
30
+ * Creates an Authorization Code Client with the given authority, or the default authority.
31
+ * @param serverTelemetryManager
32
+ * @param authorityUrl
33
+ */
34
+ protected createAuthCodeClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<AuthorizationCodeClient>;
35
+ /**
36
+ * Creates a Client Configuration object with the given request authority, or the default authority.
37
+ * @param serverTelemetryManager
38
+ * @param requestAuthority
39
+ * @param requestCorrelationId
40
+ */
41
+ protected getClientConfiguration(serverTelemetryManager: ServerTelemetryManager, requestAuthority?: string): Promise<ClientConfiguration>;
42
+ /**
43
+ * @param hash
44
+ * @param interactionType
45
+ */
46
+ protected validateAndExtractStateFromHash(hash: string, interactionType: InteractionType, requestCorrelationId?: string): string;
47
+ /**
48
+ * Used to get a discovered version of the default authority.
49
+ * @param requestAuthority
50
+ * @param requestCorrelationId
51
+ */
52
+ protected getDiscoveredAuthority(requestAuthority?: string): Promise<Authority>;
53
+ /**
54
+ * Helper to validate app environment before making a request.
55
+ * @param request
56
+ * @param interactionType
57
+ */
58
+ protected preflightInteractiveRequest(request: RedirectRequest | PopupRequest, interactionType: InteractionType): AuthorizationUrlRequest;
59
+ /**
60
+ * Helper to initialize required request parameters for interactive APIs and ssoSilent()
61
+ * @param request
62
+ * @param interactionType
63
+ */
64
+ protected initializeAuthorizationRequest(request: RedirectRequest | PopupRequest | SsoSilentRequest, interactionType: InteractionType): AuthorizationUrlRequest;
65
+ }
66
+ //# sourceMappingURL=StandardInteractionClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StandardInteractionClient.d.ts","sourceRoot":"","sources":["../../src/inter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7F;;;;OAIG;cACa,oBAAoB,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAM7I;;;;;OAKG;cACa,sBAAsB,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiC/I;;;OAGG;IACH,SAAS,CAAC,+BAA+B,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM;IAqBhI;;;;OAIG;cACa,sBAAsB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAkBrF;;;;OAIG;IACH,SAAS,CAAC,2BAA2B,CAAC,OAAO,EAAE,eAAe,GAAC,YAAY,EAAE,eAAe,EAAE,eAAe,GAAG,uBAAuB;IAavI;;;;OAIG;IACH,SAAS,CAAC,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAC,YAAY,GAAC,gBAAgB,EAAE,eAAe,EAAE,eAAe,GAAG,uBAAuB;CAwC9J"}
@@ -0,0 +1,249 @@
1
+ /*! @azure/msal-browser v2.20.0 2021-12-07 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
+ import { Constants, UrlString, AuthorizationCodeClient, AuthorityFactory, ProtocolUtils, ResponseMode, StringUtils } from '@azure/msal-common';
5
+ import { BaseInteractionClient } from './BaseInteractionClient.js';
6
+ import { BrowserConstants } from '../utils/BrowserConstants.js';
7
+ import { version } from '../packageMetadata.js';
8
+ import { BrowserAuthError } from '../error/BrowserAuthError.js';
9
+ import { BrowserProtocolUtils } from '../utils/BrowserProtocolUtils.js';
10
+ import { BrowserUtils } from '../utils/BrowserUtils.js';
11
+
12
+ /*
13
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14
+ * Licensed under the MIT License.
15
+ */
16
+ /**
17
+ * Defines the class structure and helper functions used by the "standard", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))
18
+ */
19
+ var StandardInteractionClient = /** @class */ (function (_super) {
20
+ __extends(StandardInteractionClient, _super);
21
+ function StandardInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) {
22
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, correlationId) || this;
23
+ _this.navigationClient = navigationClient;
24
+ return _this;
25
+ }
26
+ /**
27
+ * Generates an auth code request tied to the url request.
28
+ * @param request
29
+ */
30
+ StandardInteractionClient.prototype.initializeAuthorizationCodeRequest = function (request) {
31
+ return __awaiter(this, void 0, void 0, function () {
32
+ var generatedPkceParams, authCodeRequest;
33
+ return __generator(this, function (_a) {
34
+ switch (_a.label) {
35
+ case 0:
36
+ this.logger.verbose("initializeAuthorizationRequest called", request.correlationId);
37
+ return [4 /*yield*/, this.browserCrypto.generatePkceCodes()];
38
+ case 1:
39
+ generatedPkceParams = _a.sent();
40
+ authCodeRequest = __assign(__assign({}, request), { redirectUri: request.redirectUri, code: "", codeVerifier: generatedPkceParams.verifier });
41
+ request.codeChallenge = generatedPkceParams.challenge;
42
+ request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;
43
+ return [2 /*return*/, authCodeRequest];
44
+ }
45
+ });
46
+ });
47
+ };
48
+ /**
49
+ * Initializer for the logout request.
50
+ * @param logoutRequest
51
+ */
52
+ StandardInteractionClient.prototype.initializeLogoutRequest = function (logoutRequest) {
53
+ this.logger.verbose("initializeLogoutRequest called", logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
54
+ // Check if interaction is in progress. Throw error if true.
55
+ if (this.browserStorage.isInteractionInProgress()) {
56
+ throw BrowserAuthError.createInteractionInProgressError();
57
+ }
58
+ var validLogoutRequest = __assign({ correlationId: this.browserCrypto.createNewGuid() }, logoutRequest);
59
+ /*
60
+ * Only set redirect uri if logout request isn't provided or the set uri isn't null.
61
+ * Otherwise, use passed uri, config, or current page.
62
+ */
63
+ if (!logoutRequest || logoutRequest.postLogoutRedirectUri !== null) {
64
+ if (logoutRequest && logoutRequest.postLogoutRedirectUri) {
65
+ this.logger.verbose("Setting postLogoutRedirectUri to uri set on logout request", validLogoutRequest.correlationId);
66
+ validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(logoutRequest.postLogoutRedirectUri, BrowserUtils.getCurrentUri());
67
+ }
68
+ else if (this.config.auth.postLogoutRedirectUri === null) {
69
+ this.logger.verbose("postLogoutRedirectUri configured as null and no uri set on request, not passing post logout redirect", validLogoutRequest.correlationId);
70
+ }
71
+ else if (this.config.auth.postLogoutRedirectUri) {
72
+ this.logger.verbose("Setting postLogoutRedirectUri to configured uri", validLogoutRequest.correlationId);
73
+ validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(this.config.auth.postLogoutRedirectUri, BrowserUtils.getCurrentUri());
74
+ }
75
+ else {
76
+ this.logger.verbose("Setting postLogoutRedirectUri to current page", validLogoutRequest.correlationId);
77
+ validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(BrowserUtils.getCurrentUri(), BrowserUtils.getCurrentUri());
78
+ }
79
+ }
80
+ else {
81
+ this.logger.verbose("postLogoutRedirectUri passed as null, not setting post logout redirect uri", validLogoutRequest.correlationId);
82
+ }
83
+ return validLogoutRequest;
84
+ };
85
+ /**
86
+ * Creates an Authorization Code Client with the given authority, or the default authority.
87
+ * @param serverTelemetryManager
88
+ * @param authorityUrl
89
+ */
90
+ StandardInteractionClient.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var clientConfig;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
96
+ case 1:
97
+ clientConfig = _a.sent();
98
+ return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ /**
104
+ * Creates a Client Configuration object with the given request authority, or the default authority.
105
+ * @param serverTelemetryManager
106
+ * @param requestAuthority
107
+ * @param requestCorrelationId
108
+ */
109
+ StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var discoveredAuthority;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0:
115
+ this.logger.verbose("getClientConfiguration called");
116
+ return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority)];
117
+ case 1:
118
+ discoveredAuthority = _a.sent();
119
+ return [2 /*return*/, {
120
+ authOptions: {
121
+ clientId: this.config.auth.clientId,
122
+ authority: discoveredAuthority,
123
+ clientCapabilities: this.config.auth.clientCapabilities
124
+ },
125
+ systemOptions: {
126
+ tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds,
127
+ preventCorsPreflight: true
128
+ },
129
+ loggerOptions: {
130
+ loggerCallback: this.config.system.loggerOptions.loggerCallback,
131
+ piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,
132
+ logLevel: this.config.system.loggerOptions.logLevel,
133
+ correlationId: this.correlationId
134
+ },
135
+ cryptoInterface: this.browserCrypto,
136
+ networkInterface: this.networkClient,
137
+ storageInterface: this.browserStorage,
138
+ serverTelemetryManager: serverTelemetryManager,
139
+ libraryInfo: {
140
+ sku: BrowserConstants.MSAL_SKU,
141
+ version: version,
142
+ cpu: "",
143
+ os: ""
144
+ }
145
+ }];
146
+ }
147
+ });
148
+ });
149
+ };
150
+ /**
151
+ * @param hash
152
+ * @param interactionType
153
+ */
154
+ StandardInteractionClient.prototype.validateAndExtractStateFromHash = function (hash, interactionType, requestCorrelationId) {
155
+ this.logger.verbose("validateAndExtractStateFromHash called", requestCorrelationId);
156
+ // Deserialize hash fragment response parameters.
157
+ var serverParams = UrlString.getDeserializedHash(hash);
158
+ if (!serverParams.state) {
159
+ throw BrowserAuthError.createHashDoesNotContainStateError();
160
+ }
161
+ var platformStateObj = BrowserProtocolUtils.extractBrowserRequestState(this.browserCrypto, serverParams.state);
162
+ if (!platformStateObj) {
163
+ throw BrowserAuthError.createUnableToParseStateError();
164
+ }
165
+ if (platformStateObj.interactionType !== interactionType) {
166
+ throw BrowserAuthError.createStateInteractionTypeMismatchError();
167
+ }
168
+ this.logger.verbose("Returning state from hash", requestCorrelationId);
169
+ return serverParams.state;
170
+ };
171
+ /**
172
+ * Used to get a discovered version of the default authority.
173
+ * @param requestAuthority
174
+ * @param requestCorrelationId
175
+ */
176
+ StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority) {
177
+ return __awaiter(this, void 0, void 0, function () {
178
+ var authorityOptions;
179
+ return __generator(this, function (_a) {
180
+ switch (_a.label) {
181
+ case 0:
182
+ this.logger.verbose("getDiscoveredAuthority called");
183
+ authorityOptions = {
184
+ protocolMode: this.config.auth.protocolMode,
185
+ knownAuthorities: this.config.auth.knownAuthorities,
186
+ cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
187
+ authorityMetadata: this.config.auth.authorityMetadata
188
+ };
189
+ if (!requestAuthority) return [3 /*break*/, 2];
190
+ this.logger.verbose("Creating discovered authority with request authority");
191
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
192
+ case 1: return [2 /*return*/, _a.sent()];
193
+ case 2:
194
+ this.logger.verbose("Creating discovered authority with configured authority");
195
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
196
+ case 3: return [2 /*return*/, _a.sent()];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ /**
202
+ * Helper to validate app environment before making a request.
203
+ * @param request
204
+ * @param interactionType
205
+ */
206
+ StandardInteractionClient.prototype.preflightInteractiveRequest = function (request, interactionType) {
207
+ this.logger.verbose("preflightInteractiveRequest called, validating app environment", request === null || request === void 0 ? void 0 : request.correlationId);
208
+ // block the reload if it occurred inside a hidden iframe
209
+ BrowserUtils.blockReloadInHiddenIframes();
210
+ // Check if interaction is in progress. Throw error if true.
211
+ if (this.browserStorage.isInteractionInProgress(false)) {
212
+ throw BrowserAuthError.createInteractionInProgressError();
213
+ }
214
+ return this.initializeAuthorizationRequest(request, interactionType);
215
+ };
216
+ /**
217
+ * Helper to initialize required request parameters for interactive APIs and ssoSilent()
218
+ * @param request
219
+ * @param interactionType
220
+ */
221
+ StandardInteractionClient.prototype.initializeAuthorizationRequest = function (request, interactionType) {
222
+ this.logger.verbose("initializeAuthorizationRequest called");
223
+ var redirectUri = this.getRedirectUri(request.redirectUri);
224
+ var browserState = {
225
+ interactionType: interactionType
226
+ };
227
+ var state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || "", browserState);
228
+ var validatedRequest = __assign(__assign({}, this.initializeBaseRequest(request)), { redirectUri: redirectUri, state: state, nonce: request.nonce || this.browserCrypto.createNewGuid(), responseMode: ResponseMode.FRAGMENT });
229
+ var account = request.account || this.browserStorage.getActiveAccount();
230
+ if (account) {
231
+ this.logger.verbose("Setting validated request account");
232
+ this.logger.verbosePii("Setting validated request account: " + account);
233
+ validatedRequest.account = account;
234
+ }
235
+ // Check for ADAL/MSAL v1 SSO
236
+ if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
237
+ var legacyLoginHint = this.browserStorage.getLegacyLoginHint();
238
+ if (legacyLoginHint) {
239
+ validatedRequest.loginHint = legacyLoginHint;
240
+ }
241
+ }
242
+ this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || "", validatedRequest.account || null);
243
+ return validatedRequest;
244
+ };
245
+ return StandardInteractionClient;
246
+ }(BaseInteractionClient));
247
+
248
+ export { StandardInteractionClient };
249
+ //# sourceMappingURL=StandardInteractionClient.js.map