@aws-amplify/core 6.0.1-console-preview.7739091.0 → 6.0.1-preview-testing.64b45b1.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 (142) 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 +4 -2
  10. package/lib/Platform/version.d.ts +1 -1
  11. package/lib/Platform/version.js +1 -1
  12. package/lib/RNComponents/index.d.ts +1 -1
  13. package/lib/RNComponents/index.js +2 -2
  14. package/{lib-esm/storage/CookieStorage.d.ts → lib/StorageHelper/cookieStorage.d.ts} +3 -4
  15. package/lib/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +83 -35
  16. package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
  17. package/lib/StorageHelper/inMemoryStorage.js +82 -0
  18. package/lib/StorageHelper/index.d.ts +45 -0
  19. package/lib/StorageHelper/index.js +83 -0
  20. package/lib/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
  21. package/lib/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +15 -13
  22. package/lib/StorageHelper/reactnative.d.ts +83 -0
  23. package/lib/StorageHelper/reactnative.js +250 -0
  24. package/lib/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
  25. package/lib/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +43 -46
  26. package/lib/clients/handlers/authenticated.d.ts +1 -1
  27. package/lib/clients/handlers/fetch.js +2 -1
  28. package/lib/clients/handlers/unauthenticated.d.ts +1 -1
  29. package/lib/clients/internal/composeServiceApi.d.ts +5 -3
  30. package/lib/clients/types/aws.d.ts +0 -4
  31. package/lib/clients/types/http.d.ts +8 -0
  32. package/lib/clients/types/index.d.ts +1 -1
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.js +8 -6
  35. package/lib/parseAWSExports.js +1 -20
  36. package/lib/providers/pinpoint/types/buffer.d.ts +1 -1
  37. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  38. package/lib/singleton/types.d.ts +1 -4
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/lib/types/storage.d.ts +0 -3
  41. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +12 -4
  42. package/lib-esm/AwsClients/CognitoIdentity/base.js +1 -0
  43. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
  44. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +15 -3
  45. package/lib-esm/AwsClients/Pinpoint/base.d.ts +10 -2
  46. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
  47. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +17 -3
  48. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
  49. package/lib-esm/Cache/Utils/CacheUtils.js +4 -2
  50. package/lib-esm/Platform/version.d.ts +1 -1
  51. package/lib-esm/Platform/version.js +1 -1
  52. package/lib-esm/RNComponents/index.d.ts +1 -1
  53. package/lib-esm/RNComponents/index.js +2 -2
  54. package/{lib/storage/CookieStorage.d.ts → lib-esm/StorageHelper/cookieStorage.d.ts} +3 -4
  55. package/lib-esm/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +61 -36
  56. package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
  57. package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
  58. package/lib-esm/StorageHelper/index.d.ts +45 -0
  59. package/lib-esm/StorageHelper/index.js +76 -0
  60. package/lib-esm/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
  61. package/lib-esm/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +14 -12
  62. package/lib-esm/StorageHelper/reactnative.d.ts +83 -0
  63. package/lib-esm/StorageHelper/reactnative.js +244 -0
  64. package/lib-esm/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
  65. package/lib-esm/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +42 -45
  66. package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
  67. package/lib-esm/clients/handlers/fetch.js +2 -1
  68. package/lib-esm/clients/handlers/unauthenticated.d.ts +1 -1
  69. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -3
  70. package/lib-esm/clients/types/aws.d.ts +0 -4
  71. package/lib-esm/clients/types/http.d.ts +8 -0
  72. package/lib-esm/clients/types/index.d.ts +1 -1
  73. package/lib-esm/index.d.ts +1 -1
  74. package/lib-esm/index.js +1 -1
  75. package/lib-esm/parseAWSExports.js +1 -20
  76. package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
  77. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  78. package/lib-esm/singleton/types.d.ts +1 -4
  79. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  80. package/lib-esm/types/storage.d.ts +0 -3
  81. package/package.json +3 -3
  82. package/src/AwsClients/CognitoIdentity/base.ts +2 -2
  83. package/src/AwsClients/Pinpoint/base.ts +2 -6
  84. package/src/Cache/Utils/CacheUtils.ts +4 -2
  85. package/src/Platform/version.ts +1 -1
  86. package/src/RNComponents/index.ts +2 -2
  87. package/src/StorageHelper/cookieStorage.ts +99 -0
  88. package/src/StorageHelper/inMemoryStorage.ts +32 -0
  89. package/src/StorageHelper/index.ts +78 -0
  90. package/src/StorageHelper/localStorage.ts +60 -0
  91. package/src/StorageHelper/reactnative.ts +182 -0
  92. package/src/{storage/KeyValueStorage.ts → StorageHelper/sessionStorage.ts} +13 -10
  93. package/src/clients/handlers/authenticated.ts +2 -1
  94. package/src/clients/handlers/fetch.ts +2 -1
  95. package/src/clients/handlers/unauthenticated.ts +2 -1
  96. package/src/clients/internal/composeServiceApi.ts +10 -3
  97. package/src/clients/types/aws.ts +0 -10
  98. package/src/clients/types/http.ts +8 -0
  99. package/src/clients/types/index.ts +0 -1
  100. package/src/index.ts +6 -4
  101. package/src/parseAWSExports.ts +0 -26
  102. package/src/providers/pinpoint/types/buffer.ts +1 -1
  103. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  104. package/src/singleton/types.ts +1 -4
  105. package/src/types/storage.ts +0 -4
  106. package/lib/singleton/API/types.d.ts +0 -34
  107. package/lib/singleton/API/types.js +0 -2
  108. package/lib/storage/CookieStorage.native.d.ts +0 -7
  109. package/lib/storage/CookieStorage.native.js +0 -32
  110. package/lib/storage/DefaultStorage.d.ts +0 -7
  111. package/lib/storage/DefaultStorage.js +0 -33
  112. package/lib/storage/InMemoryStorage.d.ts +0 -12
  113. package/lib/storage/InMemoryStorage.js +0 -41
  114. package/lib/storage/SessionStorage.d.ts +0 -7
  115. package/lib/storage/SessionStorage.js +0 -33
  116. package/lib/storage/index.d.ts +0 -7
  117. package/lib/storage/index.js +0 -14
  118. package/lib/storage/utils.d.ts +0 -10
  119. package/lib/storage/utils.js +0 -26
  120. package/lib-esm/singleton/API/types.d.ts +0 -34
  121. package/lib-esm/singleton/API/types.js +0 -1
  122. package/lib-esm/storage/CookieStorage.native.d.ts +0 -7
  123. package/lib-esm/storage/CookieStorage.native.js +0 -29
  124. package/lib-esm/storage/DefaultStorage.d.ts +0 -7
  125. package/lib-esm/storage/DefaultStorage.js +0 -30
  126. package/lib-esm/storage/InMemoryStorage.d.ts +0 -12
  127. package/lib-esm/storage/InMemoryStorage.js +0 -38
  128. package/lib-esm/storage/SessionStorage.d.ts +0 -7
  129. package/lib-esm/storage/SessionStorage.js +0 -30
  130. package/lib-esm/storage/index.d.ts +0 -7
  131. package/lib-esm/storage/index.js +0 -10
  132. package/lib-esm/storage/utils.d.ts +0 -10
  133. package/lib-esm/storage/utils.js +0 -21
  134. package/src/singleton/API/types.ts +0 -31
  135. package/src/storage/CookieStorage.native.ts +0 -13
  136. package/src/storage/CookieStorage.ts +0 -72
  137. package/src/storage/DefaultStorage.native.ts +0 -78
  138. package/src/storage/DefaultStorage.ts +0 -14
  139. package/src/storage/InMemoryStorage.ts +0 -36
  140. package/src/storage/SessionStorage.ts +0 -14
  141. package/src/storage/index.ts +0 -13
  142. package/src/storage/utils.ts +0 -22
