@aws-amplify/core 6.0.1-console-preview.8d88eef.0 → 6.0.1-console-preview.be08038.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 (62) hide show
  1. package/lib/Cache/StorageCacheCommon.js +1 -4
  2. package/lib/I18n/I18n.js +1 -6
  3. package/lib/Platform/version.d.ts +1 -1
  4. package/lib/Platform/version.js +1 -1
  5. package/lib/Reachability/Reachability.js +6 -1
  6. package/lib/index.d.ts +2 -1
  7. package/lib/libraryUtils.d.ts +2 -0
  8. package/lib/libraryUtils.js +4 -1
  9. package/lib/parseAWSExports.js +26 -6
  10. package/lib/singleton/Auth/types.d.ts +2 -2
  11. package/lib/singleton/Interactions/types.d.ts +21 -0
  12. package/lib/singleton/Interactions/types.js +4 -0
  13. package/lib/singleton/types.d.ts +3 -5
  14. package/lib/tsconfig.tsbuildinfo +1 -1
  15. package/lib/utils/deepFreeze.js +1 -1
  16. package/lib/utils/sessionListener/SessionListener.d.ts +10 -0
  17. package/lib/utils/sessionListener/SessionListener.js +55 -0
  18. package/lib/utils/sessionListener/SessionListener.native.d.ts +10 -0
  19. package/lib/utils/sessionListener/SessionListener.native.js +54 -0
  20. package/lib/utils/sessionListener/index.d.ts +2 -0
  21. package/lib/utils/sessionListener/index.js +7 -0
  22. package/lib/utils/sessionListener/types.d.ts +6 -0
  23. package/lib/utils/sessionListener/types.js +4 -0
  24. package/lib-esm/Cache/StorageCacheCommon.js +1 -4
  25. package/lib-esm/I18n/I18n.js +1 -6
  26. package/lib-esm/Platform/version.d.ts +1 -1
  27. package/lib-esm/Platform/version.js +1 -1
  28. package/lib-esm/Reachability/Reachability.js +7 -2
  29. package/lib-esm/index.d.ts +2 -1
  30. package/lib-esm/libraryUtils.d.ts +2 -0
  31. package/lib-esm/libraryUtils.js +2 -0
  32. package/lib-esm/parseAWSExports.js +26 -6
  33. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  34. package/lib-esm/singleton/Interactions/types.d.ts +21 -0
  35. package/lib-esm/singleton/Interactions/types.js +3 -0
  36. package/lib-esm/singleton/types.d.ts +3 -5
  37. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  38. package/lib-esm/utils/deepFreeze.js +1 -1
  39. package/lib-esm/utils/sessionListener/SessionListener.d.ts +10 -0
  40. package/lib-esm/utils/sessionListener/SessionListener.js +52 -0
  41. package/lib-esm/utils/sessionListener/SessionListener.native.d.ts +10 -0
  42. package/lib-esm/utils/sessionListener/SessionListener.native.js +51 -0
  43. package/lib-esm/utils/sessionListener/index.d.ts +2 -0
  44. package/lib-esm/utils/sessionListener/index.js +4 -0
  45. package/lib-esm/utils/sessionListener/types.d.ts +6 -0
  46. package/lib-esm/utils/sessionListener/types.js +3 -0
  47. package/package.json +4 -4
  48. package/src/Cache/StorageCacheCommon.ts +0 -4
  49. package/src/I18n/I18n.ts +1 -6
  50. package/src/Platform/version.ts +1 -1
  51. package/src/Reachability/Reachability.ts +8 -2
  52. package/src/index.ts +1 -1
  53. package/src/libraryUtils.ts +4 -0
  54. package/src/parseAWSExports.ts +34 -7
  55. package/src/singleton/Auth/types.ts +2 -2
  56. package/src/singleton/Interactions/types.ts +29 -0
  57. package/src/singleton/types.ts +3 -7
  58. package/src/utils/deepFreeze.ts +1 -1
  59. package/src/utils/sessionListener/SessionListener.native.ts +70 -0
  60. package/src/utils/sessionListener/SessionListener.ts +74 -0
  61. package/src/utils/sessionListener/index.ts +6 -0
  62. package/src/utils/sessionListener/types.ts +11 -0
@@ -61,7 +61,6 @@ var __values = (this && this.__values) || function(o) {
61
61
  };
62
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
63
  exports.StorageCacheCommon = void 0;
64
- var singleton_1 = require("../singleton");
65
64
  var Logger_1 = require("../Logger");
66
65
  var constants_1 = require("./constants");
