@aws-amplify/core 6.0.1-console-preview.2f5ba46.0 → 6.0.1-console-preview.9e7dd78.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 (43) hide show
  1. package/lib/Hub/types/AuthTypes.d.ts +13 -7
  2. package/lib/Platform/index.d.ts +2 -2
  3. package/lib/Platform/index.js +2 -5
  4. package/lib/Platform/types.d.ts +4 -55
  5. package/lib/Platform/types.js +36 -48
  6. package/lib/Platform/version.d.ts +1 -1
  7. package/lib/Platform/version.js +1 -1
  8. package/lib/index.d.ts +0 -6
  9. package/lib/index.js +2 -17
  10. package/lib/parseAWSExports.d.ts +5 -4
  11. package/lib/parseAWSExports.js +37 -43
  12. package/lib/singleton/Auth/types.d.ts +1 -1
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/lib/types/core.d.ts +0 -8
  15. package/lib-esm/Hub/types/AuthTypes.d.ts +13 -7
  16. package/lib-esm/Platform/index.d.ts +2 -2
  17. package/lib-esm/Platform/index.js +2 -5
  18. package/lib-esm/Platform/types.d.ts +4 -55
  19. package/lib-esm/Platform/types.js +36 -48
  20. package/lib-esm/Platform/version.d.ts +1 -1
  21. package/lib-esm/Platform/version.js +1 -1
  22. package/lib-esm/index.d.ts +0 -6
  23. package/lib-esm/index.js +1 -6
  24. package/lib-esm/parseAWSExports.d.ts +5 -4
  25. package/lib-esm/parseAWSExports.js +37 -43
  26. package/lib-esm/singleton/Auth/types.d.ts +1 -1
  27. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  28. package/lib-esm/types/core.d.ts +0 -8
  29. package/package.json +2 -26
  30. package/src/Cache/CHANGELOG.md +12 -0
  31. package/src/Hub/types/AuthTypes.ts +8 -6
  32. package/src/Platform/index.ts +3 -8
  33. package/src/Platform/types.ts +34 -56
  34. package/src/Platform/version.ts +1 -1
  35. package/src/index.ts +1 -7
  36. package/src/parseAWSExports.ts +69 -63
  37. package/src/singleton/Auth/types.ts +1 -1
  38. package/src/types/core.ts +0 -10
  39. package/lib/Credentials.d.ts +0 -47
  40. package/lib/Credentials.js +0 -676
  41. package/lib-esm/Credentials.d.ts +0 -47
  42. package/lib-esm/Credentials.js +0 -673
  43. package/src/Credentials.ts +0 -630
@@ -1,6 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import type { UserAgent as AWSUserAgent } from '@aws-sdk/types';
4
3
 