@@ -8,9 +8,6 @@ export type SameSite = 'strict' | 'lax' | 'none';
8
8
  export type CookieStorageData = {
9
9
  domain?: string;
10
10
  path?: string;
11
- /**
12
- * Expiration in days
13
- */
14
11
  expires?: number;
15
12
  secure?: boolean;
16
13
  sameSite?: SameSite;
@@ -1,16 +1,24 @@
1
- import { Endpoint, Headers, HttpRequest, HttpResponse } from '../../clients';
2
- import { DefaultConfigOptions } from '../../clients/types';
1
+ import { Endpoint, EndpointResolverOptions, Headers, HttpRequest, HttpResponse } from '../../clients';
3
2
  /**
4
3
  * A Cognito Identity-specific transfer handler that does NOT sign requests, and
5
4
  * disables caching.
6
5
  *
7
6
  * @internal
8
7
  */
9
- export declare const cognitoIdentityTransferHandler: (request: HttpRequest, options: import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse>) => Promise<HttpResponse>;
8
+ export declare const cognitoIdentityTransferHandler: (request: HttpRequest, options: import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").HttpTransferOptions) => Promise<HttpResponse>;
10
9
  /**
11
10
  * @internal
12
11
  */
13
- export declare const defaultConfig: DefaultConfigOptions;
12
+ export declare const defaultConfig: {
13
+ service: string;
14
+ endpointResolver: ({ region }: EndpointResolverOptions) => {
15
+ url: URL;
16
+ };
17
+ retryDecider: (response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>;
18
+ computeDelay: (attempt: number) => number;
19
+ userAgentValue: string;
20
+ cache: string;
21
+ };
14
22
  /**
15
23
  * @internal
16
24
  */
@@ -83,6 +83,7 @@ export var defaultConfig = {
83
83
  retryDecider: getRetryDecider(parseJsonError),
84
84
  computeDelay: jitteredBackoff,
85
85
  userAgentValue: getAmplifyUserAgent(),
86
+ cache: 'no-store',
86
87
  };
87
88
  observeFrameworkChanges(function () {
88
89
  defaultConfig.userAgentValue = getAmplifyUserAgent();
@@ -1,9 +1,21 @@
1
- import { HttpResponse } from '../../clients';
1
+ import { Endpoint, HttpResponse } from '../../clients';
2
2
  import type { GetCredentialsForIdentityCommandInput as GetCredentialsForIdentityInput, GetCredentialsForIdentityCommandOutput as GetCredentialsForIdentityOutput } from './types';
3
3
  export type { GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getCredentialsForIdentity: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients").ServiceClientOptions> & import("../../clients").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const getCredentialsForIdentity: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients").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
+ cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
16
+ } & {
17
+ region: string;
18
+ abortSignal?: AbortSignal | undefined;
19
+ maxAttempts?: number | undefined;
20
+ userAgentHeader?: string | undefined;
9
21
  }, input: GetCredentialsForIdentityInput) => Promise<GetCredentialsForIdentityOutput>;
@@ -1,9 +1,21 @@
1
- import { HttpResponse } from '../../clients';
1
+ import { Endpoint, HttpResponse } from '../../clients';
2
2
  import { GetIdCommandInput as GetIdInput, GetIdCommandOutput as GetIdOutput } from './types';
3
3
  export type { GetIdInput, GetIdOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getId: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients").ServiceClientOptions> & import("../../clients").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const getId: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients").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
+ cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" | undefined;
16
+ } & {
17
+ region: string;
18
+ abortSignal?: AbortSignal | undefined;
19
+ maxAttempts?: number | undefined;
20
+ userAgentHeader?: string | undefined;
9
21
  }, input: GetIdInput) => Promise<GetIdOutput>;
@@ -1,8 +1,16 @@
1
- import type { DefaultConfigOptions, Headers } from '../../clients/types';
1
+ import type { EndpointResolverOptions, Headers } from '../../clients/types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare const defaultConfig: DefaultConfigOptions;
5
+ export declare const defaultConfig: {
6
+ service: string;
7
+ endpointResolver: ({ region }: EndpointResolverOptions) => {
8
+ url: URL;
9
+ };
10
+ retryDecider: (response?: import("../../clients/types").HttpResponse | undefined, error?: unknown) => Promise<boolean>;
11
+ computeDelay: (attempt: number) => number;
12
+ userAgentValue: string;
13
+ };
6
14
  /**
7
15
  * @internal
8
16
  */
@@ -1,9 +1,23 @@
1
- import { HttpResponse } from '../../clients/types';
1
+ import { Endpoint, HttpResponse } from '../../clients/types';
2
2
  import type { GetInAppMessagesCommandInput as GetInAppMessagesInput, GetInAppMessagesCommandOutput as GetInAppMessagesOutput } from './types';
3
3
  export type { GetInAppMessagesInput, GetInAppMessagesOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getInAppMessages: (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 getInAppMessages: (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("@aws-sdk/types/dist-types/credentials").Credentials | (() => Promise<import("@aws-sdk/types/dist-types/credentials").Credentials>);
18
+ region: string;
19
+ abortSignal?: AbortSignal | undefined;
20
+ cache?: RequestCache | undefined;
21
+ maxAttempts?: number | undefined;
22
+ userAgentHeader?: string | undefined;
9
23
  }, input: GetInAppMessagesInput) => Promise<GetInAppMessagesOutput>;
@@ -1,9 +1,23 @@
1
- import { HttpResponse } from '../../clients/types';
1
+ import { Endpoint, HttpResponse } from '../../clients/types';
2
2
  import type { PutEventsCommandInput as PutEventsInput, PutEventsCommandOutput as PutEventsOutput } from './types';
3
3
  export type { PutEventsInput, PutEventsOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const putEvents: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions> & import("../../clients/types").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const putEvents: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ })) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
