@aws-amplify/core 6.0.1-console-preview.814dea6.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 (219) 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/Cache/Utils/CacheUtils.js +2 -4
  10. package/lib/Platform/version.d.ts +1 -1
  11. package/lib/Platform/version.js +1 -1
  12. package/lib/ServiceWorker/ServiceWorker.js +1 -1
  13. package/lib/Util/JS.d.ts +1 -4
  14. package/lib/Util/JS.js +4 -11
  15. package/lib/Util/Reachability.js +0 -3
  16. package/lib/clients/handlers/authenticated.d.ts +1 -1
  17. package/lib/clients/handlers/fetch.d.ts +0 -1
  18. package/lib/clients/handlers/fetch.js +2 -2
  19. package/lib/clients/handlers/unauthenticated.d.ts +1 -1
  20. package/lib/clients/internal/composeServiceApi.d.ts +5 -3
  21. package/lib/clients/types/aws.d.ts +1 -5
  22. package/lib/clients/types/http.d.ts +8 -0
  23. package/lib/clients/types/index.d.ts +1 -1
  24. package/lib/index.d.ts +1 -2
  25. package/lib/index.js +6 -10
  26. package/lib/libraryUtils.d.ts +3 -3
  27. package/lib/libraryUtils.js +5 -10
  28. package/lib/parseAWSExports.js +20 -1
  29. package/lib/providers/pinpoint/apis/record.d.ts +2 -2
  30. package/lib/providers/pinpoint/apis/record.js +3 -3
  31. package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +2 -2
  32. package/lib/providers/pinpoint/types/buffer.d.ts +1 -1
  33. package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -3
  34. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
  35. package/lib/providers/pinpoint/utils/isAppInForeground.d.ts +1 -0
  36. package/lib/{RNComponents → providers/pinpoint/utils}/isAppInForeground.js +1 -4
  37. package/lib/providers/pinpoint/utils/isAppInForeground.native.d.ts +1 -0
  38. package/lib/providers/pinpoint/utils/isAppInForeground.native.js +9 -0
  39. package/lib/singleton/API/types.d.ts +34 -0
  40. package/lib/singleton/API/types.js +2 -0
  41. package/lib/singleton/Amplify.d.ts +2 -2
  42. package/lib/singleton/Amplify.js +9 -1
  43. package/lib/singleton/Auth/index.d.ts +2 -1
  44. package/lib/singleton/Auth/index.js +22 -12
  45. package/lib/singleton/Auth/utils/index.js +3 -3
  46. package/lib/singleton/Storage/types.d.ts +5 -0
  47. package/lib/singleton/types.d.ts +10 -1
  48. package/lib/{StorageHelper/cookieStorage.d.ts → storage/CookieStorage.d.ts} +4 -3
  49. package/lib/{StorageHelper/cookieStorage.js → storage/CookieStorage.js} +35 -83
  50. package/lib/storage/CookieStorage.native.d.ts +7 -0
  51. package/lib/storage/CookieStorage.native.js +32 -0
  52. package/lib/storage/DefaultStorage.d.ts +7 -0
  53. package/lib/storage/DefaultStorage.js +33 -0
  54. package/{lib-esm/StorageHelper/localStorage.d.ts → lib/storage/DefaultStorage.native.d.ts} +7 -6
  55. package/lib/{StorageHelper/sessionStorage.js → storage/DefaultStorage.native.js} +46 -43
  56. package/lib/storage/InMemoryStorage.d.ts +12 -0
  57. package/lib/storage/InMemoryStorage.js +41 -0
  58. package/lib/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
  59. package/lib/{StorageHelper/localStorage.js → storage/KeyValueStorage.js} +13 -15
  60. package/lib/storage/SessionStorage.d.ts +7 -0
  61. package/lib/storage/SessionStorage.js +33 -0
  62. package/lib/storage/index.d.ts +7 -0
  63. package/lib/storage/index.js +14 -0
  64. package/lib/storage/utils.d.ts +10 -0
  65. package/lib/storage/utils.js +26 -0
  66. package/lib/tsconfig.tsbuildinfo +1 -1
  67. package/lib/types/storage.d.ts +3 -0
  68. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +12 -4
  69. package/lib-esm/AwsClients/CognitoIdentity/base.js +1 -0
  70. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
  71. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +15 -3
  72. package/lib-esm/AwsClients/Pinpoint/base.d.ts +10 -2
  73. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
  74. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +17 -3
  75. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
  76. package/lib-esm/Cache/Utils/CacheUtils.js +2 -4
  77. package/lib-esm/Platform/version.d.ts +1 -1
  78. package/lib-esm/Platform/version.js +1 -1
  79. package/lib-esm/ServiceWorker/ServiceWorker.js +2 -2
  80. package/lib-esm/Util/JS.d.ts +1 -4
  81. package/lib-esm/Util/JS.js +2 -9
  82. package/lib-esm/Util/Reachability.js +1 -4
  83. package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
  84. package/lib-esm/clients/handlers/fetch.d.ts +0 -1
  85. package/lib-esm/clients/handlers/fetch.js +2 -2
  86. package/lib-esm/clients/handlers/unauthenticated.d.ts +1 -1
  87. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -3
  88. package/lib-esm/clients/types/aws.d.ts +1 -5
  89. package/lib-esm/clients/types/http.d.ts +8 -0
  90. package/lib-esm/clients/types/index.d.ts +1 -1
  91. package/lib-esm/index.d.ts +1 -2
  92. package/lib-esm/index.js +1 -2
  93. package/lib-esm/libraryUtils.d.ts +3 -3
  94. package/lib-esm/libraryUtils.js +2 -3
  95. package/lib-esm/parseAWSExports.js +20 -1
  96. package/lib-esm/providers/pinpoint/apis/record.d.ts +2 -2
  97. package/lib-esm/providers/pinpoint/apis/record.js +3 -3
  98. package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +2 -2
  99. package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
  100. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
  101. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +7 -5
  102. package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +3 -0
  103. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +5 -0
  104. package/lib-esm/singleton/API/types.d.ts +34 -0
  105. package/lib-esm/singleton/API/types.js +1 -0
  106. package/lib-esm/singleton/Amplify.d.ts +2 -2
  107. package/lib-esm/singleton/Amplify.js +9 -1
  108. package/lib-esm/singleton/Auth/index.d.ts +2 -1
  109. package/lib-esm/singleton/Auth/index.js +22 -12
  110. package/lib-esm/singleton/Auth/utils/index.js +3 -3
  111. package/lib-esm/singleton/Storage/types.d.ts +5 -0
  112. package/lib-esm/singleton/types.d.ts +10 -1
  113. package/lib-esm/{StorageHelper/cookieStorage.d.ts → storage/CookieStorage.d.ts} +4 -3
  114. package/lib-esm/{StorageHelper/cookieStorage.js → storage/CookieStorage.js} +36 -61
  115. package/lib-esm/storage/CookieStorage.native.d.ts +7 -0
  116. package/lib-esm/storage/CookieStorage.native.js +29 -0
  117. package/lib-esm/storage/DefaultStorage.d.ts +7 -0
  118. package/lib-esm/storage/DefaultStorage.js +30 -0
  119. package/{lib/StorageHelper/localStorage.d.ts → lib-esm/storage/DefaultStorage.native.d.ts} +7 -6
  120. package/lib-esm/{StorageHelper/sessionStorage.js → storage/DefaultStorage.native.js} +45 -42
  121. package/lib-esm/storage/InMemoryStorage.d.ts +12 -0
  122. package/lib-esm/storage/InMemoryStorage.js +38 -0
  123. package/lib-esm/{StorageHelper/sessionStorage.d.ts → storage/KeyValueStorage.d.ts} +5 -4
  124. package/lib-esm/{StorageHelper/localStorage.js → storage/KeyValueStorage.js} +12 -14
  125. package/lib-esm/storage/SessionStorage.d.ts +7 -0
  126. package/lib-esm/storage/SessionStorage.js +30 -0
  127. package/lib-esm/storage/index.d.ts +7 -0
  128. package/lib-esm/storage/index.js +10 -0
  129. package/lib-esm/storage/utils.d.ts +10 -0
  130. package/lib-esm/storage/utils.js +21 -0
  131. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  132. package/lib-esm/types/storage.d.ts +3 -0
  133. package/package.json +3 -6
  134. package/src/AwsClients/CognitoIdentity/base.ts +2 -2
  135. package/src/AwsClients/Pinpoint/base.ts +2 -6
  136. package/src/Cache/Utils/CacheUtils.ts +2 -4
  137. package/src/Platform/version.ts +1 -1
  138. package/src/ServiceWorker/ServiceWorker.ts +2 -2
  139. package/src/Util/JS.ts +2 -13
  140. package/src/Util/Reachability.ts +1 -5
  141. package/src/clients/handlers/authenticated.ts +2 -1
  142. package/src/clients/handlers/fetch.ts +2 -2
  143. package/src/clients/handlers/unauthenticated.ts +2 -1
  144. package/src/clients/internal/composeServiceApi.ts +10 -3
  145. package/src/clients/types/aws.ts +4 -11
  146. package/src/clients/types/http.ts +8 -0
  147. package/src/clients/types/index.ts +0 -1
  148. package/src/index.ts +4 -8
  149. package/src/libraryUtils.ts +3 -4
  150. package/src/parseAWSExports.ts +26 -0
  151. package/src/providers/pinpoint/apis/record.ts +8 -8
  152. package/src/providers/pinpoint/apis/updateEndpoint.ts +2 -2
  153. package/src/providers/pinpoint/types/buffer.ts +1 -1
  154. package/src/providers/pinpoint/types/pinpoint.ts +8 -7
  155. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +16 -12
  156. package/src/providers/pinpoint/utils/isAppInForeground.native.ts +7 -0
  157. package/src/providers/pinpoint/utils/isAppInForeground.ts +4 -0
  158. package/src/singleton/API/types.ts +31 -0
  159. package/src/singleton/Amplify.ts +12 -3
  160. package/src/singleton/Auth/index.ts +9 -2
  161. package/src/singleton/Auth/utils/index.ts +3 -3
  162. package/src/singleton/Storage/types.ts +6 -2
  163. package/src/singleton/types.ts +11 -1
  164. package/src/storage/CookieStorage.native.ts +13 -0
  165. package/src/storage/CookieStorage.ts +72 -0
  166. package/src/storage/DefaultStorage.native.ts +78 -0
  167. package/src/storage/DefaultStorage.ts +14 -0
  168. package/src/storage/InMemoryStorage.ts +36 -0
  169. package/src/{StorageHelper/sessionStorage.ts → storage/KeyValueStorage.ts} +10 -13
  170. package/src/storage/SessionStorage.ts +14 -0
  171. package/src/storage/index.ts +13 -0
  172. package/src/storage/utils.ts +22 -0
  173. package/src/types/storage.ts +4 -0
  174. package/lib/OAuthHelper/FacebookOAuth.d.ts +0 -6
  175. package/lib/OAuthHelper/FacebookOAuth.js +0 -124
  176. package/lib/OAuthHelper/GoogleOAuth.d.ts +0 -6
  177. package/lib/OAuthHelper/GoogleOAuth.js +0 -134
  178. package/lib/OAuthHelper/index.d.ts +0 -4
  179. package/lib/OAuthHelper/index.js +0 -9
  180. package/lib/RNComponents/index.d.ts +0 -6
  181. package/lib/RNComponents/index.js +0 -16
  182. package/lib/RNComponents/reactnative.d.ts +0 -3
  183. package/lib/RNComponents/reactnative.js +0 -14
  184. package/lib/StorageHelper/inMemoryStorage.d.ts +0 -10
  185. package/lib/StorageHelper/inMemoryStorage.js +0 -82
  186. package/lib/StorageHelper/index.d.ts +0 -45
  187. package/lib/StorageHelper/index.js +0 -83
  188. package/lib/StorageHelper/reactnative.d.ts +0 -83
  189. package/lib/StorageHelper/reactnative.js +0 -250
  190. package/lib-esm/OAuthHelper/FacebookOAuth.d.ts +0 -6
  191. package/lib-esm/OAuthHelper/FacebookOAuth.js +0 -121
  192. package/lib-esm/OAuthHelper/GoogleOAuth.d.ts +0 -6
  193. package/lib-esm/OAuthHelper/GoogleOAuth.js +0 -131
  194. package/lib-esm/OAuthHelper/index.d.ts +0 -4
  195. package/lib-esm/OAuthHelper/index.js +0 -6
  196. package/lib-esm/RNComponents/index.d.ts +0 -6
  197. package/lib-esm/RNComponents/index.js +0 -13
  198. package/lib-esm/RNComponents/isAppInForeground.js +0 -6
  199. package/lib-esm/RNComponents/reactnative.d.ts +0 -3
  200. package/lib-esm/RNComponents/reactnative.js +0 -6
  201. package/lib-esm/StorageHelper/inMemoryStorage.d.ts +0 -10
  202. package/lib-esm/StorageHelper/inMemoryStorage.js +0 -79
  203. package/lib-esm/StorageHelper/index.d.ts +0 -45
  204. package/lib-esm/StorageHelper/index.js +0 -76
  205. package/lib-esm/StorageHelper/reactnative.d.ts +0 -83
  206. package/lib-esm/StorageHelper/reactnative.js +0 -244
  207. package/src/OAuthHelper/FacebookOAuth.ts +0 -83
  208. package/src/OAuthHelper/GoogleOAuth.ts +0 -97
  209. package/src/OAuthHelper/index.ts +0 -7
  210. package/src/RNComponents/index.ts +0 -16
  211. package/src/RNComponents/isAppInForeground.ts +0 -8
  212. package/src/RNComponents/reactnative.ts +0 -6
  213. package/src/StorageHelper/cookieStorage.ts +0 -99
  214. package/src/StorageHelper/inMemoryStorage.ts +0 -32
  215. package/src/StorageHelper/index.ts +0 -78
  216. package/src/StorageHelper/localStorage.ts +0 -60
  217. package/src/StorageHelper/reactnative.ts +0 -182
  218. /package/lib-esm/{RNComponents → providers/pinpoint/utils}/isAppInForeground.d.ts +0 -0
  219. /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 { 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,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { StorageHelper } from '../../StorageHelper';
3
+ import { getDefaultStorageWithFallback } from '../../storage/utils';
4
4
  /**
5
5
  * Default cache config
6
6
  */
@@ -11,9 +11,7 @@ export var defaultConfig = {
11
11
  defaultTTL: 259200000,
12
12
  defaultPriority: 5,
13
13
  warningThreshold: 0.8,
14
- // the storage helper will check if localStorage exists,
15
- // if not, will use a in-memory object instead
16
- storage: new StorageHelper().getStorage(),
14
+ storage: getDefaultStorageWithFallback(),
17
15
  };
18
16
  /**
19
17
  * return the byte size of the string
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.814dea6.0+814dea6";
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.814dea6.0+814dea6';
2
+ export var version = '6.0.1-console-preview.047a1dd.0+047a1dd';
@@ -13,7 +13,7 @@
13
13
  * and limitations under the License.
14
14
  */
15
15
  import { ConsoleLogger as Logger } from '../Logger';
16
- import { browserOrNode } from '../Util/JS';
16
+ import { isBrowser } from '../Util/JS';
17
17
  import { Amplify } from '../Amplify';
18
18
  import { asserts } from '../Util/errors/AssertError';
19
19
  import { AmplifyError } from '../Util/Errors';
@@ -124,7 +124,7 @@ var ServiceWorkerClass = /** @class */ (function () {
124
124
  });
125
125
  this._publicKey = publicKey;
126
126
  return new Promise(function (resolve, reject) {
127
- if (browserOrNode().isBrowser) {
127
+ if (isBrowser()) {
128
128
  asserts(_this._registration !== undefined, {
129
129
  name: SERVICE_WORKER_EXCEPTION,
130
130
  message: 'Service Worker registration is undefined',
@@ -6,10 +6,7 @@ export declare const isTextFile: (contentType: string) => boolean;
6
6
  export declare const generateRandomString: () => string;
7
7
  export declare const makeQuerablePromise: (promise: any) => any;
8
8
  export declare const isWebWorker: () => boolean;
9
- export declare const browserOrNode: () => {
10
- isBrowser: boolean;
11
- isNode: boolean;
12
- };
9
+ export declare const isBrowser: () => boolean;
13
10
  /**
14
11
  * transfer the first letter of the keys to lowercase
15
12
  * @param {Object} obj - the object need to be transferred
@@ -133,15 +133,8 @@ export var isWebWorker = function () {
133
133
  return (typeof selfContext.WorkerGlobalScope !== 'undefined' &&
134
134
  self instanceof selfContext.WorkerGlobalScope);
135
135
  };
136
- export var browserOrNode = function () {
137
- var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
138
- var isNode = typeof process !== 'undefined' &&
139
- process.versions != null &&
140
- process.versions.node != null;
141
- return {
142
- isBrowser: isBrowser,
143
- isNode: isNode,
144
- };
136
+ export var isBrowser = function () {
137
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
145
138
  };
146
139
  /**
147
140
  * transfer the first letter of the keys to lowercase
@@ -12,14 +12,11 @@ var __values = (this && this.__values) || function(o) {
12
12
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
13
13
  // SPDX-License-Identifier: Apache-2.0
14
14
  import Observable from 'zen-observable-ts';
15
- import { browserOrNode, isWebWorker } from './JS';
15
+ import { isWebWorker } from './JS';
16
16
  var ReachabilityNavigator = /** @class */ (function () {
17
17
  function ReachabilityNavigator() {
18
18
  }
19
19
  ReachabilityNavigator.prototype.networkMonitor = function (netInfo) {
20
- if (browserOrNode().isNode) {
21
- return Observable.from([{ online: true }]);
22
- }
23
20
  var globalObj = isWebWorker() ? self : window;
24
21
  return new Observable(function (observer) {
25
22
  observer.next({ online: globalObj.navigator.onLine });
@@ -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>;
@@ -1,4 +1,3 @@
1
- import 'isomorphic-unfetch';
2
1
  import { HttpRequest, HttpResponse, HttpTransferOptions } from '../types/http';
3
2
  import { TransferHandler } from '../types/core';
4
3
  export declare const fetchTransferHandler: TransferHandler<HttpRequest, HttpResponse, HttpTransferOptions>;
@@ -47,7 +47,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
48
  }
49
49
  };
50
- import 'isomorphic-unfetch'; // TODO: remove this dependency in v6
51
50
  import { withMemoization } from '../utils/memoization';
52
51
  var shouldSendBody = function (method) {
53
52
  return !['HEAD', 'GET', 'DELETE'].includes(method.toUpperCase());
@@ -55,7 +54,7 @@ var shouldSendBody = function (method) {
55
54
  // TODO[AllanZhengYP]: we need to provide isCanceledError utility
56
55
  export var fetchTransferHandler = function (_a, _b) {
57
56
  var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body;
58
- var abortSignal = _b.abortSignal;
57
+ var abortSignal = _b.abortSignal, cache = _b.cache;
59
58
  return __awaiter(void 0, void 0, void 0, function () {
60
59
  var resp, e_1, responseHeaders, httpResponse, bodyWithMixin;
61
60
  var _c, _d;
@@ -68,6 +67,7 @@ export var fetchTransferHandler = function (_a, _b) {
68
67
  headers: headers,
69
68
  body: shouldSendBody(method) ? body : undefined,
70
69
  signal: abortSignal,
70
+ cache: cache,
71
71
  })];
72
72
  case 1:
73
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';
@@ -5,11 +5,10 @@ export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, Stor
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
- export { StorageHelper, MemoryStorage, LocalStorage, CookieStorage, SessionStorage, MemoryKeyValueStorage, } from './StorageHelper';
8
+ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  import { BrowserStorageCache } from './Cache/BrowserStorageCache';
11
11
  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
@@ -9,7 +9,7 @@ export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredent
9
9
  // AWSClients exports
10
10
  export { getCredentialsForIdentity, getId, } from './AwsClients/CognitoIdentity';
11
11
  // Storage helpers
12
- export { StorageHelper, MemoryStorage, LocalStorage, CookieStorage, SessionStorage, MemoryKeyValueStorage, } from './StorageHelper';
12
+ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
13
13
  // Cache exports
14
14
  import { BrowserStorageCache } from './Cache/BrowserStorageCache';
15
15
  export { InMemoryCache } from './Cache/InMemoryCache';
@@ -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
- export { browserOrNode, filenameToContentType, generateRandomString, isEmpty, isStrictObject, isTextFile, isWebWorker, makeQuerablePromise, objectLessAttributes, sortByField, transferKeyToLowerCase, transferKeyToUpperCase, } from './Util/JS';
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,8 +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 { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
18
- export { AppState, AsyncStorage, Linking } from './RNComponents';
19
19
  export { ErrorParams, AmplifyErrorMap, ServiceError } from './types';
20
20
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
21
21
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
@@ -5,7 +5,8 @@ This file maps top-level exports from `@aws-amplify/core/internals/utils`. These
5
5
  utils for use throughout the library.
6
6
  */
7
7
  // JS utilities
8
- export { browserOrNode, filenameToContentType, generateRandomString, isEmpty, isStrictObject, isTextFile, isWebWorker, makeQuerablePromise, objectLessAttributes, sortByField, transferKeyToLowerCase, transferKeyToUpperCase, } from './Util/JS';
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,8 +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 { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
30
- export { AppState, AsyncStorage, Linking } from './RNComponents';
31
30
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
32
31
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
33
32
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -9,6 +9,11 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var authTypeMapping = {
13
+ API_KEY: 'apiKey',
14
+ AWS_IAM: 'iam',
15
+ AMAZON_COGNITO_USER_POOLS: 'jwt',
16
+ };
12
17
  /**
13
18
  * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
14
19
  * consumable by Amplify.
@@ -19,7 +24,7 @@ var __assign = (this && this.__assign) || function () {
19
24
  */
20
25
  export var parseAWSExports = function (config) {
21
26
  if (config === void 0) { config = {}; }
22
- 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;
27
+ 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_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;
23
28
  var amplifyConfig = {};
24
29
  // Analytics
25
30
  if (aws_mobile_analytics_app_id) {
@@ -30,6 +35,20 @@ export var parseAWSExports = function (config) {
30
35
  },
31
36
  };
32
37
  }
38
+ // TODO: Need to support all API configurations
39
+ // API
40
+ if (aws_appsync_graphqlEndpoint) {
41
+ amplifyConfig.API = {
42
+ AppSync: {
43
+ defaultAuthMode: {
44
+ type: authTypeMapping[aws_appsync_authenticationType],
45
+ apiKey: aws_appsync_apiKey,
46
+ },
47
+ endpoint: aws_appsync_graphqlEndpoint,
48
+ region: aws_appsync_region,
49
+ },
50
+ };
51
+ }
33
52
  // Auth
34
53
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
35
54
  amplifyConfig.Auth = {
@@ -1,5 +1,5 @@
1
- import { PinpointRecordParameters } from '../types';
1
+ import { PinpointRecordInput } from '../types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare const record: ({ appId, category, credentials, event, identityId, region, userAgentValue, }: PinpointRecordParameters) => Promise<void>;
5
+ export declare const record: ({ appId, category, credentials, event, identityId, region, userAgentValue, }: PinpointRecordInput) => Promise<void>;
@@ -68,7 +68,7 @@ export var record = function (_a) {
68
68
  identityId: identityId,
69
69
  region: region,
70
70
  resendLimit: RESEND_LIMIT,
71
- userAgentValue: userAgentValue
71
+ userAgentValue: userAgentValue,
72
72
  });
73
73
  if (!!endpointId) return [3 /*break*/, 4];
74
74
  return [4 /*yield*/, updateEndpoint({
@@ -89,7 +89,7 @@ export var record = function (_a) {
89
89
  if (!endpointId) {
90
90
  throw new AmplifyError({
91
91
  name: 'ENDPOINT_NOT_CREATED',
92
- message: 'Endpoint was not created.'
92
+ message: 'Endpoint was not created.',
93
93
  });
94
94
  }
95
95
  // Generate session if required
@@ -107,7 +107,7 @@ export var record = function (_a) {
107
107
  event: event,
108
108
  session: session,
109
109
  timestamp: timestampISOString,
110
- resendLimit: RESEND_LIMIT
110
+ resendLimit: RESEND_LIMIT,
111
111
  });
112
112
  return [2 /*return*/];
113
113
  }
@@ -1,5 +1,5 @@
1
- import { PinpointUpdateEndpointParameters } from '../types';
1
+ import { PinpointUpdateEndpointInput } from '../types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare const updateEndpoint: ({ address, appId, category, channelType, credentials, identityId, optOut, region, userId, userProfile, userAgentValue, }: PinpointUpdateEndpointParameters) => Promise<void>;
5
+ export declare const updateEndpoint: ({ address, appId, category, channelType, credentials, identityId, optOut, region, userId, userProfile, userAgentValue, }: PinpointUpdateEndpointInput) => Promise<void>;
@@ -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,17 +24,17 @@ 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;
31
31
  };
32
- export type PinpointUpdateEndpointParameters = PinpointCommonParameters & PinpointServiceOptions & {
32
+ export type PinpointUpdateEndpointInput = PinpointCommonParameters & PinpointServiceOptions & {
33
33
  channelType?: SupportedChannelType;
34
34
  userId?: string;
35
35
  userProfile?: UserProfile;
36
36
  };
37
- export type PinpointRecordParameters = PinpointCommonParameters & {
37
+ export type PinpointRecordInput = PinpointCommonParameters & {
38
38
  event: PinpointAnalyticsEvent;
39
39
  };
40
40
  export {};
@@ -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'; };
@@ -0,0 +1,34 @@
1
+ export type LibraryAPIOptions = {
2
+ AppSync: {
3
+ query: string;
4
+ variables?: object;
5
+ authMode?: any;
6
+ authToken?: string;
7
+ /**
8
+ * @deprecated This property should not be used
9
+ */
10
+ userAgentSuffix?: string;
11
+ };
12
+ customHeaders: Function;
13
+ };
14
+ export type APIConfig = {
15
+ AppSync?: {
16
+ defaultAuthMode?: GraphQLAuthMode;
17
+ region?: string;
18
+ endpoint?: string;
19
+ modelIntrospectionSchema?: any;
20
+ };
21
+ };
22
+ export type GraphQLAuthMode = {
23
+ type: 'apiKey';
24
+ apiKey: string;
25
+ } | {
26
+ type: 'jwt';
27
+ token: 'id' | 'access';
28
+ } | {
29
+ type: 'iam';
30
+ } | {
31
+ type: 'lambda';
32
+ } | {
33
+ type: 'custom';
34
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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
  }