@aws-amplify/auth 4.6.1-unstable.4 → 4.6.2-size-improvement.21
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/CHANGELOG.md +12 -0
- package/dist/aws-amplify-auth.js +1156 -3271
- package/dist/aws-amplify-auth.js.map +1 -1
- package/dist/aws-amplify-auth.min.js +25 -10
- package/dist/aws-amplify-auth.min.js.map +1 -1
- package/lib/Auth.js +2 -2
- package/lib/Auth.js.map +1 -1
- package/lib/OAuth/OAuth.js +10 -13
- package/lib/OAuth/OAuth.js.map +1 -1
- package/lib-esm/Auth.js +3 -65
- package/lib-esm/Auth.js.map +1 -1
- package/lib-esm/Errors.js +1 -13
- package/lib-esm/Errors.js.map +1 -1
- package/lib-esm/OAuth/OAuth.js +11 -73
- package/lib-esm/OAuth/OAuth.js.map +1 -1
- package/lib-esm/urlListener.native.js +1 -58
- package/lib-esm/urlListener.native.js.map +1 -1
- package/package.json +7 -6
- package/src/Auth.ts +2 -2
- package/src/OAuth/OAuth.ts +25 -25
package/src/OAuth/OAuth.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { parse } from 'url'; // Used for OAuth parsing of Cognito Hosted UI
|
|
15
15
|
import { launchUri } from './urlOpener';
|
|
16
16
|
import * as oAuthStorage from './oauthStorage';
|
|
17
|
+
import { Buffer } from 'buffer';
|
|
17
18
|
|
|
18
19
|
import {
|
|
19
20
|
OAuthOpts,
|
|
@@ -23,13 +24,12 @@ import {
|
|
|
23
24
|
|
|
24
25
|
import { ConsoleLogger as Logger, Hub, urlSafeEncode } from '@aws-amplify/core';
|
|
25
26
|
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
: '@@amplify_default') as Symbol;
|
|
27
|
+
import { Sha256 as jsSha256 } from '@aws-crypto/sha256-js';
|
|
28
|
+
const AMPLIFY_SYMBOL = (
|
|
29
|
+
typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
|
|
30
|
+
? Symbol.for('amplify_default')
|
|
31
|
+
: '@@amplify_default'
|
|
32
|
+
) as Symbol;
|
|
33
33
|
|
|
34
34
|
const dispatchAuthEvent = (event: string, data: any, message: string) => {
|
|
35
35
|
Hub.dispatch('auth', { event, data, message }, 'Auth', AMPLIFY_SYMBOL);
|
|
@@ -169,18 +169,15 @@ export default class OAuth {
|
|
|
169
169
|
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
|
170
170
|
.join('&');
|
|
171
171
|
|
|
172
|
-
const {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
body,
|
|
183
|
-
})) as any).json();
|
|
172
|
+
const { access_token, refresh_token, id_token, error } = await (
|
|
173
|
+
(await fetch(oAuthTokenEndpoint, {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: {
|
|
176
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
177
|
+
},
|
|
178
|
+
body,
|
|
179
|
+
})) as any
|
|
180
|
+
).json();
|
|
184
181
|
|
|
185
182
|
if (error) {
|
|
186
183
|
throw new Error(error);
|
|
@@ -305,15 +302,18 @@ export default class OAuth {
|
|
|
305
302
|
}
|
|
306
303
|
|
|
307
304
|
private _generateChallenge(code: string) {
|
|
308
|
-
|
|
305
|
+
const awsCryptoHash = new jsSha256();
|
|
306
|
+
awsCryptoHash.update(code);
|
|
307
|
+
const resultFromAWSCrypto = awsCryptoHash.digestSync();
|
|
308
|
+
const b64 = Buffer.from(resultFromAWSCrypto).toString('base64');
|
|
309
|
+
|
|
310
|
+
const base64URLFromAWSCrypto = this._base64URL(b64);
|
|
311
|
+
|
|
312
|
+
return base64URLFromAWSCrypto;
|
|
309
313
|
}
|
|
310
314
|
|
|
311
315
|
private _base64URL(string) {
|
|
312
|
-
return string
|
|
313
|
-
.toString(Base64)
|
|
314
|
-
.replace(/=/g, '')
|
|
315
|
-
.replace(/\+/g, '-')
|
|
316
|
-
.replace(/\//g, '_');
|
|
316
|
+
return string.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
private _generateRandom(size: number) {
|