@aws-amplify/core 6.0.1-console-preview.d807e55.0 → 6.0.1-console-preview.a1c533e.0

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 (134) hide show
  1. package/internals/aws-clients/pinpoint/package.json +4 -4
  2. package/lib/Hub/index.d.ts +7 -0
  3. package/lib/Hub/index.js +8 -1
  4. package/lib/Platform/customUserAgent.d.ts +16 -0
  5. package/lib/Platform/customUserAgent.js +70 -0
  6. package/lib/Platform/index.js +10 -1
  7. package/lib/Platform/types.d.ts +59 -4
  8. package/lib/Platform/types.js +26 -35
  9. package/lib/Platform/version.d.ts +1 -1
  10. package/lib/Platform/version.js +1 -1
  11. package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +1 -0
  12. package/lib/clients/middleware/signing/signer/signatureV4/index.js +1 -0
  13. package/lib/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts +0 -0
  14. package/lib/clients/middleware/signing/signer/signatureV4/polyfills/index.js +4 -0
  15. package/lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts +1 -0
  16. package/lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.js +6 -0
  17. package/lib/index.d.ts +1 -1
  18. package/lib/index.js +3 -3
  19. package/lib/libraryUtils.d.ts +4 -3
  20. package/lib/libraryUtils.js +6 -4
  21. package/lib/parseAWSExports.js +70 -14
  22. package/lib/providers/pinpoint/apis/updateEndpoint.js +2 -2
  23. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +2 -2
  24. package/lib/singleton/Auth/types.d.ts +27 -0
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/lib/utils/globalHelpers/index.native.d.ts +2 -3
  27. package/lib/utils/globalHelpers/index.native.js +3 -3
  28. package/lib-esm/Hub/index.d.ts +7 -0
  29. package/lib-esm/Hub/index.js +7 -0
  30. package/lib-esm/Platform/customUserAgent.d.ts +16 -0
  31. package/lib-esm/Platform/customUserAgent.js +65 -0
  32. package/lib-esm/Platform/index.js +10 -1
  33. package/lib-esm/Platform/types.d.ts +59 -4
  34. package/lib-esm/Platform/types.js +26 -35
  35. package/lib-esm/Platform/version.d.ts +1 -1
  36. package/lib-esm/Platform/version.js +1 -1
  37. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +1 -0
  38. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +1 -0
  39. package/lib-esm/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts +0 -0
  40. package/lib-esm/clients/middleware/signing/signer/signatureV4/polyfills/index.js +4 -0
  41. package/lib-esm/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts +1 -0
  42. package/lib-esm/clients/middleware/signing/signer/signatureV4/polyfills/index.native.js +4 -0
  43. package/lib-esm/index.d.ts +1 -1
  44. package/lib-esm/index.js +1 -1
  45. package/lib-esm/libraryUtils.d.ts +4 -3
  46. package/lib-esm/libraryUtils.js +3 -2
  47. package/lib-esm/parseAWSExports.js +70 -14
  48. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +1 -1
  49. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +1 -1
  50. package/lib-esm/singleton/Auth/types.d.ts +27 -0
  51. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  52. package/lib-esm/utils/globalHelpers/index.native.d.ts +2 -3
  53. package/lib-esm/utils/globalHelpers/index.native.js +2 -2
  54. package/package.json +4 -4
  55. package/src/Hub/index.ts +8 -0
  56. package/src/Platform/customUserAgent.ts +75 -0
  57. package/src/Platform/index.ts +14 -1
  58. package/src/Platform/types.ts +69 -35
  59. package/src/Platform/version.ts +1 -1
  60. package/src/clients/middleware/signing/signer/signatureV4/index.ts +2 -0
  61. package/src/clients/middleware/signing/signer/signatureV4/polyfills/index.native.ts +5 -0
  62. package/src/clients/middleware/signing/signer/signatureV4/polyfills/index.ts +4 -0
  63. package/src/index.ts +1 -1
  64. package/src/libraryUtils.ts +13 -8
  65. package/src/parseAWSExports.ts +54 -13
  66. package/src/providers/pinpoint/apis/updateEndpoint.ts +1 -1
  67. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +1 -1
  68. package/src/singleton/Auth/types.ts +49 -0
  69. package/src/utils/globalHelpers/index.native.ts +2 -2
  70. package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -4
  71. package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +0 -16
  72. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -4
  73. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +0 -9
  74. package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +0 -12
  75. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.d.ts +0 -0
  76. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.js +0 -0
  77. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.d.ts +0 -0
  78. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.js +0 -0
  79. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.d.ts +0 -0
  80. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.js +0 -0
  81. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.d.ts +0 -0
  82. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.js +0 -0
  83. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.d.ts +0 -0
  84. /package/lib/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.js +0 -0
  85. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/base.d.ts +0 -0
  86. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/base.js +0 -0
  87. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/errorHelpers.d.ts +0 -0
  88. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/errorHelpers.js +0 -0
  89. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.d.ts +0 -0
  90. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.js +0 -0
  91. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/index.d.ts +0 -0
  92. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/index.js +0 -0
  93. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.d.ts +0 -0
  94. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.js +0 -0
  95. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/types.d.ts +0 -0
  96. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/types.js +0 -0
  97. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.d.ts +0 -0
  98. /package/lib/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.js +0 -0
  99. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.d.ts +0 -0
  100. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.js +0 -0
  101. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.d.ts +0 -0
  102. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.js +0 -0
  103. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.d.ts +0 -0
  104. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.js +0 -0
  105. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.d.ts +0 -0
  106. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.js +0 -0
  107. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.d.ts +0 -0
  108. /package/lib-esm/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.js +0 -0
  109. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/base.d.ts +0 -0
  110. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/base.js +0 -0
  111. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/errorHelpers.d.ts +0 -0
  112. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/errorHelpers.js +0 -0
  113. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.d.ts +0 -0
  114. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.js +0 -0
  115. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/index.d.ts +0 -0
  116. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/index.js +0 -0
  117. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.d.ts +0 -0
  118. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.js +0 -0
  119. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/types.d.ts +0 -0
  120. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/types.js +0 -0
  121. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.d.ts +0 -0
  122. /package/lib-esm/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.js +0 -0
  123. /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/base.ts +0 -0
  124. /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getCredentialsForIdentity.ts +0 -0
  125. /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/getId.ts +0 -0
  126. /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/index.ts +0 -0
  127. /package/src/{AwsClients/CognitoIdentity → awsClients/cognitoIdentity}/types.ts +0 -0
  128. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/base.ts +0 -0
  129. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/errorHelpers.ts +0 -0
  130. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/getInAppMessages.ts +0 -0
  131. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/index.ts +0 -0
  132. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/putEvents.ts +0 -0
  133. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/types.ts +0 -0
  134. /package/src/{AwsClients/Pinpoint → awsClients/pinpoint}/updateEndpoint.ts +0 -0
@@ -1,4 +1,3 @@
1
- import { encode, decode } from 'base-64';
2
1
  export declare const getCrypto: () => Crypto;
3
- export declare const getBtoa: () => typeof encode;
4
- export declare const getAtob: () => typeof decode;
2
+ export declare const getBtoa: () => typeof import("base-64").encode;
3
+ export declare const getAtob: () => typeof import("base-64").decode;
@@ -1,9 +1,9 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { loadGetRandomValues } from '@aws-amplify/react-native';
4
- import { encode, decode } from 'base-64';
3
+ import { loadGetRandomValues, loadBase64 } from '@aws-amplify/react-native';
5
4
  import { AmplifyError } from '../../errors';
6
5
  loadGetRandomValues();
6
+ var _a = loadBase64(), encode = _a.encode, decode = _a.decode;
7
7
  export var getCrypto = function () {
8
8
  if (typeof crypto !== 'undefined' &&
9
9
  typeof crypto.getRandomValues === 'function') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.1-console-preview.d807e55.0+d807e55",
3
+ "version": "6.0.1-console-preview.a1c533e.0+a1c533e",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^9.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@aws-amplify/react-native": "1.0.1-console-preview.d807e55.0+d807e55",
71
+ "@aws-amplify/react-native": "1.0.1-console-preview.a1c533e.0+a1c533e",
72
72
  "@types/js-cookie": "^2.2.7",
73
73
  "@types/uuid": "^9.0.0",
74
74
  "find": "^0.2.7",
@@ -86,7 +86,7 @@
86
86
  "name": "Core (I18n)",
87
87
  "path": "./lib-esm/index.js",
88
88
  "import": "{ I18n }",
89
- "limit": "5.48 kB"
89
+ "limit": "5.60 kB"
90
90
  },
91
91
  {
92
92
  "name": "Custom clients (fetch handler)",
@@ -179,5 +179,5 @@
179
179
  "lib-esm"
180
180
  ]
181
181
  },
182
- "gitHead": "d807e554bd4c36e287ab3b4a229260fc9b851d40"
182
+ "gitHead": "a1c533eae82c5386864fb15fc101bb3cb9bd93ae"
183
183
  }
package/src/Hub/index.ts CHANGED
@@ -203,3 +203,11 @@ export class HubClass {
203
203
  pseudo Singleton for the main messaging bus, however you can still create
204
204
  your own instance of HubClass() for a separate "private bus" of events.*/
205
205
  export const Hub = new HubClass('__default__');
206
+
207
+ /**
208
+ * @internal
209
+ *
210
+ * Internal hub used for core Amplify functionality. Not intended for use outside of Amplify.
211
+ *
212
+ */
213
+ export const HubInternal = new HubClass('internal-hub');
@@ -0,0 +1,75 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import {
5
+ AdditionalDetails,
6
+ CategoryUserAgentStateMap,
7
+ CustomUserAgentStateMap,
8
+ SetCustomUserAgentInput,
9
+ } from './types';
10
+
11
+ // Maintains custom user-agent state set by external consumers.
12
+ const customUserAgentState: CustomUserAgentStateMap = {};
13
+
14
+ /**
15
+ * Sets custom user agent state which will be appended to applicable requests. Returns a function that can be used to
16
+ * clean up any custom state set with this API.
17
+ *
18
+ * @note
19
+ * This API operates globally. Calling this API multiple times will result in the most recently set values for a
20
+ * particular API being used.
21
+ *
22
+ * @note
23
+ * This utility IS NOT compatible with SSR.
24
+ *
25
+ * @param input - SetCustomUserAgentInput that defines custom state to apply to the specified APIs.
26
+ */
27
+ export const setCustomUserAgent = (
28
+ input: SetCustomUserAgentInput
29
+ ): (() => void) => {
30
+ // Save custom user-agent state & increment reference counter
31
+ // TODO Remove `any` when we upgrade to TypeScript 5.2, see: https://github.com/microsoft/TypeScript/issues/44373
32
+ customUserAgentState[input.category] = (input.apis as any[]).reduce(
33
+ (acc: CategoryUserAgentStateMap, api: string) => ({
34
+ ...acc,
35
+ [api]: {
36
+ refCount: acc[api]?.refCount ? acc[api].refCount + 1 : 1,
37
+ additionalDetails: input.additionalDetails,
38
+ },
39
+ }),
40
+ customUserAgentState[input.category] ?? {}
41
+ );
42
+
43
+ // Callback that cleans up state for APIs recorded by this call
44
+ let cleanUpCallbackCalled = false;
45
+ const cleanUpCallback = () => {
46
+ // Only allow the cleanup callback to be called once
47
+ if (cleanUpCallbackCalled) {
48
+ return;
49
+ }
50
+ cleanUpCallbackCalled = true;
51
+
52
+ input.apis.forEach(api => {
53
+ const apiRefCount = customUserAgentState[input.category][api].refCount;
54
+
55
+ if (apiRefCount > 1) {
56
+ customUserAgentState[input.category][api].refCount = apiRefCount - 1;
57
+ } else {
58
+ delete customUserAgentState[input.category][api];
59
+
60
+ // Clean up category if no more APIs set
61
+ if (!Object.keys(customUserAgentState[input.category]).length) {
62
+ delete customUserAgentState[input.category];
63
+ }
64
+ }
65
+ });
66
+ };
67
+
68
+ return cleanUpCallback;
69
+ };
70
+
71
+ export const getCustomUserAgent = (
72
+ category: string,
73
+ api: string
74
+ ): AdditionalDetails | undefined =>
75
+ customUserAgentState[category]?.[api]?.additionalDetails;
@@ -5,6 +5,7 @@ import { CustomUserAgentDetails, Framework } from './types';
5
5
  import { version } from './version';
6
6
  import { detectFramework, observeFrameworkChanges } from './detectFramework';
7
7
  import { UserAgent as AWSUserAgent } from '@aws-sdk/types';
8
+ import { getCustomUserAgent } from './customUserAgent';
8
9
 
9
10
  const BASE_USER_AGENT = `aws-amplify`;
10
11
 
@@ -39,6 +40,16 @@ export const getAmplifyUserAgentObject = ({
39
40
  }
40
41
  userAgent.push(['framework', detectFramework()]);
41
42
 
43
+ if (category && action) {
44
+ const customState = getCustomUserAgent(category, action);
45
+
46
+ if (customState) {
47
+ customState.forEach(state => {
48
+ userAgent.push(state);
49
+ });
50
+ }
51
+ }
52
+
42
53
  return userAgent;
43
54
  };
44
55
 
@@ -47,7 +58,9 @@ export const getAmplifyUserAgent = (
47
58
  ): string => {
48
59
  const userAgent = getAmplifyUserAgentObject(customUserAgentDetails);
49
60
  const userAgentString = userAgent
50
- .map(([agentKey, agentValue]) => `${agentKey}/${agentValue}`)
61
+ .map(([agentKey, agentValue]) =>
62
+ agentKey && agentValue ? `${agentKey}/${agentValue}` : agentKey
63
+ )
51
64
  .join(' ');
52
65
 
53
66
  return userAgentString;
@@ -53,40 +53,30 @@ export enum ApiAction {
53
53
  Head = '7',
54
54
  }
55
55
  export enum AuthAction {
56
- // SignUp = '1',
57
- // ConfirmSignUp = '2',
58
- // ResendSignUp = '3',
59
- // SignIn = '4',
60
- // GetMFAOptions = '5',
61
- // GetPreferredMFA = '6',
62
- // SetPreferredMFA = '7',
63
- // DisableSMS = '8',
64
- // EnableSMS = '9',
65
- // SetupTOTP = '10',
66
- // VerifyTotpToken = '11',
67
- // ConfirmSignIn = '12',
68
- // CompleteNewPassword = '13',
69
- // SendCustomChallengeAnswer = '14',
70
- // DeleteUserAttributes = '15',
71
- // DeleteUser = '16',
72
- // UpdateUserAttributes = '17',
73
- // UserAttributes = '18',
74
- // CurrentUserPoolUser = '19',
75
- // CurrentAuthenticatedUser = '20',
76
- // CurrentSession = '21',
77
- // VerifyUserAttribute = '22',
78
- // VerifyUserAttributeSubmit = '23',
79
- // VerifyCurrentUserAttribute = '24',
80
- // VerifyCurrentUserAttributeSubmit = '25',
81
- // SignOut = '26',
82
- // ChangePassword = '27',
83
- // ForgotPassword = '28',
84
- // ForgotPasswordSubmit = '29',
56
+ SignUp = '1',
57
+ ConfirmSignUp = '2',
58
+ ResendSignUpCode = '3',
59
+ SignIn = '4',
60
+ FetchMFAPreference = '6',
61
+ UpdateMFAPreference = '7',
62
+ SetUpTOTP = '10',
63
+ VerifyTOTPSetup = '11',
64
+ ConfirmSignIn = '12',
65
+ DeleteUserAttributes = '15',
66
+ DeleteUser = '16',
67
+ UpdateUserAttributes = '17',
68
+ FetchUserAttributes = '18',
69
+ ConfirmUserAttribute = '22',
70
+ SignOut = '26',
71
+ UpdatePassword = '27',
72
+ ResetPassword = '28',
73
+ ConfirmResetPassword = '29',
85
74
  FederatedSignIn = '30',
86
- // CurrentUserInfo = '31',
87
- // RememberDevice = '32',
88
- // ForgetDevice = '33',
89
- // FetchDevices = '34',
75
+ RememberDevice = '32',
76
+ ForgetDevice = '33',
77
+ FetchDevices = '34',
78
+ SendUserAttributeVerificationCode = '35',
79
+ SignInWithRedirect = '36',
90
80
  }
91
81
  export enum DataStoreAction {
92
82
  Subscribe = '1',
@@ -114,12 +104,13 @@ export enum PushNotificationAction {
114
104
  None = '0',
115
105
  }
116
106
  export enum StorageAction {
117
- Put = '1',
118
- Get = '2',
107
+ UploadData = '1',
108
+ DownloadData = '2',
119
109
  List = '3',
120
110
  Copy = '4',
121
111
  Remove = '5',
122
112
  GetProperties = '6',
113
+ GetUrl = '7',
123
114
  }
124
115
 
125
116
  type ActionMap = {
@@ -159,3 +150,46 @@ export type CustomUserAgentDetails =
159
150
  | UserAgentDetailsWithCategory<Category.PubSub>
160
151
  | UserAgentDetailsWithCategory<Category.PushNotification>
161
152
  | UserAgentDetailsWithCategory<Category.Storage>;
153
+
154
+ /**
155
+ * `refCount` tracks how many consumers have set state for a particular API to avoid it being cleared before all
156
+ * consumers are done using it.
157
+ *
158
+ * Category -> Action -> Custom State
159
+ */
160
+ export type CategoryUserAgentStateMap = Record<
161
+ string,
162
+ { refCount: number; additionalDetails: AdditionalDetails }
163
+ >;
164
+ export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
165
+
166
+ export type AdditionalDetails = [string, string?][];
167
+
168
+ type StorageUserAgentInput = {
169
+ category: Category.Storage;
170
+ apis: StorageAction[];
171
+ };
172
+
173
+ type AuthUserAgentInput = {
174
+ category: Category.Auth;
175
+ apis: AuthAction[];
176
+ };
177
+
178
+ type InAppMessagingUserAgentInput = {
179
+ category: Category.InAppMessaging;
180
+ apis: InAppMessagingAction[];
181
+ };
182
+
183
+ type GeoUserAgentInput = {
184
+ category: Category.Geo;
185
+ apis: GeoAction[];
186
+ };
187
+
188
+ export type SetCustomUserAgentInput = (
189
+ | StorageUserAgentInput
190
+ | AuthUserAgentInput
191
+ | InAppMessagingUserAgentInput
192
+ | GeoUserAgentInput
193
+ ) & {
194
+ additionalDetails: AdditionalDetails;
195
+ };
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.1-console-preview.d807e55.0+d807e55';
2
+ export const version = '6.0.1-console-preview.a1c533e.0+a1c533e';
@@ -1,6 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import './polyfills';
5
+
4
6
  // TODO: V6 replace Signer
5
7
  export { signRequest } from './signRequest';
6
8
  export { presignUrl } from './presignUrl';
@@ -0,0 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { loadUrlPolyfill } from '@aws-amplify/react-native';
4
+
5
+ loadUrlPolyfill();
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // noop - polyfills not required on platform
package/src/index.ts CHANGED
@@ -44,7 +44,7 @@ export {
44
44
  getId,
45
45
  GetCredentialsForIdentityInput,
46
46
  GetCredentialsForIdentityOutput,
47
- } from './AwsClients/CognitoIdentity';
47
+ } from './awsClients/cognitoIdentity';
48
48
 
49
49
  // Amplify-wide constructs
50
50
  export { UserProfile } from './types';
@@ -20,12 +20,7 @@ export {
20
20
  } from './utils';
21
21
  export { parseAWSExports } from './parseAWSExports';
22
22
  export { LegacyConfig } from './singleton/types';
23
- export {
24
- JWT,
25
- StrictUnion,
26
- CognitoIdentityPoolConfig,
27
- JwtPayload,
28
- } from './singleton/Auth/types';
23
+
29
24
  // Auth utilities
30
25
  export {
31
26
  decodeJWT,
@@ -36,11 +31,19 @@ export {
36
31
  export { isTokenExpired } from './singleton/Auth';
37
32
  export { APIAuthMode, DocumentType } from './singleton/API/types';
38
33
  export { Signer } from './Signer';
34
+ export {
35
+ JWT,
36
+ StrictUnion,
37
+ CognitoIdentityPoolConfig,
38
+ JwtPayload,
39
+ AuthStandardAttributeKey,
40
+ AuthVerifiableAttributeKey,
41
+ } from './singleton/Auth/types';
39
42
 
40
43
  // Logging utilities
41
44
  export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
42
45
 
43
- // Platform & device utils
46
+ // Platform & user-agent utilities
44
47
  export { ClientDevice } from './ClientDevice';
45
48
  export {
46
49
  Platform,
@@ -62,7 +65,9 @@ export {
62
65
  PubSubAction,
63
66
  PushNotificationAction,
64
67
  StorageAction,
68
+ SetCustomUserAgentInput,
65
69
  } from './Platform/types';
70
+ export { setCustomUserAgent } from './Platform/customUserAgent';
66
71
 
67
72
  // Service worker
68
73
  export { ServiceWorker } from './ServiceWorker';
@@ -93,4 +98,4 @@ export { base64Decoder, base64Encoder } from './utils/convert';
93
98
  export { getCrypto } from './utils/globalHelpers';
94
99
 
95
100
  // Hub
96
- export { HubClass } from './Hub';
101
+ export { HubInternal } from './Hub';
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ConsoleLogger as Logger } from './Logger';
4
- import { OAuthConfig } from './singleton/Auth/types';
4
+ import { OAuthConfig, AuthStandardAttributeKey, AuthConfigUserAttributes } from './singleton/Auth/types';
5
5
  import { ResourcesConfig } from './singleton/types';
6
6
 
7
7
  const logger = new Logger('parseAWSExports');
@@ -34,6 +34,12 @@ export const parseAWSExports = (
34
34
  aws_appsync_region,
35
35
  aws_cognito_identity_pool_id,
36
36
  aws_cognito_sign_up_verification_method,
37
+ aws_cognito_mfa_configuration,
38
+ aws_cognito_mfa_types,
39
+ aws_cognito_password_protection_settings,
40
+ aws_cognito_verification_mechanisms,
41
+ aws_cognito_signup_attributes,
42
+ aws_cognito_username_attributes,
37
43
  aws_mandatory_sign_in,
38
44
  aws_mobile_analytics_app_id,
39
45
  aws_mobile_analytics_app_region,
@@ -93,18 +99,55 @@ export const parseAWSExports = (
93
99
  }
94
100
 
95
101
  // Auth
102
+ const mfaConfig = aws_cognito_mfa_configuration ? {
103
+ status: aws_cognito_mfa_configuration && aws_cognito_mfa_configuration.toLowerCase(),
104
+ totpEnabled: aws_cognito_mfa_types?.includes('TOTP') ?? false,
105
+ smsEnabled: aws_cognito_mfa_types?.includes('SMS') ?? false
106
+ } : undefined;
107
+ const passwordFormatConfig = aws_cognito_password_protection_settings ? {
108
+ minLength: aws_cognito_password_protection_settings.passwordPolicyMinLength,
109
+ requireLowercase:
110
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_LOWERCASE') ?? false,
111
+ requireUppercase:
112
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_UPPERCASE') ?? false,
113
+ requireNumbers:
114
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_NUMBERS') ?? false,
115
+ requireSpecialCharacters:
116
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes('REQUIRES_SYMBOLS') ?? false,
117
+ } : undefined;
118
+ const mergedUserAttributes = Array.from(
119
+ new Set([
120
+ ...(aws_cognito_verification_mechanisms ?? []),
121
+ ...(aws_cognito_signup_attributes ?? [])
122
+ ])
123
+ );
124
+ const userAttributesConfig = mergedUserAttributes.map((s: string) => ({
125
+ [s.toLowerCase()]: {
126
+ required: true // All user attributes generated by the CLI will be required
127
+ }
128
+ })) as unknown as AuthConfigUserAttributes;
129
+ const loginWithEmailEnabled = aws_cognito_username_attributes?.includes('EMAIL') ?? false;
130
+ const loginWithPhoneEnabled = aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;
96
131
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
97
132
  amplifyConfig.Auth = {
98
133
  Cognito: {
99
134
  identityPoolId: aws_cognito_identity_pool_id,
100
135
  allowGuestAccess: aws_mandatory_sign_in !== 'enable',
101
136
  signUpVerificationMethod: aws_cognito_sign_up_verification_method,
137
+ userAttributes: userAttributesConfig,
102
138
  userPoolClientId: aws_user_pools_web_client_id,
103
139
  userPoolId: aws_user_pools_id,
104
- ...(oauth &&
105
- Object.keys(oauth).length > 0 && {
106
- loginWith: getOAuthConfig(oauth),
107
- }),
140
+ mfa: mfaConfig,
141
+ passwordFormat: passwordFormatConfig,
142
+ loginWith: {
143
+ username: (loginWithEmailEnabled || loginWithPhoneEnabled) ? false : true,
144
+ email: loginWithEmailEnabled,
145
+ phone: loginWithPhoneEnabled,
146
+ ...(oauth &&
147
+ Object.keys(oauth).length > 0 && {
148
+ oauth: getOAuthConfig(oauth),
149
+ }),
150
+ },
108
151
  },
109
152
  };
110
153
  }
@@ -168,12 +211,10 @@ const getOAuthConfig = ({
168
211
  redirectSignIn,
169
212
  redirectSignOut,
170
213
  responseType,
171
- }: Record<string, any>): { oauth: OAuthConfig } => ({
172
- oauth: {
173
- domain,
174
- scopes: scope,
175
- redirectSignIn: getRedirectUrl(redirectSignIn),
176
- redirectSignOut: getRedirectUrl(redirectSignOut),
177
- responseType,
178
- },
214
+ }: Record<string, any>): OAuthConfig => ({
215
+ domain,
216
+ scopes: scope,
217
+ redirectSignIn: getRedirectUrl(redirectSignIn),
218
+ redirectSignOut: getRedirectUrl(redirectSignOut),
219
+ responseType,
179
220
  });
@@ -6,7 +6,7 @@ import { ClientDevice } from '../../../ClientDevice';
6
6
  import {
7
7
  updateEndpoint as clientUpdateEndpoint,
8
8
  UpdateEndpointInput,
9
- } from '../../../AwsClients/Pinpoint';
9
+ } from '../../../awsClients/pinpoint';
10
10
  import { PinpointUpdateEndpointInput } from '../types';
11
11
  import { cacheEndpointId, getEndpointId } from '../utils';
12
12
 
@@ -7,7 +7,7 @@ import {
7
7
  putEvents,
8
8
  PutEventsInput,
9
9
  PutEventsOutput,
10
- } from '../../../AwsClients/Pinpoint';
10
+ } from '../../../awsClients/pinpoint';
11
11
  import {
12
12
  EventBufferConfig,
13
13
  BufferedEvent,
@@ -70,6 +70,33 @@ export type AuthTokens = {
70
70
  accessToken: JWT;
71
71
  };
72
72
 
73
+ export type AuthStandardAttributeKey =
74
+ | 'address'
75
+ | 'birthdate'
76
+ | 'email_verified'
77
+ | 'family_name'
78
+ | 'gender'
79
+ | 'given_name'
80
+ | 'locale'
81
+ | 'middle_name'
82
+ | 'name'
83
+ | 'nickname'
84
+ | 'phone_number_verified'
85
+ | 'picture'
86
+ | 'preferred_username'
87
+ | 'profile'
88
+ | 'sub'
89
+ | 'updated_at'
90
+ | 'website'
91
+ | 'zoneinfo'
92
+ | AuthVerifiableAttributeKey;
93
+
94
+ export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
95
+
96
+ export type AuthConfigUserAttributes = Partial<
97
+ Record<AuthStandardAttributeKey, { required: boolean }>
98
+ >;
99
+
73
100
  export type AuthConfig = StrictUnion<
74
101
  | AuthIdentityPoolConfig
75
102
  | AuthUserPoolConfig
@@ -87,6 +114,11 @@ export type AuthIdentityPoolConfig = {
87
114
  userPoolClientId?: never;
88
115
  userPoolId?: never;
89
116
  loginWith?: never;
117
+ signUpVerificationMethod?: never;
118
+ userAttributes?: never;
119
+ mfa?: never;
120
+ passwordFormat?: never;
121
+ endpoint?: never;
90
122
  };
91
123
  };
92
124
 
@@ -108,7 +140,24 @@ export type CognitoUserPoolConfig = {
108
140
  signUpVerificationMethod?: 'code' | 'link';
109
141
  loginWith?: {
110
142
  oauth?: OAuthConfig;
143
+ username?: boolean;
144
+ email?: boolean;
145
+ phone?: boolean;
146
+ };
147
+ userAttributes?: AuthConfigUserAttributes;
148
+ mfa?: {
149
+ status?: 'on' | 'off' | 'optional';
150
+ totpEnabled?: boolean;
151
+ smsEnabled?: boolean;
152
+ };
153
+ passwordFormat?: {
154
+ minLength?: number;
155
+ requireLowercase?: boolean;
156
+ requireUppercase?: boolean;
157
+ requireNumbers?: boolean;
158
+ requireSpecialCharacters?: boolean;
111
159
  };
160
+ endpoint?: string;
112
161
  };
113
162
 
114
163
  export type OAuthConfig = {
@@ -1,11 +1,11 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { loadGetRandomValues } from '@aws-amplify/react-native';
5
- import { encode, decode } from 'base-64';
4
+ import { loadGetRandomValues, loadBase64 } from '@aws-amplify/react-native';
6
5
  import { AmplifyError } from '../../errors';
7
6
 
8
7
  loadGetRandomValues();
8
+ const { encode, decode } = loadBase64();
9
9
 
10
10
  export const getCrypto = () => {
11
11
  if (
@@ -1,4 +0,0 @@
1
- export { signRequest } from './signRequest';
2
- export { presignUrl } from './presignUrl';
3
- export { TOKEN_QUERY_PARAM } from './constants';
4
- export { getHashedPayload } from './utils/getHashedPayload';
@@ -1,16 +0,0 @@
1
- "use strict";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getHashedPayload = exports.TOKEN_QUERY_PARAM = exports.presignUrl = exports.signRequest = void 0;
6
- var react_native_1 = require("@aws-amplify/react-native");
7
- (0, react_native_1.loadUrlPolyfill)();
8
- // TODO: V6 replace Signer
9
- var signRequest_1 = require("./signRequest");
10
- Object.defineProperty(exports, "signRequest", { enumerable: true, get: function () { return signRequest_1.signRequest; } });
11
- var presignUrl_1 = require("./presignUrl");
12
- Object.defineProperty(exports, "presignUrl", { enumerable: true, get: function () { return presignUrl_1.presignUrl; } });
13
- var constants_1 = require("./constants");
14
- Object.defineProperty(exports, "TOKEN_QUERY_PARAM", { enumerable: true, get: function () { return constants_1.TOKEN_QUERY_PARAM; } });
15
- var getHashedPayload_1 = require("./utils/getHashedPayload");
16
- Object.defineProperty(exports, "getHashedPayload", { enumerable: true, get: function () { return getHashedPayload_1.getHashedPayload; } });
@@ -1,4 +0,0 @@
1
- export { signRequest } from './signRequest';
2
- export { presignUrl } from './presignUrl';
3
- export { TOKEN_QUERY_PARAM } from './constants';
4
- export { getHashedPayload } from './utils/getHashedPayload';
@@ -1,9 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { loadUrlPolyfill } from '@aws-amplify/react-native';
4
- loadUrlPolyfill();
5
- // TODO: V6 replace Signer
6
- export { signRequest } from './signRequest';
7
- export { presignUrl } from './presignUrl';
8
- export { TOKEN_QUERY_PARAM } from './constants';
9
- export { getHashedPayload } from './utils/getHashedPayload';
@@ -1,12 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { loadUrlPolyfill } from '@aws-amplify/react-native';
5
-
6
- loadUrlPolyfill();
7
-
8
- // TODO: V6 replace Signer
9
- export { signRequest } from './signRequest';
10
- export { presignUrl } from './presignUrl';
11
- export { TOKEN_QUERY_PARAM } from './constants';
12
- export { getHashedPayload } from './utils/getHashedPayload';