@aws-amplify/core 6.0.1-console-preview.11cf989.0 → 6.0.1-console-preview.4ae78ed.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 (122) hide show
  1. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
  2. package/lib/AwsClients/CognitoIdentity/getId.d.ts +2 -1
  3. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
  4. package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -2
  5. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
  6. package/lib/Cache/AsyncStorageCache.d.ts +1 -1
  7. package/lib/Cache/AsyncStorageCache.js +20 -22
  8. package/lib/Platform/types.d.ts +3 -2
  9. package/lib/Platform/types.js +3 -2
  10. package/lib/Platform/version.d.ts +1 -1
  11. package/lib/Platform/version.js +1 -1
  12. package/lib/Reachability/Reachability.native.d.ts +2 -2
  13. package/lib/clients/handlers/fetch.js +2 -1
  14. package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
  15. package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
  16. package/lib/clients/types/http.d.ts +17 -1
  17. package/lib/libraryUtils.d.ts +2 -1
  18. package/lib/libraryUtils.js +4 -1
  19. package/lib/parseAWSExports.js +24 -8
  20. package/lib/providers/kinesis/types/index.d.ts +1 -0
  21. package/lib/providers/kinesis/types/index.js +19 -0
  22. package/lib/providers/kinesis/types/kinesis.d.ts +9 -0
  23. package/lib/providers/kinesis/types/kinesis.js +4 -0
  24. package/lib/providers/kinesis-firehose/types/index.d.ts +1 -0
  25. package/lib/providers/kinesis-firehose/types/index.js +4 -0
  26. package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
  27. package/lib/providers/kinesis-firehose/types/kinesis-firehose.js +4 -0
  28. package/lib/providers/personalize/types/index.d.ts +1 -0
  29. package/lib/providers/personalize/types/index.js +4 -0
  30. package/lib/providers/personalize/types/personalize.d.ts +8 -0
  31. package/lib/providers/personalize/types/personalize.js +4 -0
  32. package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -0
  33. package/lib/providers/pinpoint/apis/flushEvents.js +21 -0
  34. package/lib/providers/pinpoint/apis/index.d.ts +1 -0
  35. package/lib/providers/pinpoint/apis/index.js +3 -1
  36. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  37. package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
  38. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +3 -0
  39. package/lib/singleton/API/types.d.ts +66 -29
  40. package/lib/singleton/Analytics/types.d.ts +4 -1
  41. package/lib/singleton/Auth/utils/index.js +1 -1
  42. package/lib/storage/DefaultStorage.native.d.ts +2 -2
  43. package/lib/storage/DefaultStorage.native.js +3 -24
  44. package/lib/tsconfig.tsbuildinfo +1 -1
  45. package/lib/utils/globalHelpers/index.native.d.ts +0 -1
  46. package/lib/utils/globalHelpers/index.native.js +2 -1
  47. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
  48. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +2 -1
  49. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
  50. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -2
  51. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
  52. package/lib-esm/Cache/AsyncStorageCache.d.ts +1 -1
  53. package/lib-esm/Cache/AsyncStorageCache.js +2 -1
  54. package/lib-esm/Platform/types.d.ts +3 -2
  55. package/lib-esm/Platform/types.js +3 -2
  56. package/lib-esm/Platform/version.d.ts +1 -1
  57. package/lib-esm/Platform/version.js +1 -1
  58. package/lib-esm/Reachability/Reachability.native.d.ts +2 -2
  59. package/lib-esm/clients/handlers/fetch.js +2 -1
  60. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
  61. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
  62. package/lib-esm/clients/types/http.d.ts +17 -1
  63. package/lib-esm/libraryUtils.d.ts +2 -1
  64. package/lib-esm/libraryUtils.js +2 -0
  65. package/lib-esm/parseAWSExports.js +24 -8
  66. package/lib-esm/providers/kinesis/types/index.d.ts +1 -0
  67. package/lib-esm/providers/kinesis/types/index.js +3 -0
  68. package/lib-esm/providers/kinesis/types/kinesis.d.ts +9 -0
  69. package/lib-esm/providers/kinesis/types/kinesis.js +3 -0
  70. package/lib-esm/providers/kinesis-firehose/types/index.d.ts +1 -0
  71. package/lib-esm/providers/kinesis-firehose/types/index.js +3 -0
  72. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
  73. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.js +3 -0
  74. package/lib-esm/providers/personalize/types/index.d.ts +1 -0
  75. package/lib-esm/providers/personalize/types/index.js +3 -0
  76. package/lib-esm/providers/personalize/types/personalize.d.ts +8 -0
  77. package/lib-esm/providers/personalize/types/personalize.js +3 -0
  78. package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -0
  79. package/lib-esm/providers/pinpoint/apis/flushEvents.js +17 -0
  80. package/lib-esm/providers/pinpoint/apis/index.d.ts +1 -0
  81. package/lib-esm/providers/pinpoint/apis/index.js +1 -0
  82. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  83. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
  84. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +3 -0
  85. package/lib-esm/singleton/API/types.d.ts +66 -29
  86. package/lib-esm/singleton/Analytics/types.d.ts +4 -1
  87. package/lib-esm/singleton/Auth/utils/index.js +1 -1
  88. package/lib-esm/storage/DefaultStorage.native.d.ts +2 -2
  89. package/lib-esm/storage/DefaultStorage.native.js +3 -24
  90. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  91. package/lib-esm/utils/globalHelpers/index.native.d.ts +0 -1
  92. package/lib-esm/utils/globalHelpers/index.native.js +2 -1
  93. package/package.json +4 -10
  94. package/src/Cache/AsyncStorageCache.ts +2 -1
  95. package/src/Hub/index.ts +1 -0
  96. package/src/Platform/types.ts +3 -2
  97. package/src/Platform/version.ts +1 -1
  98. package/src/Reachability/Reachability.native.ts +4 -2
  99. package/src/Signer/DateUtils.ts +1 -1
  100. package/src/clients/handlers/fetch.ts +5 -1
  101. package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +3 -1
  102. package/src/clients/types/http.ts +19 -1
  103. package/src/libraryUtils.ts +4 -1
  104. package/src/parseAWSExports.ts +38 -7
  105. package/src/providers/kinesis/types/index.ts +4 -0
  106. package/src/providers/kinesis/types/kinesis.ts +12 -0
  107. package/src/providers/kinesis-firehose/types/index.ts +4 -0
  108. package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +12 -0
  109. package/src/providers/personalize/types/index.ts +4 -0
  110. package/src/providers/personalize/types/personalize.ts +11 -0
  111. package/src/providers/pinpoint/apis/flushEvents.ts +31 -0
  112. package/src/providers/pinpoint/apis/index.ts +1 -0
  113. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  114. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +4 -0
  115. package/src/singleton/API/types.ts +77 -26
  116. package/src/singleton/Analytics/types.ts +7 -1
  117. package/src/singleton/Auth/utils/index.ts +1 -1
  118. package/src/storage/DefaultStorage.native.ts +6 -26
  119. package/src/utils/globalHelpers/index.native.ts +3 -1
  120. package/polyfills/URL/index.ts +0 -14
  121. package/polyfills/URL/tsconfig.json +0 -10
  122. package/polyfills/URL/webpack.config.js +0 -43
