@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,11 +1,17 @@
1
- export type AuthHubEventData = {
1
+ export type AuthHubEventData =
2
+ /** Dispatched when a user signs in with an oauth provider such as Google.*/
3
+ {
2
4
  event: 'signInWithRedirect';
3
- } | {
5
+ }
6
+ /** Dispatched when there is an error in the oauth flow process.*/
7
+ | {
8
+ event: 'signInWithRedirect_failure';
9
+ }
10
+ /** Dispatched when auth tokens are successfully refreshed.*/
11
+ | {
4
12
  event: 'tokenRefresh';
5
- } | {
13
+ }
14
+ /** Dispatched when there is an error in the refresh of tokens.*/
15
+ | {
6
16
  event: 'tokenRefresh_failure';
7
- } | {
8
- event: 'customOAuthState';
9
- } | {
10
- event: 'customState_failure';
11
17
  };
@@ -1,5 +1,5 @@
1
1
  import { CustomUserAgentDetails, Framework } from './types';
2
- import type { UserAgent as AWSUserAgent } from '@aws-sdk/types';
2
+ import { UserAgent as AWSUserAgent } from '@aws-sdk/types';
3
3
  declare class PlatformBuilder {
4
4
  userAgent: string;
5
5
  get framework(): Framework;
@@ -7,6 +7,6 @@ declare class PlatformBuilder {
7
7
  observeFrameworkChanges(fcn: () => void): void;
8
8
  }
9
9
  export declare const Platform: PlatformBuilder;
10
- export declare const getAmplifyUserAgentObject: ({ category, action, framework, additionalInfo, }?: CustomUserAgentDetails) => AWSUserAgent;
10
+ export declare const getAmplifyUserAgentObject: ({ category, action, framework, }?: CustomUserAgentDetails) => AWSUserAgent;
11
11
  export declare const getAmplifyUserAgent: (customUserAgentDetails?: CustomUserAgentDetails) => string;
12
12
  export {};
@@ -49,15 +49,12 @@ var PlatformBuilder = /** @class */ (function () {
49
49
  }());
50
50
  exports.Platform = new PlatformBuilder();
51
51
  var getAmplifyUserAgentObject = function (_a) {
52
- var _b = _a === void 0 ? {} : _a, category = _b.category, action = _b.action, framework = _b.framework, additionalInfo = _b.additionalInfo;
52
+ var _b = _a === void 0 ? {} : _a, category = _b.category, action = _b.action, framework = _b.framework;
53
53
  var userAgent = [[BASE_USER_AGENT, version_1.version]];
54
54
  if (category) {
55
55
  userAgent.push([category, action]);
56
56
  }
57
- userAgent.push(['framework', framework || (0, detectFramework_1.detectFramework)()]);
58
- if (additionalInfo) {
59
- userAgent = userAgent.concat(additionalInfo);
60
- }
57
+ userAgent.push(['framework', (0, detectFramework_1.detectFramework)()]);
61
58
  return userAgent;
62
59
  };
63
60
  exports.getAmplifyUserAgentObject = getAmplifyUserAgentObject;
@@ -1,4 +1,3 @@
1
- import type { UserAgent as AWSUserAgent } from '@aws-sdk/types';
2
1
  export declare enum Framework {
3
2
  WebUnknown = "0",
4
3
  React = "1",
@@ -44,63 +43,17 @@ export declare enum ApiAction {
44
43
  Head = "7"
45
44
  }
46
45
  export declare enum AuthAction {
47
- SignUp = "1",
48
- ConfirmSignUp = "2",
49
- ResendSignUp = "3",
50
- SignIn = "4",
51
- GetMFAOptions = "5",
52
- GetPreferredMFA = "6",
53
- SetPreferredMFA = "7",
54
- DisableSMS = "8",
55
- EnableSMS = "9",
56
- SetupTOTP = "10",
57
- VerifyTotpToken = "11",
58
- ConfirmSignIn = "12",
59
- CompleteNewPassword = "13",
60
- SendCustomChallengeAnswer = "14",
61
- DeleteUserAttributes = "15",
62
- DeleteUser = "16",
63
- UpdateUserAttributes = "17",
64
- UserAttributes = "18",
65
- CurrentUserPoolUser = "19",
66
- CurrentAuthenticatedUser = "20",
67
- CurrentSession = "21",
68
- VerifyUserAttribute = "22",
69
- VerifyUserAttributeSubmit = "23",
70
- VerifyCurrentUserAttribute = "24",
71
- VerifyCurrentUserAttributeSubmit = "25",
72
- SignOut = "26",
73
- ChangePassword = "27",
74
- ForgotPassword = "28",
75
- ForgotPasswordSubmit = "29",
76
- FederatedSignIn = "30",
77
- VerifiedContact = "31",
78
- UserSession = "32",
79
- CurrentUserCredentials = "33",
80
- CurrentCredentials = "34",
81
- CurrentUserInfo = "35",
82
- RememberDevice = "36",
83
- ForgetDevice = "37",
84
- FetchDevices = "38"
46
+ FederatedSignIn = "30"
85
47
  }
86
48
  export declare enum DataStoreAction {
87
49
  Subscribe = "1",
88
50
  GraphQl = "2"
89
51
  }
90
52
  export declare enum GeoAction {
91
- SearchByText = "1",
92
- SearchForSuggestions = "2",
93
- SearchByPlaceId = "3",
94
- SearchByCoordinates = "4",
95
- SaveGeofences = "5",
96
- GetGeofence = "6",
97
- ListGeofences = "7",
98
- DeleteGeofences = "8"
53
+ None = "0"
99
54
  }
100
55
  export declare enum InAppMessagingAction {
101
- None = "0",
102
- SyncMessages = "1",
103
- IdentifyUser = "2"
56
+ None = "0"
104
57
  }
105
58
  export declare enum InteractionsAction {
106
59
  None = "0"
@@ -122,8 +75,7 @@ export declare enum StorageAction {
122
75
  List = "3",
123
76
  Copy = "4",
124
77
  Remove = "5",
125
- GetProperties = "6",
126
- Cancel = "7"
78
+ GetProperties = "6"
127
79
  }
128
80
  type ActionMap = {
129
81
  [Category.Auth]: AuthAction;
@@ -144,9 +96,6 @@ type UserAgentDetailsWithCategory<T extends Category> = CustomUserAgentDetailsBa
144
96
  };
145
97
  type CustomUserAgentDetailsBase = {
146
98
  framework?: Framework;
147
- /** Accepts an array of arrays with exactly 1 or 2 values and translates
148
- those arrays to "item" or "item1/item2" strings on the custom user agent */
149
- additionalInfo?: AWSUserAgent;
150
99
  };
151
100
  export type CustomUserAgentDetails = (CustomUserAgentDetailsBase & {
152
101
  category?: never;
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.StorageAction = exports.PushNotificationAction = exports.PubSubAction = exports.PredictionsAction = exports.InteractionsAction = exports.InAppMessagingAction = exports.GeoAction = exports.DataStoreAction = exports.AuthAction = exports.ApiAction = exports.AnalyticsAction = exports.Category = exports.Framework = void 0;
4
6
  var Framework;
@@ -54,44 +56,40 @@ var ApiAction;
54
56
  })(ApiAction = exports.ApiAction || (exports.ApiAction = {}));
55
57
  var AuthAction;
56
58
  (function (AuthAction) {
57
- AuthAction["SignUp"] = "1";
58
- AuthAction["ConfirmSignUp"] = "2";
59
- AuthAction["ResendSignUp"] = "3";
60
- AuthAction["SignIn"] = "4";
61
- AuthAction["GetMFAOptions"] = "5";
62
- AuthAction["GetPreferredMFA"] = "6";
63
- AuthAction["SetPreferredMFA"] = "7";
64
- AuthAction["DisableSMS"] = "8";
65
- AuthAction["EnableSMS"] = "9";
66
- AuthAction["SetupTOTP"] = "10";
67
- AuthAction["VerifyTotpToken"] = "11";
68
- AuthAction["ConfirmSignIn"] = "12";
69
- AuthAction["CompleteNewPassword"] = "13";
70
- AuthAction["SendCustomChallengeAnswer"] = "14";
71
- AuthAction["DeleteUserAttributes"] = "15";
72
- AuthAction["DeleteUser"] = "16";
73
- AuthAction["UpdateUserAttributes"] = "17";
74
- AuthAction["UserAttributes"] = "18";
75
- AuthAction["CurrentUserPoolUser"] = "19";
76
- AuthAction["CurrentAuthenticatedUser"] = "20";
77
- AuthAction["CurrentSession"] = "21";
78
- AuthAction["VerifyUserAttribute"] = "22";
79
- AuthAction["VerifyUserAttributeSubmit"] = "23";
80
- AuthAction["VerifyCurrentUserAttribute"] = "24";
81
- AuthAction["VerifyCurrentUserAttributeSubmit"] = "25";
82
- AuthAction["SignOut"] = "26";
83
- AuthAction["ChangePassword"] = "27";
84
- AuthAction["ForgotPassword"] = "28";
85
- AuthAction["ForgotPasswordSubmit"] = "29";
59
+ // SignUp = '1',
60
+ // ConfirmSignUp = '2',
61
+ // ResendSignUp = '3',
62
+ // SignIn = '4',
63
+ // GetMFAOptions = '5',
64
+ // GetPreferredMFA = '6',
65
+ // SetPreferredMFA = '7',
66
+ // DisableSMS = '8',
67
+ // EnableSMS = '9',
68
+ // SetupTOTP = '10',
69
+ // VerifyTotpToken = '11',
70
+ // ConfirmSignIn = '12',
71
+ // CompleteNewPassword = '13',
72
+ // SendCustomChallengeAnswer = '14',
73
+ // DeleteUserAttributes = '15',
74
+ // DeleteUser = '16',
75
+ // UpdateUserAttributes = '17',
76
+ // UserAttributes = '18',
77
+ // CurrentUserPoolUser = '19',
78
+ // CurrentAuthenticatedUser = '20',
79
+ // CurrentSession = '21',
80
+ // VerifyUserAttribute = '22',
81
+ // VerifyUserAttributeSubmit = '23',
82
+ // VerifyCurrentUserAttribute = '24',
83
+ // VerifyCurrentUserAttributeSubmit = '25',
84
+ // SignOut = '26',
85
+ // ChangePassword = '27',
86
+ // ForgotPassword = '28',
87
+ // ForgotPasswordSubmit = '29',
86
88
  AuthAction["FederatedSignIn"] = "30";
87
- AuthAction["VerifiedContact"] = "31";
88
- AuthAction["UserSession"] = "32";
89
- AuthAction["CurrentUserCredentials"] = "33";
90
- AuthAction["CurrentCredentials"] = "34";
91
- AuthAction["CurrentUserInfo"] = "35";
92
- AuthAction["RememberDevice"] = "36";
93
- AuthAction["ForgetDevice"] = "37";
94
- AuthAction["FetchDevices"] = "38";
89
+ // CurrentUserInfo = '31',
90
+ // RememberDevice = '32',
91
+ // ForgetDevice = '33',
92
+ // FetchDevices = '34',
95
93
  })(AuthAction = exports.AuthAction || (exports.AuthAction = {}));
96
94
  var DataStoreAction;
97
95
  (function (DataStoreAction) {
@@ -100,20 +98,11 @@ var DataStoreAction;
100
98
  })(DataStoreAction = exports.DataStoreAction || (exports.DataStoreAction = {}));
101
99
  var GeoAction;
102
100
  (function (GeoAction) {
103
- GeoAction["SearchByText"] = "1";
104
- GeoAction["SearchForSuggestions"] = "2";
105
- GeoAction["SearchByPlaceId"] = "3";
106
- GeoAction["SearchByCoordinates"] = "4";
107
- GeoAction["SaveGeofences"] = "5";
108
- GeoAction["GetGeofence"] = "6";
109
- GeoAction["ListGeofences"] = "7";
110
- GeoAction["DeleteGeofences"] = "8";
101
+ GeoAction["None"] = "0";
111
102
  })(GeoAction = exports.GeoAction || (exports.GeoAction = {}));
112
103
  var InAppMessagingAction;
113
104
  (function (InAppMessagingAction) {
114
105
  InAppMessagingAction["None"] = "0";
115
- InAppMessagingAction["SyncMessages"] = "1";
116
- InAppMessagingAction["IdentifyUser"] = "2";
117
106
  })(InAppMessagingAction = exports.InAppMessagingAction || (exports.InAppMessagingAction = {}));
118
107
  var InteractionsAction;
119
108
  (function (InteractionsAction) {
@@ -141,5 +130,4 @@ var StorageAction;
141
130
  StorageAction["Copy"] = "4";
142
131
  StorageAction["Remove"] = "5";
143
132
  StorageAction["GetProperties"] = "6";
144
- StorageAction["Cancel"] = "7";
145
133
  })(StorageAction = exports.StorageAction || (exports.StorageAction = {}));
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.2f5ba46.0+2f5ba46";
1
+ export declare const version = "6.0.1-console-preview.9e7dd78.0+9e7dd78";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // generated by genversion
5
- exports.version = '6.0.1-console-preview.2f5ba46.0+2f5ba46';
5
+ exports.version = '6.0.1-console-preview.9e7dd78.0+9e7dd78';
package/lib/index.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- export { ClientDevice } from './ClientDevice';
2
- export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
3
1
  export { Hub } from './Hub';
4
2
  export { HubCapsule, HubCallback, HubPayload } from './Hub/types';
5
- export { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
6
- export { AppState, AsyncStorage, Linking } from './RNComponents';
7
- export { Credentials, CredentialsClass } from './Credentials';
8
- export { ICredentials } from './types';
9
3
  export { TokenProvider, AuthTokens, FetchAuthSessionOptions, AWSCredentialsAndIdentityIdProvider, AWSCredentialsAndIdentityId, Identity, OAuthConfig, CognitoUserPoolConfig, } from './singleton/Auth/types';
10
4
  export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, } from './singleton/types';
11
5
  export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
package/lib/index.js CHANGED
@@ -2,28 +2,13 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.parseAWSExports = exports.I18n = exports.Cache = exports.BrowserStorageCache = exports.InMemoryCache = exports.UniversalStorage = exports.MemoryKeyValueStorage = exports.SessionStorage = exports.CookieStorage = exports.LocalStorage = exports.MemoryStorage = exports.StorageHelper = exports.getId = exports.getCredentialsForIdentity = exports.clearCredentials = exports.AmplifyClassV6 = exports.fetchAuthSession = exports.Amplify = exports.CredentialsClass = exports.Credentials = exports.Linking = exports.AsyncStorage = exports.AppState = exports.GoogleOAuth = exports.FacebookOAuth = exports.Hub = exports.Logger = exports.ConsoleLogger = exports.ClientDevice = void 0;
5
+ exports.parseAWSExports = exports.I18n = exports.Cache = exports.BrowserStorageCache = exports.InMemoryCache = exports.UniversalStorage = exports.MemoryKeyValueStorage = exports.SessionStorage = exports.CookieStorage = exports.LocalStorage = exports.MemoryStorage = exports.StorageHelper = exports.getId = exports.getCredentialsForIdentity = exports.clearCredentials = exports.AmplifyClassV6 = exports.fetchAuthSession = exports.Amplify = exports.Hub = void 0;
6
6
  /*
7
7
  This file maps top-level exports from `@aws-amplify/core`. These are intended to be potentially customer-facing exports.
8
8
  */
9
- // TODO Remove these
10
- var ClientDevice_1 = require("./ClientDevice");
11
- Object.defineProperty(exports, "ClientDevice", { enumerable: true, get: function () { return ClientDevice_1.ClientDevice; } });
12
- var Logger_1 = require("./Logger");
13
- Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return Logger_1.ConsoleLogger; } });
14
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.ConsoleLogger; } });
9
+ // Hub exports
15
10
  var Hub_1 = require("./Hub");
