@aws-amplify/auth 4.6.2-next.20 → 4.6.2-next.36
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 +43 -0
- package/lib/.tsbuildinfo +3 -0
- package/lib/Auth.d.ts +2 -1
- package/lib/Auth.js +4 -3
- package/lib/Auth.js.map +1 -1
- package/lib/Errors.js +1 -1
- package/lib/OAuth/OAuth.js +11 -11
- package/lib/OAuth/OAuth.js.map +1 -1
- package/lib/OAuth/oauthStorage.js +1 -1
- package/lib/OAuth/oauthStorage.native.js +1 -1
- package/lib/OAuth/urlOpener.js +1 -1
- package/lib/OAuth/urlOpener.native.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/Auth.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/urlListener.js +1 -1
- package/lib/urlListener.native.js +1 -1
- package/lib-esm/.tsbuildinfo +3 -0
- package/lib-esm/Auth.d.ts +2 -1
- package/lib-esm/Auth.js +5 -4
- package/lib-esm/Auth.js.map +1 -1
- package/lib-esm/Errors.js +1 -1
- package/lib-esm/OAuth/OAuth.js +11 -11
- package/lib-esm/OAuth/OAuth.js.map +1 -1
- package/lib-esm/OAuth/oauthStorage.js +1 -1
- package/lib-esm/OAuth/oauthStorage.native.js +1 -1
- package/lib-esm/OAuth/urlOpener.js +1 -1
- package/lib-esm/OAuth/urlOpener.native.js +1 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/types/Auth.js +1 -1
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/urlListener.js +1 -1
- package/lib-esm/urlListener.native.js +1 -1
- package/package.json +12 -6
- package/src/Auth.ts +5 -4
- package/src/Errors.ts +1 -1
- package/src/OAuth/OAuth.ts +26 -26
- package/src/OAuth/oauthStorage.native.ts +1 -1
- package/src/OAuth/oauthStorage.ts +1 -1
- package/src/OAuth/urlOpener.native.ts +1 -1
- package/src/OAuth/urlOpener.ts +1 -1
- package/src/index.ts +1 -1
- package/src/types/Auth.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/urlListener.native.ts +1 -1
- package/src/urlListener.ts +1 -1
- package/build.js +0 -5
- package/dist/aws-amplify-auth.js +0 -13501
- package/dist/aws-amplify-auth.js.map +0 -1
- package/dist/aws-amplify-auth.min.js +0 -44
- package/dist/aws-amplify-auth.min.js.map +0 -1
- package/index.js +0 -7
- package/testSequencer.js +0 -24
- package/webpack.config.dev.js +0 -6
package/src/OAuth/OAuth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -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 } 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 Sha256();
|
|
306
|
+
awsCryptoHash.update(code);
|
|
307
|
+
|
|
308
|
+
const resultFromAWSCrypto = awsCryptoHash.digestSync();
|
|
309
|
+
const b64 = Buffer.from(resultFromAWSCrypto).toString('base64');
|
|
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) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/OAuth/urlOpener.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/types/Auth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|
package/src/urlListener.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2017-
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
5
|
* the License. A copy of the License is located at
|