13
+ computeDelay?: ((attempt: number) => number) | undefined;
14
+ userAgentValue?: string | undefined;
15
+ } & {
16
+ uriEscapePath?: boolean | undefined;
17
+ credentials: import("@aws-sdk/types/dist-types/credentials").Credentials | (() => Promise<import("@aws-sdk/types/dist-types/credentials").Credentials>);
18
+ region: string;
19
+ abortSignal?: AbortSignal | undefined;
20
+ cache?: RequestCache | undefined;
21
+ maxAttempts?: number | undefined;
22
+ userAgentHeader?: string | undefined;
9
23
  }, input: PutEventsInput) => Promise<PutEventsOutput>;
@@ -1,9 +1,23 @@
1
- import { HttpResponse } from '../../clients/types';
1
+ import { Endpoint, HttpResponse } from '../../clients/types';
2
2
  import type { UpdateEndpointCommandInput as UpdateEndpointInput, UpdateEndpointCommandOutput as UpdateEndpointOutput } from './types';
3
3
  export type { UpdateEndpointInput, UpdateEndpointOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const updateEndpoint: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions> & import("../../clients/types").EndpointResolverOptions, string> & {
8
- [x: string]: unknown;
7
+ export declare const updateEndpoint: (config: {
8
+ service?: string | undefined;
9
+ endpointResolver?: (((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
+ url: URL;
11
+ })) | undefined;
12
+ retryDecider?: (((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse | undefined, error?: unknown) => Promise<boolean>)) | undefined;
13
+ computeDelay?: ((attempt: number) => number) | undefined;
14
+ userAgentValue?: string | undefined;
15
+ } & {
16
+ uriEscapePath?: boolean | undefined;
17
+ credentials: import("@aws-sdk/types/dist-types/credentials").Credentials | (() => Promise<import("@aws-sdk/types/dist-types/credentials").Credentials>);
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 { getDefaultStorageWithFallback } from '../../storage/utils';
3
+ import { StorageHelper } from '../../StorageHelper';
4
4
  /**
5
5
  * Default cache config
6
6
  */
@@ -11,7 +11,9 @@ export var defaultConfig = {
11
11
  defaultTTL: 259200000,
12
12
  defaultPriority: 5,
13
13
  warningThreshold: 0.8,
14
- storage: getDefaultStorageWithFallback(),
14
+ // the storage helper will check if localStorage exists,
15
+ // if not, will use a in-memory object instead
16
+ storage: new StorageHelper().getStorage(),
15
17
  };
16
18
  /**
17
19
  * return the byte size of the string
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.7739091.0+7739091";
1
+ export declare const version = "6.0.1-preview-testing.64b45b1.0+64b45b1";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '6.0.1-console-preview.7739091.0+7739091';
2
+ export var version = '6.0.1-preview-testing.64b45b1.0+64b45b1';
@@ -3,4 +3,4 @@ export declare const AppState: {
3
3
  addEventListener: (action: any, handler: any) => undefined;
4
4
  currentState: string;
5
5
  };
6
- export declare const AsyncStorage: Storage | undefined;
6
+ export declare const AsyncStorage: any;
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { getDefaultStorageWithFallback } from '../storage/utils';
4
3
  import { isBrowser } from '../Util/JS';
4
+ import { StorageHelper } from '../StorageHelper';
5
5
  export var Linking = {};
6
6
  export var AppState = {
7
7
  addEventListener: function (action, handler) { return undefined; },
@@ -9,5 +9,5 @@ export var AppState = {
9
9
  };
10
10
  // if not in react native, just use local storage
11
11
  export var AsyncStorage = isBrowser()
12
- ? getDefaultStorageWithFallback()
12
+ ? new StorageHelper().getStorage()
13
13
  : undefined;
@@ -1,14 +1,13 @@
1
1
  import { CookieStorageData, KeyValueStorageInterface, SameSite } from '../types';
2
2
  export declare class CookieStorage implements KeyValueStorageInterface {
3
- path: string;
4
3
  domain?: string;
4
+ path: string;
5
5
  expires?: number;
6
- sameSite?: SameSite;
7
6
  secure?: boolean;
7
+ sameSite?: SameSite;
8
8
  constructor(data?: CookieStorageData);
9
9
  setItem(key: string, value: string): Promise<void>;
10
- getItem(key: string): Promise<string | null>;
10
+ getItem(key: string): Promise<string>;
11
11
  removeItem(key: string): Promise<void>;
12
12
  clear(): Promise<void>;
13
- private getData;
14
13
  }
@@ -1,16 +1,3 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,60 +34,101 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
35
  }
49
36
  };
50
- import { get as getJsCookie, remove as removeJsCookie, set as setJsCookie, } from 'js-cookie';
37
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
38
+ // SPDX-License-Identifier: Apache-2.0
39
+ // @ts-ignore
40
+ import * as Cookies from 'js-cookie';
51
41
  var CookieStorage = /** @class */ (function () {
52
42
  function CookieStorage(data) {
53
43
  if (data === void 0) { data = {}; }
54
- var path = data.path, domain = data.domain, expires = data.expires, sameSite = data.sameSite, secure = data.secure;
55
- this.domain = domain;
56
- this.path = path ? path : '/';
57
- this.expires = data.hasOwnProperty('expires') ? expires : 365;
58
- this.secure = data.hasOwnProperty('secure') ? secure : true;
44
+ if (data.domain) {
45
+ this.domain = data.domain;
46
+ }
47
+ if (data.path) {
48
+ this.path = data.path;
49
+ }
50
+ else {
51
+ this.path = '/';
52
+ }
53
+ if (Object.prototype.hasOwnProperty.call(data, 'expires')) {
54
+ this.expires = data.expires;
55
+ }
56
+ else {
57
+ this.expires = 365;
58
+ }
59
+ if (Object.prototype.hasOwnProperty.call(data, 'secure')) {
60
+ this.secure = data.secure;
61
+ }
62
+ else {
63
+ this.secure = true;
64
+ }
59
65
  if (data.hasOwnProperty('sameSite')) {
60
- if (!sameSite || !['strict', 'lax', 'none'].includes(sameSite)) {
66
+ if (!data.sameSite ||
67
+ !['strict', 'lax', 'none'].includes(data.sameSite)) {
61
68
  throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');
62
69
  }
63
- if (sameSite === 'none' && !this.secure) {
70
+ if (data.sameSite === 'none' && !this.secure) {
64
71
  throw new Error('sameSite = None requires the Secure attribute in latest browser versions.');
65
72
  }
66
- this.sameSite = sameSite;
73
+ this.sameSite = data.sameSite;
67
74
  }
68
75
  }
69
76
  CookieStorage.prototype.setItem = function (key, value) {
70
77
  return __awaiter(this, void 0, void 0, function () {
78
+ var options;
71
79
  return __generator(this, function (_a) {
72
- setJsCookie(key, value, this.getData());
73
- return [2 /*return*/];
80
+ options = {
81
+ path: this.path,
82
+ expires: this.expires,
83
+ domain: this.domain,
84
+ secure: this.secure,
85
+ };
86
+ if (this.sameSite) {
87
+ options.sameSite = this.sameSite;
88
+ }
89
+ Cookies.set(key, value, options);
90
+ return [2 /*return*/, Cookies.get(key)];
74
91
  });
75
92
  });
76
93
  };
77
94
  CookieStorage.prototype.getItem = function (key) {
78
95
  return __awaiter(this, void 0, void 0, function () {
79
- var item;
80
96
  return __generator(this, function (_a) {
81
- item = getJsCookie(key);
82
- return [2 /*return*/, item !== null && item !== void 0 ? item : null];
97
+ return [2 /*return*/, Cookies.get(key)];
83
98
  });
84
99
  });
85
100
  };
86
101
  CookieStorage.prototype.removeItem = function (key) {
87
102
  return __awaiter(this, void 0, void 0, function () {
103
+ var options;
88
104
  return __generator(this, function (_a) {
89
- removeJsCookie(key, this.getData());
105
+ options = {
106
+ path: this.path,
107
+ expires: this.expires,
108
+ domain: this.domain,
109
+ secure: this.secure,
110
+ };
111
+ if (this.sameSite) {
112
+ options.sameSite = this.sameSite;
113
+ }
114
+ Cookies.remove(key, options);
90
115
  return [2 /*return*/];
91
116
  });
92
117
  });
93
118
  };
94
119
  CookieStorage.prototype.clear = function () {
95
120
  return __awaiter(this, void 0, void 0, function () {
96
- var cookie, promises;
97
- var _this = this;
121
+ var cookies, numKeys, promiseArray, index;
98
122
  return __generator(this, function (_a) {
99
123
  switch (_a.label) {
100
124
  case 0:
101
- cookie = getJsCookie();
102
- promises = Object.keys(cookie).map(function (key) { return _this.removeItem(key); });
103
- return [4 /*yield*/, Promise.all(promises)];
125
+ cookies = Cookies.get();
126
+ numKeys = Object.keys(cookies).length;
127
+ promiseArray = [];
128
+ for (index = 0; index < numKeys; ++index) {
129
+ promiseArray.push(this.removeItem(Object.keys(cookies)[index]));
130
+ }
131
+ return [4 /*yield*/, Promise.all(promiseArray)];
104
132
  case 1:
105
133
  _a.sent();
106
134
  return [2 /*return*/];
@@ -108,9 +136,6 @@ var CookieStorage = /** @class */ (function () {
108
136
  });
109
137
  });
110
138
  };
111
- CookieStorage.prototype.getData = function () {
112
- return __assign({ path: this.path, expires: this.expires, domain: this.domain, secure: this.secure }, (this.sameSite && { sameSite: this.sameSite }));
113
- };
114
139
  return CookieStorage;
115
140
  }());
116
141
  export { CookieStorage };
@@ -0,0 +1,10 @@
1
+ import { KeyValueStorageInterface } from '../types';
2
+ declare class MemoryKeyValueStorageClass implements KeyValueStorageInterface {
3
+ myStorage: Record<string, string>;
4
+ setItem(key: string, value: string): Promise<void>;
5
+ getItem(key: string): Promise<string | null>;
6
+ removeItem(key: string): Promise<void>;
7
+ clear(): Promise<void>;
8
+ }
9
+ export declare const MemoryKeyValueStorage: MemoryKeyValueStorageClass;
10
+ export {};
@@ -0,0 +1,79 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ var MemoryKeyValueStorageClass = /** @class */ (function () {
40
+ function MemoryKeyValueStorageClass() {
41
+ this.myStorage = {};
42
+ }
43
+ MemoryKeyValueStorageClass.prototype.setItem = function (key, value) {
44
+ return __awaiter(this, void 0, void 0, function () {
45
+ return __generator(this, function (_a) {
46
+ this.myStorage[key] = value;
47
+ return [2 /*return*/];
48
+ });
49
+ });
50
+ };
51
+ MemoryKeyValueStorageClass.prototype.getItem = function (key) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ return __generator(this, function (_a) {
54
+ return [2 /*return*/, this.myStorage[key]];
55
+ });
56
+ });
57
+ };
58
+ MemoryKeyValueStorageClass.prototype.removeItem = function (key) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ delete this.myStorage[key];
62
+ return [2 /*return*/];
63
+ });
64
+ });
65
+ };
66
+ MemoryKeyValueStorageClass.prototype.clear = function () {
67
+ return __awaiter(this, void 0, void 0, function () {
68
+ var _this = this;
69
+ return __generator(this, function (_a) {
70
+ Object.keys(this.myStorage).forEach(function (key) {
71
+ delete _this.myStorage[key];
72
+ });
73
+ return [2 /*return*/];
74
+ });
75
+ });
76
+ };
77
+ return MemoryKeyValueStorageClass;
78
+ }());
79
+ export var MemoryKeyValueStorage = new MemoryKeyValueStorageClass();
@@ -0,0 +1,45 @@
1
+ /** @class */
2
+ export declare class MemoryStorage {
3
+ /**
4
+ * This is used to set a specific item in storage
5
+ * @param {string} key - the key for the item
6
+ * @param {object} value - the value
7
+ * @returns {string} value that was set
8
+ */
9
+ static setItem(key: string, value: any): string;
10
+ /**
11
+ * This is used to get a specific key from storage
12
+ * @param {string} key - the key for the item
13
+ * This is used to clear the storage
14
+ * @returns {string} the data item
15
+ */
16
+ static getItem(key: string): string | undefined;
17
+ /**
18
+ * This is used to remove an item from storage
19
+ * @param {string} key - the key being set
20
+ * @returns {string} value - value that was deleted
21
+ */
22
+ static removeItem(key: string): boolean;
23
+ /**
24
+ * This is used to clear the storage
25
+ * @returns {string} nothing
26
+ */
27
+ static clear(): Record<string, string>;
28
+ }
29
+ export declare class StorageHelper {
30
+ private storageWindow;
31
+ /**
32
+ * This is used to get a storage object
33
+ * @returns {object} the storage
34
+ */
35
+ constructor();
36
+ /**
37
+ * This is used to return the storage
38
+ * @returns {object} the storage
39
+ */
40
+ getStorage(): any;
41
+ }
42
+ export { SessionStorage } from './sessionStorage';
43
+ export { LocalStorage } from './localStorage';
44
+ export { MemoryKeyValueStorage } from './inMemoryStorage';
45
+ export { CookieStorage } from './cookieStorage';
@@ -0,0 +1,76 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var dataMemory = {};
4
+ /** @class */
5
+ var MemoryStorage = /** @class */ (function () {
6
+ function MemoryStorage() {
7
+ }
8
+ /**
9
+ * This is used to set a specific item in storage
10
+ * @param {string} key - the key for the item
11
+ * @param {object} value - the value
12
+ * @returns {string} value that was set
13
+ */
14
+ MemoryStorage.setItem = function (key, value) {
15
+ dataMemory[key] = value;
16
+ return dataMemory[key];
17
+ };
18
+ /**
19
+ * This is used to get a specific key from storage
20
+ * @param {string} key - the key for the item
21
+ * This is used to clear the storage
22
+ * @returns {string} the data item
23
+ */
24
+ MemoryStorage.getItem = function (key) {
25
+ return Object.prototype.hasOwnProperty.call(dataMemory, key)
26
+ ? dataMemory[key]
27
+ : undefined;
28
+ };
29
+ /**
30
+ * This is used to remove an item from storage
31
+ * @param {string} key - the key being set
32
+ * @returns {string} value - value that was deleted
33
+ */
34
+ MemoryStorage.removeItem = function (key) {
35
+ return delete dataMemory[key];
36
+ };
37
+ /**
38
+ * This is used to clear the storage
39
+ * @returns {string} nothing
40
+ */
41
+ MemoryStorage.clear = function () {
42
+ dataMemory = {};
43
+ return dataMemory;
44
+ };
45
+ return MemoryStorage;
46
+ }());
47
+ export { MemoryStorage };
48
+ var StorageHelper = /** @class */ (function () {
49
+ /**
50
+ * This is used to get a storage object
51
+ * @returns {object} the storage
52
+ */
53
+ function StorageHelper() {
54
+ try {
55
+ this.storageWindow = window.localStorage;
56
+ this.storageWindow.setItem('aws.amplify.test-ls', 1);
57
+ this.storageWindow.removeItem('aws.amplify.test-ls');
58
+ }
59
+ catch (exception) {
60
+ this.storageWindow = MemoryStorage;
61
+ }
62
+ }
63
+ /**
64
+ * This is used to return the storage
65
+ * @returns {object} the storage
66
+ */
67
+ StorageHelper.prototype.getStorage = function () {
68
+ return this.storageWindow;
69
+ };
70
+ return StorageHelper;
71
+ }());
72
+ export { StorageHelper };
73
+ export { SessionStorage } from './sessionStorage';
74
+ export { LocalStorage } from './localStorage';
75
+ export { MemoryKeyValueStorage } from './inMemoryStorage';
76
+ export { CookieStorage } from './cookieStorage';