16
11
  Object.defineProperty(exports, "Hub", { enumerable: true, get: function () { return Hub_1.Hub; } });
17
- var OAuthHelper_1 = require("./OAuthHelper");
18
- Object.defineProperty(exports, "FacebookOAuth", { enumerable: true, get: function () { return OAuthHelper_1.FacebookOAuth; } });
19
- Object.defineProperty(exports, "GoogleOAuth", { enumerable: true, get: function () { return OAuthHelper_1.GoogleOAuth; } });
20
- var RNComponents_1 = require("./RNComponents");
21
- Object.defineProperty(exports, "AppState", { enumerable: true, get: function () { return RNComponents_1.AppState; } });
22
- Object.defineProperty(exports, "AsyncStorage", { enumerable: true, get: function () { return RNComponents_1.AsyncStorage; } });
23
- Object.defineProperty(exports, "Linking", { enumerable: true, get: function () { return RNComponents_1.Linking; } });
24
- var Credentials_1 = require("./Credentials");
25
- Object.defineProperty(exports, "Credentials", { enumerable: true, get: function () { return Credentials_1.Credentials; } });
26
- Object.defineProperty(exports, "CredentialsClass", { enumerable: true, get: function () { return Credentials_1.CredentialsClass; } });
27
12
  var singleton_1 = require("./singleton");
