@aws-amplify/core 6.0.1-console-preview.5a31ca1.0 → 6.0.1-console-preview.8f82e46.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 (37) hide show
  1. package/lib/Platform/version.d.ts +1 -1
  2. package/lib/Platform/version.js +1 -1
  3. package/lib/ServiceWorker/ServiceWorker.js +69 -17
  4. package/lib/ServiceWorker/index.d.ts +0 -12
  5. package/lib/ServiceWorker/index.js +0 -12
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +4 -1
  8. package/lib/libraryUtils.d.ts +0 -1
  9. package/lib/libraryUtils.js +2 -5
  10. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  11. package/lib/singleton/Auth/types.d.ts +2 -2
  12. package/lib/tsconfig.tsbuildinfo +1 -1
  13. package/lib-esm/Platform/version.d.ts +1 -1
  14. package/lib-esm/Platform/version.js +1 -1
  15. package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
  16. package/lib-esm/ServiceWorker/index.d.ts +0 -12
  17. package/lib-esm/ServiceWorker/index.js +0 -12
  18. package/lib-esm/index.d.ts +1 -0
  19. package/lib-esm/index.js +2 -0
  20. package/lib-esm/libraryUtils.d.ts +0 -1
  21. package/lib-esm/libraryUtils.js +0 -2
  22. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  23. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  24. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +3 -3
  26. package/src/Platform/version.ts +1 -1
  27. package/src/ServiceWorker/ServiceWorker.ts +20 -17
  28. package/src/ServiceWorker/index.ts +0 -12
  29. package/src/index.ts +3 -0
  30. package/src/libraryUtils.ts +0 -3
  31. package/src/providers/pinpoint/types/pinpoint.ts +1 -0
  32. package/src/singleton/Auth/types.ts +2 -2
  33. package/lib/Amplify.d.ts +0 -29
  34. package/lib/Amplify.js +0 -118
  35. package/lib-esm/Amplify.d.ts +0 -29
  36. package/lib-esm/Amplify.js +0 -115
  37. package/src/Amplify.ts +0 -106
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.5a31ca1.0+5a31ca1";
1
+ export declare const version = "6.0.1-console-preview.8f82e46.0+8f82e46";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '6.0.1-console-preview.5a31ca1.0+5a31ca1';
2
+ export var version = '6.0.1-console-preview.8f82e46.0+8f82e46';
@@ -1,10 +1,47 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
3
39
  import { ConsoleLogger as Logger } from '../Logger';
4
40
  import { isBrowser } from '../utils';
5
- import { Amplify } from '../Amplify';
6
41
  import { AmplifyError } from '../errors';
7
42
  import { assert, ServiceWorkerErrorCode } from './errorHelpers';
