@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.
- package/internals/package.json +8 -0
- package/lib/Auth.d.ts +4 -81
- package/lib/Auth.js +45 -2252
- package/lib/Auth.js.map +1 -1
- package/lib/OAuth/OAuth.d.ts +1 -1
- package/lib/OAuth/OAuth.js +5 -9
- package/lib/OAuth/OAuth.js.map +1 -1
- package/lib/internals/InternalAuth.d.ts +353 -0
- package/lib/internals/InternalAuth.js +2630 -0
- package/lib/internals/InternalAuth.js.map +1 -0
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +7 -0
- package/lib/internals/index.js.map +1 -0
- package/lib/utils.d.ts +3 -0
- package/lib/utils.js +15 -0
- package/lib/utils.js.map +1 -0
- package/lib-esm/Auth.d.ts +4 -81
- package/lib-esm/Auth.js +47 -2254
- package/lib-esm/Auth.js.map +1 -1
- package/lib-esm/OAuth/OAuth.d.ts +1 -1
- package/lib-esm/OAuth/OAuth.js +6 -10
- package/lib-esm/OAuth/OAuth.js.map +1 -1
- package/lib-esm/internals/InternalAuth.d.ts +353 -0
- package/lib-esm/internals/InternalAuth.js +2628 -0
- package/lib-esm/internals/InternalAuth.js.map +1 -0
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +4 -0
- package/lib-esm/internals/index.js.map +1 -0
- package/lib-esm/utils.d.ts +3 -0
- package/lib-esm/utils.js +11 -0
- package/lib-esm/utils.js.map +1 -0
- package/package.json +8 -6
- package/src/Auth.ts +76 -2410
- package/src/OAuth/OAuth.ts +10 -9
- package/src/internals/InternalAuth.ts +3270 -0
- package/src/internals/index.ts +3 -0
- package/src/utils.ts +27 -0
package/src/OAuth/OAuth.ts
CHANGED
|
@@ -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]:
|
|
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(
|
|
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 {
|
|
245
|
+
return {
|
|
246
|
+
...(await this._handleCodeFlow(currentUrl, userAgentValue)),
|
|
247
|
+
state,
|
|
248
|
+
};
|
|
248
249
|
} else {
|
|
249
250
|
return { ...(await this._handleImplicitFlow(currentUrl)), state };
|
|
250
251
|
}
|