28
13
  Object.defineProperty(exports, "Amplify", { enumerable: true, get: function () { return singleton_1.Amplify; } });
29
14
  Object.defineProperty(exports, "fetchAuthSession", { enumerable: true, get: function () { return singleton_1.fetchAuthSession; } });
@@ -1,9 +1,10 @@
1
- import { AmplifyConfig } from './types';
1
+ import { ResourcesConfig } from './singleton/types';
2
2
  /**
3
- * This utility generates an `AmplifyConfig` object from an `aws-exports.js` file generated by the Amplify CLI.
3
+ * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
4
+ * consumable by Amplify.
4
5
  *
5
6
  * @param config A configuration object from `aws-exports.js`.
6
7
  *
7
- * @returns An AmplifyConfig object.
8
+ * @returns A {@link ResourcesConfig} object.
8
9
  */
9
- export declare const parseAWSExports: (config: Record<string, any>) => AmplifyConfig;
10
+ export declare const parseAWSExports: (config?: Record<string, any>) => ResourcesConfig;
@@ -12,71 +12,65 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.parseAWSExports = void 0;
15
- var Logger_1 = require("./Logger");
16
- var logger = new Logger_1.ConsoleLogger('Parser');
17
15
  /**
18
- * This utility generates an `AmplifyConfig` object from an `aws-exports.js` file generated by the Amplify CLI.
16
+ * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
17
+ * consumable by Amplify.
19
18
  *
20
19
  * @param config A configuration object from `aws-exports.js`.
21
20
  *
22
- * @returns An AmplifyConfig object.
21
+ * @returns A {@link ResourcesConfig} object.
23
22
  */
