@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.
Files changed (54) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/Auth.d.ts +2 -1
  4. package/lib/Auth.js +4 -3
  5. package/lib/Auth.js.map +1 -1
  6. package/lib/Errors.js +1 -1
  7. package/lib/OAuth/OAuth.js +11 -11
  8. package/lib/OAuth/OAuth.js.map +1 -1
  9. package/lib/OAuth/oauthStorage.js +1 -1
  10. package/lib/OAuth/oauthStorage.native.js +1 -1
  11. package/lib/OAuth/urlOpener.js +1 -1
  12. package/lib/OAuth/urlOpener.native.js +1 -1
  13. package/lib/index.js +1 -1
  14. package/lib/types/Auth.js +1 -1
  15. package/lib/types/index.js +1 -1
  16. package/lib/urlListener.js +1 -1
  17. package/lib/urlListener.native.js +1 -1
  18. package/lib-esm/.tsbuildinfo +3 -0
  19. package/lib-esm/Auth.d.ts +2 -1
  20. package/lib-esm/Auth.js +5 -4
  21. package/lib-esm/Auth.js.map +1 -1
  22. package/lib-esm/Errors.js +1 -1
  23. package/lib-esm/OAuth/OAuth.js +11 -11
  24. package/lib-esm/OAuth/OAuth.js.map +1 -1
  25. package/lib-esm/OAuth/oauthStorage.js +1 -1
  26. package/lib-esm/OAuth/oauthStorage.native.js +1 -1
  27. package/lib-esm/OAuth/urlOpener.js +1 -1
  28. package/lib-esm/OAuth/urlOpener.native.js +1 -1
  29. package/lib-esm/index.js +1 -1
  30. package/lib-esm/types/Auth.js +1 -1
  31. package/lib-esm/types/index.js +1 -1
  32. package/lib-esm/urlListener.js +1 -1
  33. package/lib-esm/urlListener.native.js +1 -1
  34. package/package.json +12 -6
  35. package/src/Auth.ts +5 -4
  36. package/src/Errors.ts +1 -1
  37. package/src/OAuth/OAuth.ts +26 -26
  38. package/src/OAuth/oauthStorage.native.ts +1 -1
  39. package/src/OAuth/oauthStorage.ts +1 -1
  40. package/src/OAuth/urlOpener.native.ts +1 -1
  41. package/src/OAuth/urlOpener.ts +1 -1
  42. package/src/index.ts +1 -1
  43. package/src/types/Auth.ts +1 -1
  44. package/src/types/index.ts +1 -1
  45. package/src/urlListener.native.ts +1 -1
  46. package/src/urlListener.ts +1 -1
  47. package/build.js +0 -5
  48. package/dist/aws-amplify-auth.js +0 -13501
  49. package/dist/aws-amplify-auth.js.map +0 -1
  50. package/dist/aws-amplify-auth.min.js +0 -44
  51. package/dist/aws-amplify-auth.min.js.map +0 -1
  52. package/index.js +0 -7
  53. package/testSequencer.js +0 -24
  54. package/webpack.config.dev.js +0 -6
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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 sha256 from 'crypto-js/sha256';
27
- import Base64 from 'crypto-js/enc-base64';
28
-
29
- const AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' &&
30
- typeof Symbol.for === 'function'
31
- ? Symbol.for('amplify_default')
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
- access_token,
174
- refresh_token,
175
- id_token,
176
- error,
177
- } = await ((await fetch(oAuthTokenEndpoint, {
178
- method: 'POST',
179
- headers: {
180
- 'Content-Type': 'application/x-www-form-urlencoded',
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
- return this._base64URL(sha256(code));
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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/build.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const build = require('../../scripts/build');
4
-
5
- build(process.argv[2], process.argv[3]);