@aws-amplify/core 6.0.1-ssr-api.df60e41.0 → 6.0.1-unstable.04fd02c.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 (59) hide show
  1. package/lib/Platform/version.d.ts +1 -1
  2. package/lib/Platform/version.js +1 -1
  3. package/lib/Signer/DateUtils.d.ts +9 -0
  4. package/lib/Signer/DateUtils.js +9 -1
  5. package/lib/Signer/Signer.d.ts +9 -0
  6. package/lib/Signer/Signer.js +9 -2
  7. package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  8. package/lib/libraryUtils.d.ts +3 -0
  9. package/lib/libraryUtils.js +10 -3
  10. package/lib/providers/kinesis/types/kinesis.d.ts +1 -1
  11. package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
  12. package/lib/providers/personalize/types/personalize.d.ts +1 -1
  13. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  14. package/lib/singleton/Amplify.d.ts +4 -0
  15. package/lib/singleton/Amplify.js +9 -31
  16. package/lib/singleton/Analytics/types.d.ts +5 -1
  17. package/lib/tsconfig.tsbuildinfo +1 -1
  18. package/lib/utils/WordArray.d.ts +7 -0
  19. package/lib/utils/WordArray.js +49 -0
  20. package/lib/utils/amplifyUuid/index.d.ts +1 -1
  21. package/lib/utils/cryptoSecureRandomInt.d.ts +1 -0
  22. package/lib/utils/cryptoSecureRandomInt.js +16 -0
  23. package/lib-esm/Platform/version.d.ts +1 -1
  24. package/lib-esm/Platform/version.js +1 -1
  25. package/lib-esm/Signer/DateUtils.d.ts +9 -0
  26. package/lib-esm/Signer/DateUtils.js +9 -1
  27. package/lib-esm/Signer/Signer.d.ts +9 -0
  28. package/lib-esm/Signer/Signer.js +9 -2
  29. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  30. package/lib-esm/libraryUtils.d.ts +3 -0
  31. package/lib-esm/libraryUtils.js +3 -0
  32. package/lib-esm/providers/kinesis/types/kinesis.d.ts +1 -1
  33. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
  34. package/lib-esm/providers/personalize/types/personalize.d.ts +1 -1
  35. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  36. package/lib-esm/singleton/Amplify.d.ts +4 -0
  37. package/lib-esm/singleton/Amplify.js +9 -31
  38. package/lib-esm/singleton/Analytics/types.d.ts +5 -1
  39. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  40. package/lib-esm/utils/WordArray.d.ts +7 -0
  41. package/lib-esm/utils/WordArray.js +46 -0
  42. package/lib-esm/utils/amplifyUuid/index.d.ts +1 -1
  43. package/lib-esm/utils/cryptoSecureRandomInt.d.ts +1 -0
  44. package/lib-esm/utils/cryptoSecureRandomInt.js +12 -0
  45. package/package.json +4 -4
  46. package/src/Platform/version.ts +1 -1
  47. package/src/Signer/DateUtils.ts +10 -2
  48. package/src/Signer/Signer.ts +9 -2
  49. package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -1
  50. package/src/libraryUtils.ts +3 -1
  51. package/src/providers/kinesis/types/kinesis.ts +1 -1
  52. package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +1 -1
  53. package/src/providers/personalize/types/personalize.ts +1 -1
  54. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  55. package/src/singleton/Amplify.ts +9 -52
  56. package/src/singleton/Analytics/types.ts +9 -4
  57. package/src/utils/WordArray.ts +57 -0
  58. package/src/utils/amplifyUuid/index.ts +1 -1
  59. package/src/utils/cryptoSecureRandomInt.ts +14 -0
@@ -1 +1 @@
1
- export declare const version = "6.0.1-ssr-api.df60e41.0+df60e41";
1
+ export declare const version = "6.0.1-unstable.04fd02c.0+04fd02c";
@@ -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-ssr-api.df60e41.0+df60e41';
5
+ exports.version = '6.0.1-unstable.04fd02c.0+04fd02c';
@@ -14,5 +14,14 @@ type DateUtils = {
14
14
  isClockSkewError: (error: any) => boolean;
15
15
  setClockOffset: (offset: number) => void;
16
16
  };
17
+ /**
18
+ * This utility is intended to be deprecated and replaced by `signRequest` and `presignUrl` functions from
19
+ * `clients/middleware/signing/signer/signatureV4`.
20
+ *
21
+ * TODO: refactor the logics here into `signRequest` and `presignUrl` functions and remove this class.
22
+ *
23
+ * @internal
24
+ * @deprecated
25
+ */
17
26
  export declare const DateUtils: DateUtils;
18
27
  export {};
@@ -9,8 +9,16 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.DateUtils = void 0;
12
- // Comment - TODO: remove
13
12
  const FIVE_MINUTES_IN_MS = 1000 * 60 * 5;
13
+ /**
14
+ * This utility is intended to be deprecated and replaced by `signRequest` and `presignUrl` functions from
15
+ * `clients/middleware/signing/signer/signatureV4`.
16
+ *
17
+ * TODO: refactor the logics here into `signRequest` and `presignUrl` functions and remove this class.
18
+ *
19
+ * @internal
20
+ * @deprecated
21
+ */
14
22
  exports.DateUtils = {
15
23
  /**
16
24
  * Milliseconds to offset the date to compensate for clock skew between device & services
@@ -1,3 +1,12 @@
1
+ /**
2
+ * This class is intended to be deprecated and replaced by `signRequest` and `presignUrl` functions from
3
+ * `clients/middleware/signing/signer/signatureV4`.
4
+ *
5
+ * TODO: refactor the logics here into `signRequest` and `presignUrl` functions and remove this class.
6
+ *
7
+ * @internal
8
+ * @deprecated
9
+ */
1
10
  export declare class Signer {
2
11
  /**
3
12
  * Sign a HTTP request, add 'Authorization' header to request param
@@ -9,6 +9,15 @@ const amplifyUrl_1 = require("../utils/amplifyUrl");
9
9
  const IOT_SERVICE_NAME = 'iotdevicegateway';
10
10
  // Best practice regex to parse the service and region from an AWS endpoint
11
11
  const AWS_ENDPOINT_REGEX = /([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com(.cn)?$/;
12
+ /**
13
+ * This class is intended to be deprecated and replaced by `signRequest` and `presignUrl` functions from
14
+ * `clients/middleware/signing/signer/signatureV4`.
15
+ *
16
+ * TODO: refactor the logics here into `signRequest` and `presignUrl` functions and remove this class.
17
+ *
18
+ * @internal
19
+ * @deprecated
20
+ */
12
21
  class Signer {
13
22
  /**
14
23
  * Sign a HTTP request, add 'Authorization' header to request param
@@ -108,7 +117,6 @@ const getOptions = (request, accessInfo, serviceInfo, expiration) => {
108
117
  ...(expiration && { expiration }),
109
118
  };
110
119
  };
111
- // TODO: V6 investigate whether add to custom clients' general signer implementation.
112
120
  const parseServiceInfo = (url) => {
113
121
  const host = url.host;
114
122
  const matched = host.match(AWS_ENDPOINT_REGEX) ?? [];
@@ -124,5 +132,4 @@ const parseServiceInfo = (url) => {
124
132
  };
125
133
  // IoT service does not allow the session token in the canonical request
126
134
  // https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html
127
- // TODO: V6 investigate whether add to custom clients' general signer implementation.
128
135
  const sessionTokenRequiredInSigning = (service) => service !== IOT_SERVICE_NAME;
@@ -3,7 +3,6 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.getHashedPayload = exports.TOKEN_QUERY_PARAM = exports.presignUrl = exports.signRequest = void 0;
6
- // TODO: V6 replace Signer
7
6
  var signRequest_1 = require("./signRequest");
8
7
  Object.defineProperty(exports, "signRequest", { enumerable: true, get: function () { return signRequest_1.signRequest; } });
9
8
  var presignUrl_1 = require("./presignUrl");
@@ -1,3 +1,4 @@
1
+ import WordArray from './utils/WordArray';
1
2
  export { generateRandomString, isBrowser, isNonRetryableError, isWebWorker, jitteredBackoff, jitteredExponentialRetry, NonRetryableError, retry, urlSafeDecode, urlSafeEncode, } from './utils';
2
3
  export { parseAWSExports } from './parseAWSExports';
3
4
  export { LegacyConfig } from './singleton/types';
@@ -21,6 +22,8 @@ export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
21
22
  export { AMPLIFY_SYMBOL } from './Hub';
22
23
  export { base64Decoder, base64Encoder } from './utils/convert';
23
24
  export { getCrypto } from './utils/globalHelpers';
25
+ export { cryptoSecureRandomInt } from './utils/cryptoSecureRandomInt';
26
+ export { WordArray };
24
27
  export { HubInternal } from './Hub';
25
28
  export { sessionListener } from './utils/sessionListener';
26
29
  export { SessionState } from './utils/sessionListener/types';
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
5
6
  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.SESSION_STOP_EVENT = exports.SESSION_START_EVENT = exports.sessionListener = exports.HubInternal = exports.getCrypto = void 0;
7
+ exports.SESSION_STOP_EVENT = exports.SESSION_START_EVENT = exports.sessionListener = exports.HubInternal = exports.WordArray = exports.cryptoSecureRandomInt = exports.getCrypto = void 0;
8
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
9
+ // SPDX-License-Identifier: Apache-2.0
10
+ const WordArray_1 = __importDefault(require("./utils/WordArray"));
11
+ exports.WordArray = WordArray_1.default;
7
12
  /*
8
13
  This file maps top-level exports from `@aws-amplify/core/internals/utils`. These are intended to be internal
9
14
  utils for use throughout the library.
@@ -84,6 +89,8 @@ Object.defineProperty(exports, "base64Decoder", { enumerable: true, get: functio
84
89
  Object.defineProperty(exports, "base64Encoder", { enumerable: true, get: function () { return convert_1.base64Encoder; } });
85
90
  var globalHelpers_1 = require("./utils/globalHelpers");
86
91
  Object.defineProperty(exports, "getCrypto", { enumerable: true, get: function () { return globalHelpers_1.getCrypto; } });
92
+ var cryptoSecureRandomInt_1 = require("./utils/cryptoSecureRandomInt");
93
+ Object.defineProperty(exports, "cryptoSecureRandomInt", { enumerable: true, get: function () { return cryptoSecureRandomInt_1.cryptoSecureRandomInt; } });
87
94
  // Hub
88
95
  var Hub_2 = require("./Hub");
89
96
  Object.defineProperty(exports, "HubInternal", { enumerable: true, get: function () { return Hub_2.HubInternal; } });
@@ -1,5 +1,5 @@
1
1
  export type KinesisProviderConfig = {
2
- Kinesis?: {
2
+ Kinesis: {
3
3
  region: string;
4
4
  bufferSize?: number;
5
5
  flushSize?: number;
@@ -1,5 +1,5 @@
1
1
  export type KinesisFirehoseProviderConfig = {
2
- KinesisFirehose?: {
2
+ KinesisFirehose: {
3
3
  region: string;
4
4
  bufferSize?: number;
5
5
  flushSize?: number;
@@ -1,5 +1,5 @@
1
1
  export type PersonalizeProviderConfig = {
2
- Personalize?: {
2
+ Personalize: {
3
3
  trackingId: string;
4
4
  region: string;
5
5
  flushSize?: number;
@@ -3,7 +3,7 @@ import { UserProfile } from '../../../types';
3
3
  export type SupportedCategory = 'Analytics' | 'Core' | 'InAppMessaging' | 'PushNotification';
4
4
  type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
5
5
  export type PinpointProviderConfig = {
6
- Pinpoint?: {
6
+ Pinpoint: {
7
7
  appId: string;
8
8
  region: string;
9
9
  };
@@ -14,6 +14,10 @@ export declare class AmplifyClass {
14
14
  * Configures Amplify for use with your back-end resources.
15
15
  *
16
16
  * @remarks
17
+ * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
18
+ * provided values will be used after configuration.
19
+ *
20
+ * @remarks
17
21
  * `configure` can be used to specify additional library options where available for supported categories.
18
22
  *
19
23
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
@@ -17,12 +17,16 @@ class AmplifyClass {
17
17
  * Configures Amplify for use with your back-end resources.
18
18
  *
19
19
  * @remarks
20
+ * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
21
+ * provided values will be used after configuration.
22
+ *
23
+ * @remarks
20
24
  * `configure` can be used to specify additional library options where available for supported categories.
21
25
  *
22
26
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
23
27
  * @param libraryOptions - Additional options for customizing the behavior of the library.
24
28
  */
25
- configure(resourcesConfig, libraryOptions = {}) {
29
+ configure(resourcesConfig, libraryOptions) {
26
30
  let resolvedResourceConfig;
27
31
  if (Object.keys(resourcesConfig).some(key => key.startsWith('aws_'))) {
28
32
  resolvedResourceConfig = (0, parseAWSExports_1.parseAWSExports)(resourcesConfig);
@@ -30,8 +34,10 @@ class AmplifyClass {
30
34
  else {
31
35
  resolvedResourceConfig = resourcesConfig;
32
36
  }
33
- this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resolvedResourceConfig);
34
- this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
37
+ this.resourcesConfig = resolvedResourceConfig;
38
+ if (libraryOptions) {
39
+ this.libraryOptions = libraryOptions;
40
+ }
35
41
  // Make resource config immutable
36
42
  this.resourcesConfig = (0, utils_1.deepFreeze)(this.resourcesConfig);
37
43
  this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
@@ -57,31 +63,3 @@ exports.AmplifyClass = AmplifyClass;
57
63
  * `Amplify` is responsible for orchestrating cross-category communication within the library.
58
64
  */
59
65
  exports.Amplify = new AmplifyClass();
60
- // TODO(v6): validate until which level this will nested, during Amplify.configure API review.
61
- function mergeResourceConfig(existingConfig, newConfig) {
62
- const resultConfig = {};
63
- for (const category of Object.keys(existingConfig)) {
64
- resultConfig[category] = existingConfig[category];
65
- }
66
- for (const key of Object.keys(newConfig)) {
67
- resultConfig[key] = {
68
- ...resultConfig[key],
69
- ...newConfig[key],
70
- };
71
- }
72
- return resultConfig;
73
- }
74
- function mergeLibraryOptions(existingConfig, newConfig) {
75
- const resultConfig = {};
76
- for (const category of Object.keys(existingConfig)) {
77
- resultConfig[category] = existingConfig[category];
78
- }
79
- for (const key of Object.keys(newConfig).filter(key => key !== 'ssr')) {
80
- resultConfig[key] = {
81
- ...resultConfig[key],
82
- ...newConfig[key],
83
- };
84
- }
85
- resultConfig.ssr = newConfig.ssr;
86
- return resultConfig;
87
- }
@@ -2,4 +2,8 @@ import { PinpointProviderConfig } from '../../providers/pinpoint/types';
2
2
  import { KinesisProviderConfig } from '../../providers/kinesis/types';
3
3
  import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
4
4
  import { PersonalizeProviderConfig } from '../../providers/personalize/types';
5
- export type AnalyticsConfig = PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig;
5
+ type AtLeastOne<T, U = {
6
+ [K in keyof T]: Pick<T, K>;
7
+ }> = Partial<T> & U[keyof U];
8
+ export type AnalyticsConfig = AtLeastOne<PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig>;
9
+ export {};