@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,42 @@
1
+ import { AuthenticationResult } from "@azure/msal-common";
2
+ import { StandardInteractionClient } from "./StandardInteractionClient";
3
+ import { EndSessionRequest } from "../request/EndSessionRequest";
4
+ import { RedirectRequest } from "../request/RedirectRequest";
5
+ export declare class RedirectClient extends StandardInteractionClient {
6
+ /**
7
+ * Redirects the page to the /authorize endpoint of the IDP
8
+ * @param request
9
+ */
10
+ acquireToken(request: RedirectRequest): Promise<void>;
11
+ /**
12
+ * Checks if navigateToLoginRequestUrl is set, and:
13
+ * - if true, performs logic to cache and navigate
14
+ * - if false, handles hash string and parses response
15
+ * @param hash
16
+ */
17
+ handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null>;
18
+ /**
19
+ * Gets the response hash for a redirect request
20
+ * Returns null if interactionType in the state value is not "redirect" or the hash does not contain known properties
21
+ * @param hash
22
+ */
23
+ private getRedirectResponseHash;
24
+ /**
25
+ * Checks if hash exists and handles in window.
26
+ * @param hash
27
+ * @param state
28
+ */
29
+ private handleHash;
30
+ /**
31
+ * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
32
+ * Default behaviour is to redirect the user to `window.location.href`.
33
+ * @param logoutRequest
34
+ */
35
+ logout(logoutRequest?: EndSessionRequest): Promise<void>;
36
+ /**
37
+ * Use to get the redirectStartPage either from request or use current window
38
+ * @param requestStartPage
39
+ */
40
+ protected getRedirectStartPage(requestStartPage?: string): string;
41
+ }
42
+ //# sourceMappingURL=RedirectClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedirectClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/RedirectClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAyG,MAAM,oBAAoB,CAAC;AACjK,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,qBAAa,cAAe,SAAQ,yBAAyB;IACzD;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC3D;;;;;OAKG;IACG,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA6FhF;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;;OAIG;YACW,UAAU;IAgBxB;;;;OAIG;IACG,MAAM,CAAC,aAAa,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmD9D;;;OAGG;IACH,SAAS,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;CAIpE"}
@@ -0,0 +1,301 @@
1
+ /*! @azure/msal-browser v2.20.0 2021-12-07 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
+ import { AuthError, UrlString } from '@azure/msal-common';
5
+ import { StandardInteractionClient } from './StandardInteractionClient.js';
6
+ import { InteractionType, ApiId, TemporaryCacheKeys } from '../utils/BrowserConstants.js';
7
+ import { RedirectHandler } from '../interaction_handler/RedirectHandler.js';
8
+ import { BrowserUtils } from '../utils/BrowserUtils.js';
9
+ import { EventType } from '../event/EventType.js';
10
+ import { BrowserAuthError } from '../error/BrowserAuthError.js';
11
+
12
+ /*
13
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14
+ * Licensed under the MIT License.
15
+ */
16
+ var RedirectClient = /** @class */ (function (_super) {
17
+ __extends(RedirectClient, _super);
18
+ function RedirectClient() {
19
+ return _super !== null && _super.apply(this, arguments) || this;
20
+ }
21
+ /**
22
+ * Redirects the page to the /authorize endpoint of the IDP
23
+ * @param request
24
+ */
25
+ RedirectClient.prototype.acquireToken = function (request) {
26
+ return __awaiter(this, void 0, void 0, function () {
27
+ var validRequest, serverTelemetryManager, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_1;
28
+ return __generator(this, function (_a) {
29
+ switch (_a.label) {
30
+ case 0:
31
+ validRequest = this.preflightInteractiveRequest(request, InteractionType.Redirect);
32
+ serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenRedirect);
33
+ _a.label = 1;
34
+ case 1:
35
+ _a.trys.push([1, 6, , 7]);
36
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
37
+ case 2:
38
+ authCodeRequest = _a.sent();
39
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
40
+ case 3:
41
+ authClient = _a.sent();
42
+ this.logger.verbose("Auth code client created");
43
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
44
+ return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
45
+ case 4:
46
+ navigateUrl = _a.sent();
47
+ redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
48
+ this.logger.verbosePii("Redirect start page: " + redirectStartPage);
49
+ return [4 /*yield*/, interactionHandler.initiateAuthRequest(navigateUrl, {
50
+ navigationClient: this.navigationClient,
51
+ redirectTimeout: this.config.system.redirectNavigationTimeout,
52
+ redirectStartPage: redirectStartPage,
53
+ onRedirectNavigate: request.onRedirectNavigate
54
+ })];
55
+ case 5:
56
+ // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.
57
+ return [2 /*return*/, _a.sent()];
58
+ case 6:
59
+ e_1 = _a.sent();
60
+ if (e_1 instanceof AuthError) {
61
+ e_1.setCorrelationId(this.correlationId);
62
+ }
63
+ serverTelemetryManager.cacheFailedRequest(e_1);
64
+ this.browserStorage.cleanRequestByState(validRequest.state);
65
+ throw e_1;
66
+ case 7: return [2 /*return*/];
67
+ }
68
+ });
69
+ });
70
+ };
71
+ /**
72
+ * Checks if navigateToLoginRequestUrl is set, and:
73
+ * - if true, performs logic to cache and navigate
74
+ * - if false, handles hash string and parses response
75
+ * @param hash
76
+ */
77
+ RedirectClient.prototype.handleRedirectPromise = function (hash) {
78
+ return __awaiter(this, void 0, void 0, function () {
79
+ var serverTelemetryManager, responseHash, state, loginRequestUrl, loginRequestUrlNormalized, currentUrlNormalized, handleHashResult, navigationOptions, processHashOnRedirect, homepage, e_2;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0:
83
+ serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise);
84
+ _a.label = 1;
85
+ case 1:
86
+ _a.trys.push([1, 10, , 11]);
87
+ if (!this.browserStorage.isInteractionInProgress(true)) {
88
+ this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null.");
89
+ return [2 /*return*/, null];
90
+ }
91
+ responseHash = this.getRedirectResponseHash(hash || window.location.hash);
92
+ if (!responseHash) {
93
+ // Not a recognized server response hash or hash not associated with a redirect request
94
+ this.logger.info("handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache.");
95
+ this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);
96
+ return [2 /*return*/, null];
97
+ }
98
+ state = void 0;
99
+ try {
100
+ state = this.validateAndExtractStateFromHash(responseHash, InteractionType.Redirect);
101
+ BrowserUtils.clearHash(window);
102
+ this.logger.verbose("State extracted from hash");
103
+ }
104
+ catch (e) {
105
+ this.logger.info("handleRedirectPromise was unable to extract state due to: " + e);
106
+ this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);
107
+ return [2 /*return*/, null];
108
+ }
109
+ loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || "";
110
+ loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);
111
+ currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);
112
+ if (!(loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl)) return [3 /*break*/, 3];
113
+ // We are on the page we need to navigate to - handle hash
114
+ this.logger.verbose("Current page is loginRequestUrl, handling hash");
115
+ return [4 /*yield*/, this.handleHash(responseHash, state, serverTelemetryManager)];
116
+ case 2:
117
+ handleHashResult = _a.sent();
118
+ if (loginRequestUrl.indexOf("#") > -1) {
119
+ // Replace current hash with non-msal hash, if present
120
+ BrowserUtils.replaceHash(loginRequestUrl);
121
+ }
122
+ return [2 /*return*/, handleHashResult];
123
+ case 3:
124
+ if (!!this.config.auth.navigateToLoginRequestUrl) return [3 /*break*/, 4];
125
+ this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash");
126
+ return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
127
+ case 4:
128
+ if (!(!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe)) return [3 /*break*/, 9];
129
+ /*
130
+ * Returned from authority using redirect - need to perform navigation before processing response
131
+ * Cache the hash to be retrieved after the next redirect
132
+ */
133
+ this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);
134
+ navigationOptions = {
135
+ apiId: ApiId.handleRedirectPromise,
136
+ timeout: this.config.system.redirectNavigationTimeout,
137
+ noHistory: true
138
+ };
139
+ processHashOnRedirect = true;
140
+ if (!(!loginRequestUrl || loginRequestUrl === "null")) return [3 /*break*/, 6];
141
+ homepage = BrowserUtils.getHomepage();
142
+ // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage
143
+ this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);
144
+ this.logger.warning("Unable to get valid login request url from cache, redirecting to home page");
145
+ return [4 /*yield*/, this.navigationClient.navigateInternal(homepage, navigationOptions)];
146
+ case 5:
147
+ processHashOnRedirect = _a.sent();
148
+ return [3 /*break*/, 8];
149
+ case 6:
150
+ // Navigate to page that initiated the redirect request
151
+ this.logger.verbose("Navigating to loginRequestUrl: " + loginRequestUrl);
152
+ return [4 /*yield*/, this.navigationClient.navigateInternal(loginRequestUrl, navigationOptions)];
153
+ case 7:
154
+ processHashOnRedirect = _a.sent();
155
+ _a.label = 8;
156
+ case 8:
157
+ // If navigateInternal implementation returns false, handle the hash now
158
+ if (!processHashOnRedirect) {
159
+ return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
160
+ }
161
+ _a.label = 9;
162
+ case 9: return [2 /*return*/, null];
163
+ case 10:
164
+ e_2 = _a.sent();
165
+ if (e_2 instanceof AuthError) {
166
+ e_2.setCorrelationId(this.correlationId);
167
+ }
168
+ serverTelemetryManager.cacheFailedRequest(e_2);
169
+ this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);
170
+ throw e_2;
171
+ case 11: return [2 /*return*/];
172
+ }
173
+ });
174
+ });
175
+ };
176
+ /**
177
+ * Gets the response hash for a redirect request
178
+ * Returns null if interactionType in the state value is not "redirect" or the hash does not contain known properties
179
+ * @param hash
180
+ */
181
+ RedirectClient.prototype.getRedirectResponseHash = function (hash) {
182
+ this.logger.verbose("getRedirectResponseHash called");
183
+ // Get current location hash from window or cache.
184
+ var isResponseHash = UrlString.hashContainsKnownProperties(hash);
185
+ var cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);
186
+ this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));
187
+ if (isResponseHash) {
188
+ this.logger.verbose("Hash contains known properties, returning response hash");
189
+ return hash;
190
+ }
191
+ this.logger.verbose("Hash does not contain known properties, returning cached hash");
192
+ return cachedHash;
193
+ };
194
+ /**
195
+ * Checks if hash exists and handles in window.
196
+ * @param hash
197
+ * @param state
198
+ */
199
+ RedirectClient.prototype.handleHash = function (hash, state, serverTelemetryManager) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var cachedRequest, currentAuthority, authClient, interactionHandler;
202
+ return __generator(this, function (_a) {
203
+ switch (_a.label) {
204
+ case 0:
205
+ cachedRequest = this.browserStorage.getCachedRequest(state, this.browserCrypto);
206
+ this.logger.verbose("handleHash called, retrieved cached request");
207
+ currentAuthority = this.browserStorage.getCachedAuthority(state);
208
+ if (!currentAuthority) {
209
+ throw BrowserAuthError.createNoCachedAuthorityError();
210
+ }
211
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, currentAuthority)];
212
+ case 1:
213
+ authClient = _a.sent();
214
+ this.logger.verbose("Auth code client created");
215
+ interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
216
+ return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId)];
217
+ case 2: return [2 /*return*/, _a.sent()];
218
+ }
219
+ });
220
+ });
221
+ };
222
+ /**
223
+ * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
224
+ * Default behaviour is to redirect the user to `window.location.href`.
225
+ * @param logoutRequest
226
+ */
227
+ RedirectClient.prototype.logout = function (logoutRequest) {
228
+ return __awaiter(this, void 0, void 0, function () {
229
+ var validLogoutRequest, serverTelemetryManager, navigationOptions, authClient, logoutUri, navigate, e_3;
230
+ return __generator(this, function (_a) {
231
+ switch (_a.label) {
232
+ case 0:
233
+ this.logger.verbose("logoutRedirect called");
234
+ validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
235
+ serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logout);
236
+ _a.label = 1;
237
+ case 1:
238
+ _a.trys.push([1, 10, , 11]);
239
+ this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Redirect, logoutRequest);
240
+ // Clear cache on logout
241
+ return [4 /*yield*/, this.clearCacheOnLogout(validLogoutRequest.account)];
242
+ case 2:
243
+ // Clear cache on logout
244
+ _a.sent();
245
+ navigationOptions = {
246
+ apiId: ApiId.logout,
247
+ timeout: this.config.system.redirectNavigationTimeout,
248
+ noHistory: false
249
+ };
250
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority)];
251
+ case 3:
252
+ authClient = _a.sent();
253
+ this.logger.verbose("Auth code client created");
254
+ logoutUri = authClient.getLogoutUri(validLogoutRequest);
255
+ this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Redirect, validLogoutRequest);
256
+ if (!(logoutRequest && typeof logoutRequest.onRedirectNavigate === "function")) return [3 /*break*/, 7];
257
+ navigate = logoutRequest.onRedirectNavigate(logoutUri);
258
+ if (!(navigate !== false)) return [3 /*break*/, 5];
259
+ this.logger.verbose("Logout onRedirectNavigate did not return false, navigating");
260
+ return [4 /*yield*/, this.navigationClient.navigateExternal(logoutUri, navigationOptions)];
261
+ case 4:
262
+ _a.sent();
263
+ return [2 /*return*/];
264
+ case 5:
265
+ this.logger.verbose("Logout onRedirectNavigate returned false, stopping navigation");
266
+ _a.label = 6;
267
+ case 6: return [3 /*break*/, 9];
268
+ case 7: return [4 /*yield*/, this.navigationClient.navigateExternal(logoutUri, navigationOptions)];
269
+ case 8:
270
+ _a.sent();
271
+ return [2 /*return*/];
272
+ case 9: return [3 /*break*/, 11];
273
+ case 10:
274
+ e_3 = _a.sent();
275
+ if (e_3 instanceof AuthError) {
276
+ e_3.setCorrelationId(this.correlationId);
277
+ }
278
+ serverTelemetryManager.cacheFailedRequest(e_3);
279
+ this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Redirect, null, e_3);
280
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);
281
+ throw e_3;
282
+ case 11:
283
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);
284
+ return [2 /*return*/];
285
+ }
286
+ });
287
+ });
288
+ };
289
+ /**
290
+ * Use to get the redirectStartPage either from request or use current window
291
+ * @param requestStartPage
292
+ */
293
+ RedirectClient.prototype.getRedirectStartPage = function (requestStartPage) {
294
+ var redirectStartPage = requestStartPage || window.location.href;
295
+ return UrlString.getAbsoluteUrl(redirectStartPage, BrowserUtils.getCurrentUri());
296
+ };
297
+ return RedirectClient;
298
+ }(StandardInteractionClient));
299
+
300
+ export { RedirectClient };
301
+ //# sourceMappingURL=RedirectClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RedirectClient.js","sources":["../../src/interaction_client/RedirectClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, CommonAuthorizationCodeRequest, AuthorizationCodeClient, UrlString, AuthError, ServerTelemetryManager } from \"@azure/msal-common\";\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { ApiId, InteractionType, TemporaryCacheKeys } from \"../utils/BrowserConstants\";\nimport { RedirectHandler } from \"../interaction_handler/RedirectHandler\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { NavigationOptions } from \"../navigation/NavigationOptions\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\n\nexport class RedirectClient extends StandardInteractionClient { \n /**\n * Redirects the page to the /authorize endpoint of the IDP\n * @param request \n */\n async acquireToken(request: RedirectRequest): Promise<void> {\n const validRequest: AuthorizationUrlRequest = this.preflightInteractiveRequest(request, InteractionType.Redirect);\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenRedirect);\n\n try {\n // Create auth code request and generate PKCE params\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);\n\n // Initialize the client\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create redirect interaction handler.\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);\n\n // Create acquire token url.\n const navigateUrl = await authClient.getAuthCodeUrl(validRequest);\n\n const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);\n this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);\n\n // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.\n return await interactionHandler.initiateAuthRequest(navigateUrl, {\n navigationClient: this.navigationClient,\n redirectTimeout: this.config.system.redirectNavigationTimeout,\n redirectStartPage: redirectStartPage,\n onRedirectNavigate: request.onRedirectNavigate\n });\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByState(validRequest.state);\n throw e;\n }\n }\n\n /**\n * Checks if navigateToLoginRequestUrl is set, and:\n * - if true, performs logic to cache and navigate\n * - if false, handles hash string and parses response\n * @param hash\n */\n async handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null> {\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise);\n try {\n if (!this.browserStorage.isInteractionInProgress(true)) {\n this.logger.info(\"handleRedirectPromise called but there is no interaction in progress, returning null.\");\n return null;\n }\n\n const responseHash = this.getRedirectResponseHash(hash || window.location.hash);\n if (!responseHash) {\n // Not a recognized server response hash or hash not associated with a redirect request\n this.logger.info(\"handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache.\");\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n return null;\n }\n\n let state: string;\n try {\n state = this.validateAndExtractStateFromHash(responseHash, InteractionType.Redirect);\n BrowserUtils.clearHash(window);\n this.logger.verbose(\"State extracted from hash\");\n } catch (e) {\n this.logger.info(`handleRedirectPromise was unable to extract state due to: ${e}`);\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n return null;\n }\n\n // If navigateToLoginRequestUrl is true, get the url where the redirect request was initiated\n const loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || \"\";\n const loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);\n const currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);\n\n if (loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl) {\n // We are on the page we need to navigate to - handle hash\n this.logger.verbose(\"Current page is loginRequestUrl, handling hash\");\n const handleHashResult = await this.handleHash(responseHash, state, serverTelemetryManager);\n\n if (loginRequestUrl.indexOf(\"#\") > -1) {\n // Replace current hash with non-msal hash, if present\n BrowserUtils.replaceHash(loginRequestUrl);\n }\n\n return handleHashResult;\n } else if (!this.config.auth.navigateToLoginRequestUrl) {\n this.logger.verbose(\"NavigateToLoginRequestUrl set to false, handling hash\");\n return this.handleHash(responseHash, state, serverTelemetryManager);\n } else if (!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe) {\n /*\n * Returned from authority using redirect - need to perform navigation before processing response\n * Cache the hash to be retrieved after the next redirect\n */\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);\n const navigationOptions: NavigationOptions = {\n apiId: ApiId.handleRedirectPromise,\n timeout: this.config.system.redirectNavigationTimeout,\n noHistory: true\n };\n\n /**\n * Default behavior is to redirect to the start page and not process the hash now. \n * The start page is expected to also call handleRedirectPromise which will process the hash in one of the checks above.\n */ \n let processHashOnRedirect: boolean = true;\n if (!loginRequestUrl || loginRequestUrl === \"null\") {\n // Redirect to home page if login request url is null (real null or the string null)\n const homepage = BrowserUtils.getHomepage();\n // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);\n this.logger.warning(\"Unable to get valid login request url from cache, redirecting to home page\");\n processHashOnRedirect = await this.navigationClient.navigateInternal(homepage, navigationOptions);\n } else {\n // Navigate to page that initiated the redirect request\n this.logger.verbose(`Navigating to loginRequestUrl: ${loginRequestUrl}`);\n processHashOnRedirect = await this.navigationClient.navigateInternal(loginRequestUrl, navigationOptions);\n }\n\n // If navigateInternal implementation returns false, handle the hash now\n if (!processHashOnRedirect) {\n return this.handleHash(responseHash, state, serverTelemetryManager);\n }\n }\n\n return null;\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n throw e;\n }\n }\n\n /**\n * Gets the response hash for a redirect request\n * Returns null if interactionType in the state value is not \"redirect\" or the hash does not contain known properties\n * @param hash\n */\n private getRedirectResponseHash(hash: string): string | null {\n this.logger.verbose(\"getRedirectResponseHash called\");\n // Get current location hash from window or cache.\n const isResponseHash: boolean = UrlString.hashContainsKnownProperties(hash);\n const cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));\n\n if (isResponseHash) {\n this.logger.verbose(\"Hash contains known properties, returning response hash\");\n return hash;\n }\n\n this.logger.verbose(\"Hash does not contain known properties, returning cached hash\");\n return cachedHash;\n }\n\n /**\n * Checks if hash exists and handles in window.\n * @param hash\n * @param state\n */\n private async handleHash(hash: string, state: string, serverTelemetryManager: ServerTelemetryManager): Promise<AuthenticationResult> {\n const cachedRequest = this.browserStorage.getCachedRequest(state, this.browserCrypto);\n this.logger.verbose(\"handleHash called, retrieved cached request\");\n\n // Hash contains known properties - handle and return in callback\n const currentAuthority = this.browserStorage.getCachedAuthority(state);\n if (!currentAuthority) {\n throw BrowserAuthError.createNoCachedAuthorityError();\n }\n\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, currentAuthority);\n this.logger.verbose(\"Auth code client created\");\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);\n return await interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId);\n }\n\n /**\n * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.\n * Default behaviour is to redirect the user to `window.location.href`.\n * @param logoutRequest\n */\n async logout(logoutRequest?: EndSessionRequest): Promise<void> {\n this.logger.verbose(\"logoutRedirect called\");\n const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logout);\n\n try {\n this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Redirect, logoutRequest);\n \n // Clear cache on logout\n await this.clearCacheOnLogout(validLogoutRequest.account);\n \n const navigationOptions: NavigationOptions = {\n apiId: ApiId.logout,\n timeout: this.config.system.redirectNavigationTimeout,\n noHistory: false\n };\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create logout string and navigate user window to logout.\n const logoutUri: string = authClient.getLogoutUri(validLogoutRequest);\n \n this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Redirect, validLogoutRequest);\n // Check if onRedirectNavigate is implemented, and invoke it if so\n if (logoutRequest && typeof logoutRequest.onRedirectNavigate === \"function\") {\n const navigate = logoutRequest.onRedirectNavigate(logoutUri);\n\n if (navigate !== false) {\n this.logger.verbose(\"Logout onRedirectNavigate did not return false, navigating\");\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\n return;\n } else {\n this.logger.verbose(\"Logout onRedirectNavigate returned false, stopping navigation\");\n }\n } else {\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\n return;\n }\n } catch(e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Redirect, null, e);\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\n throw e;\n }\n\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\n }\n\n /**\n * Use to get the redirectStartPage either from request or use current window\n * @param requestStartPage\n */\n protected getRedirectStartPage(requestStartPage?: string): string {\n const redirectStartPage = requestStartPage || window.location.href;\n return UrlString.getAbsoluteUrl(redirectStartPage, BrowserUtils.getCurrentUri());\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;IAiBoC,kCAAyB;IAA7D;;KAwPC;;;;;IAnPS,qCAAY,GAAlB,UAAmB,OAAwB;;;;;;wBACjC,YAAY,GAA4B,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;wBAC5G,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;;;;wBAIrC,qBAAM,IAAI,CAAC,kCAAkC,C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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 { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
9
+ export declare class SilentAuthCodeClient 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 redeeming an authorization code against the /token endpoint
14
+ * @param request
15
+ */
16
+ acquireToken(request: AuthorizationCodeRequest): Promise<AuthenticationResult>;
17
+ /**
18
+ * Currently Unsupported
19
+ */
20
+ logout(): Promise<void>;
21
+ }
22
+ //# sourceMappingURL=SilentAuthCodeClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentAuthCodeClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/SilentAuthCodeClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAA6C,MAAM,oBAAoB,CAAC;AACtH,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,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAG/E,qBAAa,oBAAqB,SAAQ,yBAAyB;IAC/D,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,wBAAwB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoDpF;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAI1B"}
@@ -0,0 +1,80 @@
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 } 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
+ import { HybridSpaAuthorizationCodeClient } from './HybridSpaAuthorizationCodeClient.js';
10
+
11
+ /*
12
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13
+ * Licensed under the MIT License.
14
+ */
15
+ var SilentAuthCodeClient = /** @class */ (function (_super) {
16
+ __extends(SilentAuthCodeClient, _super);
17
+ function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
18
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
19
+ _this.apiId = apiId;
20
+ return _this;
21
+ }
22
+ /**
23
+ * Acquires a token silently by redeeming an authorization code against the /token endpoint
24
+ * @param request
25
+ */
26
+ SilentAuthCodeClient.prototype.acquireToken = function (request) {
27
+ return __awaiter(this, void 0, void 0, function () {
28
+ var silentRequest, serverTelemetryManager, authCodeRequest, clientConfig, authClient, silentHandler, e_1;
29
+ return __generator(this, function (_a) {
30
+ switch (_a.label) {
31
+ case 0:
32
+ this.logger.trace("SilentAuthCodeClient.acquireToken called");
33
+ // Auth code payload is required
34
+ if (!request.code) {
35
+ throw BrowserAuthError.createAuthCodeRequiredError();
36
+ }
37
+ silentRequest = this.initializeAuthorizationRequest(request, InteractionType.Silent);
38
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
39
+ _a.label = 1;
40
+ case 1:
41
+ _a.trys.push([1, 3, , 4]);
42
+ authCodeRequest = __assign(__assign({}, silentRequest), { code: request.code });
43
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
44
+ case 2:
45
+ clientConfig = _a.sent();
46
+ authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
47
+ this.logger.verbose("Auth code client created");
48
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
49
+ // Handle auth code parameters from request
50
+ return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
51
+ code: request.code,
52
+ msgraph_host: request.msGraphHost,
53
+ cloud_graph_host_name: request.cloudGraphHostName,
54
+ cloud_instance_host_name: request.cloudInstanceHostName
55
+ }, silentRequest.state, authClient.authority, this.networkClient, false)];
56
+ case 3:
57
+ e_1 = _a.sent();
58
+ if (e_1 instanceof AuthError) {
59
+ e_1.setCorrelationId(this.correlationId);
60
+ }
61
+ serverTelemetryManager.cacheFailedRequest(e_1);
62
+ this.browserStorage.cleanRequestByState(silentRequest.state);
63
+ throw e_1;
64
+ case 4: return [2 /*return*/];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ /**
70
+ * Currently Unsupported
71
+ */
72
+ SilentAuthCodeClient.prototype.logout = function () {
73
+ // Synchronous so we must reject
74
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
75
+ };
76
+ return SilentAuthCodeClient;
77
+ }(StandardInteractionClient));
78
+
79
+ export { SilentAuthCodeClient };
80
+ //# sourceMappingURL=SilentAuthCodeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentAuthCodeClient.js","sources":["../../src/interaction_client/SilentAuthCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, ICrypto, Logger, CommonAuthorizationCodeRequest, 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 { AuthorizationCodeRequest } from \"../request/AuthorizationCodeRequest\";\nimport { HybridSpaAuthorizationCodeClient } from \"./HybridSpaAuthorizationCodeClient\";\n\nexport class SilentAuthCodeClient 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 redeeming an authorization code against the /token endpoint\n * @param request \n */\n async acquireToken(request: AuthorizationCodeRequest): Promise<AuthenticationResult> {\n this.logger.trace(\"SilentAuthCodeClient.acquireToken called\");\n\n // Auth code payload is required\n if (!request.code) {\n throw BrowserAuthError.createAuthCodeRequiredError();\n }\n\n // Create silent request\n const silentRequest: AuthorizationUrlRequest = this.initializeAuthorizationRequest(request, InteractionType.Silent);\n\n const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);\n\n try {\n\n // Create auth code request (PKCE not needed)\n const authCodeRequest: CommonAuthorizationCodeRequest = {\n ...silentRequest,\n code: request.code\n };\n\n // Initialize the client\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, silentRequest.authority);\n const authClient: HybridSpaAuthorizationCodeClient = new HybridSpaAuthorizationCodeClient(clientConfig);\n this.logger.verbose(\"Auth code client created\");\n\n // Create silent handler\n const silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);\n\n // Handle auth code parameters from request\n return silentHandler.handleCodeResponseFromServer(\n {\n code: request.code,\n msgraph_host: request.msGraphHost,\n cloud_graph_host_name: request.cloudGraphHostName,\n cloud_instance_host_name: request.cloudInstanceHostName\n },\n silentRequest.state, \n authClient.authority, \n this.networkClient,\n false\n );\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"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;IAkB0C,wCAAyB;IAG/D,8BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,KAAY,EAAE,aAAsB;QAAzN,YACI,kBAAM,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,CAAC,SAEnG;QADG,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;KACtB;;;;;IAMK,2CAAY,GAAlB,UAAmB,OAAiC;;;;;;wBAChD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;;wBAG9D,IAAI,CAAC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,mBAAmB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;wBAC7D,MAAM,GAAC,CAAC;;;;;KAEf;;;;IAKD,qCAAM,GAAN;;QAEI,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kCAAkC,EAAE,CAAC,CAAC;KAChF;IACL,2BAAC;AAAD,CAvEA,CAA0C,yBAAyB;;;;"}
@@ -0,0 +1,22 @@
1
+ import { StandardInteractionClient } from "./StandardInteractionClient";
2
+ import { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo } from "@azure/msal-common";
3
+ import { SilentRequest } from "../request/SilentRequest";
4
+ export declare class SilentCacheClient extends StandardInteractionClient {
5
+ /**
6
+ * Returns unexpired tokens from the cache, if available
7
+ * @param silentRequest
8
+ */
9
+ acquireToken(silentRequest: CommonSilentFlowRequest): Promise<AuthenticationResult>;
10
+ /**
11
+ * Currently Unsupported
12
+ */
13
+ logout(): Promise<void>;
14
+ /**
15
+ * Creates an Silent Flow Client with the given authority, or the default authority.
16
+ * @param serverTelemetryManager
17
+ * @param authorityUrl
18
+ */
19
+ protected createSilentFlowClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<SilentFlowClient>;
20
+ initializeSilentRequest(request: SilentRequest, account: AccountInfo): CommonSilentFlowRequest;
21
+ }
22
+ //# sourceMappingURL=SilentCacheClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SilentCacheClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/SilentCacheClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,qBAAa,iBAAkB,SAAQ,yBAAyB;IAC5D;;;OAGG;IACG,YAAY,CAAC,aAAa,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkBzF;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB;;;;OAIG;cACa,sBAAsB,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMxI,uBAAuB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,uBAAuB;CAQjG"}
@@ -0,0 +1,85 @@
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 { SilentFlowClient } from '@azure/msal-common';
6
+ import { EventType } from '../event/EventType.js';
7
+ import { InteractionType, ApiId } from '../utils/BrowserConstants.js';
8
+ import { BrowserAuthError, BrowserAuthErrorMessage } from '../error/BrowserAuthError.js';
9
+
10
+ /*
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License.
13
+ */
14
+ var SilentCacheClient = /** @class */ (function (_super) {
15
+ __extends(SilentCacheClient, _super);
16
+ function SilentCacheClient() {
17
+ return _super !== null && _super.apply(this, arguments) || this;
18
+ }
19
+ /**
20
+ * Returns unexpired tokens from the cache, if available
21
+ * @param silentRequest
22
+ */
23
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
24
+ return __awaiter(this, void 0, void 0, function () {
25
+ var serverTelemetryManager, silentAuthClient, cachedToken, error_1;
26
+ return __generator(this, function (_a) {
27
+ switch (_a.label) {
28
+ case 0:
29
+ serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
30
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority)];
31
+ case 1:
32
+ silentAuthClient = _a.sent();
33
+ this.logger.verbose("Silent auth client created");
34
+ _a.label = 2;
35
+ case 2:
36
+ _a.trys.push([2, 4, , 5]);
37
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
38
+ case 3:
39
+ cachedToken = _a.sent();
40
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, cachedToken);
41
+ return [2 /*return*/, cachedToken];
42
+ case 4:
43
+ error_1 = _a.sent();
44
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
45
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
46
+ }
47
+ throw error_1;
48
+ case 5: return [2 /*return*/];
49
+ }
50
+ });
51
+ });
52
+ };
53
+ /**
54
+ * Currently Unsupported
55
+ */
56
+ SilentCacheClient.prototype.logout = function () {
57
+ // Synchronous so we must reject
58
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
59
+ };
60
+ /**
61
+ * Creates an Silent Flow Client with the given authority, or the default authority.
62
+ * @param serverTelemetryManager
63
+ * @param authorityUrl
64
+ */
65
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl) {
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var clientConfig;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
71
+ case 1:
72
+ clientConfig = _a.sent();
73
+ return [2 /*return*/, new SilentFlowClient(clientConfig)];
74
+ }
75
+ });
76
+ });
77
+ };
78
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
79
+ return __assign(__assign(__assign({}, request), this.initializeBaseRequest(request)), { account: account, forceRefresh: request.forceRefresh || false });
80
+ };
81
+ return SilentCacheClient;
82
+ }(StandardInteractionClient));
83
+
84
+ export { SilentCacheClient };
85
+ //# sourceMappingURL=SilentCacheClient.js.map