5
4
  export enum Framework {
6
5
  // < 100 - Web frameworks
@@ -54,63 +53,50 @@ export enum ApiAction {
54
53
  Head = '7',
55
54
  }
56
55
  export enum AuthAction {
57
- SignUp = '1',
58
- ConfirmSignUp = '2',
59
- ResendSignUp = '3',
60
- SignIn = '4',
61
- GetMFAOptions = '5',
62
- GetPreferredMFA = '6',
63
- SetPreferredMFA = '7',
64
- DisableSMS = '8',
65
- EnableSMS = '9',
66
- SetupTOTP = '10',
67
- VerifyTotpToken = '11',
68
- ConfirmSignIn = '12',
69
- CompleteNewPassword = '13',
70
- SendCustomChallengeAnswer = '14',
71
- DeleteUserAttributes = '15',
72
- DeleteUser = '16',
73
- UpdateUserAttributes = '17',
74
- UserAttributes = '18',
75
- CurrentUserPoolUser = '19',
76
- CurrentAuthenticatedUser = '20',
77
- CurrentSession = '21',
78
- VerifyUserAttribute = '22',
79
- VerifyUserAttributeSubmit = '23',
80
- VerifyCurrentUserAttribute = '24',
81
- VerifyCurrentUserAttributeSubmit = '25',
82
- SignOut = '26',
83
- ChangePassword = '27',
84
- ForgotPassword = '28',
85
- ForgotPasswordSubmit = '29',
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',
86
85
  FederatedSignIn = '30',
87
- VerifiedContact = '31',
88
- UserSession = '32',
89
- CurrentUserCredentials = '33',
90
- CurrentCredentials = '34',
91
- CurrentUserInfo = '35',
92
- RememberDevice = '36',
93
- ForgetDevice = '37',
94
- FetchDevices = '38',
86
+ // CurrentUserInfo = '31',
87
+ // RememberDevice = '32',
88
+ // ForgetDevice = '33',
89
+ // FetchDevices = '34',
95
90
  }
96
91
  export enum DataStoreAction {
97
92
  Subscribe = '1',
98
93
  GraphQl = '2',
99
94
  }
100
95
  export enum GeoAction {
101
- SearchByText = '1',
102
- SearchForSuggestions = '2',
103
- SearchByPlaceId = '3',
104
- SearchByCoordinates = '4',
105
- SaveGeofences = '5',
106
- GetGeofence = '6',
107
- ListGeofences = '7',
108
- DeleteGeofences = '8',
96
+ None = '0',
109
97
  }
110
98
  export enum InAppMessagingAction {
111
99
  None = '0',
112
- SyncMessages = '1',
113
- IdentifyUser = '2',
114
100
  }
115
101
  export enum InteractionsAction {
116
102
  None = '0',
@@ -133,7 +119,6 @@ export enum StorageAction {
133
119
  Copy = '4',
134
120
  Remove = '5',
135
121
  GetProperties = '6',
136
- Cancel = '7',
137
122
  }
138
123
 
139
124
  type ActionMap = {
@@ -158,15 +143,8 @@ type UserAgentDetailsWithCategory<T extends Category> =
158
143
 
159
144
  type CustomUserAgentDetailsBase = {
160
145
  framework?: Framework;
161
- // DO NOT REMOVE:
162
- // Used by other Amplify teams to pass information to the custom user agent
163
- /** Accepts an array of arrays with exactly 1 or 2 values and translates
164
- those arrays to "item" or "item1/item2" strings on the custom user agent */
165
- additionalInfo?: AWSUserAgent;
166
146
  };
167
147
 
168
- // DO NOT MAKE ANY PROP REQUIRED on CustomUserAgentDetails
169
- // This object is used by other Amplify teams to pass information to the user agent
170
148
  export type CustomUserAgentDetails =
171
149
  | (CustomUserAgentDetailsBase & { category?: never; action?: never })
172
150
  | UserAgentDetailsWithCategory<Category.API>
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.1-console-preview.2f5ba46.0+2f5ba46';
2
+ export const version = '6.0.1-console-preview.9e7dd78.0+9e7dd78';
package/src/index.ts CHANGED
@@ -4,15 +4,9 @@
4
4
  /*
5
5
  This file maps top-level exports from `@aws-amplify/core`. These are intended to be potentially customer-facing exports.
6
6
  */
7
- // TODO Remove these
8
- export { ClientDevice } from './ClientDevice';
9
- export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
7
+ // Hub exports
10
8
  export { Hub } from './Hub';
11
9
  export { HubCapsule, HubCallback, HubPayload } from './Hub/types';
12
- export { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
13
- export { AppState, AsyncStorage, Linking } from './RNComponents';
14
- export { Credentials, CredentialsClass } from './Credentials';
15
- export { ICredentials } from './types';
16
10
 
17
11
  // Singleton exports
18
12
  export {
@@ -1,91 +1,97 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AmplifyConfig } from './types';
4
- import { ConsoleLogger as Logger } from './Logger';
5
-
6
- const logger = new Logger('Parser');
3
+ import { OAuthConfig } from './singleton/Auth/types';
4
+ import { ResourcesConfig } from './singleton/types';
7
5
 
8
6
  /**
9
- * This utility generates an `AmplifyConfig` object from an `aws-exports.js` file generated by the Amplify CLI.
10
- *
7
+ * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
8
+ * consumable by Amplify.
9
+ *
11
10
  * @param config A configuration object from `aws-exports.js`.
12
- *
13
- * @returns An AmplifyConfig object.
11
+ *
12
+ * @returns A {@link ResourcesConfig} object.
14
13
  */
15
- export const parseAWSExports = (config:Record<string,any>): AmplifyConfig => {
16
- const amplifyConfig: AmplifyConfig = {};
14
+ export const parseAWSExports = (
15
+ config: Record<string, any> = {}
16
+ ): ResourcesConfig => {
17
+ const {
18
+ aws_cognito_identity_pool_id,
19
+ aws_cognito_sign_up_verification_method,
20
+ aws_mandatory_sign_in,
21
+ aws_mobile_analytics_app_id,
22
+ aws_mobile_analytics_app_region,
23
+ aws_user_files_s3_bucket,
24
+ aws_user_files_s3_bucket_region,
25
+ aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,
26
+ aws_user_pools_id,
27
+ aws_user_pools_web_client_id,
28
+ geo,
29
+ oauth,
30
+ } = config;
31
+ const amplifyConfig: ResourcesConfig = {};
32
+
17
33
  // Analytics
18
- if (config['aws_mobile_analytics_app_id']) {
19
- const Analytics = {
34
+ if (aws_mobile_analytics_app_id) {
35
+ amplifyConfig.Analytics = {
20
36
  Pinpoint: {
21
- appId: config['aws_mobile_analytics_app_id'],
22
- region: config['aws_mobile_analytics_app_region'],
37
+ appId: aws_mobile_analytics_app_id,
38
+ region: aws_mobile_analytics_app_region,
23
39
  },
24
40
  };
25
- amplifyConfig.Analytics = Analytics;
26
41
  }
27
42
 
28
43
  // Auth
29
- if (config['aws_cognito_identity_pool_id'] || config['aws_user_pools_id']) {
44
+ if (aws_cognito_identity_pool_id || aws_user_pools_id) {
30
45
  amplifyConfig.Auth = {
31
- userPoolId: config['aws_user_pools_id'],
32
- userPoolWebClientId: config['aws_user_pools_web_client_id'],
33
- region: config['aws_cognito_region'],
34
- identityPoolId: config['aws_cognito_identity_pool_id'],
35
- identityPoolRegion: config['aws_cognito_region'],
36
- mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable',
37
- signUpVerificationMethod:
38
- config['aws_cognito_sign_up_verification_method'] || 'code',
46
+ Cognito: {
47
+ identityPoolId: aws_cognito_identity_pool_id,
48
+ allowGuestAccess: aws_mandatory_sign_in !== 'enable',
49
+ signUpVerificationMethod: aws_cognito_sign_up_verification_method,
50
+ userPoolClientId: aws_user_pools_web_client_id,
51
+ userPoolId: aws_user_pools_id,
52
+ ...(oauth && { loginWith: getOAuthConfig(oauth) }),
53
+ },
39
54
  };
40
55
  }
41
56
 
42
57
  // Storage
43
- let storageConfig;
44
- if (config['aws_user_files_s3_bucket']) {
45
- storageConfig = {
46
- AWSS3: {
47
- bucket: config['aws_user_files_s3_bucket'],
48
- region: config['aws_user_files_s3_bucket_region'],
58
+ if (aws_user_files_s3_bucket) {
59
+ amplifyConfig.Storage = {
60
+ S3: {
61
+ bucket: aws_user_files_s3_bucket,
62
+ region: aws_user_files_s3_bucket_region,
49
63
  dangerouslyConnectToHttpEndpointForTesting:
50
- config[
51
- 'aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing'
52
- ],
64
+ aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,
53
65
  },
54
66
  };
55
- } else {
56
- storageConfig = config ? config.Storage || config : {};
57
- }
58
-
59
- // Logging
60
- if (config['Logging']) {
61
- amplifyConfig.Logging = {
62
- ...config['Logging'],
63
- region: config['aws_project_region'],
64
- };
65
67
  }
66
68
 
67
69
  // Geo
68
- if (config['geo']) {
69
- amplifyConfig.Geo = Object.assign({}, config.geo);
70
- if (config.geo['amazon_location_service']) {
71
- amplifyConfig.Geo = {
72
- AmazonLocationService: config.geo['amazon_location_service'],
73
- };
74
- }
70
+ if (geo) {
71
+ const { amazon_location_service } = geo;
72
+ (amplifyConfig as any).Geo = amazon_location_service
73
+ ? { AmazonLocationService: amazon_location_service }
74
+ : { ...geo };
75
75
  }
76
76
 
77
- amplifyConfig.Analytics = Object.assign(
78
- {},
79
- amplifyConfig.Analytics,
80
- config.Analytics
81
- );
82
- amplifyConfig.Auth = Object.assign({}, amplifyConfig.Auth, config.Auth);
83
- amplifyConfig.Storage = Object.assign({}, storageConfig);
84
- amplifyConfig.Logging = Object.assign(
85
- {},
86
- amplifyConfig.Logging,
87
- config.Logging
88
- );
89
- logger.debug('parse config', config, 'to amplifyconfig', amplifyConfig);
90
77
  return amplifyConfig;
91
78
  };
79
+
80
+ const getRedirectUrl = (redirectStr: string): string[] =>
81
+ redirectStr.split(',');
82
+
83
+ const getOAuthConfig = ({
84
+ domain,
85
+ scope,
86
+ redirectSignIn,
87
+ redirectSignOut,
88
+ responseType,
89
+ }: Record<string, any>): { oauth: OAuthConfig } => ({
90
+ oauth: {
91
+ domain,
92
+ scopes: scope,
93
+ redirectSignIn: getRedirectUrl(redirectSignIn),
94
+ redirectSignOut: getRedirectUrl(redirectSignOut),
95
+ responseType,
96
+ },
97
+ });
@@ -49,7 +49,7 @@ export type Identity = {
49
49
  export interface AWSCredentialsAndIdentityIdProvider {
50
50
  getCredentialsAndIdentityId: (
51
51
  getCredentialsOptions: GetCredentialsOptions
52
- ) => Promise<AWSCredentialsAndIdentityId>;
52
+ ) => Promise<AWSCredentialsAndIdentityId | undefined>;
53
53
  clearCredentialsAndIdentityId: () => void;
54
54
  }
55
55
 
package/src/types/core.ts CHANGED
@@ -38,16 +38,6 @@ export type UserProfile = {
38
38
  metrics?: Record<string, number>;
39
39
  };
40
40
 
41
- export interface ICredentials {
42
- accessKeyId: string;
43
- sessionToken: string;
44
- secretAccessKey: string;
45
- identityId: string;
46
- authenticated: boolean;
47
- // Long term creds do not provide an expiration date
48
- expiration?: Date;
49
- }
50
-
51
41
  /**
52
42
  * @internal
53
43
  */
@@ -1,47 +0,0 @@
1
- import { ICredentials } from './types';
2
- export declare class CredentialsClass {
3
- private _config;
4
- private _credentials;
5
- private _credentials_source;
6
- private _gettingCredPromise;
7
- private _refreshHandlers;
8
- private _storage;
9
- private _storageSync;
10
- private _identityId;
11
- private _nextCredentialsRefresh;
12
- Auth: undefined;
13
- constructor(config: any);
14
- getModuleName(): string;
15
- getCredSource(): any;
16
- configure(config: any): any;
17
- get(): any;
18
- private _getCognitoIdentityIdStorageKey;
19
- private _pickupCredentials;
20
- private _keepAlive;
21
- refreshFederatedToken(federatedInfo: any): Promise<ICredentials>;
22
- private _providerRefreshWithRetry;
23
- private _isExpired;
24
- private _isPastTTL;
25
- private _setCredentialsForGuest;
26
- private _setCredentialsFromFederation;
27
- private _setCredentialsFromSession;
28
- private _loadCredentials;
29
- set(params: any, source: any): Promise<ICredentials>;
30
- clear(): Promise<void>;
31
- private _getGuestIdentityId;
32
- private _setGuestIdentityId;
33
- private _removeGuestIdentityId;
34
- /**
35
- * Compact version of credentials
36
- * @param {Object} credentials
37
- * @return {Object} - Credentials
38
- */
39
- shear(credentials: any): {
40
- accessKeyId: any;
41
- sessionToken: any;
42
- secretAccessKey: any;
43
- identityId: any;
44
- authenticated: any;
45
- };
46
- }
47
- export declare const Credentials: CredentialsClass;