@@ -1,4 +1,3 @@
1
- import 'react-native-get-random-values';
2
1
  import { encode, decode } from 'base-64';
3
2
  export declare const getCrypto: () => Crypto;
4
3
  export declare const getBtoa: () => typeof encode;
@@ -3,9 +3,10 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.getAtob = exports.getBtoa = exports.getCrypto = void 0;
6
- require("react-native-get-random-values");
6
+ var react_native_1 = require("@aws-amplify/react-native");
7
7
  var base_64_1 = require("base-64");
8
8
  var errors_1 = require("../../errors");
9
+ (0, react_native_1.loadGetRandomValues)();
9
10
  var getCrypto = function () {
10
11
  if (typeof crypto !== 'undefined' &&
11
12
  typeof crypto.getRandomValues === 'function') {
@@ -14,8 +14,9 @@ export declare const getCredentialsForIdentity: (config: {
14
14
  userAgentValue?: string | undefined;
15
15
  cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
16
16
  } & {
17
- region: string;
18
17
  abortSignal?: AbortSignal | undefined;
18
+ withCrossDomainCredentials?: boolean | undefined;
19
19
  maxAttempts?: number | undefined;
20
20
  userAgentHeader?: string | undefined;
21
+ region: string;
21
22
  }, input: GetCredentialsForIdentityInput) => Promise<GetCredentialsForIdentityOutput>;
@@ -14,8 +14,9 @@ export declare const getId: (config: {
14
14
  userAgentValue?: string | undefined;
15
15
  cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
16
16
  } & {
17
- region: string;
18
17
  abortSignal?: AbortSignal | undefined;
18
+ withCrossDomainCredentials?: boolean | undefined;
19
19
  maxAttempts?: number | undefined;
20
20
  userAgentHeader?: string | undefined;
21
+ region: string;
21
22
  }, input: GetIdInput) => Promise<GetIdOutput>;
@@ -13,11 +13,12 @@ export declare const getInAppMessages: (config: {
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
16
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
17
- region: string;
18
16
  abortSignal?: AbortSignal | undefined;
19
17
  cache?: RequestCache | undefined;
18
+ withCrossDomainCredentials?: boolean | undefined;
20
19
  maxAttempts?: number | undefined;
21
20
  userAgentHeader?: string | undefined;
22
21
  uriEscapePath?: boolean | undefined;
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
+ region: string;
23
24
  }, input: GetInAppMessagesInput) => Promise<GetInAppMessagesOutput>;
@@ -13,11 +13,12 @@ export declare const putEvents: (config: {
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
16
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
17
- region: string;
18
16
  abortSignal?: AbortSignal | undefined;
19
17
  cache?: RequestCache | undefined;
18
+ withCrossDomainCredentials?: boolean | undefined;
20
19
  maxAttempts?: number | undefined;
21
20
  userAgentHeader?: string | undefined;
22
21
  uriEscapePath?: boolean | undefined;
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
+ region: string;
23
24
  }, input: PutEventsInput) => Promise<PutEventsOutput>;
@@ -13,11 +13,12 @@ export declare const updateEndpoint: (config: {
13
13
  computeDelay?: ((attempt: number) => number) | undefined;
14
14
  userAgentValue?: string | undefined;
15
15
  } & {
16
- credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
17
- region: string;
18
16
  abortSignal?: AbortSignal | undefined;
19
17
  cache?: RequestCache | undefined;
18
+ withCrossDomainCredentials?: boolean | undefined;
20
19
  maxAttempts?: number | undefined;
21
20
  userAgentHeader?: string | undefined;
22
21
  uriEscapePath?: boolean | undefined;
22
+ credentials: import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity | (() => Promise<import("@smithy/types/dist-types/identity/awsCredentialIdentity").AwsCredentialIdentity>);
23
+ region: string;
23
24
  }, input: UpdateEndpointInput) => Promise<UpdateEndpointOutput>;
@@ -1,6 +1,6 @@
1
- import AsyncStorage from '@react-native-async-storage/async-storage';
2
1
  import { StorageCache } from './StorageCache';
3
2
  import { CacheConfig, CacheItem, CacheItemOptions, ICache } from './types';
3
+ declare const AsyncStorage: import("@react-native-async-storage/async-storage").AsyncStorageStatic;
4
4
  export declare class AsyncStorageCache extends StorageCache implements ICache {
5
5
  /**
6
6
  * initialize the cache
@@ -51,13 +51,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
51
51
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
52
52
  }
53
53
  };
54
- import AsyncStorage from '@react-native-async-storage/async-storage';
54
+ import { loadAsyncStorage } from '@aws-amplify/react-native';
55
55
  import { ConsoleLogger as Logger } from '../Logger';
56
56
  import { StorageCache } from './StorageCache';
57
57
  import { defaultConfig, getCurrTime } from './Utils';
58
58
  import { getCurrSizeKey } from './Utils/CacheUtils';
59
59
  import { assert, CacheErrorCode } from './Utils/errorHelpers';
60
60
  var logger = new Logger('AsyncStorageCache');
61
+ var AsyncStorage = loadAsyncStorage();
61
62
  /*
62
63
  * Customized cache which based on the AsyncStorage with LRU implemented
63
64
  */
@@ -31,7 +31,7 @@ export declare enum Category {
31
31
  }
32
32
  export declare enum AnalyticsAction {
33
33
  Record = "1",
34
- UpdateEndpoint = "2"
34
+ IdentifyUser = "2"
35
35
  }
36
36
  export declare enum ApiAction {
37
37
  GraphQl = "1",
@@ -53,7 +53,8 @@ export declare enum GeoAction {
53
53
  None = "0"
54
54
  }
55
55
  export declare enum InAppMessagingAction {
56
- None = "0"
56
+ SyncMessages = "1",
57
+ IdentifyUser = "2"
57
58
  }
58
59
  export declare enum InteractionsAction {
59
60
  None = "0"
@@ -39,7 +39,7 @@ export var Category;
39
39
  export var AnalyticsAction;
40
40
  (function (AnalyticsAction) {
41
41
  AnalyticsAction["Record"] = "1";
42
- AnalyticsAction["UpdateEndpoint"] = "2";
42
+ AnalyticsAction["IdentifyUser"] = "2";
43
43
  })(AnalyticsAction || (AnalyticsAction = {}));
44
44
  export var ApiAction;
45
45
  (function (ApiAction) {
@@ -99,7 +99,8 @@ export var GeoAction;
99
99
  })(GeoAction || (GeoAction = {}));
100
100
  export var InAppMessagingAction;
101
101
  (function (InAppMessagingAction) {
102
- InAppMessagingAction["None"] = "0";
102
+ InAppMessagingAction["SyncMessages"] = "1";
103
+ InAppMessagingAction["IdentifyUser"] = "2";
103
104
  })(InAppMessagingAction || (InAppMessagingAction = {}));
104
105
  export var InteractionsAction;
105
106
  (function (InteractionsAction) {
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.11cf989.0+11cf989";
1
+ export declare const version = "6.0.1-console-preview.4ae78ed.0+4ae78ed";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '6.0.1-console-preview.11cf989.0+11cf989';
2
+ export var version = '6.0.1-console-preview.4ae78ed.0+4ae78ed';
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
- import type NetInfo from '@react-native-community/netinfo';
2
+ import { loadNetInfo } from '@aws-amplify/react-native';
3
3
  import { NetworkStatus } from './types';
4
4
  export declare class Reachability {
5
- networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
5
+ networkMonitor(netInfo?: ReturnType<typeof loadNetInfo>): Observable<NetworkStatus>;
6
6
  }
@@ -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, cache = _b.cache;
57
+ var abortSignal = _b.abortSignal, cache = _b.cache, withCrossDomainCredentials = _b.withCrossDomainCredentials;
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;
@@ -68,6 +68,7 @@ export var fetchTransferHandler = function (_a, _b) {
68
68
  body: shouldSendBody(method) ? body : undefined,
69
69
  signal: abortSignal,
70
70
  cache: cache,
71
+ credentials: withCrossDomainCredentials ? 'include' : 'same-origin',
71
72
  })];
72
73
  case 1:
73
74
  resp = _e.sent();
@@ -1,4 +1,3 @@
1
- import '@aws-amplify/core/polyfills/URL';
2
1
  export { signRequest } from './signRequest';
3
2
  export { presignUrl } from './presignUrl';
4
3
  export { TOKEN_QUERY_PARAM } from './constants';
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import '@aws-amplify/core/polyfills/URL';
3
+ import { loadUrlPolyfill } from '@aws-amplify/react-native';
4
+ loadUrlPolyfill();
4
5
  // TODO: V6 replace Signer
5
6
  export { signRequest } from './signRequest';
6
7
  export { presignUrl } from './presignUrl';
@@ -17,7 +17,7 @@ export interface HttpRequest extends Request {
17
17
  */
18
18
  export type ResponseBodyMixin = Pick<Body, 'blob' | 'json' | 'text'>;
19
19
  export interface HttpResponse extends Response {
20
- body: (ResponseBodyMixin & ReadableStream) | ResponseBodyMixin | null;
20
+ body: (ResponseBodyMixin & ReadableStream) | ResponseBodyMixin;
21
21
  statusCode: number;
22
22
  /**
23
23
  * @see {@link HttpRequest.headers}
@@ -34,5 +34,21 @@ export interface HttpTransferOptions {
34
34
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/cache}
35
35
  */
36
36
  cache?: RequestCache;
37
+ /**
38
+ * Internal-only option controls whether or not cross-site Access-Control requests should be made using credentials
39
+ * such as cookies, authorization headers or TLS client certificates. It has no effect on same-origin requests.
40
+ * If set to `true`, the request will include credentials such as cookies, authorization headers, TLS
41
+ * client certificates, and so on. Moreover the response cookies will also be set.
42
+ * If set to `false`, the cross-site request will not include credentials, and the response cookies from a different
43
+ * domain will be ignored.
44
+ *
45
+ * This option is only conformed by {@link fetchTransferHandler | fetchTransferHandler }
46
+ *
47
+ * @default 'same-origin'
48
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials}
49
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials}
50
+ * @internal
51
+ */
52
+ withCrossDomainCredentials?: boolean;
37
53
  }
38
54
  export type HttpTransferHandler = TransferHandler<HttpRequest, HttpResponse, HttpTransferOptions>;
@@ -4,7 +4,7 @@ export { LegacyConfig } from './singleton/types';
4
4
  export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, } from './singleton/Auth/types';
5
5
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
6
6
  export { isTokenExpired } from './singleton/Auth';
7
- export { GraphQLAuthMode, GraphQLAuthModeKeys } from './singleton/API/types';
7
+ export { APIAuthMode, DocumentType } from './singleton/API/types';
8
8
  export { Signer } from './Signer';
9
9
  export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
10
10
  export { ClientDevice } from './ClientDevice';
@@ -21,3 +21,4 @@ export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
21
21
  export { AMPLIFY_SYMBOL } from './Hub';
22
22
  export { base64Decoder, base64Encoder } from './utils/convert';
23
23
  export { getCrypto } from './utils/globalHelpers';
24
+ export { HubClass } from './Hub';
@@ -30,3 +30,5 @@ export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
30
30
  export { AMPLIFY_SYMBOL } from './Hub';
31
31
  export { base64Decoder, base64Encoder } from './utils/convert';
32
32
  export { getCrypto } from './utils/globalHelpers';
33
+ // Hub
34
+ export { HubClass } from './Hub';
@@ -9,10 +9,17 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
13
+ // SPDX-License-Identifier: Apache-2.0
14
+ import { ConsoleLogger as Logger } from './Logger';
15
+ var logger = new Logger('parseAWSExports');
12
16
  var authTypeMapping = {
13
17
  API_KEY: 'apiKey',
14
18
  AWS_IAM: 'iam',
15
- AMAZON_COGNITO_USER_POOLS: 'jwt',
19
+ AMAZON_COGNITO_USER_POOLS: 'userPool',
20
+ OPENID_CONNECT: 'oidc',
21
+ NONE: 'none',
22
+ LAMBDA: 'lambda',
16
23
  };
17
24
  /**
18
25
  * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
@@ -24,7 +31,7 @@ var authTypeMapping = {
24
31
  */
25
32
  export var parseAWSExports = function (config) {
26
33
  if (config === void 0) { config = {}; }
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;
34
+ 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, aws_cloud_logic_custom = config.aws_cloud_logic_custom;
28
35
  var amplifyConfig = {};
29
36
  // Analytics
30
37
  if (aws_mobile_analytics_app_id) {
@@ -35,17 +42,18 @@ export var parseAWSExports = function (config) {
35
42
  },
36
43
  };
37
44
  }
38
- // TODO: Need to support all API configurations
39
45
  // API
40
46
  if (aws_appsync_graphqlEndpoint) {
47
+ var defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];
48
+ if (!defaultAuthMode) {
49
+ logger.debug("Invalid authentication type ".concat(aws_appsync_authenticationType, ". Falling back to IAM."));
50
+ }
41
51
  amplifyConfig.API = {
42
- AppSync: {
43
- defaultAuthMode: {
44
- type: authTypeMapping[aws_appsync_authenticationType],
45
- apiKey: aws_appsync_apiKey,
46
- },
52
+ GraphQL: {
47
53
  endpoint: aws_appsync_graphqlEndpoint,
54
+ apiKey: aws_appsync_apiKey,
48
55
  region: aws_appsync_region,
56
+ defaultAuthMode: defaultAuthMode !== null && defaultAuthMode !== void 0 ? defaultAuthMode : 'iam',
49
57
  },
50
58
  };
51
59
  }
@@ -77,6 +85,14 @@ export var parseAWSExports = function (config) {
77
85
  }
78
86
  : __assign({}, geo);
79
87
  }
88
+ // REST API
89
+ if (aws_cloud_logic_custom) {
90
+ amplifyConfig.API = __assign(__assign({}, amplifyConfig.API), { REST: aws_cloud_logic_custom.reduce(function (acc, api) {
91
+ var _a;
92
+ var name = api.name, endpoint = api.endpoint, region = api.region, service = api.service;
93
+ return __assign(__assign({}, acc), (_a = {}, _a[name] = __assign(__assign({ endpoint: endpoint }, (service ? { service: service } : undefined)), (region ? { region: region } : undefined)), _a));
94
+ }, {}) });
95
+ }
80
96
  return amplifyConfig;
81
97
  };
82
98
  var getRedirectUrl = function (redirectStr) {
@@ -0,0 +1 @@
1
+ export * from './kinesis';
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export * from './kinesis';
@@ -0,0 +1,9 @@
1
+ export type KinesisProviderConfig = {
2
+ Kinesis?: {
3
+ region: string;
4
+ bufferSize?: number;
5
+ flushSize?: number;
6
+ flushInterval?: number;
7
+ resendLimit?: number;
8
+ };
9
+ };
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1 @@
1
+ export { KinesisFirehoseProviderConfig } from './kinesis-firehose';
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1,9 @@
1
+ export type KinesisFirehoseProviderConfig = {
2
+ KinesisFirehose?: {
3
+ region: string;
4
+ bufferSize?: number;
5
+ flushSize?: number;
6
+ flushInterval?: number;
7
+ resendLimit?: number;
8
+ };
9
+ };
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1 @@
1
+ export { PersonalizeProviderConfig } from './personalize';
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1,8 @@
1
+ export type PersonalizeProviderConfig = {
2
+ Personalize?: {
3
+ trackingId: string;
4
+ region: string;
5
+ flushSize?: number;
6
+ flushInterval?: number;
7
+ };
8
+ };
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Credentials } from '@aws-sdk/types';
2
+ export declare const flushEvents: (appId: string, region: string, credentials: Credentials, identityId?: string, userAgentValue?: string) => void;
@@ -0,0 +1,17 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { getEventBuffer } from '../utils/getEventBuffer';
4
+ import { BUFFER_SIZE, FLUSH_INTERVAL, FLUSH_SIZE, RESEND_LIMIT, } from '../utils/constants';
5
+ export var flushEvents = function (appId, region, credentials, identityId, userAgentValue) {
6
+ getEventBuffer({
7
+ appId: appId,
8
+ bufferSize: BUFFER_SIZE,
9
+ credentials: credentials,
10
+ flushInterval: FLUSH_INTERVAL,
11
+ flushSize: FLUSH_SIZE,
12
+ identityId: identityId,
13
+ region: region,
14
+ resendLimit: RESEND_LIMIT,
15
+ userAgentValue: userAgentValue,
16
+ }).flushAll();
17
+ };
@@ -1,2 +1,3 @@
1
1
  export { updateEndpoint } from './updateEndpoint';
2
2
  export { record } from './record';
3
+ export { flushEvents } from './flushEvents';
@@ -2,3 +2,4 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export { updateEndpoint } from './updateEndpoint';
4
4
  export { record } from './record';
5
+ export { flushEvents } from './flushEvents';
@@ -3,7 +3,7 @@ import { UserProfile } from '../../../types';
3
3
  export type SupportedCategory = 'Analytics' | 'InAppMessaging' | 'PushNotification';
4
4
  export 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
  };
@@ -12,6 +12,7 @@ export declare class PinpointEventBuffer {
12
12
  resume(): void;
13
13
  flush(): void;
14
14
  identityHasChanged(identityId: AuthSession['identityId']): boolean;
15
+ flushAll(): void;
15
16
  private _startLoop;
16
17
  private _sendBatch;
17
18
  private _putEvents;
@@ -110,6 +110,9 @@ var PinpointEventBuffer = /** @class */ (function () {
110
110
  PinpointEventBuffer.prototype.identityHasChanged = function (identityId) {
111
111
  return this._config.identityId !== identityId;
112
112
  };
113
+ PinpointEventBuffer.prototype.flushAll = function () {
114
+ this._putEvents(this._buffer.splice(0, this._buffer.length));
115
+ };
113
116
  PinpointEventBuffer.prototype._startLoop = function () {
114
117
  if (this._interval) {
115
118
  clearInterval(this._interval);
@@ -1,35 +1,72 @@
1
+ import { Headers } from '../../clients';
1
2
  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;
3
+ GraphQL?: {
4
+ headers?: (options: {
5
+ query: string;
6
+ variables: Record<string, DocumentType>;
7
+ }) => Promise<Headers>;
11
8
  };
12
- customHeaders: Function;
9
+ REST?: {
10
+ headers?: (options: {
11
+ apiName: string;
12
+ }) => Promise<Headers>;
13
+ };
14
+ };
15
+ type APIGraphQLConfig = {
16
+ /**
17
+ * Required GraphQL endpoint, must be a valid URL string.
18
+ */
19
+ endpoint: string;
20
+ /**
21
+ * Optional region string used to sign the request. Required only if the auth mode is 'iam'.
22
+ */
23
+ region?: string;
24
+ /**
25
+ * Optional API key string. Required only if the auth mode is 'apiKey'.
26
+ */
27
+ apiKey?: string;
28
+ /**
29
+ * Custom domain endpoint for GraphQL API.
30
+ */
31
+ customEndpoint?: string;
32
+ /**
33
+ * Optional region string used to sign the request to `customEndpoint`. Effective only if `customEndpoint` is
34
+ * specified, and the auth mode is 'iam'.
35
+ */
36
+ customEndpointRegion?: string;
37
+ /**
38
+ * Default auth mode for all the API calls to given service.
39
+ */
40
+ defaultAuthMode: APIAuthMode;
41
+ };
42
+ type APIRestConfig = {
43
+ /**
44
+ * Required REST endpoint, must be a valid URL string.
45
+ */
46
+ endpoint: string;
47
+ /**
48
+ * Optional region string used to sign the request with IAM credentials. If Omitted, region will be extracted from
49
+ * the endpoint.
50
+ *
51
+ * @default 'us-east-1'
52
+ */
53
+ region?: string;
54
+ /**
55
+ * Optional service name string to sign the request with IAM credentials.
56
+ *
57
+ * @default 'execute-api'
58
+ */
59
+ service?: string;
13
60
  };
14
61
  export type APIConfig = {
15
- AppSync?: {
16
- defaultAuthMode: GraphQLAuthMode;
17
- region: string;
18
- endpoint: string;
19
- modelIntrospectionSchema?: any;
20
- };
62
+ REST?: Record<string, APIRestConfig>;
63
+ GraphQL?: APIGraphQLConfig;
21
64
  };
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';
65
+ export type APIAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'lambda' | 'none';
66
+ /**
67
+ * Type representing a plain JavaScript object that can be serialized to JSON.
68
+ */
69
+ export type DocumentType = null | boolean | number | string | DocumentType[] | {
70
+ [prop: string]: DocumentType;
34
71
  };
35
- export type GraphQLAuthModeKeys = 'apiKey' | 'jwt' | 'iam' | 'lambda' | 'custom';
72
+ export {};
@@ -1,2 +1,5 @@
1
1
  import { PinpointProviderConfig } from '../../providers/pinpoint/types';
2
- export type AnalyticsConfig = PinpointProviderConfig;
2
+ import { KinesisProviderConfig } from '../../providers/kinesis/types';
3
+ import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
4
+ import { PersonalizeProviderConfig } from '../../providers/personalize/types';
5
+ export type AnalyticsConfig = PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig;
@@ -9,7 +9,7 @@ export function assertTokenProviderConfig(cognitoConfig) {
9
9
  }
10
10
  else {
11
11
  assertionValid =
12
- !!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
12
+ !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;
13
13
  }
14
14
  return assert(assertionValid, AuthConfigurationErrorCode.AuthTokenConfigException);
15
15
  }
@@ -3,7 +3,8 @@ import { KeyValueStorageInterface } from '../types';
3
3
  * @internal
4
4
  */
5
5
  export declare class DefaultStorage implements KeyValueStorageInterface {
6
- private asyncStorage?;
6
+ private asyncStorage;
7
+ constructor();
7
8
  /**
8
9
  * This is used to set a specific item in storage
9
10
  * @param {string} key - the key for the item
@@ -29,5 +30,4 @@ export declare class DefaultStorage implements KeyValueStorageInterface {
29
30
  * @returns {string} nothing
30
31
  */
31
32
  clear(): Promise<void>;
32
- private assertModule;
33
33
  }