@azure/msal-common 4.2.1 → 4.5.1

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 (190) hide show
  1. package/CHANGELOG.json +212 -1
  2. package/LICENSE +21 -21
  3. package/README.md +61 -58
  4. package/changelog.md +402 -344
  5. package/dist/_virtual/_tslib.js +90 -0
  6. package/dist/_virtual/_tslib.js.map +1 -0
  7. package/dist/account/AuthToken.js +43 -0
  8. package/dist/account/AuthToken.js.map +1 -0
  9. package/dist/account/CcsCredential.d.ts +9 -0
  10. package/dist/account/CcsCredential.d.ts.map +1 -0
  11. package/dist/account/CcsCredential.js +14 -0
  12. package/dist/account/CcsCredential.js.map +1 -0
  13. package/dist/account/ClientInfo.d.ts +6 -1
  14. package/dist/account/ClientInfo.d.ts.map +1 -1
  15. package/dist/account/ClientInfo.js +44 -0
  16. package/dist/account/ClientInfo.js.map +1 -0
  17. package/dist/account/TokenClaims.d.ts +1 -0
  18. package/dist/account/TokenClaims.d.ts.map +1 -1
  19. package/dist/authority/Authority.d.ts +25 -0
  20. package/dist/authority/Authority.d.ts.map +1 -1
  21. package/dist/authority/Authority.js +574 -0
  22. package/dist/authority/Authority.js.map +1 -0
  23. package/dist/authority/AuthorityFactory.js +69 -0
  24. package/dist/authority/AuthorityFactory.js.map +1 -0
  25. package/dist/authority/AuthorityOptions.d.ts +2 -0
  26. package/dist/authority/AuthorityOptions.d.ts.map +1 -1
  27. package/dist/authority/AuthorityType.js +17 -0
  28. package/dist/authority/AuthorityType.js.map +1 -0
  29. package/dist/authority/AzureRegion.d.ts +2 -0
  30. package/dist/authority/AzureRegion.d.ts.map +1 -0
  31. package/dist/authority/AzureRegionConfiguration.d.ts +6 -0
  32. package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -0
  33. package/dist/authority/CloudInstanceDiscoveryResponse.js +13 -0
  34. package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -0
  35. package/dist/authority/OpenIdConfigResponse.js +15 -0
  36. package/dist/authority/OpenIdConfigResponse.js.map +1 -0
  37. package/dist/authority/ProtocolMode.js +17 -0
  38. package/dist/authority/ProtocolMode.js.map +1 -0
  39. package/dist/authority/RegionDiscovery.d.ts +31 -0
  40. package/dist/authority/RegionDiscovery.d.ts.map +1 -0
  41. package/dist/authority/RegionDiscovery.js +119 -0
  42. package/dist/authority/RegionDiscovery.js.map +1 -0
  43. package/dist/authority/RegionDiscoveryMetadata.d.ts +7 -0
  44. package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -0
  45. package/dist/cache/CacheManager.js +713 -0
  46. package/dist/cache/CacheManager.js.map +1 -0
  47. package/dist/cache/entities/AccessTokenEntity.js +111 -0
  48. package/dist/cache/entities/AccessTokenEntity.js.map +1 -0
  49. package/dist/cache/entities/AccountEntity.d.ts +5 -5
  50. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  51. package/dist/cache/entities/AccountEntity.js +242 -0
  52. package/dist/cache/entities/AccountEntity.js.map +1 -0
  53. package/dist/cache/entities/AppMetadataEntity.js +74 -0
  54. package/dist/cache/entities/AppMetadataEntity.js.map +1 -0
  55. package/dist/cache/entities/AuthorityMetadataEntity.js +81 -0
  56. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -0
  57. package/dist/cache/entities/CacheRecord.js +19 -0
  58. package/dist/cache/entities/CacheRecord.js.map +1 -0
  59. package/dist/cache/entities/CredentialEntity.js +142 -0
  60. package/dist/cache/entities/CredentialEntity.js.map +1 -0
  61. package/dist/cache/entities/IdTokenEntity.js +71 -0
  62. package/dist/cache/entities/IdTokenEntity.js.map +1 -0
  63. package/dist/cache/entities/RefreshTokenEntity.js +73 -0
  64. package/dist/cache/entities/RefreshTokenEntity.js.map +1 -0
  65. package/dist/cache/entities/ServerTelemetryEntity.js +35 -0
  66. package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -0
  67. package/dist/cache/entities/ThrottlingEntity.js +32 -0
  68. package/dist/cache/entities/ThrottlingEntity.js.map +1 -0
  69. package/dist/cache/persistence/TokenCacheContext.js +39 -0
  70. package/dist/cache/persistence/TokenCacheContext.js.map +1 -0
  71. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  72. package/dist/client/AuthorizationCodeClient.js +388 -0
  73. package/dist/client/AuthorizationCodeClient.js.map +1 -0
  74. package/dist/client/BaseClient.d.ts +2 -1
  75. package/dist/client/BaseClient.d.ts.map +1 -1
  76. package/dist/client/BaseClient.js +101 -0
  77. package/dist/client/BaseClient.js.map +1 -0
  78. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  79. package/dist/client/ClientCredentialClient.js +169 -0
  80. package/dist/client/ClientCredentialClient.js.map +1 -0
  81. package/dist/client/DeviceCodeClient.d.ts +6 -0
  82. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  83. package/dist/client/DeviceCodeClient.js +212 -0
  84. package/dist/client/DeviceCodeClient.js.map +1 -0
  85. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  86. package/dist/client/OnBehalfOfClient.js +209 -0
  87. package/dist/client/OnBehalfOfClient.js.map +1 -0
  88. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  89. package/dist/client/RefreshTokenClient.js +212 -0
  90. package/dist/client/RefreshTokenClient.js.map +1 -0
  91. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  92. package/dist/client/SilentFlowClient.js +132 -0
  93. package/dist/client/SilentFlowClient.js.map +1 -0
  94. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  95. package/dist/client/UsernamePasswordClient.js +112 -0
  96. package/dist/client/UsernamePasswordClient.js.map +1 -0
  97. package/dist/config/ClientConfiguration.d.ts +3 -0
  98. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  99. package/dist/config/ClientConfiguration.js +91 -0
  100. package/dist/config/ClientConfiguration.js.map +1 -0
  101. package/dist/crypto/ICrypto.js +53 -0
  102. package/dist/crypto/ICrypto.js.map +1 -0
  103. package/dist/crypto/PopTokenGenerator.js +72 -0
  104. package/dist/crypto/PopTokenGenerator.js.map +1 -0
  105. package/dist/error/AuthError.js +46 -0
  106. package/dist/error/AuthError.js.map +1 -0
  107. package/dist/error/ClientAuthError.d.ts +13 -6
  108. package/dist/error/ClientAuthError.d.ts.map +1 -1
  109. package/dist/error/ClientAuthError.js +456 -0
  110. package/dist/error/ClientAuthError.js.map +1 -0
  111. package/dist/error/ClientConfigurationError.d.ts +1 -6
  112. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  113. package/dist/error/ClientConfigurationError.js +210 -0
  114. package/dist/error/ClientConfigurationError.js.map +1 -0
  115. package/dist/error/InteractionRequiredAuthError.js +48 -0
  116. package/dist/error/InteractionRequiredAuthError.js.map +1 -0
  117. package/dist/error/ServerError.js +25 -0
  118. package/dist/error/ServerError.js.map +1 -0
  119. package/dist/index.cjs.js +7045 -0
  120. package/dist/index.cjs.js.map +1 -0
  121. package/dist/index.d.ts +4 -0
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +43 -6479
  124. package/dist/index.js.map +1 -0
  125. package/dist/logger/Logger.d.ts +12 -3
  126. package/dist/logger/Logger.d.ts.map +1 -1
  127. package/dist/logger/Logger.js +183 -0
  128. package/dist/logger/Logger.js.map +1 -0
  129. package/dist/network/INetworkModule.d.ts +1 -1
  130. package/dist/network/INetworkModule.d.ts.map +1 -1
  131. package/dist/network/INetworkModule.js +21 -0
  132. package/dist/network/INetworkModule.js.map +1 -0
  133. package/dist/network/NetworkManager.js +56 -0
  134. package/dist/network/NetworkManager.js.map +1 -0
  135. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  136. package/dist/network/ThrottlingUtils.js +95 -0
  137. package/dist/network/ThrottlingUtils.js.map +1 -0
  138. package/dist/packageMetadata.d.ts +1 -1
  139. package/dist/packageMetadata.js +8 -0
  140. package/dist/packageMetadata.js.map +1 -0
  141. package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -0
  142. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  143. package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -0
  144. package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
  145. package/dist/request/CommonClientCredentialRequest.d.ts +7 -4
  146. package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
  147. package/dist/request/CommonRefreshTokenRequest.d.ts +2 -0
  148. package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
  149. package/dist/request/RequestParameterBuilder.d.ts +11 -0
  150. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  151. package/dist/request/RequestParameterBuilder.js +340 -0
  152. package/dist/request/RequestParameterBuilder.js.map +1 -0
  153. package/dist/request/RequestValidator.d.ts.map +1 -1
  154. package/dist/request/RequestValidator.js +92 -0
  155. package/dist/request/RequestValidator.js.map +1 -0
  156. package/dist/request/ScopeSet.js +192 -0
  157. package/dist/request/ScopeSet.js.map +1 -0
  158. package/dist/response/AuthenticationResult.d.ts +1 -1
  159. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  160. package/dist/response/AuthorizationCodePayload.d.ts +1 -0
  161. package/dist/response/AuthorizationCodePayload.d.ts.map +1 -1
  162. package/dist/response/IMDSBadResponse.d.ts +5 -0
  163. package/dist/response/IMDSBadResponse.d.ts.map +1 -0
  164. package/dist/response/ResponseHandler.d.ts.map +1 -1
  165. package/dist/response/ResponseHandler.js +281 -0
  166. package/dist/response/ResponseHandler.js.map +1 -0
  167. package/dist/telemetry/server/ServerTelemetryManager.d.ts +23 -1
  168. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  169. package/dist/telemetry/server/ServerTelemetryManager.js +168 -0
  170. package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -0
  171. package/dist/url/UrlString.d.ts +10 -0
  172. package/dist/url/UrlString.d.ts.map +1 -1
  173. package/dist/url/UrlString.js +223 -0
  174. package/dist/url/UrlString.js.map +1 -0
  175. package/dist/utils/Constants.d.ts +47 -4
  176. package/dist/utils/Constants.d.ts.map +1 -1
  177. package/dist/utils/Constants.js +362 -0
  178. package/dist/utils/Constants.js.map +1 -0
  179. package/dist/utils/ProtocolUtils.js +77 -0
  180. package/dist/utils/ProtocolUtils.js.map +1 -0
  181. package/dist/utils/StringUtils.d.ts +5 -0
  182. package/dist/utils/StringUtils.d.ts.map +1 -1
  183. package/dist/utils/StringUtils.js +128 -0
  184. package/dist/utils/StringUtils.js.map +1 -0
  185. package/dist/utils/TimeUtils.d.ts +13 -0
  186. package/dist/utils/TimeUtils.d.ts.map +1 -1
  187. package/dist/utils/TimeUtils.js +53 -0
  188. package/dist/utils/TimeUtils.js.map +1 -0
  189. package/package.json +10 -19
  190. package/dist/index.es.js +0 -6472