67
66
  var utils_1 = require("./utils");
@@ -79,9 +78,7 @@ var StorageCacheCommon = /** @class */ (function () {
79
78
  */
80
79
  function StorageCacheCommon(_a) {
81
80
  var config = _a.config, keyValueStorage = _a.keyValueStorage;
82
- var _b;
83
- var globalCacheConfig = (_b = singleton_1.Amplify.getConfig().Cache) !== null && _b !== void 0 ? _b : {};
84
- this.config = __assign(__assign(__assign({}, constants_1.defaultConfig), globalCacheConfig), config);
81
+ this.config = __assign(__assign({}, constants_1.defaultConfig), config);
85
82
  this.keyValueStorage = keyValueStorage;
86
83
  this.sanitizeConfig();
87
84
  }
package/lib/I18n/I18n.js CHANGED
@@ -15,7 +15,6 @@ var __assign = (this && this.__assign) || function () {
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.I18n = void 0;
17
17
  var Logger_1 = require("../Logger");
18
- var singleton_1 = require("../singleton");
19
18
  var logger = new Logger_1.ConsoleLogger('I18n');
20
19
  /**
21
20
  * Language translation utility.
@@ -44,11 +43,7 @@ var I18n = /** @class */ (function () {
44
43
  * Sets the default language from the configuration when required.
45
44
  */
46
45
  I18n.prototype.setDefaultLanguage = function () {
47
- if (!this._lang) {
48
- var i18nConfig = singleton_1.Amplify.getConfig().I18n;
49
- this._lang = i18nConfig === null || i18nConfig === void 0 ? void 0 : i18nConfig.language;
50
- }
51
- // Default to window language if not set in config
46
+ // Default to window language if not set in instance
52
47
  if (!this._lang &&
53
48
  typeof window !== 'undefined' &&
54
49
  window &&
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.8d88eef.0+8d88eef";
1
+ export declare const version = "6.0.1-console-preview.be08038.0+be08038";
@@ -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.8d88eef.0+8d88eef';
5
+ exports.version = '6.0.1-console-preview.be08038.0+be08038';
@@ -20,7 +20,12 @@ var Reachability = exports.Reachability = /** @class */ (function () {
20
20
  function Reachability() {
21
21
  }
22
22
  Reachability.prototype.networkMonitor = function (_) {
23
- var globalObj = (0, libraryUtils_1.isWebWorker)() ? self : window;
23
+ var globalObj = (0, libraryUtils_1.isWebWorker)()
24
+ ? self
25
+ : typeof window !== 'undefined' && window;
26
+ if (!globalObj) {
27
+ return (0, rxjs_1.from)([{ online: true }]);
28
+ }
24
29
  return new rxjs_1.Observable(function (observer) {
25
30
  observer.next({ online: globalObj.navigator.onLine });
26
31
  var notifyOnline = function () { return observer.next({ online: true }); };
package/lib/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  export { Hub } from './Hub';
2
2
  export { HubCapsule, HubCallback, HubPayload } from './Hub/types';
3
3
  export { TokenProvider, AuthTokens, FetchAuthSessionOptions, AWSCredentialsAndIdentityIdProvider, AWSCredentialsAndIdentityId, Identity, OAuthConfig, CognitoUserPoolConfig, } from './singleton/Auth/types';
4
- export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, APIConfig, CacheConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, GeoConfig, } from './singleton/types';
4
+ export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, APIConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, GeoConfig, } from './singleton/types';
5
5
  export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
6
6
  export { getCredentialsForIdentity, getId, GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, } from './awsClients/cognitoIdentity';
7
7
  export { UserProfile } from './types';
8
8
  export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  export { Cache } from './Cache';
11
+ export { CacheConfig } from './Cache/types';
11
12
  export { I18n } from './I18n';
12
13
  export { ConsoleLogger } from './Logger';
13
14
  export { ServiceWorker } from './ServiceWorker';
@@ -22,3 +22,5 @@ export { AMPLIFY_SYMBOL } from './Hub';
22
22
  export { base64Decoder, base64Encoder } from './utils/convert';
23
23
  export { getCrypto } from './utils/globalHelpers';
24
24
  export { HubInternal } from './Hub';
25
+ export { sessionListener } from './utils/sessionListener';
26
+ export { SessionState } from './utils/sessionListener/types';
@@ -3,7 +3,7 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.base64Encoder = exports.base64Decoder = exports.AMPLIFY_SYMBOL = exports.fetchAuthSession = exports.USER_AGENT_HEADER = exports.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = exports.Reachability = exports.Mutex = exports.BackgroundProcessManager = exports.AmplifyErrorCode = exports.createAssertionFunction = exports.PlatformNotSupportedError = exports.AmplifyError = exports.setCustomUserAgent = exports.StorageAction = exports.PushNotificationAction = exports.PubSubAction = exports.PredictionsAction = exports.InAppMessagingAction = exports.InteractionsAction = exports.GeoAction = exports.Framework = exports.DataStoreAction = exports.Category = exports.AnalyticsAction = exports.AuthAction = exports.ApiAction = exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = exports.Signer = exports.isTokenExpired = exports.assertOAuthConfig = exports.assertIdentityPoolIdConfig = exports.assertTokenProviderConfig = exports.decodeJWT = exports.AmplifyUrlSearchParams = exports.AmplifyUrl = exports.amplifyUuid = exports.parseAWSExports = exports.urlSafeEncode = exports.urlSafeDecode = exports.retry = exports.NonRetryableError = exports.jitteredExponentialRetry = exports.jitteredBackoff = exports.isWebWorker = exports.isNonRetryableError = exports.isBrowser = exports.generateRandomString = void 0;
6
- exports.HubInternal = exports.getCrypto = void 0;
6
+ exports.sessionListener = exports.HubInternal = exports.getCrypto = void 0;
7
7
  /*
8
8
  This file maps top-level exports from `@aws-amplify/core/internals/utils`. These are intended to be internal
9
9
  utils for use throughout the library.
@@ -87,3 +87,6 @@ Object.defineProperty(exports, "getCrypto", { enumerable: true, get: function ()
87
87
  // Hub
88
88
  var Hub_2 = require("./Hub");
89
89
  Object.defineProperty(exports, "HubInternal", { enumerable: true, get: function () { return Hub_2.HubInternal; } });
90
+ // Session listener
91
+ var sessionListener_1 = require("./utils/sessionListener");
92
+ Object.defineProperty(exports, "sessionListener", { enumerable: true, get: function () { return sessionListener_1.sessionListener; } });
@@ -60,7 +60,7 @@ var authTypeMapping = {
60
60
  var parseAWSExports = function (config) {
61
61
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
62
62
  if (config === void 0) { config = {}; }
63
- var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, 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_cognito_mfa_configuration = config.aws_cognito_mfa_configuration, aws_cognito_mfa_types = config.aws_cognito_mfa_types, aws_cognito_password_protection_settings = config.aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms = config.aws_cognito_verification_mechanisms, aws_cognito_signup_attributes = config.aws_cognito_signup_attributes, aws_cognito_username_attributes = config.aws_cognito_username_attributes, 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, aws_cloud_logic_custom = config.aws_cloud_logic_custom, Notifications = config.Notifications;
63
+ var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, aws_bots = config.aws_bots, aws_bots_config = config.aws_bots_config, 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_cognito_mfa_configuration = config.aws_cognito_mfa_configuration, aws_cognito_mfa_types = config.aws_cognito_mfa_types, aws_cognito_password_protection_settings = config.aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms = config.aws_cognito_verification_mechanisms, aws_cognito_signup_attributes = config.aws_cognito_signup_attributes, aws_cognito_social_providers = config.aws_cognito_social_providers, aws_cognito_username_attributes = config.aws_cognito_username_attributes, 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, aws_cloud_logic_custom = config.aws_cloud_logic_custom, Notifications = config.Notifications;
64
64
  var amplifyConfig = {};
65
65
  // Analytics
66
66
  if (aws_mobile_analytics_app_id) {
@@ -94,6 +94,12 @@ var parseAWSExports = function (config) {
94
94
  };
95
95
  }
96
96
  }
97
+ // Interactions
98
+ if (Array.isArray(aws_bots_config)) {
99
+ amplifyConfig.Interactions = {
100
+ LexV1: Object.fromEntries(aws_bots_config.map(function (bot) { return [bot.name, bot]; })),
101
+ };
102
+ }
97
103
  // API
98
104
  if (aws_appsync_graphqlEndpoint) {
99
105
  var defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];
@@ -149,13 +155,21 @@ var parseAWSExports = function (config) {
149
155
  userPoolId: aws_user_pools_id,
150
156
  mfa: mfaConfig,
151
157
  passwordFormat: passwordFormatConfig,
152
- loginWith: __assign({ username: loginWithEmailEnabled || loginWithPhoneEnabled ? false : true, email: loginWithEmailEnabled, phone: loginWithPhoneEnabled }, (oauth &&
153
- Object.keys(oauth).length > 0 && {
154
- oauth: getOAuthConfig(oauth),
155
- })),
158
+ loginWith: {
159
+ username: loginWithEmailEnabled || loginWithPhoneEnabled ? false : true,
160
+ email: loginWithEmailEnabled,
161
+ phone: loginWithPhoneEnabled
162
+ },
156
163
  },
157
164
  };
158
165
  }
166
+ var hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;
167
+ var hasSocialProviderConfig = aws_cognito_social_providers ? aws_cognito_social_providers.length > 0 : false;
168
+ if (amplifyConfig.Auth && hasOAuthConfig) {
169
+ amplifyConfig.Auth.Cognito.loginWith = __assign(__assign({}, amplifyConfig.Auth.Cognito.loginWith), { oauth: __assign(__assign({}, (getOAuthConfig(oauth))), (hasSocialProviderConfig && {
170
+ providers: parseSocialProviders(aws_cognito_social_providers)
171
+ })) });
172
+ }
159
173
  // Storage
160
174
  if (aws_user_files_s3_bucket) {
161
175
  amplifyConfig.Storage = {
@@ -196,6 +210,12 @@ var getOAuthConfig = function (_a) {
196
210
  scopes: scope,
197
211
  redirectSignIn: getRedirectUrl(redirectSignIn),
198
212
  redirectSignOut: getRedirectUrl(redirectSignOut),
199
- responseType: responseType,
213
+ responseType: responseType
214
+ });
215
+ };
216
+ var parseSocialProviders = function (aws_cognito_social_providers) {
217
+ return aws_cognito_social_providers.map(function (provider) {
218
+ var updatedProvider = provider.toLowerCase();
219
+ return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);
200
220
  });
201
221
  };
@@ -112,9 +112,9 @@ export type OAuthConfig = {
112
112
  redirectSignIn: Array<string>;
113
113
  redirectSignOut: Array<string>;
114
114
  responseType: 'code' | 'token';
115
- providers?: Array<OAuthProviders | CustomProvider>;
115
+ providers?: Array<OAuthProvider | CustomProvider>;
116
116
  };
117
- type OAuthProviders = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
117
+ export type OAuthProvider = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
118
118
  type CustomProvider = {
119
119
  custom: string;
120
120
  };
@@ -0,0 +1,21 @@
1
+ interface LexV1BotConfig {
2
+ alias: string;
3
+ region: string;
4
+ }
5
+ interface LexV2BotConfig {
6
+ botId: string;
7
+ aliasId: string;
8
+ localeId: string;
9
+ region: string;
10
+ }
11
+ type InteractionsLexV1Config = {
12
+ LexV1: Record<string, LexV1BotConfig>;
13
+ };
14
+ type InteractionsLexV2Config = {
15
+ LexV2: Record<string, LexV2BotConfig>;
16
+ };
17
+ type AtLeastOne<T, U = {
18
+ [K in keyof T]: Pick<T, K>;
19
+ }> = Partial<T> & U[keyof U];
20
+ export type InteractionsConfig = AtLeastOne<InteractionsLexV1Config & InteractionsLexV2Config>;
21
+ export {};
@@ -0,0 +1,4 @@
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 });
@@ -1,11 +1,10 @@
1
1
  import { APIConfig, LibraryAPIOptions } from './API/types';
2
2
  import { AnalyticsConfig } from './Analytics/types';
3
3
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
- import { CacheConfig } from './Cache/types';
5
4
  import { GeoConfig } from './Geo/types';
6
5
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
7
- import { I18nConfig } from '../I18n/types';
8
6
  import { NotificationsConfig } from './Notifications/types';
7
+ import { InteractionsConfig } from './Interactions/types';
9
8
  export type LegacyConfig = {
10
9
  /**
11
10
  * @deprecated The field should not be used.
@@ -16,8 +15,7 @@ export type ResourcesConfig = {
16
15
  API?: APIConfig;
17
16
  Analytics?: AnalyticsConfig;
18
17
  Auth?: AuthConfig;
19
- Cache?: CacheConfig;
20
- I18n?: I18nConfig;
18
+ Interactions?: InteractionsConfig;
21
19
  Notifications?: NotificationsConfig;
22
20
  Storage?: StorageConfig;
23
21
  Geo?: GeoConfig;
@@ -28,4 +26,4 @@ export type LibraryOptions = {
28
26
  Storage?: LibraryStorageOptions;
29
27
  ssr?: boolean;
30
28
  };
31
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, CacheConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
29
+ export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, InteractionsConfig, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };