@aws-amplify/core 6.0.1-console-preview.7739091.0 → 6.0.1-console-preview.047a1dd.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 (104) hide show
  1. package/lib/AwsClients/CognitoIdentity/base.d.ts +12 -4
  2. package/lib/AwsClients/CognitoIdentity/base.js +1 -0
  3. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
  4. package/lib/AwsClients/CognitoIdentity/getId.d.ts +15 -3
  5. package/lib/AwsClients/Pinpoint/base.d.ts +10 -2
  6. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
  7. package/lib/AwsClients/Pinpoint/putEvents.d.ts +17 -3
  8. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
  9. package/lib/Platform/version.d.ts +1 -1
  10. package/lib/Platform/version.js +1 -1
  11. package/lib/clients/handlers/authenticated.d.ts +1 -1
  12. package/lib/clients/handlers/fetch.js +2 -1
  13. package/lib/clients/handlers/unauthenticated.d.ts +1 -1
  14. package/lib/clients/internal/composeServiceApi.d.ts +5 -3
  15. package/lib/clients/types/aws.d.ts +1 -5
  16. package/lib/clients/types/http.d.ts +8 -0
  17. package/lib/clients/types/index.d.ts +1 -1
  18. package/lib/index.d.ts +0 -1
  19. package/lib/index.js +1 -3
  20. package/lib/libraryUtils.d.ts +2 -1
  21. package/lib/libraryUtils.js +4 -6
  22. package/lib/providers/pinpoint/types/buffer.d.ts +1 -1
  23. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  24. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
  25. package/lib/providers/pinpoint/utils/isAppInForeground.d.ts +1 -0
  26. package/lib/{RNComponents → providers/pinpoint/utils}/isAppInForeground.js +1 -4
  27. package/lib/providers/pinpoint/utils/isAppInForeground.native.d.ts +1 -0
  28. package/lib/providers/pinpoint/utils/isAppInForeground.native.js +9 -0
  29. package/lib/singleton/Amplify.d.ts +2 -2
  30. package/lib/singleton/Amplify.js +9 -1
  31. package/lib/singleton/Auth/index.d.ts +2 -1
  32. package/lib/singleton/Auth/index.js +22 -12
  33. package/lib/singleton/Auth/utils/index.js +3 -3
  34. package/lib/singleton/types.d.ts +6 -0
  35. package/lib/tsconfig.tsbuildinfo +1 -1
  36. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +12 -4
  37. package/lib-esm/AwsClients/CognitoIdentity/base.js +1 -0
  38. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
  39. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +15 -3
  40. package/lib-esm/AwsClients/Pinpoint/base.d.ts +10 -2
  41. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
  42. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +17 -3
  43. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
  44. package/lib-esm/Platform/version.d.ts +1 -1
  45. package/lib-esm/Platform/version.js +1 -1
  46. package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
  47. package/lib-esm/clients/handlers/fetch.js +2 -1
  48. package/lib-esm/clients/handlers/unauthenticated.d.ts +1 -1
  49. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -3
  50. package/lib-esm/clients/types/aws.d.ts +1 -5
  51. package/lib-esm/clients/types/http.d.ts +8 -0
  52. package/lib-esm/clients/types/index.d.ts +1 -1
  53. package/lib-esm/index.d.ts +0 -1
  54. package/lib-esm/index.js +0 -1
  55. package/lib-esm/libraryUtils.d.ts +2 -1
  56. package/lib-esm/libraryUtils.js +1 -1
  57. package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
  58. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  59. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
  60. package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +3 -0
  61. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +5 -0
  62. package/lib-esm/singleton/Amplify.d.ts +2 -2
  63. package/lib-esm/singleton/Amplify.js +9 -1
  64. package/lib-esm/singleton/Auth/index.d.ts +2 -1
  65. package/lib-esm/singleton/Auth/index.js +22 -12
  66. package/lib-esm/singleton/Auth/utils/index.js +3 -3
  67. package/lib-esm/singleton/types.d.ts +6 -0
  68. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  69. package/package.json +2 -3
  70. package/src/AwsClients/CognitoIdentity/base.ts +2 -2
  71. package/src/AwsClients/Pinpoint/base.ts +2 -6
  72. package/src/Platform/version.ts +1 -1
  73. package/src/clients/handlers/authenticated.ts +2 -1
  74. package/src/clients/handlers/fetch.ts +2 -1
  75. package/src/clients/handlers/unauthenticated.ts +2 -1
  76. package/src/clients/internal/composeServiceApi.ts +10 -3
  77. package/src/clients/types/aws.ts +4 -11
  78. package/src/clients/types/http.ts +8 -0
  79. package/src/clients/types/index.ts +0 -1
  80. package/src/index.ts +0 -2
  81. package/src/libraryUtils.ts +2 -2
  82. package/src/providers/pinpoint/types/buffer.ts +1 -1
  83. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  84. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +16 -12
  85. package/src/providers/pinpoint/utils/isAppInForeground.native.ts +7 -0
  86. package/src/providers/pinpoint/utils/isAppInForeground.ts +4 -0
  87. package/src/singleton/Amplify.ts +12 -3
  88. package/src/singleton/Auth/index.ts +9 -2
  89. package/src/singleton/Auth/utils/index.ts +3 -3
  90. package/src/singleton/types.ts +7 -0
  91. package/lib/RNComponents/index.d.ts +0 -6
  92. package/lib/RNComponents/index.js +0 -16
  93. package/lib/RNComponents/reactnative.d.ts +0 -3
  94. package/lib/RNComponents/reactnative.js +0 -14
  95. package/lib-esm/RNComponents/index.d.ts +0 -6
  96. package/lib-esm/RNComponents/index.js +0 -13
  97. package/lib-esm/RNComponents/isAppInForeground.js +0 -6
  98. package/lib-esm/RNComponents/reactnative.d.ts +0 -3
  99. package/lib-esm/RNComponents/reactnative.js +0 -6
  100. package/src/RNComponents/index.ts +0 -16
  101. package/src/RNComponents/isAppInForeground.ts +0 -8
  102. package/src/RNComponents/reactnative.ts +0 -6
  103. /package/lib-esm/{RNComponents → providers/pinpoint/utils}/isAppInForeground.d.ts +0 -0
  104. /package/{lib/RNComponents/isAppInForeground.d.ts → lib-esm/providers/pinpoint/utils/isAppInForeground.native.d.ts} +0 -0
@@ -1,9 +1,23 @@
1
- import { HttpResponse } from '../../clients/types';
1
+ import { Endpoint, HttpResponse } from '../../clients/types';
2
2
  import type { PutEventsCommandInput as PutEventsInput, PutEventsCommandOutput as PutEventsOutput } from './types';
3
3
  export type { PutEventsInput, PutEventsOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const putEvents: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions> & import("../../clients/types").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const putEvents: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ })) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
13
+ computeDelay?: ((attempt: number) => number) | undefined;
14
+ userAgentValue?: string | undefined;
15
+ } & {
16
+ uriEscapePath?: boolean | undefined;
17
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
18
+ region: string;
19
+ abortSignal?: AbortSignal | undefined;
20
+ cache?: RequestCache | undefined;
21
+ maxAttempts?: number | undefined;
22
+ userAgentHeader?: string | undefined;
9
23
  }, input: PutEventsInput) => Promise<PutEventsOutput>;
@@ -1,9 +1,23 @@
1
- import { HttpResponse } from '../../clients/types';
1
+ import { Endpoint, HttpResponse } from '../../clients/types';
2
2
  import type { UpdateEndpointCommandInput as UpdateEndpointInput, UpdateEndpointCommandOutput as UpdateEndpointOutput } from './types';
3
3
  export type { UpdateEndpointInput, UpdateEndpointOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const updateEndpoint: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions> & import("../../clients/types").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const updateEndpoint: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ })) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
13
+ computeDelay?: ((attempt: number) => number) | undefined;
14
+ userAgentValue?: string | undefined;
15
+ } & {
16
+ uriEscapePath?: boolean | undefined;
17
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
18
+ region: string;
19
+ abortSignal?: AbortSignal | undefined;
20
+ cache?: RequestCache | undefined;
21
+ maxAttempts?: number | undefined;
22
+ userAgentHeader?: string | undefined;
9
23
  }, input: UpdateEndpointInput) => Promise<UpdateEndpointOutput>;
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.7739091.0+7739091";
1
+ export declare const version = "6.0.1-console-preview.047a1dd.0+047a1dd";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '6.0.1-console-preview.7739091.0+7739091';
2
+ export var version = '6.0.1-console-preview.047a1dd.0+047a1dd';
@@ -2,4 +2,4 @@ import { RetryOptions } from '../middleware/retry';
2
2
  import { SigningOptions } from '../middleware/signing';
3
3
  import { UserAgentOptions } from '../middleware/userAgent';
4
4
  import { HttpRequest, HttpResponse } from '../types';
5
- export declare const authenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & SigningOptions) => Promise<HttpResponse>;
5
+ export declare const authenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & SigningOptions & import("../types").HttpTransferOptions) => Promise<HttpResponse>;
@@ -54,7 +54,7 @@ var shouldSendBody = function (method) {
54
54
  // TODO[AllanZhengYP]: we need to provide isCanceledError utility
55
55
  export var fetchTransferHandler = function (_a, _b) {
56
56
  var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body;
57
- var abortSignal = _b.abortSignal;
57
+ var abortSignal = _b.abortSignal, cache = _b.cache;
58
58
  return __awaiter(void 0, void 0, void 0, function () {
59
59
  var resp, e_1, responseHeaders, httpResponse, bodyWithMixin;
60
60
  var _c, _d;
@@ -67,6 +67,7 @@ export var fetchTransferHandler = function (_a, _b) {
67
67
  headers: headers,
68
68
  body: shouldSendBody(method) ? body : undefined,
69
69
  signal: abortSignal,
70
+ cache: cache,
70
71
  })];
71
72
  case 1:
72
73
  resp = _e.sent();
@@ -1,4 +1,4 @@
1
1
  import { RetryOptions } from '../middleware/retry';
2
2
  import { UserAgentOptions } from '../middleware/userAgent';
3
3
  import { HttpRequest, HttpResponse } from '../types';
4
- export declare const unauthenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse>) => Promise<HttpResponse>;
4
+ export declare const unauthenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & import("../types").HttpTransferOptions) => Promise<HttpResponse>;
@@ -1,9 +1,11 @@
1
1
  import { ServiceClientOptions } from '../types/aws';
2
2
  import { TransferHandler, Endpoint } from '../types/core';
3
3
  import { HttpRequest, HttpResponse } from '../types/http';
4
- export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & Partial<DefaultConfig> & InferEndpointResolverOptionType<DefaultConfig>, keyof DefaultConfig>, input: Input) => Promise<Output>;
5
- type OptionalizeKey<T, K extends keyof T> = Omit<T, K> & {
6
- [P in K & keyof T]?: T[P];
4
+ export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & Partial<DefaultConfig> & InferEndpointResolverOptionType<DefaultConfig>, DefaultConfig>, input: Input) => Promise<Output>;
5
+ type OptionalizeKey<InputType, InputDefaultsType> = {
6
+ [KeyWithDefaultValue in keyof InputDefaultsType]?: KeyWithDefaultValue extends keyof InputType ? InputType[KeyWithDefaultValue] : never;
7
+ } & {
8
+ [KeyWithoutDefaultValue in keyof Omit<InputType, keyof InputDefaultsType>]: InputType[KeyWithoutDefaultValue];
7
9
  };
8
10
  type InferEndpointResolverOptionType<T> = T extends {
9
11
  endpointResolver: (options: infer EndpointOptions) => any;
@@ -1,7 +1,7 @@
1
1
  import { MetadataBearer } from '@aws-sdk/types';
2
2
  import { Endpoint } from './core';
3
3
  import { HttpResponse } from './http';
4
- export type { Credentials, MetadataBearer } from '@aws-sdk/types';
4
+ export type { AwsCredentialIdentity as Credentials, MetadataBearer, } from '@aws-sdk/types';
5
5
  export type SourceData = string | ArrayBuffer | ArrayBufferView;
6
6
  /**
7
7
  * Basic option type for endpoint resolvers. It contains region only.
@@ -18,7 +18,3 @@ export interface ServiceClientOptions {
18
18
  * This function is protocol-specific (e.g. JSON, XML, etc.)
19
19
  */
20
20
  export type ErrorParser = (response?: HttpResponse) => Promise<(Error & MetadataBearer) | undefined>;
21
- /**
22
- * Default config options for the `composeServiceApi`.
23
- */
24
- export type DefaultConfigOptions<TransferHandlerOptions extends Record<string, unknown> = Record<string, unknown>> = Partial<TransferHandlerOptions & ServiceClientOptions>;
@@ -26,5 +26,13 @@ export interface HttpResponse extends Response {
26
26
  }
27
27
  export interface HttpTransferOptions {
28
28
  abortSignal?: AbortSignal;
29
+ /**
30
+ * Cache mode for the request. Note that this is only effective when the underlying HTTP handler is fetch.
31
+ * For XHR handler, or Node.js `"http(s)"` module or running on React Native, this option is ignored.
32
+ * Instead, you can configure the `Cache-Control` headers to achieve similar effects.
33
+ * @default 'default'
34
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/cache}
35
+ */
36
+ cache?: RequestCache;
29
37
  }
30
38
  export type HttpTransferHandler = TransferHandler<HttpRequest, HttpResponse, HttpTransferOptions>;
@@ -1,3 +1,3 @@
1
1
  export { Middleware, MiddlewareHandler, Request, Response, TransferHandler, Endpoint, } from './core';
2
2
  export { Headers, HttpRequest, HttpResponse, HttpTransferHandler, HttpTransferOptions, ResponseBodyMixin, } from './http';
3
- export { Credentials, EndpointResolverOptions, ErrorParser, ServiceClientOptions, DefaultConfigOptions, } from './aws';
3
+ export { Credentials, EndpointResolverOptions, ErrorParser, ServiceClientOptions, } from './aws';
@@ -12,4 +12,3 @@ export { InMemoryCache } from './Cache/InMemoryCache';
12
12
  export { BrowserStorageCache };
13
13
  export { BrowserStorageCache as Cache };
14
14
  export { I18n } from './I18n';
15
- export { parseAWSExports } from './parseAWSExports';
package/lib-esm/index.js CHANGED
@@ -17,4 +17,3 @@ export { BrowserStorageCache };
17
17
  export { BrowserStorageCache as Cache }; // Maintain interoperability with React Native
18
18
  // Internationalization utilities
19
19
  export { I18n } from './I18n';
20
- export { parseAWSExports } from './parseAWSExports';
@@ -1,4 +1,6 @@
1
1
  export { isBrowser, filenameToContentType, generateRandomString, isEmpty, isStrictObject, isTextFile, isWebWorker, makeQuerablePromise, objectLessAttributes, sortByField, transferKeyToLowerCase, transferKeyToUpperCase, } from './Util/JS';
2
+ export { parseAWSExports } from './parseAWSExports';
3
+ export { LegacyConfig } from './singleton/types';
2
4
  export { JWT, StrictUnion, CognitoIdentityPoolConfig, } from './singleton/Auth/types';
3
5
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPooIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
4
6
  export { isTokenExpired } from './singleton/Auth';
@@ -14,7 +16,6 @@ export { ServiceWorker } from './ServiceWorker';
14
16
  export { AWS_CLOUDWATCH_CATEGORY, BackgroundManagerNotOpenError, BackgroundProcessManager, BackgroundProcessManagerState, DateUtils, Mutex, NO_CREDS_ERROR_STRING, NonRetryableError, RETRY_ERROR_CODES, Reachability, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, urlSafeDecode, urlSafeEncode, } from './Util';
15
17
  export { asserts } from './Util/errors/AssertError';
16
18
  export { invalidParameter, missingConfig, AmplifyError, AmplifyErrorString, } from './Util/Errors';
17
- export { AppState, AsyncStorage, Linking } from './RNComponents';
18
19
  export { ErrorParams, AmplifyErrorMap, ServiceError } from './types';
19
20
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
20
21
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
@@ -6,6 +6,7 @@ utils for use throughout the library.
6
6
  */
7
7
  // JS utilities
8
8
  export { isBrowser, filenameToContentType, generateRandomString, isEmpty, isStrictObject, isTextFile, isWebWorker, makeQuerablePromise, objectLessAttributes, sortByField, transferKeyToLowerCase, transferKeyToUpperCase, } from './Util/JS';
9
+ export { parseAWSExports } from './parseAWSExports';
9
10
  // Auth utilities
10
11
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPooIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
11
12
  export { isTokenExpired } from './singleton/Auth';
@@ -26,7 +27,6 @@ export { ServiceWorker } from './ServiceWorker';
26
27
  export { AWS_CLOUDWATCH_CATEGORY, BackgroundManagerNotOpenError, BackgroundProcessManager, BackgroundProcessManagerState, DateUtils, Mutex, NO_CREDS_ERROR_STRING, NonRetryableError, RETRY_ERROR_CODES, Reachability, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, urlSafeDecode, urlSafeEncode, } from './Util';
27
28
  export { asserts } from './Util/errors/AssertError';
28
29
  export { invalidParameter, missingConfig, AmplifyError, AmplifyErrorString, } from './Util/Errors';
29
- export { AppState, AsyncStorage, Linking } from './RNComponents';
30
30
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
31
31
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
32
32
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -3,7 +3,7 @@ import { PinpointAnalyticsEvent, PinpointSession } from './pinpoint';
3
3
  export type EventBufferConfig = {
4
4
  appId: string;
5
5
  bufferSize: number;
6
- credentials: AuthSession['credentials'];
6
+ credentials: Required<AuthSession>['credentials'];
7
7
  identityId: AuthSession['identityId'];
8
8
  flushInterval: number;
9
9
  flushSize: number;
@@ -24,7 +24,7 @@ export type PinpointAnalyticsEvent = {
24
24
  type PinpointCommonParameters = {
25
25
  appId: string;
26
26
  category: SupportedCategory;
27
- credentials: AuthSession['credentials'];
27
+ credentials: Required<AuthSession>['credentials'];
28
28
  identityId?: AuthSession['identityId'];
29
29
  region: string;
30
30
  userAgentValue?: string;
@@ -74,7 +74,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
74
74
  };
75
75
  import { ConsoleLogger as Logger } from '../../../Logger';
76
76
  import { putEvents, } from '../../../AwsClients/Pinpoint';
77
- import { isAppInForeground } from '../../../RNComponents/isAppInForeground';
77
+ import { isAppInForeground } from './isAppInForeground';
78
78
  var logger = new Logger('PinpointEventBuffer');
79
79
  var RETRYABLE_CODES = [429, 500];
80
80
  var ACCEPTED_CODES = [202];
@@ -91,7 +91,9 @@ var PinpointEventBuffer = /** @class */ (function () {
91
91
  PinpointEventBuffer.prototype.push = function (event) {
92
92
  var _a;
93
93
  if (this._buffer.length >= this._config.bufferSize) {
94
- logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', { eventId: event.eventId });
94
+ logger.debug('Exceeded Pinpoint event buffer limits, event dropped.', {
95
+ eventId: event.eventId,
96
+ });
95
97
  return;
96
98
  }
97
99
  this._buffer.push((_a = {}, _a[event.eventId] = event, _a));
@@ -230,7 +232,7 @@ var PinpointEventBuffer = /** @class */ (function () {
230
232
  logger.warn('Pinpoint event failed to send.', {
231
233
  eventId: eventId,
232
234
  name: name,
233
- message: Message
235
+ message: Message,
234
236
  });
235
237
  });
236
238
  });
@@ -250,14 +252,14 @@ var PinpointEventBuffer = /** @class */ (function () {
250
252
  logger.debug('Resending event.', {
251
253
  eventId: eventId,
252
254
  name: name,
253
- remainingAttempts: bufferedEvent.resendLimit
255
+ remainingAttempts: bufferedEvent.resendLimit,
254
256
  });
255
257
  eligibleEvents.push((_a = {}, _a[eventId] = bufferedEvent, _a));
256
258
  return;
257
259
  }
258
260
  logger.debug('No retry attempts remaining for event.', {
259
261
  eventId: eventId,
260
- name: name
262
+ name: name,
261
263
  });
262
264
  });
263
265
  // add the events to the front of the buffer
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export var isAppInForeground = function () { return true; };
@@ -0,0 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // @ts-ignore: missing type definition
4
+ import { AppState } from 'react-native';
5
+ export var isAppInForeground = function () { return AppState.currentState === 'active'; };
@@ -1,5 +1,5 @@
1
1
  import { AuthClass } from './Auth';
2
- import { LibraryOptions, ResourcesConfig } from './types';
2
+ import { LegacyConfig, LibraryOptions, ResourcesConfig } from './types';
3
3
  export declare class AmplifyClass {
4
4
  resourcesConfig: ResourcesConfig;
5
5
  libraryOptions: LibraryOptions;
@@ -19,7 +19,7 @@ export declare class AmplifyClass {
19
19
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
20
20
  * @param libraryOptions - Additional options for customizing the behavior of the library.
21
21
  */
22
- configure(resourcesConfig: ResourcesConfig, libraryOptions?: LibraryOptions): void;
22
+ configure(resourcesConfig: ResourcesConfig | LegacyConfig, libraryOptions?: LibraryOptions): void;
23
23
  /**
24
24
  * Provides access to the current back-end resource configuration for the Library.
25
25
  *
@@ -24,6 +24,7 @@ var __values = (this && this.__values) || function(o) {
24
24
  // SPDX-License-Identifier: Apache-2.0
25
25
  import { AuthClass } from './Auth';
26
26
  import { Hub, AMPLIFY_SYMBOL } from '../Hub';
27
+ import { parseAWSExports } from '../parseAWSExports';
27
28
  // TODO(v6): add default AuthTokenStore for each platform
28
29
  var AmplifyClass = /** @class */ (function () {
29
30
  function AmplifyClass() {
@@ -43,7 +44,14 @@ var AmplifyClass = /** @class */ (function () {
43
44
  */
44
45
  AmplifyClass.prototype.configure = function (resourcesConfig, libraryOptions) {
45
46
  if (libraryOptions === void 0) { libraryOptions = {}; }
46
- this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resourcesConfig);
47
+ var resolvedResourceConfig;
48
+ if (Object.keys(resourcesConfig).some(function (key) { return key.startsWith('aws_'); })) {
49
+ resolvedResourceConfig = parseAWSExports(resourcesConfig);
50
+ }
51
+ else {
52
+ resolvedResourceConfig = resourcesConfig;
53
+ }
54
+ this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resolvedResourceConfig);
47
55
  this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
48
56
  this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
49
57
  Hub.dispatch('core', {
@@ -1,4 +1,4 @@
1
- import { AuthConfig, AuthSession, FetchAuthSessionOptions, LibraryAuthOptions } from './types';
1
+ import { AuthConfig, AuthSession, AuthTokens, FetchAuthSessionOptions, LibraryAuthOptions } from './types';
2
2
  export declare function isTokenExpired({ expiresAt, clockDrift, }: {
3
3
  expiresAt: number;
4
4
  clockDrift: number;
@@ -20,4 +20,5 @@ export declare class AuthClass {
20
20
  configure(authResourcesConfig: AuthConfig, authOptions?: LibraryAuthOptions): void;
21
21
  fetchAuthSession(options?: FetchAuthSessionOptions): Promise<AuthSession>;
22
22
  clearCredentials(): Promise<void>;
23
+ getTokens(options: FetchAuthSessionOptions): Promise<AuthTokens | undefined>;
23
24
  }
@@ -57,20 +57,19 @@ var AuthClass = /** @class */ (function () {
57
57
  this.authOptions = authOptions;
58
58
  };
59
59
  AuthClass.prototype.fetchAuthSession = function (options) {
60
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
60
+ var _a, _b, _c, _d, _e, _f;
61
61
  if (options === void 0) { options = {}; }
62
62
  return __awaiter(this, void 0, void 0, function () {
63
63
  var tokens, credentialsAndIdentityId, userSub;
64
- return __generator(this, function (_k) {
65
- switch (_k.label) {
66
- case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
64
+ return __generator(this, function (_g) {
65
+ switch (_g.label) {
66
+ case 0: return [4 /*yield*/, this.getTokens(options)];
67
67
  case 1:
68
68
  // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
69
- tokens =
70
- (_c = (_k.sent())) !== null && _c !== void 0 ? _c : undefined;
69
+ tokens = _g.sent();
71
70
  if (!tokens) return [3 /*break*/, 3];
72
- userSub = (_e = (_d = tokens.accessToken) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.sub;
73
- return [4 /*yield*/, ((_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.credentialsProvider) === null || _g === void 0 ? void 0 : _g.getCredentialsAndIdentityId({
71
+ userSub = (_b = (_a = tokens.accessToken) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.sub;
72
+ return [4 /*yield*/, ((_d = (_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.credentialsProvider) === null || _d === void 0 ? void 0 : _d.getCredentialsAndIdentityId({
74
73
  authConfig: this.authConfig,
75
74
  tokens: tokens,
76
75
  authenticated: true,
@@ -79,9 +78,9 @@ var AuthClass = /** @class */ (function () {
79
78
  case 2:
80
79
  // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
81
80
  credentialsAndIdentityId =
82
- _k.sent();
81
+ _g.sent();
83
82
  return [3 /*break*/, 5];
84
- case 3: return [4 /*yield*/, ((_j = (_h = this.authOptions) === null || _h === void 0 ? void 0 : _h.credentialsProvider) === null || _j === void 0 ? void 0 : _j.getCredentialsAndIdentityId({
83
+ case 3: return [4 /*yield*/, ((_f = (_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.credentialsProvider) === null || _f === void 0 ? void 0 : _f.getCredentialsAndIdentityId({
85
84
  authConfig: this.authConfig,
86
85
  authenticated: false,
87
86
  forceRefresh: options.forceRefresh,
@@ -89,8 +88,8 @@ var AuthClass = /** @class */ (function () {
89
88
  case 4:
90
89
  // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
91
90
  credentialsAndIdentityId =
92
- _k.sent();
93
- _k.label = 5;
91
+ _g.sent();
92
+ _g.label = 5;
94
93
  case 5: return [2 /*return*/, {
95
94
  tokens: tokens,
96
95
  credentials: credentialsAndIdentityId === null || credentialsAndIdentityId === void 0 ? void 0 : credentialsAndIdentityId.credentials,
@@ -115,6 +114,17 @@ var AuthClass = /** @class */ (function () {
115
114
  });
116
115
  });
117
116
  };
117
+ AuthClass.prototype.getTokens = function (options) {
118
+ var _a, _b, _c;
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ return __generator(this, function (_d) {
121
+ switch (_d.label) {
122
+ case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
123
+ case 1: return [2 /*return*/, ((_c = (_d.sent())) !== null && _c !== void 0 ? _c : undefined)];
124
+ }
125
+ });
126
+ });
127
+ };
118
128
  return AuthClass;
119
129
  }());
120
130
  export { AuthClass };
@@ -31,9 +31,9 @@ export function assertOAuthConfig(cognitoConfig) {
31
31
  export function assertIdentityPooIdConfig(cognitoConfig) {
32
32
  var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
33
33
  return asserts(validConfig, {
34
- name: 'AuthIdentityPoolIdException',
35
- message: 'Auth IdentityPoolId not configured',
36
- recoverySuggestion: 'Make sure to call Amplify.configure in your app with a valid IdentityPoolId',
34
+ name: 'InvalidIdentityPoolIdException',
35
+ message: 'Invalid identity pool id provided.',
36
+ recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
37
37
  });
38
38
  }
39
39
  function assertUserPoolAndIdentityPooConfig(authConfig) {
@@ -2,6 +2,12 @@ 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
4
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
5
+ export type LegacyConfig = {
6
+ /**
7
+ * @deprecated The field should not be used.
8
+ */
9
+ aws_project_region?: string;
10
+ };
5
11
  export type ResourcesConfig = {
6
12
  API?: APIConfig;
7
13
  Analytics?: AnalyticsConfig;