@@ -1 +1 @@
1
- {"version":3,"file":"RequestParameterBuilder.d.ts","sourceRoot":"","sources":["../../src/request/RequestParameterBuilder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiC,YAAY,EAAkI,MAAM,oBAAoB,CAAC;AAGjN,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,UAAU,CAAsB;;IAMxC;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAM3B;;;OAGG;IACH,eAAe,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI;IAOlD;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,GAAE,OAAc,GAAG,IAAI;IAMhE;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKzC;;;OAGG;IACH,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKnD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE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from '../_virtual/_tslib.js';
4
+ import { AADServerParamKeys, Constants, ResponseMode, OIDC_DEFAULT_SCOPES, SSOTypes, HeaderNames, CLIENT_INFO, ClaimsRequestKeys, PasswordGrantConstants, AuthenticationScheme, ThrottlingConstants } from '../utils/Constants.js';
5
+ import { ScopeSet } from './ScopeSet.js';
6
+ import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
7
+ import { RequestValidator } from './RequestValidator.js';
8
+ import { StringUtils } from '../utils/StringUtils.js';
9
+
10
+ /*
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License.
13
+ */
14
+ var RequestParameterBuilder = /** @class */ (function () {
15
+ function RequestParameterBuilder() {
16
+ this.parameters = new Map();
17
+ }
18
+ /**
19
+ * add response_type = code
20
+ */
21
+ RequestParameterBuilder.prototype.addResponseTypeCode = function () {
22
+ this.parameters.set(AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.CODE_RESPONSE_TYPE));
23
+ };
24
+ /**
25
+ * add response_mode. defaults to query.
26
+ * @param responseMode
27
+ */
28
+ RequestParameterBuilder.prototype.addResponseMode = function (responseMode) {
29
+ this.parameters.set(AADServerParamKeys.RESPONSE_MODE, encodeURIComponent((responseMode) ? responseMode : ResponseMode.QUERY));
30
+ };
31
+ /**
32
+ * add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
33
+ * @param scopeSet
34
+ * @param addOidcScopes
35
+ */
36
+ RequestParameterBuilder.prototype.addScopes = function (scopes, addOidcScopes) {
37
+ if (addOidcScopes === void 0) { addOidcScopes = true; }
38
+ var requestScopes = addOidcScopes ? __spreadArrays(scopes || [], OIDC_DEFAULT_SCOPES) : scopes || [];
39
+ var scopeSet = new ScopeSet(requestScopes);
40
+ this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));
41
+ };
42
+ /**
43
+ * add clientId
44
+ * @param clientId
45
+ */
46
+ RequestParameterBuilder.prototype.addClientId = function (clientId) {
47
+ this.parameters.set(AADServerParamKeys.CLIENT_ID, encodeURIComponent(clientId));
48
+ };
49
+ /**
50
+ * add redirect_uri
51
+ * @param redirectUri
52
+ */
53
+ RequestParameterBuilder.prototype.addRedirectUri = function (redirectUri) {
54
+ RequestValidator.validateRedirectUri(redirectUri);
55
+ this.parameters.set(AADServerParamKeys.REDIRECT_URI, encodeURIComponent(redirectUri));
56
+ };
57
+ /**
58
+ * add post logout redirectUri
59
+ * @param redirectUri
60
+ */
61
+ RequestParameterBuilder.prototype.addPostLogoutRedirectUri = function (redirectUri) {
62
+ RequestValidator.validateRedirectUri(redirectUri);
63
+ this.parameters.set(AADServerParamKeys.POST_LOGOUT_URI, encodeURIComponent(redirectUri));
64
+ };
65
+ /**
66
+ * add id_token_hint to logout request
67
+ * @param idTokenHint
68
+ */
69
+ RequestParameterBuilder.prototype.addIdTokenHint = function (idTokenHint) {
70
+ this.parameters.set(AADServerParamKeys.ID_TOKEN_HINT, encodeURIComponent(idTokenHint));
71
+ };
72
+ /**
73
+ * add domain_hint
74
+ * @param domainHint
75
+ */
76
+ RequestParameterBuilder.prototype.addDomainHint = function (domainHint) {
77
+ this.parameters.set(SSOTypes.DOMAIN_HINT, encodeURIComponent(domainHint));
78
+ };
79
+ /**
80
+ * add login_hint
81
+ * @param loginHint
82
+ */
83
+ RequestParameterBuilder.prototype.addLoginHint = function (loginHint) {
84
+ this.parameters.set(SSOTypes.LOGIN_HINT, encodeURIComponent(loginHint));
85
+ };
86
+ /**
87
+ * Adds the CCS (Cache Credential Service) query parameter for login_hint
88
+ * @param loginHint
89
+ */
90
+ RequestParameterBuilder.prototype.addCcsUpn = function (loginHint) {
91
+ this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent("UPN:" + loginHint));
92
+ };
93
+ /**
94
+ * Adds the CCS (Cache Credential Service) query parameter for account object
95
+ * @param loginHint
96
+ */
97
+ RequestParameterBuilder.prototype.addCcsOid = function (clientInfo) {
98
+ this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent("Oid:" + clientInfo.uid + "@" + clientInfo.utid));
99
+ };
100
+ /**
101
+ * add sid
102
+ * @param sid
103
+ */
104
+ RequestParameterBuilder.prototype.addSid = function (sid) {
105
+ this.parameters.set(SSOTypes.SID, encodeURIComponent(sid));
106
+ };
107
+ /**
108
+ * add claims
109
+ * @param claims
110
+ */
111
+ RequestParameterBuilder.prototype.addClaims = function (claims, clientCapabilities) {
112
+ var mergedClaims = this.addClientCapabilitiesToClaims(claims, clientCapabilities);
113
+ RequestValidator.validateClaims(mergedClaims);
114
+ this.parameters.set(AADServerParamKeys.CLAIMS, encodeURIComponent(mergedClaims));
115
+ };
116
+ /**
117
+ * add correlationId
118
+ * @param correlationId
119
+ */
120
+ RequestParameterBuilder.prototype.addCorrelationId = function (correlationId) {
121
+ this.parameters.set(AADServerParamKeys.CLIENT_REQUEST_ID, encodeURIComponent(correlationId));
122
+ };
123
+ /**
124
+ * add library info query params
125
+ * @param libraryInfo
126
+ */
127
+ RequestParameterBuilder.prototype.addLibraryInfo = function (libraryInfo) {
128
+ // Telemetry Info
129
+ this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);
130
+ this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);
131
+ this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
132
+ this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);
133
+ };
134
+ /**
135
+ * add prompt
136
+ * @param prompt
137
+ */
138
+ RequestParameterBuilder.prototype.addPrompt = function (prompt) {
139
+ RequestValidator.validatePrompt(prompt);
140
+ this.parameters.set("" + AADServerParamKeys.PROMPT, encodeURIComponent(prompt));
141
+ };
142
+ /**
143
+ * add state
144
+ * @param state
145
+ */
146
+ RequestParameterBuilder.prototype.addState = function (state) {
147
+ if (!StringUtils.isEmpty(state)) {
148
+ this.parameters.set(AADServerParamKeys.STATE, encodeURIComponent(state));
149
+ }
150
+ };
151
+ /**
152
+ * add nonce
153
+ * @param nonce
154
+ */
155
+ RequestParameterBuilder.prototype.addNonce = function (nonce) {
156
+ this.parameters.set(AADServerParamKeys.NONCE, encodeURIComponent(nonce));
157
+ };
158
+ /**
159
+ * add code_challenge and code_challenge_method
160
+ * - throw if either of them are not passed
161
+ * @param codeChallenge
162
+ * @param codeChallengeMethod
163
+ */
164
+ RequestParameterBuilder.prototype.addCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {
165
+ RequestValidator.validateCodeChallengeParams(codeChallenge, codeChallengeMethod);
166
+ if (codeChallenge && codeChallengeMethod) {
167
+ this.parameters.set(AADServerParamKeys.CODE_CHALLENGE, encodeURIComponent(codeChallenge));
168
+ this.parameters.set(AADServerParamKeys.CODE_CHALLENGE_METHOD, encodeURIComponent(codeChallengeMethod));
169
+ }
170
+ else {
171
+ throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
172
+ }
173
+ };
174
+ /**
175
+ * add the `authorization_code` passed by the user to exchange for a token
176
+ * @param code
177
+ */
178
+ RequestParameterBuilder.prototype.addAuthorizationCode = function (code) {
179
+ this.parameters.set(AADServerParamKeys.CODE, encodeURIComponent(code));
180
+ };
181
+ /**
182
+ * add the `authorization_code` passed by the user to exchange for a token
183
+ * @param code
184
+ */
185
+ RequestParameterBuilder.prototype.addDeviceCode = function (code) {
186
+ this.parameters.set(AADServerParamKeys.DEVICE_CODE, encodeURIComponent(code));
187
+ };
188
+ /**
189
+ * add the `refreshToken` passed by the user
190
+ * @param refreshToken
191
+ */
192
+ RequestParameterBuilder.prototype.addRefreshToken = function (refreshToken) {
193
+ this.parameters.set(AADServerParamKeys.REFRESH_TOKEN, encodeURIComponent(refreshToken));
194
+ };
195
+ /**
196
+ * add the `code_verifier` passed by the user to exchange for a token
197
+ * @param codeVerifier
198
+ */
199
+ RequestParameterBuilder.prototype.addCodeVerifier = function (codeVerifier) {
200
+ this.parameters.set(AADServerParamKeys.CODE_VERIFIER, encodeURIComponent(codeVerifier));
201
+ };
202
+ /**
203
+ * add client_secret
204
+ * @param clientSecret
205
+ */
206
+ RequestParameterBuilder.prototype.addClientSecret = function (clientSecret) {
207
+ this.parameters.set(AADServerParamKeys.CLIENT_SECRET, encodeURIComponent(clientSecret));
208
+ };
209
+ /**
210
+ * add clientAssertion for confidential client flows
211
+ * @param clientAssertion
212
+ */
213
+ RequestParameterBuilder.prototype.addClientAssertion = function (clientAssertion) {
214
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
215
+ };
216
+ /**
217
+ * add clientAssertionType for confidential client flows
218
+ * @param clientAssertionType
219
+ */
220
+ RequestParameterBuilder.prototype.addClientAssertionType = function (clientAssertionType) {
221
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
222
+ };
223
+ /**
224
+ * add OBO assertion for confidential client flows
225
+ * @param clientAssertion
226
+ */
227
+ RequestParameterBuilder.prototype.addOboAssertion = function (oboAssertion) {
228
+ this.parameters.set(AADServerParamKeys.OBO_ASSERTION, encodeURIComponent(oboAssertion));
229
+ };
230
+ /**
231
+ * add grant type
232
+ * @param grantType
233
+ */
234
+ RequestParameterBuilder.prototype.addRequestTokenUse = function (tokenUse) {
235
+ this.parameters.set(AADServerParamKeys.REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));
236
+ };
237
+ /**
238
+ * add grant type
239
+ * @param grantType
240
+ */
241
+ RequestParameterBuilder.prototype.addGrantType = function (grantType) {
242
+ this.parameters.set(AADServerParamKeys.GRANT_TYPE, encodeURIComponent(grantType));
243
+ };
244
+ /**
245
+ * add client info
246
+ *
247
+ */
248
+ RequestParameterBuilder.prototype.addClientInfo = function () {
249
+ this.parameters.set(CLIENT_INFO, "1");
250
+ };
251
+ /**
252
+ * add extraQueryParams
253
+ * @param eQparams
254
+ */
255
+ RequestParameterBuilder.prototype.addExtraQueryParameters = function (eQparams) {
256
+ var _this = this;
257
+ RequestValidator.sanitizeEQParams(eQparams, this.parameters);
258
+ Object.keys(eQparams).forEach(function (key) {
259
+ _this.parameters.set(key, eQparams[key]);
260
+ });
261
+ };
262
+ RequestParameterBuilder.prototype.addClientCapabilitiesToClaims = function (claims, clientCapabilities) {
263
+ var mergedClaims;
264
+ // Parse provided claims into JSON object or initialize empty object
265
+ if (!claims) {
266
+ mergedClaims = {};
267
+ }
268
+ else {
269
+ try {
270
+ mergedClaims = JSON.parse(claims);
271
+ }
272
+ catch (e) {
273
+ throw ClientConfigurationError.createInvalidClaimsRequestError();
274
+ }
275
+ }
276
+ if (clientCapabilities && clientCapabilities.length > 0) {
277
+ if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
278
+ // Add access_token key to claims object
279
+ mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
280
+ }
281
+ // Add xms_cc claim with provided clientCapabilities to access_token key
282
+ mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {
283
+ values: clientCapabilities
284
+ };
285
+ }
286
+ return JSON.stringify(mergedClaims);
287
+ };
288
+ /**
289
+ * adds `username` for Password Grant flow
290
+ * @param username
291
+ */
292
+ RequestParameterBuilder.prototype.addUsername = function (username) {
293
+ this.parameters.set(PasswordGrantConstants.username, username);
294
+ };
295
+ /**
296
+ * adds `password` for Password Grant flow
297
+ * @param password
298
+ */
299
+ RequestParameterBuilder.prototype.addPassword = function (password) {
300
+ this.parameters.set(PasswordGrantConstants.password, password);
301
+ };
302
+ /**
303
+ * add pop_jwk to query params
304
+ * @param cnfString
305
+ */
306
+ RequestParameterBuilder.prototype.addPopToken = function (cnfString) {
307
+ if (!StringUtils.isEmpty(cnfString)) {
308
+ this.parameters.set(AADServerParamKeys.TOKEN_TYPE, AuthenticationScheme.POP);
309
+ this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
310
+ }
311
+ };
312
+ /**
313
+ * add server telemetry fields
314
+ * @param serverTelemetryManager
315
+ */
316
+ RequestParameterBuilder.prototype.addServerTelemetry = function (serverTelemetryManager) {
317
+ this.parameters.set(AADServerParamKeys.X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
318
+ this.parameters.set(AADServerParamKeys.X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
319
+ };
320
+ /**
321
+ * Adds parameter that indicates to the server that throttling is supported
322
+ */
323
+ RequestParameterBuilder.prototype.addThrottling = function () {
324
+ this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
325
+ };
326
+ /**
327
+ * Utility to create a URL from the params map
328
+ */
329
+ RequestParameterBuilder.prototype.createQueryString = function () {
330
+ var queryParameterArray = new Array();
331
+ this.parameters.forEach(function (value, key) {
332
+ queryParameterArray.push(key + "=" + value);
333
+ });
334
+ return queryParameterArray.join("&");
335
+ };
336
+ return RequestParameterBuilder;
337
+ }());
338
+
339
+ export { RequestParameterBuilder };
340
+ //# sourceMappingURL=RequestParameterBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestParameterBuilder.js","sources":["../../src/request/RequestParameterBuilder.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AADServerParamKeys, Constants, ResponseMode, SSOTypes, CLIENT_INFO, AuthenticationScheme, ClaimsRequestKeys, PasswordGrantConstants, OIDC_DEFAULT_SCOPES, ThrottlingConstants, HeaderNames} from \"../utils/Constants\";\nimport { ScopeSet } from \"./ScopeSet\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { StringDict } from \"../utils/MsalTypes\";\nimport { RequestValidator } from \"./RequestValidator\";\nimport { LibraryInfo } from \"../config/ClientConfiguration\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { ClientInfo } from \"../account/ClientInfo\";\n\nexport class RequestParameterBuilder {\n\n private parameters: Map<string, string>;\n\n constructor() {\n this.parameters = new Map<string, string>();\n }\n\n /**\n * add response_type = code\n */\n addResponseTypeCode(): void {\n this.parameters.set(\n AADServerParamKeys.RESPONSE_TYPE, encodeURIComponent(Constants.CODE_RESPONSE_TYPE)\n );\n }\n\n /**\n * add response_mode. defaults to query.\n * @param responseMode\n */\n addResponseMode(responseMode?: ResponseMode): void {\n this.parameters.set(\n AADServerParamKeys.RESPONSE_MODE,\n encodeURIComponent((responseMode) ? responseMode : ResponseMode.QUERY)\n );\n }\n\n /**\n * add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios\n * @param scopeSet\n * @param addOidcScopes\n */\n addScopes(scopes: string[], addOidcScopes: boolean = true): void {\n const requestScopes = addOidcScopes ? [...scopes || [], ...OIDC_DEFAULT_SCOPES] : scopes || [];\n const scopeSet = new ScopeSet(requestScopes);\n this.parameters.set(AADServerParamKeys.SCOPE, encodeURIComponent(scopeSet.printScopes()));\n }\n\n /**\n * add clientId\n * @param clientId\n */\n addClientId(clientId: string): void {\n this.parameters.set(AADServerParamKeys.CLIENT_ID, encodeURIComponent(clientId));\n }\n\n /**\n * add redirect_uri\n * @param redirectUri\n */\n addRedirectUri(redirectUri: string): void {\n RequestValidator.validateRedirectUri(redirectUri);\n this.parameters.set(AADServerParamKeys.REDIRECT_URI, encodeURIComponent(redirectUri));\n }\n\n /**\n * add post logout redirectUri\n * @param redirectUri\n */\n addPostLogoutRedirectUri(redirectUri: string): void {\n RequestValidator.validateRedirectUri(redirectUri);\n this.parameters.set(AADServerParamKeys.POST_LOGOUT_URI, encodeURIComponent(redirectUri));\n }\n\n /**\n * add id_token_hint to logout request\n * @param idTokenHint\n */\n addIdTokenHint(idTokenHint: string): void {\n this.parameters.set(AADServerParamKeys.ID_TOKEN_HINT, encodeURIComponent(idTokenHint));\n }\n\n /**\n * add domain_hint\n * @param domainHint\n */\n addDomainHint(domainHint: string): void {\n this.parameters.set(SSOTypes.DOMAIN_HINT, encodeURIComponent(domainHint));\n }\n\n /**\n * add login_hint\n * @param loginHint\n */\n addLoginHint(loginHint: string): void {\n this.parameters.set(SSOTypes.LOGIN_HINT, encodeURIComponent(loginHint));\n }\n\n /**\n * Adds the CCS (Cache Credential Service) query parameter for login_hint\n * @param loginHint \n */\n addCcsUpn(loginHint: string): void {\n this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`UPN:${loginHint}`));\n }\n\n /**\n * Adds the CCS (Cache Credential Service) query parameter for account object\n * @param loginHint \n */\n addCcsOid(clientInfo: ClientInfo): void {\n this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`Oid:${clientInfo.uid}@${clientInfo.utid}`));\n }\n\n /**\n * add sid\n * @param sid\n */\n addSid(sid: string): void {\n this.parameters.set(SSOTypes.SID, encodeURIComponent(sid));\n }\n\n /**\n * add claims\n * @param claims\n */\n addClaims(claims?: string, clientCapabilities?: Array<string>): void {\n const mergedClaims = this.addClientCapabilitiesToClaims(claims, clientCapabilities);\n RequestValidator.validateClaims(mergedClaims);\n this.parameters.set(AADServerParamKeys.CLAIMS, encodeURIComponent(mergedClaims));\n }\n\n /**\n * add correlationId\n * @param correlationId\n */\n addCorrelationId(correlationId: string): void {\n this.parameters.set(AADServerParamKeys.CLIENT_REQUEST_ID, encodeURIComponent(correlationId));\n }\n\n /**\n * add library info query params\n * @param libraryInfo\n */\n addLibraryInfo(libraryInfo: LibraryInfo): void {\n // Telemetry Info\n this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);\n this.parameters.set(AADServerParamKeys.X_CLIENT_VER, libraryInfo.version);\n this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);\n this.parameters.set(AADServerParamKeys.X_CLIENT_CPU, libraryInfo.cpu);\n }\n\n /**\n * add prompt\n * @param prompt\n */\n addPrompt(prompt: string): void {\n RequestValidator.validatePrompt(prompt);\n this.parameters.set(`${AADServerParamKeys.PROMPT}`, encodeURIComponent(prompt));\n }\n\n /**\n * add state\n * @param state\n */\n addState(state: string): void {\n if (!StringUtils.isEmpty(state)) {\n this.parameters.set(AADServerParamKeys.STATE, encodeURIComponent(state));\n }\n }\n\n /**\n * add nonce\n * @param nonce\n */\n addNonce(nonce: string): void {\n this.parameters.set(AADServerParamKeys.NONCE, encodeURIComponent(nonce));\n }\n\n /**\n * add code_challenge and code_challenge_method\n * - throw if either of them are not passed\n * @param codeChallenge\n * @param codeChallengeMethod\n */\n addCodeChallengeParams(\n codeChallenge: string,\n codeChallengeMethod: string\n ): void {\n RequestValidator.validateCodeChallengeParams(codeChallenge, codeChallengeMethod);\n if (codeChallenge && codeChallengeMethod) {\n this.parameters.set(AADServerParamKeys.CODE_CHALLENGE, encodeURIComponent(codeChallenge));\n this.parameters.set(AADServerParamKeys.CODE_CHALLENGE_METHOD, encodeURIComponent(codeChallengeMethod));\n } else {\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\n }\n }\n\n /**\n * add the `authorization_code` passed by the user to exchange for a token\n * @param code\n */\n addAuthorizationCode(code: string): void {\n this.parameters.set(AADServerParamKeys.CODE, encodeURIComponent(code));\n }\n\n /**\n * add the `authorization_code` passed by the user to exchange for a token\n * @param code\n */\n addDeviceCode(code: string): void {\n this.parameters.set(AADServerParamKeys.DEVICE_CODE, encodeURIComponent(code));\n }\n\n /**\n * add the `refreshToken` passed by the user\n * @param refreshToken\n */\n addRefreshToken(refreshToken: string): void {\n this.parameters.set(AADServerParamKeys.REFRESH_TOKEN, encodeURIComponent(refreshToken));\n }\n\n /**\n * add the `code_verifier` passed by the user to exchange for a token\n * @param codeVerifier\n */\n addCodeVerifier(codeVerifier: string): void {\n this.parameters.set(AADServerParamKeys.CODE_VERIFIER, encodeURIComponent(codeVerifier));\n }\n\n /**\n * add client_secret\n * @param clientSecret\n */\n addClientSecret(clientSecret: string): void {\n this.parameters.set(AADServerParamKeys.CLIENT_SECRET, encodeURIComponent(clientSecret));\n }\n\n /**\n * add clientAssertion for confidential client flows\n * @param clientAssertion\n */\n addClientAssertion(clientAssertion: string): void {\n this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));\n }\n\n /**\n * add clientAssertionType for confidential client flows\n * @param clientAssertionType\n */\n addClientAssertionType(clientAssertionType: string): void {\n this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));\n }\n\n /**\n * add OBO assertion for confidential client flows\n * @param clientAssertion\n */\n addOboAssertion(oboAssertion: string): void {\n this.parameters.set(AADServerParamKeys.OBO_ASSERTION, encodeURIComponent(oboAssertion));\n }\n\n /**\n * add grant type\n * @param grantType\n */\n addRequestTokenUse(tokenUse: string): void {\n this.parameters.set(AADServerParamKeys.REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));\n }\n\n /**\n * add grant type\n * @param grantType\n */\n addGrantType(grantType: string): void {\n this.parameters.set(AADServerParamKeys.GRANT_TYPE, encodeURIComponent(grantType));\n }\n\n /**\n * add client info\n *\n */\n addClientInfo(): void {\n this.parameters.set(CLIENT_INFO, \"1\");\n }\n\n /**\n * add extraQueryParams\n * @param eQparams\n */\n addExtraQueryParameters(eQparams: StringDict): void {\n RequestValidator.sanitizeEQParams(eQparams, this.parameters);\n Object.keys(eQparams).forEach((key) => {\n this.parameters.set(key, eQparams[key]);\n });\n }\n\n addClientCapabilitiesToClaims(claims?: string, clientCapabilities?: Array<string>): string {\n let mergedClaims: object;\n\n // Parse provided claims into JSON object or initialize empty object\n if (!claims) {\n mergedClaims = {};\n } else {\n try {\n mergedClaims = JSON.parse(claims);\n } catch(e) {\n throw ClientConfigurationError.createInvalidClaimsRequestError();\n }\n }\n\n if (clientCapabilities && clientCapabilities.length > 0) {\n if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)){\n // Add access_token key to claims object\n mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};\n }\n\n // Add xms_cc claim with provided clientCapabilities to access_token key\n mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {\n values: clientCapabilities\n };\n }\n\n return JSON.stringify(mergedClaims);\n }\n\n /**\n * adds `username` for Password Grant flow\n * @param username\n */\n addUsername(username: string): void {\n this.parameters.set(PasswordGrantConstants.username, username);\n }\n\n /**\n * adds `password` for Password Grant flow\n * @param password\n */\n addPassword(password: string): void {\n this.parameters.set(PasswordGrantConstants.password, password);\n }\n\n /**\n * add pop_jwk to query params\n * @param cnfString\n */\n addPopToken(cnfString: string): void {\n if (!StringUtils.isEmpty(cnfString)) {\n this.parameters.set(AADServerParamKeys.TOKEN_TYPE, AuthenticationScheme.POP);\n this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));\n }\n }\n\n /**\n * add server telemetry fields\n * @param serverTelemetryManager \n */\n addServerTelemetry(serverTelemetryManager: ServerTelemetryManager): void {\n this.parameters.set(AADServerParamKeys.X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());\n this.parameters.set(AADServerParamKeys.X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());\n }\n\n /**\n * Adds parameter that indicates to the server that throttling is supported\n */\n addThrottling(): void {\n this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);\n }\n\n /**\n * Utility to create a URL from the params map\n */\n createQueryString(): string {\n const queryParameterArray: Array<string> = new Array<string>();\n\n this.parameters.forEach((value, key) => {\n queryParameterArray.push(`${key}=${value}`);\n });\n\n return queryParameterArray.join(\"&\");\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAmBI;QACI,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;KAC/C;;;;IAKD,qDAAmB,GAAnB;QACI,IAAI,CAAC,UAAU,CAAC,GAAG,CACf,kBAAkB,CAAC,aAAa,EAAE,kBAAkB,CAAC,SAAS,CAAC,kBAAkB,CAAC,C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M,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAI,UAAU;CAc/F"}
1
+ {"version":3,"file":"RequestValidator.d.ts","sourceRoot":"","sources":["../../src/request/RequestValidator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,qBAAa,gBAAgB;IAEzB;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAI,IAAI;IAMtD;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAI,IAAI;IAY5C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAI,IAAI;IAQ5C;;;;OAIG;IACH,MAAM,CAAC,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAI,IAAI;IAQ7F;;;OAGG;IACH,MAAM,CAAC,2BAA2B,CAAC,mBAAmB,EAAE,MAAM,GAAI,IAAI;IAWtE;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAI,UAAU;CAc/F"}
@@ -0,0 +1,92 @@
1
+ /*! @azure/msal-common v4.5.1 2021-08-02 */
2
+ 'use strict';
3
+ import { StringUtils } from '../utils/StringUtils.js';
4
+ import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
5
+ import { CodeChallengeMethodValues, PromptValue } from '../utils/Constants.js';
6
+
7
+ /*
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License.
10
+ */
11
+ /**
12
+ * Validates server consumable params from the "request" objects
13
+ */
14
+ var RequestValidator = /** @class */ (function () {
15
+ function RequestValidator() {
16
+ }
17
+ /**
18
+ * Utility to check if the `redirectUri` in the request is a non-null value
19
+ * @param redirectUri
20
+ */
21
+ RequestValidator.validateRedirectUri = function (redirectUri) {
22
+ if (StringUtils.isEmpty(redirectUri)) {
23
+ throw ClientConfigurationError.createRedirectUriEmptyError();
24
+ }
25
+ };
26
+ /**
27
+ * Utility to validate prompt sent by the user in the request
28
+ * @param prompt
29
+ */
30
+ RequestValidator.validatePrompt = function (prompt) {
31
+ var promptValues = [];
32
+ for (var value in PromptValue) {
33
+ promptValues.push(PromptValue[value]);
34
+ }
35
+ if (promptValues.indexOf(prompt) < 0) {
36
+ throw ClientConfigurationError.createInvalidPromptError(prompt);
37
+ }
38
+ };
39
+ RequestValidator.validateClaims = function (claims) {
40
+ try {
41
+ JSON.parse(claims);
42
+ }
43
+ catch (e) {
44
+ throw ClientConfigurationError.createInvalidClaimsRequestError();
45
+ }
46
+ };
47
+ /**
48
+ * Utility to validate code_challenge and code_challenge_method
49
+ * @param codeChallenge
50
+ * @param codeChallengeMethod
51
+ */
52
+ RequestValidator.validateCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {
53
+ if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {
54
+ throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
55
+ }
56
+ else {
57
+ this.validateCodeChallengeMethod(codeChallengeMethod);
58
+ }
59
+ };
60
+ /**
61
+ * Utility to validate code_challenge_method
62
+ * @param codeChallengeMethod
63
+ */
64
+ RequestValidator.validateCodeChallengeMethod = function (codeChallengeMethod) {
65
+ if ([
66
+ CodeChallengeMethodValues.PLAIN,
67
+ CodeChallengeMethodValues.S256
68
+ ].indexOf(codeChallengeMethod) < 0) {
69
+ throw ClientConfigurationError.createInvalidCodeChallengeMethodError();
70
+ }
71
+ };
72
+ /**
73
+ * Removes unnecessary or duplicate query parameters from extraQueryParameters
74
+ * @param request
75
+ */
76
+ RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
77
+ if (!eQParams) {
78
+ return {};
79
+ }
80
+ // Remove any query parameters already included in SSO params
81
+ queryParams.forEach(function (value, key) {
82
+ if (eQParams[key]) {
83
+ delete eQParams[key];
84
+ }
85
+ });
86
+ return eQParams;
87
+ };
88
+ return RequestValidator;
89
+ }());
90
+
91
+ export { RequestValidator };
92
+ //# sourceMappingURL=RequestValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestValidator.js","sources":["../../src/request/RequestValidator.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { PromptValue, CodeChallengeMethodValues} from \"../utils/Constants\";\nimport { StringDict } from \"../utils/MsalTypes\";\n\n/**\n * Validates server consumable params from the \"request\" objects\n */\nexport class RequestValidator {\n\n /**\n * Utility to check if the `redirectUri` in the request is a non-null value\n * @param redirectUri\n */\n static validateRedirectUri(redirectUri: string) : void {\n if (StringUtils.isEmpty(redirectUri)) {\n throw ClientConfigurationError.createRedirectUriEmptyError();\n }\n }\n\n /**\n * Utility to validate prompt sent by the user in the request\n * @param prompt\n */\n static validatePrompt(prompt: string) : void {\n const promptValues = [];\n\n for (const value in PromptValue) {\n promptValues.push(PromptValue[value]);\n }\n\n if (promptValues.indexOf(prompt) < 0) {\n throw ClientConfigurationError.createInvalidPromptError(prompt);\n }\n }\n\n static validateClaims(claims: string) : void {\n try {\n JSON.parse(claims);\n } catch(e) {\n throw ClientConfigurationError.createInvalidClaimsRequestError();\n }\n }\n\n /**\n * Utility to validate code_challenge and code_challenge_method\n * @param codeChallenge\n * @param codeChallengeMethod\n */\n static validateCodeChallengeParams(codeChallenge: string, codeChallengeMethod: string) : void {\n if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\n } else {\n this.validateCodeChallengeMethod(codeChallengeMethod);\n }\n }\n\n /**\n * Utility to validate code_challenge_method\n * @param codeChallengeMethod\n */\n static validateCodeChallengeMethod(codeChallengeMethod: string) : void {\n if (\n [\n CodeChallengeMethodValues.PLAIN,\n CodeChallengeMethodValues.S256\n ].indexOf(codeChallengeMethod) < 0\n ) {\n throw ClientConfigurationError.createInvalidCodeChallengeMethodError();\n }\n }\n\n /**\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\n * @param request\n */\n static sanitizeEQParams(eQParams: StringDict, queryParams: Map<string, string>) : StringDict {\n if (!eQParams) {\n return {};\n }\n\n // Remove any query parameters already included in SSO params\n queryParams.forEach((value, key) => {\n if (eQParams[key]) {\n delete eQParams[key];\n }\n });\n\n return eQParams;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;AAUA;;;;IAGA;KAkFC;;;;;IA5EU,oCAAmB,GAA1B,UAA2B,WAAmB;QAC1C,IAAI,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAClC,MAAM,wBAAwB,CAAC,2BAA2B,EAAE,CAAC;SAChE;KACJ;;;;;IAMM,+BAAc,GAArB,UAAsB,MAAc;QAChC,IAAM,YAAY,GAAG,EAAE,CAAC;QAExB,KAAK,IAAM,KAAK,IAAI,WAAW,EAAE;YAC7B,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SACzC;QAED,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,wBAAwB,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;SACnE;KACJ;IAEM,+BAAc,GAArB,UAAsB,MAAc;QAChC,IAAI;YACA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACtB;QAAC,OAAM,CAAC,EAAE;YACP,MAAM,wBAAwB,CAAC,+BAA+B,EAAE,CAAC;SACpE;KACJ;;;;;;IAOM,4CAA2B,GAAlC,UAAmC,aAAqB,EAAE,mBAA2B;QACjF,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,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