@aws-amplify/auth 5.5.4-api-v6.29 → 5.5.4-api-v6-models.35

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.
@@ -117,7 +117,7 @@ export default class OAuth {
117
117
  this._urlOpener(URL, redirectSignIn);
118
118
  }
119
119
 
120
- private async _handleCodeFlow(currentUrl: string) {
120
+ private async _handleCodeFlow(currentUrl: string, userAgentValue?: string) {
121
121
  /* Convert URL into an object with parameters as keys
122
122
  { redirect_uri: 'http://localhost:3000/', response_type: 'code', ...} */
123
123
  const { code } = (parse(currentUrl).query || '')
@@ -169,17 +169,12 @@ export default class OAuth {
169
169
  .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
170
170
  .join('&');
171
171
 
172
- const customUserAgentDetails: CustomUserAgentDetails = {
173
- category: Category.Auth,
174
- action: AuthAction.FederatedSignIn,
175
- };
176
-
177
172
  const { access_token, refresh_token, id_token, error } = await (
178
173
  (await fetch(oAuthTokenEndpoint, {
179
174
  method: 'POST',
180
175
  headers: {
181
176
  'Content-Type': 'application/x-www-form-urlencoded',
182
- [USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
177
+ [USER_AGENT_HEADER]: userAgentValue,
183
178
  },
184
179
  body,
185
180
  })) as any
@@ -217,7 +212,10 @@ export default class OAuth {
217
212
  };
218
213
  }
219
214
 
220
- public async handleAuthResponse(currentUrl?: string) {
215
+ public async handleAuthResponse(
216
+ currentUrl?: string,
217
+ userAgentValue?: string
218
+ ) {
221
219
  try {
222
220
  const urlParams = currentUrl
223
221
  ? ({
@@ -244,7 +242,10 @@ export default class OAuth {
244
242
  `Starting ${this._config.responseType} flow with ${currentUrl}`
245
243
  );
246
244
  if (this._config.responseType === 'code') {
247
- return { ...(await this._handleCodeFlow(currentUrl)), state };
245
+ return {
246
+ ...(await this._handleCodeFlow(currentUrl, userAgentValue)),
247
+ state,
248
+ };
248
249
  } else {
249
250
  return { ...(await this._handleImplicitFlow(currentUrl)), state };
250
251
  }