@aws-amplify/core 6.0.1-console-preview.deaebd5.0 → 6.0.1-console-preview.b5a42af.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.
- package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
- package/lib/AwsClients/CognitoIdentity/getId.d.ts +2 -1
- package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -2
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
- package/lib/Cache/AsyncStorageCache.d.ts +1 -1
- package/lib/Cache/AsyncStorageCache.js +20 -22
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.native.d.ts +2 -2
- package/lib/clients/handlers/fetch.js +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
- package/lib/clients/types/http.d.ts +16 -0
- package/lib/libraryUtils.d.ts +1 -1
- package/lib/parseAWSExports.js +24 -8
- package/lib/providers/pinpoint/index.d.ts +1 -0
- package/lib/providers/pinpoint/index.js +3 -0
- package/lib/singleton/API/types.d.ts +66 -29
- package/lib/singleton/Auth/utils/index.js +1 -1
- package/lib/singleton/Notifications/InAppMessaging/types.d.ts +2 -0
- package/lib/singleton/Notifications/InAppMessaging/types.js +4 -0
- package/lib/singleton/Notifications/types.d.ts +4 -0
- package/lib/singleton/Notifications/types.js +4 -0
- package/lib/singleton/types.d.ts +2 -0
- package/lib/storage/DefaultStorage.native.d.ts +2 -2
- package/lib/storage/DefaultStorage.native.js +3 -24
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/globalHelpers/index.native.d.ts +0 -1
- package/lib/utils/globalHelpers/index.native.js +2 -1
- package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
- package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +2 -1
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -2
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
- package/lib-esm/Cache/AsyncStorageCache.d.ts +1 -1
- package/lib-esm/Cache/AsyncStorageCache.js +2 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.native.d.ts +2 -2
- package/lib-esm/clients/handlers/fetch.js +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
- package/lib-esm/clients/types/http.d.ts +16 -0
- package/lib-esm/libraryUtils.d.ts +1 -1
- package/lib-esm/parseAWSExports.js +24 -8
- package/lib-esm/providers/pinpoint/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/index.js +1 -0
- package/lib-esm/singleton/API/types.d.ts +66 -29
- package/lib-esm/singleton/Auth/utils/index.js +1 -1
- package/lib-esm/singleton/Notifications/InAppMessaging/types.d.ts +2 -0
- package/lib-esm/singleton/Notifications/InAppMessaging/types.js +3 -0
- package/lib-esm/singleton/Notifications/types.d.ts +4 -0
- package/lib-esm/singleton/Notifications/types.js +3 -0
- package/lib-esm/singleton/types.d.ts +2 -0
- package/lib-esm/storage/DefaultStorage.native.d.ts +2 -2
- package/lib-esm/storage/DefaultStorage.native.js +3 -24
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/utils/globalHelpers/index.native.d.ts +0 -1
- package/lib-esm/utils/globalHelpers/index.native.js +2 -1
- package/package.json +3 -9
- package/src/Cache/AsyncStorageCache.ts +2 -1
- package/src/Platform/version.ts +1 -1
- package/src/Reachability/Reachability.native.ts +4 -2
- package/src/clients/handlers/fetch.ts +5 -1
- package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +3 -1
- package/src/clients/types/http.ts +18 -0
- package/src/libraryUtils.ts +1 -1
- package/src/parseAWSExports.ts +38 -7
- package/src/providers/pinpoint/index.ts +1 -0
- package/src/singleton/API/types.ts +77 -26
- package/src/singleton/Auth/utils/index.ts +1 -1
- package/src/singleton/Notifications/InAppMessaging/types.ts +6 -0
- package/src/singleton/Notifications/types.ts +8 -0
- package/src/singleton/types.ts +2 -1
- package/src/storage/DefaultStorage.native.ts +6 -26
- package/src/utils/globalHelpers/index.native.ts +3 -1
- package/polyfills/URL/index.ts +0 -14
- package/polyfills/URL/tsconfig.json +0 -10
- package/polyfills/URL/webpack.config.js +0 -43
|
@@ -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
|
|
@@ -52,19 +52,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
56
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
57
|
-
};
|
|
58
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
56
|
exports.Cache = exports.AsyncStorage = exports.AsyncStorageCache = void 0;
|
|
60
|
-
var
|
|
61
|
-
exports.AsyncStorage = async_storage_1.default;
|
|
57
|
+
var react_native_1 = require("@aws-amplify/react-native");
|
|
62
58
|
var Logger_1 = require("../Logger");
|
|
63
59
|
var StorageCache_1 = require("./StorageCache");
|
|
64
60
|
var Utils_1 = require("./Utils");
|
|
65
61
|
var CacheUtils_1 = require("./Utils/CacheUtils");
|
|
66
62
|
var errorHelpers_1 = require("./Utils/errorHelpers");
|
|
67
63
|
var logger = new Logger_1.ConsoleLogger('AsyncStorageCache');
|
|
64
|
+
var AsyncStorage = (0, react_native_1.loadAsyncStorage)();
|
|
65
|
+
exports.AsyncStorage = AsyncStorage;
|
|
68
66
|
/*
|
|
69
67
|
* Customized cache which based on the AsyncStorage with LRU implemented
|
|
70
68
|
*/
|
|
@@ -96,7 +94,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
96
94
|
case 0: return [4 /*yield*/, this.getCacheCurSize()];
|
|
97
95
|
case 1:
|
|
98
96
|
curSize = _a.sent();
|
|
99
|
-
return [4 /*yield*/,
|
|
97
|
+
return [4 /*yield*/, AsyncStorage.setItem((0, CacheUtils_1.getCurrSizeKey)(this.cacheConfig.keyPrefix), (curSize - amount).toString())];
|
|
100
98
|
case 2:
|
|
101
99
|
_a.sent();
|
|
102
100
|
return [2 /*return*/];
|
|
@@ -117,7 +115,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
117
115
|
case 0: return [4 /*yield*/, this.getCacheCurSize()];
|
|
118
116
|
case 1:
|
|
119
117
|
curSize = _a.sent();
|
|
120
|
-
return [4 /*yield*/,
|
|
118
|
+
return [4 /*yield*/, AsyncStorage.setItem((0, CacheUtils_1.getCurrSizeKey)(this.cacheConfig.keyPrefix), (curSize + amount).toString())];
|
|
121
119
|
case 2:
|
|
122
120
|
_a.sent();
|
|
123
121
|
return [2 /*return*/];
|
|
@@ -139,7 +137,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
139
137
|
switch (_a.label) {
|
|
140
138
|
case 0:
|
|
141
139
|
item.visitedTime = (0, Utils_1.getCurrTime)();
|
|
142
|
-
return [4 /*yield*/,
|
|
140
|
+
return [4 /*yield*/, AsyncStorage.setItem(prefixedKey, JSON.stringify(item))];
|
|
143
141
|
case 1:
|
|
144
142
|
_a.sent();
|
|
145
143
|
return [2 /*return*/, item];
|
|
@@ -159,7 +157,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
159
157
|
var text, item;
|
|
160
158
|
return __generator(this, function (_a) {
|
|
161
159
|
switch (_a.label) {
|
|
162
|
-
case 0: return [4 /*yield*/,
|
|
160
|
+
case 0: return [4 /*yield*/, AsyncStorage.getItem(key)];
|
|
163
161
|
case 1:
|
|
164
162
|
text = _a.sent();
|
|
165
163
|
(0, errorHelpers_1.assert)(text !== null, errorHelpers_1.CacheErrorCode.NoCacheItem, "Key: ".concat(key));
|
|
@@ -183,7 +181,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
183
181
|
var config, itemSize, removeItemError_1;
|
|
184
182
|
return __generator(this, function (_a) {
|
|
185
183
|
switch (_a.label) {
|
|
186
|
-
case 0: return [4 /*yield*/,
|
|
184
|
+
case 0: return [4 /*yield*/, AsyncStorage.getItem(prefixedKey)];
|
|
187
185
|
case 1:
|
|
188
186
|
config = _a.sent();
|
|
189
187
|
(0, errorHelpers_1.assert)(!!config, errorHelpers_1.CacheErrorCode.NoCacheItem, "Key: ".concat(prefixedKey));
|
|
@@ -196,7 +194,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
196
194
|
_a.label = 3;
|
|
197
195
|
case 3:
|
|
198
196
|
_a.trys.push([3, 5, , 7]);
|
|
199
|
-
return [4 /*yield*/,
|
|
197
|
+
return [4 /*yield*/, AsyncStorage.removeItem(prefixedKey)];
|
|
200
198
|
case 4:
|
|
201
199
|
_a.sent();
|
|
202
200
|
return [3 /*break*/, 7];
|
|
@@ -235,7 +233,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
235
233
|
_a.label = 2;
|
|
236
234
|
case 2:
|
|
237
235
|
_a.trys.push([2, 4, , 6]);
|
|
238
|
-
return [4 /*yield*/,
|
|
236
|
+
return [4 /*yield*/, AsyncStorage.setItem(prefixedKey, JSON.stringify(item))];
|
|
239
237
|
case 3:
|
|
240
238
|
_a.sent();
|
|
241
239
|
return [3 /*break*/, 6];
|
|
@@ -314,7 +312,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
314
312
|
case 0:
|
|
315
313
|
keys = [];
|
|
316
314
|
keyInCache = [];
|
|
317
|
-
return [4 /*yield*/,
|
|
315
|
+
return [4 /*yield*/, AsyncStorage.getAllKeys()];
|
|
318
316
|
case 1:
|
|
319
317
|
keyInCache = _a.sent();
|
|
320
318
|
i = 0;
|
|
@@ -362,7 +360,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
362
360
|
_a.label = 1;
|
|
363
361
|
case 1:
|
|
364
362
|
if (!(i < keys.length)) return [3 /*break*/, 4];
|
|
365
|
-
return [4 /*yield*/,
|
|
363
|
+
return [4 /*yield*/, AsyncStorage.getItem(keys[i])];
|
|
366
364
|
case 2:
|
|
367
365
|
val = _a.sent();
|
|
368
366
|
if (val != null) {
|
|
@@ -469,7 +467,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
469
467
|
_a.label = 1;
|
|
470
468
|
case 1:
|
|
471
469
|
_a.trys.push([1, 12, , 13]);
|
|
472
|
-
return [4 /*yield*/,
|
|
470
|
+
return [4 /*yield*/, AsyncStorage.getItem(prefixedKey)];
|
|
473
471
|
case 2:
|
|
474
472
|
val = _a.sent();
|
|
475
473
|
if (!val) return [3 /*break*/, 4];
|
|
@@ -540,7 +538,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
540
538
|
_a.label = 1;
|
|
541
539
|
case 1:
|
|
542
540
|
_a.trys.push([1, 8, , 9]);
|
|
543
|
-
return [4 /*yield*/,
|
|
541
|
+
return [4 /*yield*/, AsyncStorage.getItem(prefixedKey)];
|
|
544
542
|
case 2:
|
|
545
543
|
ret = _a.sent();
|
|
546
544
|
if (!(ret != null)) return [3 /*break*/, 7];
|
|
@@ -599,7 +597,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
599
597
|
_a.label = 1;
|
|
600
598
|
case 1:
|
|
601
599
|
_a.trys.push([1, 5, , 6]);
|
|
602
|
-
return [4 /*yield*/,
|
|
600
|
+
return [4 /*yield*/, AsyncStorage.getItem(prefixedKey)];
|
|
603
601
|
case 2:
|
|
604
602
|
val = _a.sent();
|
|
605
603
|
if (!val) return [3 /*break*/, 4];
|
|
@@ -633,7 +631,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
633
631
|
_a.label = 1;
|
|
634
632
|
case 1:
|
|
635
633
|
_a.trys.push([1, 7, , 8]);
|
|
636
|
-
return [4 /*yield*/,
|
|
634
|
+
return [4 /*yield*/, AsyncStorage.getAllKeys()];
|
|
637
635
|
case 2:
|
|
638
636
|
keys = _a.sent();
|
|
639
637
|
keysToRemove = [];
|
|
@@ -646,7 +644,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
646
644
|
_a.label = 3;
|
|
647
645
|
case 3:
|
|
648
646
|
if (!(i < keysToRemove.length)) return [3 /*break*/, 6];
|
|
649
|
-
return [4 /*yield*/,
|
|
647
|
+
return [4 /*yield*/, AsyncStorage.removeItem(keysToRemove[i])];
|
|
650
648
|
case 4:
|
|
651
649
|
_a.sent();
|
|
652
650
|
_a.label = 5;
|
|
@@ -672,11 +670,11 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
672
670
|
var ret;
|
|
673
671
|
return __generator(this, function (_a) {
|
|
674
672
|
switch (_a.label) {
|
|
675
|
-
case 0: return [4 /*yield*/,
|
|
673
|
+
case 0: return [4 /*yield*/, AsyncStorage.getItem((0, CacheUtils_1.getCurrSizeKey)(this.cacheConfig.keyPrefix))];
|
|
676
674
|
case 1:
|
|
677
675
|
ret = _a.sent();
|
|
678
676
|
if (!!ret) return [3 /*break*/, 3];
|
|
679
|
-
return [4 /*yield*/,
|
|
677
|
+
return [4 /*yield*/, AsyncStorage.setItem((0, CacheUtils_1.getCurrSizeKey)(this.cacheConfig.keyPrefix), '0')];
|
|
680
678
|
case 2:
|
|
681
679
|
_a.sent();
|
|
682
680
|
ret = '0';
|
|
@@ -698,7 +696,7 @@ var AsyncStorageCache = /** @class */ (function (_super) {
|
|
|
698
696
|
switch (_a.label) {
|
|
699
697
|
case 0:
|
|
700
698
|
_a.trys.push([0, 2, , 3]);
|
|
701
|
-
return [4 /*yield*/,
|
|
699
|
+
return [4 /*yield*/, AsyncStorage.getAllKeys()];
|
|
702
700
|
case 1:
|
|
703
701
|
keys = _a.sent();
|
|
704
702
|
retKeys = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.1-console-preview.
|
|
1
|
+
export declare const version = "6.0.1-console-preview.b5a42af.0+b5a42af";
|
package/lib/Platform/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import
|
|
2
|
+
import { loadNetInfo } from '@aws-amplify/react-native';
|
|
3
3
|
import { NetworkStatus } from './types';
|
|
4
4
|
export declare class Reachability {
|
|
5
|
-
networkMonitor(netInfo?: typeof
|
|
5
|
+
networkMonitor(netInfo?: ReturnType<typeof loadNetInfo>): Observable<NetworkStatus>;
|
|
6
6
|
}
|
|
@@ -57,7 +57,7 @@ var shouldSendBody = function (method) {
|
|
|
57
57
|
// TODO[AllanZhengYP]: we need to provide isCanceledError utility
|
|
58
58
|
var fetchTransferHandler = function (_a, _b) {
|
|
59
59
|
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body;
|
|
60
|
-
var abortSignal = _b.abortSignal, cache = _b.cache;
|
|
60
|
+
var abortSignal = _b.abortSignal, cache = _b.cache, withCrossDomainCredentials = _b.withCrossDomainCredentials;
|
|
61
61
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
62
62
|
var resp, e_1, responseHeaders, httpResponse, bodyWithMixin;
|
|
63
63
|
var _c, _d;
|
|
@@ -71,6 +71,7 @@ var fetchTransferHandler = function (_a, _b) {
|
|
|
71
71
|
body: shouldSendBody(method) ? body : undefined,
|
|
72
72
|
signal: abortSignal,
|
|
73
73
|
cache: cache,
|
|
74
|
+
credentials: withCrossDomainCredentials ? 'include' : 'same-origin',
|
|
74
75
|
})];
|
|
75
76
|
case 1:
|
|
76
77
|
resp = _e.sent();
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getHashedPayload = exports.TOKEN_QUERY_PARAM = exports.presignUrl = exports.signRequest = void 0;
|
|
6
|
-
require("@aws-amplify/
|
|
6
|
+
var react_native_1 = require("@aws-amplify/react-native");
|
|
7
|
+
(0, react_native_1.loadUrlPolyfill)();
|
|
7
8
|
// TODO: V6 replace Signer
|
|
8
9
|
var signRequest_1 = require("./signRequest");
|
|
9
10
|
Object.defineProperty(exports, "signRequest", { enumerable: true, get: function () { return signRequest_1.signRequest; } });
|
|
@@ -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>;
|
package/lib/libraryUtils.d.ts
CHANGED
|
@@ -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 {
|
|
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';
|
package/lib/parseAWSExports.js
CHANGED
|
@@ -12,10 +12,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.parseAWSExports = void 0;
|
|
15
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
var Logger_1 = require("./Logger");
|
|
18
|
+
var logger = new Logger_1.ConsoleLogger('parseAWSExports');
|
|
15
19
|
var authTypeMapping = {
|
|
16
20
|
API_KEY: 'apiKey',
|
|
17
21
|
AWS_IAM: 'iam',
|
|
18
|
-
AMAZON_COGNITO_USER_POOLS: '
|
|
22
|
+
AMAZON_COGNITO_USER_POOLS: 'userPool',
|
|
23
|
+
OPENID_CONNECT: 'oidc',
|
|
24
|
+
NONE: 'none',
|
|
25
|
+
LAMBDA: 'lambda',
|
|
19
26
|
};
|
|
20
27
|
/**
|
|
21
28
|
* This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
|
|
@@ -27,7 +34,7 @@ var authTypeMapping = {
|
|
|
27
34
|
*/
|
|
28
35
|
var parseAWSExports = function (config) {
|
|
29
36
|
if (config === void 0) { config = {}; }
|
|
30
|
-
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;
|
|
37
|
+
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;
|
|
31
38
|
var amplifyConfig = {};
|
|
32
39
|
// Analytics
|
|
33
40
|
if (aws_mobile_analytics_app_id) {
|
|
@@ -38,17 +45,18 @@ var parseAWSExports = function (config) {
|
|
|
38
45
|
},
|
|
39
46
|
};
|
|
40
47
|
}
|
|
41
|
-
// TODO: Need to support all API configurations
|
|
42
48
|
// API
|
|
43
49
|
if (aws_appsync_graphqlEndpoint) {
|
|
50
|
+
var defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];
|
|
51
|
+
if (!defaultAuthMode) {
|
|
52
|
+
logger.debug("Invalid authentication type ".concat(aws_appsync_authenticationType, ". Falling back to IAM."));
|
|
53
|
+
}
|
|
44
54
|
amplifyConfig.API = {
|
|
45
|
-
|
|
46
|
-
defaultAuthMode: {
|
|
47
|
-
type: authTypeMapping[aws_appsync_authenticationType],
|
|
48
|
-
apiKey: aws_appsync_apiKey,
|
|
49
|
-
},
|
|
55
|
+
GraphQL: {
|
|
50
56
|
endpoint: aws_appsync_graphqlEndpoint,
|
|
57
|
+
apiKey: aws_appsync_apiKey,
|
|
51
58
|
region: aws_appsync_region,
|
|
59
|
+
defaultAuthMode: defaultAuthMode !== null && defaultAuthMode !== void 0 ? defaultAuthMode : 'iam',
|
|
52
60
|
},
|
|
53
61
|
};
|
|
54
62
|
}
|
|
@@ -80,6 +88,14 @@ var parseAWSExports = function (config) {
|
|
|
80
88
|
}
|
|
81
89
|
: __assign({}, geo);
|
|
82
90
|
}
|
|
91
|
+
// REST API
|
|
92
|
+
if (aws_cloud_logic_custom) {
|
|
93
|
+
amplifyConfig.API = __assign(__assign({}, amplifyConfig.API), { REST: aws_cloud_logic_custom.reduce(function (acc, api) {
|
|
94
|
+
var _a;
|
|
95
|
+
var name = api.name, endpoint = api.endpoint, region = api.region, service = api.service;
|
|
96
|
+
return __assign(__assign({}, acc), (_a = {}, _a[name] = __assign(__assign({ endpoint: endpoint }, (service ? { service: service } : undefined)), (region ? { region: region } : undefined)), _a));
|
|
97
|
+
}, {}) });
|
|
98
|
+
}
|
|
83
99
|
return amplifyConfig;
|
|
84
100
|
};
|
|
85
101
|
exports.parseAWSExports = parseAWSExports;
|
|
@@ -16,4 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.getEndpointId = void 0;
|
|
19
20
|
__exportStar(require("./apis"), exports);
|
|
21
|
+
var utils_1 = require("./utils");
|
|
22
|
+
Object.defineProperty(exports, "getEndpointId", { enumerable: true, get: function () { return utils_1.getEndpointId; } });
|
|
@@ -1,35 +1,72 @@
|
|
|
1
|
+
import { Headers } from '../../clients';
|
|
1
2
|
export type LibraryAPIOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
region: string;
|
|
18
|
-
endpoint: string;
|
|
19
|
-
modelIntrospectionSchema?: any;
|
|
20
|
-
};
|
|
62
|
+
REST?: Record<string, APIRestConfig>;
|
|
63
|
+
GraphQL?: APIGraphQLConfig;
|
|
21
64
|
};
|
|
22
|
-
export type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
72
|
+
export {};
|
|
@@ -12,7 +12,7 @@ function assertTokenProviderConfig(cognitoConfig) {
|
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
assertionValid =
|
|
15
|
-
!!cognitoConfig.
|
|
15
|
+
!!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;
|
|
16
16
|
}
|
|
17
17
|
return (0, errorHelpers_1.assert)(assertionValid, errorHelpers_1.AuthConfigurationErrorCode.AuthTokenConfigException);
|
|
18
18
|
}
|
package/lib/singleton/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolCon
|
|
|
4
4
|
import { GeoConfig } from './Geo/types';
|
|
5
5
|
import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
|
|
6
6
|
import { I18nConfig } from '../I18n/types';
|
|
7
|
+
import { NotificationsConfig } from './Notifications/types';
|
|
7
8
|
export type LegacyConfig = {
|
|
8
9
|
/**
|
|
9
10
|
* @deprecated The field should not be used.
|
|
@@ -15,6 +16,7 @@ export type ResourcesConfig = {
|
|
|
15
16
|
Analytics?: AnalyticsConfig;
|
|
16
17
|
Auth?: AuthConfig;
|
|
17
18
|
I18n?: I18nConfig;
|
|
19
|
+
Notifications?: NotificationsConfig;
|
|
18
20
|
Storage?: StorageConfig;
|
|
19
21
|
Geo?: GeoConfig;
|
|
20
22
|
};
|
|
@@ -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
|
}
|