24
23
  var parseAWSExports = function (config) {
24
+ if (config === void 0) { config = {}; }
25
+ var aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth;
25
26
  var amplifyConfig = {};
26
27
  // Analytics
27
- if (config['aws_mobile_analytics_app_id']) {
28
- var Analytics = {
28
+ if (aws_mobile_analytics_app_id) {
29
+ amplifyConfig.Analytics = {
29
30
  Pinpoint: {
30
- appId: config['aws_mobile_analytics_app_id'],
31
- region: config['aws_mobile_analytics_app_region'],
31
+ appId: aws_mobile_analytics_app_id,
32
+ region: aws_mobile_analytics_app_region,
32
33
  },
33
34
  };
34
- amplifyConfig.Analytics = Analytics;
35
35
  }
36
36
  // Auth
37
- if (config['aws_cognito_identity_pool_id'] || config['aws_user_pools_id']) {
37
+ if (aws_cognito_identity_pool_id || aws_user_pools_id) {
38
38
  amplifyConfig.Auth = {
39
- userPoolId: config['aws_user_pools_id'],
40
- userPoolWebClientId: config['aws_user_pools_web_client_id'],
41
- region: config['aws_cognito_region'],
42
- identityPoolId: config['aws_cognito_identity_pool_id'],
43
- identityPoolRegion: config['aws_cognito_region'],
44
- mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable',
45
- signUpVerificationMethod: config['aws_cognito_sign_up_verification_method'] || 'code',
39
+ Cognito: __assign({ identityPoolId: aws_cognito_identity_pool_id, allowGuestAccess: aws_mandatory_sign_in !== 'enable', signUpVerificationMethod: aws_cognito_sign_up_verification_method, userPoolClientId: aws_user_pools_web_client_id, userPoolId: aws_user_pools_id }, (oauth && { loginWith: getOAuthConfig(oauth) })),
46
40
  };
47
41
  }
48
42
  // Storage
49
- var storageConfig;
50
- if (config['aws_user_files_s3_bucket']) {
51
- storageConfig = {
52
- AWSS3: {
53
- bucket: config['aws_user_files_s3_bucket'],
54
- region: config['aws_user_files_s3_bucket_region'],
55
- dangerouslyConnectToHttpEndpointForTesting: config['aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing'],
43
+ if (aws_user_files_s3_bucket) {
44
+ amplifyConfig.Storage = {
45
+ S3: {
46
+ bucket: aws_user_files_s3_bucket,
47
+ region: aws_user_files_s3_bucket_region,
48
+ dangerouslyConnectToHttpEndpointForTesting: aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing,
56
49
  },
57
50
  };
58
51
  }
59
- else {
60
- storageConfig = config ? config.Storage || config : {};
61
- }
62
- // Logging
63
- if (config['Logging']) {
64
- amplifyConfig.Logging = __assign(__assign({}, config['Logging']), { region: config['aws_project_region'] });
65
- }
66
52
  // Geo
67
- if (config['geo']) {
68
- amplifyConfig.Geo = Object.assign({}, config.geo);
69
- if (config.geo['amazon_location_service']) {
70
- amplifyConfig.Geo = {
71
- AmazonLocationService: config.geo['amazon_location_service'],
72
- };
73
- }
53
+ if (geo) {
54
+ var amazon_location_service = geo.amazon_location_service;
55
+ amplifyConfig.Geo = amazon_location_service
56
+ ? { AmazonLocationService: amazon_location_service }
57
+ : __assign({}, geo);
74
58
  }
75
- amplifyConfig.Analytics = Object.assign({}, amplifyConfig.Analytics, config.Analytics);
76
- amplifyConfig.Auth = Object.assign({}, amplifyConfig.Auth, config.Auth);
77
- amplifyConfig.Storage = Object.assign({}, storageConfig);
78
- amplifyConfig.Logging = Object.assign({}, amplifyConfig.Logging, config.Logging);
79
- logger.debug('parse config', config, 'to amplifyconfig', amplifyConfig);
80
59
  return amplifyConfig;
81
60
  };
82
61
  exports.parseAWSExports = parseAWSExports;
62
+ var getRedirectUrl = function (redirectStr) {
63
+ return redirectStr.split(',');
64
+ };
65
+ var getOAuthConfig = function (_a) {
66
+ var domain = _a.domain, scope = _a.scope, redirectSignIn = _a.redirectSignIn, redirectSignOut = _a.redirectSignOut, responseType = _a.responseType;
67
+ return ({
68
+ oauth: {
69
+ domain: domain,
70
+ scopes: scope,
71
+ redirectSignIn: getRedirectUrl(redirectSignIn),
72
+ redirectSignOut: getRedirectUrl(redirectSignOut),
73
+ responseType: responseType,
74
+ },
75
+ });
76
+ };
@@ -35,7 +35,7 @@ export type Identity = {
35
35
  type: 'guest' | 'primary';
36
36
  };
37
37
  export interface AWSCredentialsAndIdentityIdProvider {
38
- getCredentialsAndIdentityId: (getCredentialsOptions: GetCredentialsOptions) => Promise<AWSCredentialsAndIdentityId>;
38
+ getCredentialsAndIdentityId: (getCredentialsOptions: GetCredentialsOptions) => Promise<AWSCredentialsAndIdentityId | undefined>;
39
39
  clearCredentialsAndIdentityId: () => void;
40
40
  }
41
41
  export type TokenProvider = {