43
+ import { record } from '../providers/pinpoint';
44
+ import { Amplify, fetchAuthSession } from '../singleton';
8
45
  /**
9
46
  * Provides a means to registering a service worker in the browser
10
47
  * and communicating with it via postMessage events.
@@ -173,19 +210,37 @@ var ServiceWorkerClass = /** @class */ (function () {
173
210
  **/
174
211
  ServiceWorkerClass.prototype._setupListeners = function () {
175
212
  var _this = this;
176
- this.serviceWorker.addEventListener('statechange', function (event) {
177
- var currentState = _this.serviceWorker.state;
178
- _this._logger.debug("ServiceWorker statechange: ".concat(currentState));
179
- Amplify.Analytics;
180
- if (isAmplifyWithAnalytics(Amplify)) {
181
- Amplify.Analytics.record({
182
- name: 'ServiceWorker',
183
- attributes: {
184
- state: currentState,
185
- },
186
- });
187
- }
188
- });
213
+ this.serviceWorker.addEventListener('statechange', function (event) { return __awaiter(_this, void 0, void 0, function () {
214
+ var currentState, _a, appId, region, credentials;
215
+ var _b, _c;
216
+ return __generator(this, function (_d) {
217
+ switch (_d.label) {
218
+ case 0:
219
+ currentState = this.serviceWorker.state;
220
+ this._logger.debug("ServiceWorker statechange: ".concat(currentState));
221
+ _a = (_c = (_b = Amplify.getConfig().Analytics) === null || _b === void 0 ? void 0 : _b.Pinpoint) !== null && _c !== void 0 ? _c : {}, appId = _a.appId, region = _a.region;
222
+ return [4 /*yield*/, fetchAuthSession()];
223
+ case 1:
224
+ credentials = (_d.sent()).credentials;
225
+ if (appId && region && credentials) {
226
+ // Pinpoint is configured, record an event
227
+ record({
228
+ appId: appId,
229
+ region: region,
230
+ category: 'Core',
231
+ credentials: credentials,
232
+ event: {
233
+ name: 'ServiceWorker',
234
+ attributes: {
235
+ state: currentState,
236
+ },
237
+ },
238
+ });
239
+ }
240
+ return [2 /*return*/];
241
+ }
242
+ });
243
+ }); });
189
244
  this.serviceWorker.addEventListener('message', function (event) {
190
245
  _this._logger.debug("ServiceWorker message event: ".concat(event));
191
246
  });
@@ -193,6 +248,3 @@ var ServiceWorkerClass = /** @class */ (function () {
193
248
  return ServiceWorkerClass;
194
249
  }());
195
250
  export { ServiceWorkerClass };
196
- function isAmplifyWithAnalytics(amplify) {
197
- return amplify.Analytics && typeof amplify.Analytics.record === 'function';
198
- }
@@ -1,13 +1 @@
1
- /**
2
- * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
- * the License. A copy of the License is located at
6
- *
7
- * http://aws.amazon.com/apache2.0/
8
- *
9
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
- * and limitations under the License.
12
- */
13
1
  export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
@@ -1,15 +1,3 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
7
- * the License. A copy of the License is located at
8
- *
9
- * http://aws.amazon.com/apache2.0/
10
- *
11
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
13
- * and limitations under the License.
14
- */
15
3
  export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
@@ -9,3 +9,4 @@ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, }
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  export { Cache } from './Cache';
11
11
  export { I18n } from './I18n';
12
+ export { ServiceWorker } from './ServiceWorker';
package/lib-esm/index.js CHANGED
@@ -14,3 +14,5 @@ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, }
14
14
  export { Cache } from './Cache';
15
15
  // Internationalization utilities
16
16
  export { I18n } from './I18n';
17
+ // Service worker
18
+ export { ServiceWorker } from './ServiceWorker';
@@ -12,7 +12,6 @@ export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
12
12
  export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
13
13
  export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, } from './Platform/types';
14
14
  export { setCustomUserAgent } from './Platform/customUserAgent';
15
- export { ServiceWorker } from './ServiceWorker';
16
15
  export { BackgroundProcessManager } from './BackgroundProcessManager';
17
16
  export { Mutex } from './Mutex';
18
17
  export { Reachability } from './Reachability';
@@ -19,8 +19,6 @@ export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
19
19
  export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
20
20
  export { ApiAction, AuthAction, AnalyticsAction, Category, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, } from './Platform/types';
21
21
  export { setCustomUserAgent } from './Platform/customUserAgent';
22
- // Service worker
23
- export { ServiceWorker } from './ServiceWorker';
24
22
  // Other utilities & constants
25
23
  export { BackgroundProcessManager } from './BackgroundProcessManager';
26
24
  export { Mutex } from './Mutex';
@@ -1,6 +1,6 @@
1
1
  import { AuthSession } from '../../../singleton/Auth/types';
2
2
  import { UserProfile } from '../../../types';
3
- export type SupportedCategory = 'Analytics' | 'InAppMessaging' | 'PushNotification';
3
+ export type SupportedCategory = 'Analytics' | 'Core' | 'InAppMessaging' | 'PushNotification';
4
4
  export type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
5
5
  export type PinpointProviderConfig = {
6
6
  Pinpoint?: {
@@ -63,12 +63,12 @@ export type AuthIdentityPoolConfig = {
63
63
  Cognito: CognitoIdentityPoolConfig & {
64
64
  userPoolClientId?: never;
65
65
  userPoolId?: never;
66
+ userPoolEndpoint?: never;
66
67
  loginWith?: never;
67
68
  signUpVerificationMethod?: never;
68
69
  userAttributes?: never;
69
70
  mfa?: never;
70
71
  passwordFormat?: never;
71
- endpoint?: never;
72
72
  };
73
73
  };
74
74
  export type CognitoIdentityPoolConfig = {
@@ -84,6 +84,7 @@ export type AuthUserPoolConfig = {
84
84
  export type CognitoUserPoolConfig = {
85
85
  userPoolClientId: string;
86
86
  userPoolId: string;
87
+ userPoolEndpoint?: string;
87
88
  signUpVerificationMethod?: 'code' | 'link';
88
89
  loginWith?: {
89
90
  oauth?: OAuthConfig;
@@ -104,7 +105,6 @@ export type CognitoUserPoolConfig = {
104
105
  requireNumbers?: boolean;
105
106
  requireSpecialCharacters?: boolean;
106
107
  };
107
- endpoint?: string;
108
108
  };
109
109
  export type OAuthConfig = {
110
110
  domain: string;