@aws-amplify/core 6.0.1-console-preview.7739091.0 → 6.0.1-preview-testing.ddb17c0.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 (150) 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 +1 -5
  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/Auth/index.d.ts +2 -1
  39. package/lib/singleton/Auth/index.js +22 -12
  40. package/lib/singleton/Auth/utils/index.js +3 -3
  41. package/lib/singleton/types.d.ts +1 -4
  42. package/lib/tsconfig.tsbuildinfo +1 -1
  43. package/lib/types/storage.d.ts +0 -3
  44. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +12 -4
  45. package/lib-esm/AwsClients/CognitoIdentity/base.js +1 -0
  46. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +15 -3
  47. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +15 -3
  48. package/lib-esm/AwsClients/Pinpoint/base.d.ts +10 -2
  49. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +17 -3
  50. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +17 -3
  51. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +17 -3
  52. package/lib-esm/Cache/Utils/CacheUtils.js +4 -2
  53. package/lib-esm/Platform/version.d.ts +1 -1
  54. package/lib-esm/Platform/version.js +1 -1
  55. package/lib-esm/RNComponents/index.d.ts +1 -1
  56. package/lib-esm/RNComponents/index.js +2 -2
  57. package/{lib/storage/CookieStorage.d.ts → lib-esm/StorageHelper/cookieStorage.d.ts} +3 -4
  58. package/lib-esm/{storage/CookieStorage.js → StorageHelper/cookieStorage.js} +61 -36
  59. package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
  60. package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
  61. package/lib-esm/StorageHelper/index.d.ts +45 -0
  62. package/lib-esm/StorageHelper/index.js +76 -0
  63. package/lib-esm/{storage/DefaultStorage.native.d.ts → StorageHelper/localStorage.d.ts} +6 -7
  64. package/lib-esm/{storage/KeyValueStorage.js → StorageHelper/localStorage.js} +14 -12
  65. package/lib-esm/StorageHelper/reactnative.d.ts +83 -0
  66. package/lib-esm/StorageHelper/reactnative.js +244 -0
  67. package/lib-esm/{storage/KeyValueStorage.d.ts → StorageHelper/sessionStorage.d.ts} +4 -5
  68. package/lib-esm/{storage/DefaultStorage.native.js → StorageHelper/sessionStorage.js} +42 -45
  69. package/lib-esm/clients/handlers/authenticated.d.ts +1 -1
  70. package/lib-esm/clients/handlers/fetch.js +2 -1
  71. package/lib-esm/clients/handlers/unauthenticated.d.ts +1 -1
  72. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -3
  73. package/lib-esm/clients/types/aws.d.ts +1 -5
  74. package/lib-esm/clients/types/http.d.ts +8 -0
  75. package/lib-esm/clients/types/index.d.ts +1 -1
  76. package/lib-esm/index.d.ts +1 -1
  77. package/lib-esm/index.js +1 -1
  78. package/lib-esm/parseAWSExports.js +1 -20
  79. package/lib-esm/providers/pinpoint/types/buffer.d.ts +1 -1
  80. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  81. package/lib-esm/singleton/Auth/index.d.ts +2 -1
  82. package/lib-esm/singleton/Auth/index.js +22 -12
  83. package/lib-esm/singleton/Auth/utils/index.js +3 -3
  84. package/lib-esm/singleton/types.d.ts +1 -4
  85. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  86. package/lib-esm/types/storage.d.ts +0 -3
  87. package/package.json +3 -3
  88. package/src/AwsClients/CognitoIdentity/base.ts +2 -2
  89. package/src/AwsClients/Pinpoint/base.ts +2 -6
  90. package/src/Cache/Utils/CacheUtils.ts +4 -2
  91. package/src/Platform/version.ts +1 -1
  92. package/src/RNComponents/index.ts +2 -2
  93. package/src/StorageHelper/cookieStorage.ts +99 -0
  94. package/src/StorageHelper/inMemoryStorage.ts +32 -0
  95. package/src/StorageHelper/index.ts +78 -0
  96. package/src/StorageHelper/localStorage.ts +60 -0
  97. package/src/StorageHelper/reactnative.ts +182 -0
  98. package/src/{storage/KeyValueStorage.ts → StorageHelper/sessionStorage.ts} +13 -10
  99. package/src/clients/handlers/authenticated.ts +2 -1
  100. package/src/clients/handlers/fetch.ts +2 -1
  101. package/src/clients/handlers/unauthenticated.ts +2 -1
  102. package/src/clients/internal/composeServiceApi.ts +10 -3
  103. package/src/clients/types/aws.ts +4 -11
  104. package/src/clients/types/http.ts +8 -0
  105. package/src/clients/types/index.ts +0 -1
  106. package/src/index.ts +6 -4
  107. package/src/parseAWSExports.ts +0 -26
  108. package/src/providers/pinpoint/types/buffer.ts +1 -1
  109. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  110. package/src/singleton/Auth/index.ts +9 -2
  111. package/src/singleton/Auth/utils/index.ts +3 -3
  112. package/src/singleton/types.ts +1 -4
  113. package/src/types/storage.ts +0 -4
  114. package/lib/singleton/API/types.d.ts +0 -34
  115. package/lib/singleton/API/types.js +0 -2
  116. package/lib/storage/CookieStorage.native.d.ts +0 -7
  117. package/lib/storage/CookieStorage.native.js +0 -32
  118. package/lib/storage/DefaultStorage.d.ts +0 -7
  119. package/lib/storage/DefaultStorage.js +0 -33
  120. package/lib/storage/InMemoryStorage.d.ts +0 -12
  121. package/lib/storage/InMemoryStorage.js +0 -41
  122. package/lib/storage/SessionStorage.d.ts +0 -7
  123. package/lib/storage/SessionStorage.js +0 -33
  124. package/lib/storage/index.d.ts +0 -7
  125. package/lib/storage/index.js +0 -14
  126. package/lib/storage/utils.d.ts +0 -10
  127. package/lib/storage/utils.js +0 -26
  128. package/lib-esm/singleton/API/types.d.ts +0 -34
  129. package/lib-esm/singleton/API/types.js +0 -1
  130. package/lib-esm/storage/CookieStorage.native.d.ts +0 -7
  131. package/lib-esm/storage/CookieStorage.native.js +0 -29
  132. package/lib-esm/storage/DefaultStorage.d.ts +0 -7
  133. package/lib-esm/storage/DefaultStorage.js +0 -30
  134. package/lib-esm/storage/InMemoryStorage.d.ts +0 -12
  135. package/lib-esm/storage/InMemoryStorage.js +0 -38
  136. package/lib-esm/storage/SessionStorage.d.ts +0 -7
  137. package/lib-esm/storage/SessionStorage.js +0 -30
  138. package/lib-esm/storage/index.d.ts +0 -7
  139. package/lib-esm/storage/index.js +0 -10
  140. package/lib-esm/storage/utils.d.ts +0 -10
  141. package/lib-esm/storage/utils.js +0 -21
  142. package/src/singleton/API/types.ts +0 -31
  143. package/src/storage/CookieStorage.native.ts +0 -13
  144. package/src/storage/CookieStorage.ts +0 -72
  145. package/src/storage/DefaultStorage.native.ts +0 -78
  146. package/src/storage/DefaultStorage.ts +0 -14
  147. package/src/storage/InMemoryStorage.ts +0 -36
  148. package/src/storage/SessionStorage.ts +0 -14
  149. package/src/storage/index.ts +0 -13
  150. package/src/storage/utils.ts +0 -22
@@ -1,4 +1,4 @@
1
1
  import { RetryOptions } from '../middleware/retry';
2
2
  import { UserAgentOptions } from '../middleware/userAgent';
3
3
  import { HttpRequest, HttpResponse } from '../types';
4
- export declare const unauthenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse>) => Promise<HttpResponse>;
4
+ export declare const unauthenticatedHandler: (request: HttpRequest, options: UserAgentOptions & RetryOptions<HttpResponse> & import("../types").HttpTransferOptions) => Promise<HttpResponse>;
@@ -1,9 +1,11 @@
1
1
  import { ServiceClientOptions } from '../types/aws';
2
2
  import { TransferHandler, Endpoint } from '../types/core';
3
3
  import { HttpRequest, HttpResponse } from '../types/http';
4
- export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & Partial<DefaultConfig> & InferEndpointResolverOptionType<DefaultConfig>, keyof DefaultConfig>, input: Input) => Promise<Output>;
5
- type OptionalizeKey<T, K extends keyof T> = Omit<T, K> & {
6
- [P in K & keyof T]?: T[P];
4
+ export declare const composeServiceApi: <TransferHandlerOptions, Input, Output, DefaultConfig>(transferHandler: TransferHandler<HttpRequest, HttpResponse, TransferHandlerOptions>, serializer: (input: Input, endpoint: Endpoint) => Promise<HttpRequest> | HttpRequest, deserializer: (output: HttpResponse) => Promise<Output>, defaultConfig: Partial<DefaultConfig>) => (config: OptionalizeKey<TransferHandlerOptions & ServiceClientOptions & Partial<DefaultConfig> & InferEndpointResolverOptionType<DefaultConfig>, DefaultConfig>, input: Input) => Promise<Output>;
5
+ type OptionalizeKey<InputType, InputDefaultsType> = {
6
+ [KeyWithDefaultValue in keyof InputDefaultsType]?: KeyWithDefaultValue extends keyof InputType ? InputType[KeyWithDefaultValue] : never;
7
+ } & {
8
+ [KeyWithoutDefaultValue in keyof Omit<InputType, keyof InputDefaultsType>]: InputType[KeyWithoutDefaultValue];
7
9
  };
8
10
  type InferEndpointResolverOptionType<T> = T extends {
9
11
  endpointResolver: (options: infer EndpointOptions) => any;
@@ -1,7 +1,7 @@
1
1
  import { MetadataBearer } from '@aws-sdk/types';
2
2
  import { Endpoint } from './core';
3
3
  import { HttpResponse } from './http';
4
- export type { Credentials, MetadataBearer } from '@aws-sdk/types';
4
+ export type { AwsCredentialIdentity as Credentials, MetadataBearer, } from '@aws-sdk/types';
5
5
  export type SourceData = string | ArrayBuffer | ArrayBufferView;
6
6
  /**
7
7
  * Basic option type for endpoint resolvers. It contains region only.
@@ -18,7 +18,3 @@ export interface ServiceClientOptions {
18
18
  * This function is protocol-specific (e.g. JSON, XML, etc.)
19
19
  */
20
20
  export type ErrorParser = (response?: HttpResponse) => Promise<(Error & MetadataBearer) | undefined>;
21
- /**
22
- * Default config options for the `composeServiceApi`.
23
- */
24
- export type DefaultConfigOptions<TransferHandlerOptions extends Record<string, unknown> = Record<string, unknown>> = Partial<TransferHandlerOptions & ServiceClientOptions>;
@@ -26,5 +26,13 @@ export interface HttpResponse extends Response {
26
26
  }
27
27
  export interface HttpTransferOptions {
28
28
  abortSignal?: AbortSignal;
29
+ /**
30
+ * Cache mode for the request. Note that this is only effective when the underlying HTTP handler is fetch.
31
+ * For XHR handler, or Node.js `"http(s)"` module or running on React Native, this option is ignored.
32
+ * Instead, you can configure the `Cache-Control` headers to achieve similar effects.
33
+ * @default 'default'
34
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/cache}
35
+ */
36
+ cache?: RequestCache;
29
37
  }
30
38
  export type HttpTransferHandler = TransferHandler<HttpRequest, HttpResponse, HttpTransferOptions>;
@@ -1,3 +1,3 @@
1
1
  export { Middleware, MiddlewareHandler, Request, Response, TransferHandler, Endpoint, } from './core';
2
2
  export { Headers, HttpRequest, HttpResponse, HttpTransferHandler, HttpTransferOptions, ResponseBodyMixin, } from './http';
3
- export { Credentials, EndpointResolverOptions, ErrorParser, ServiceClientOptions, DefaultConfigOptions, } from './aws';
3
+ export { Credentials, EndpointResolverOptions, ErrorParser, ServiceClientOptions, } from './aws';
package/lib/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, Stor
5
5
  export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
6
6
  export { getCredentialsForIdentity, getId, GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, } from './AwsClients/CognitoIdentity';
7
7
  export { UserProfile } from './types';
8
- export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, } from './storage';
8
+ export { StorageHelper, MemoryStorage, LocalStorage, CookieStorage, SessionStorage, MemoryKeyValueStorage, } from './StorageHelper';
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  import { BrowserStorageCache } from './Cache/BrowserStorageCache';
11
11
  export { InMemoryCache } from './Cache/InMemoryCache';
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.parseAWSExports = exports.I18n = exports.Cache = exports.BrowserStorageCache = exports.InMemoryCache = exports.sharedInMemoryStorage = exports.sessionStorage = exports.defaultStorage = exports.CookieStorage = exports.getId = exports.getCredentialsForIdentity = exports.clearCredentials = exports.AmplifyClassV6 = exports.fetchAuthSession = exports.Amplify = exports.Hub = void 0;
5
+ exports.parseAWSExports = exports.I18n = exports.Cache = exports.BrowserStorageCache = exports.InMemoryCache = exports.MemoryKeyValueStorage = exports.SessionStorage = exports.CookieStorage = exports.LocalStorage = exports.MemoryStorage = exports.StorageHelper = exports.getId = exports.getCredentialsForIdentity = exports.clearCredentials = exports.AmplifyClassV6 = exports.fetchAuthSession = exports.Amplify = exports.Hub = void 0;
6
6
  /*
7
7
  This file maps top-level exports from `@aws-amplify/core`. These are intended to be potentially customer-facing exports.
8
8
  */
@@ -19,11 +19,13 @@ var CognitoIdentity_1 = require("./AwsClients/CognitoIdentity");
19
19
  Object.defineProperty(exports, "getCredentialsForIdentity", { enumerable: true, get: function () { return CognitoIdentity_1.getCredentialsForIdentity; } });
20
20
  Object.defineProperty(exports, "getId", { enumerable: true, get: function () { return CognitoIdentity_1.getId; } });
21
21
  // Storage helpers
22
- var storage_1 = require("./storage");
23
- Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return storage_1.CookieStorage; } });
24
- Object.defineProperty(exports, "defaultStorage", { enumerable: true, get: function () { return storage_1.defaultStorage; } });
25
- Object.defineProperty(exports, "sessionStorage", { enumerable: true, get: function () { return storage_1.sessionStorage; } });
26
- Object.defineProperty(exports, "sharedInMemoryStorage", { enumerable: true, get: function () { return storage_1.sharedInMemoryStorage; } });
22
+ var StorageHelper_1 = require("./StorageHelper");
23
+ Object.defineProperty(exports, "StorageHelper", { enumerable: true, get: function () { return StorageHelper_1.StorageHelper; } });
24
+ Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return StorageHelper_1.MemoryStorage; } });
25
+ Object.defineProperty(exports, "LocalStorage", { enumerable: true, get: function () { return StorageHelper_1.LocalStorage; } });
26
+ Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return StorageHelper_1.CookieStorage; } });
27
+ Object.defineProperty(exports, "SessionStorage", { enumerable: true, get: function () { return StorageHelper_1.SessionStorage; } });
28
+ Object.defineProperty(exports, "MemoryKeyValueStorage", { enumerable: true, get: function () { return StorageHelper_1.MemoryKeyValueStorage; } });
27
29
  // Cache exports
28
30
  var BrowserStorageCache_1 = require("./Cache/BrowserStorageCache");
29
31
  Object.defineProperty(exports, "BrowserStorageCache", { enumerable: true, get: function () { return BrowserStorageCache_1.BrowserStorageCache; } });
@@ -12,11 +12,6 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.parseAWSExports = void 0;
15
- var authTypeMapping = {
16
- API_KEY: 'apiKey',
17
- AWS_IAM: 'iam',
18
- AMAZON_COGNITO_USER_POOLS: 'jwt',
19
- };
20
15
  /**
21
16
  * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object
22
17
  * consumable by Amplify.
@@ -27,7 +22,7 @@ var authTypeMapping = {
27
22
  */
28
23
  var parseAWSExports = function (config) {
29
24
  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;
25
+ var aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth;
31
26
  var amplifyConfig = {};
32
27
  // Analytics
33
28
  if (aws_mobile_analytics_app_id) {
@@ -38,20 +33,6 @@ var parseAWSExports = function (config) {
38
33
  },
39
34
  };
40
35
  }
41
- // TODO: Need to support all API configurations
42
- // API
43
- if (aws_appsync_graphqlEndpoint) {
44
- amplifyConfig.API = {
45
- AppSync: {
46
- defaultAuthMode: {
47
- type: authTypeMapping[aws_appsync_authenticationType],
48
- apiKey: aws_appsync_apiKey,
49
- },
50
- endpoint: aws_appsync_graphqlEndpoint,
51
- region: aws_appsync_region,
52
- },
53
- };
54
- }
55
36
  // Auth
56
37
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
57
38
  amplifyConfig.Auth = {
@@ -3,7 +3,7 @@ import { PinpointAnalyticsEvent, PinpointSession } from './pinpoint';
3
3
  export type EventBufferConfig = {
4
4
  appId: string;
5
5
  bufferSize: number;
6
- credentials: AuthSession['credentials'];
6
+ credentials: Required<AuthSession>['credentials'];
7
7
  identityId: AuthSession['identityId'];
8
8
  flushInterval: number;
9
9
  flushSize: number;
@@ -24,7 +24,7 @@ export type PinpointAnalyticsEvent = {
24
24
  type PinpointCommonParameters = {
25
25
  appId: string;
26
26
  category: SupportedCategory;
27
- credentials: AuthSession['credentials'];
27
+ credentials: Required<AuthSession>['credentials'];
28
28
  identityId?: AuthSession['identityId'];
29
29
  region: string;
30
30
  userAgentValue?: string;
@@ -1,4 +1,4 @@
1
- import { AuthConfig, AuthSession, FetchAuthSessionOptions, LibraryAuthOptions } from './types';
1
+ import { AuthConfig, AuthSession, AuthTokens, FetchAuthSessionOptions, LibraryAuthOptions } from './types';
2
2
  export declare function isTokenExpired({ expiresAt, clockDrift, }: {
3
3
  expiresAt: number;
4
4
  clockDrift: number;
@@ -20,4 +20,5 @@ export declare class AuthClass {
20
20
  configure(authResourcesConfig: AuthConfig, authOptions?: LibraryAuthOptions): void;
21
21
  fetchAuthSession(options?: FetchAuthSessionOptions): Promise<AuthSession>;
22
22
  clearCredentials(): Promise<void>;
23
+ getTokens(options: FetchAuthSessionOptions): Promise<AuthTokens | undefined>;
23
24
  }
@@ -61,20 +61,19 @@ var AuthClass = /** @class */ (function () {
61
61
  this.authOptions = authOptions;
62
62
  };
63
63
  AuthClass.prototype.fetchAuthSession = function (options) {
64
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
64
+ var _a, _b, _c, _d, _e, _f;
65
65
  if (options === void 0) { options = {}; }
66
66
  return __awaiter(this, void 0, void 0, function () {
67
67
  var tokens, credentialsAndIdentityId, userSub;
68
- return __generator(this, function (_k) {
69
- switch (_k.label) {
70
- case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
68
+ return __generator(this, function (_g) {
69
+ switch (_g.label) {
70
+ case 0: return [4 /*yield*/, this.getTokens(options)];
71
71
  case 1:
72
72
  // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
73
- tokens =
74
- (_c = (_k.sent())) !== null && _c !== void 0 ? _c : undefined;
73
+ tokens = _g.sent();
75
74
  if (!tokens) return [3 /*break*/, 3];
76
- userSub = (_e = (_d = tokens.accessToken) === null || _d === void 0 ? void 0 : _d.payload) === null || _e === void 0 ? void 0 : _e.sub;
77
- return [4 /*yield*/, ((_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.credentialsProvider) === null || _g === void 0 ? void 0 : _g.getCredentialsAndIdentityId({
75
+ userSub = (_b = (_a = tokens.accessToken) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.sub;
76
+ return [4 /*yield*/, ((_d = (_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.credentialsProvider) === null || _d === void 0 ? void 0 : _d.getCredentialsAndIdentityId({
78
77
  authConfig: this.authConfig,
79
78
  tokens: tokens,
80
79
  authenticated: true,
@@ -83,9 +82,9 @@ var AuthClass = /** @class */ (function () {
83
82
  case 2:
84
83
  // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
85
84
  credentialsAndIdentityId =
86
- _k.sent();
85
+ _g.sent();
87
86
  return [3 /*break*/, 5];
88
- case 3: return [4 /*yield*/, ((_j = (_h = this.authOptions) === null || _h === void 0 ? void 0 : _h.credentialsProvider) === null || _j === void 0 ? void 0 : _j.getCredentialsAndIdentityId({
87
+ case 3: return [4 /*yield*/, ((_f = (_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.credentialsProvider) === null || _f === void 0 ? void 0 : _f.getCredentialsAndIdentityId({
89
88
  authConfig: this.authConfig,
90
89
  authenticated: false,
91
90
  forceRefresh: options.forceRefresh,
@@ -93,8 +92,8 @@ var AuthClass = /** @class */ (function () {
93
92
  case 4:
94
93
  // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
95
94
  credentialsAndIdentityId =
96
- _k.sent();
97
- _k.label = 5;
95
+ _g.sent();
96
+ _g.label = 5;
98
97
  case 5: return [2 /*return*/, {
99
98
  tokens: tokens,
100
99
  credentials: credentialsAndIdentityId === null || credentialsAndIdentityId === void 0 ? void 0 : credentialsAndIdentityId.credentials,
@@ -119,6 +118,17 @@ var AuthClass = /** @class */ (function () {
119
118
  });
120
119
  });
121
120
  };
121
+ AuthClass.prototype.getTokens = function (options) {
122
+ var _a, _b, _c;
123
+ return __awaiter(this, void 0, void 0, function () {
124
+ return __generator(this, function (_d) {
125
+ switch (_d.label) {
126
+ case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
127
+ case 1: return [2 /*return*/, ((_c = (_d.sent())) !== null && _c !== void 0 ? _c : undefined)];
128
+ }
129
+ });
130
+ });
131
+ };
122
132
  return AuthClass;
123
133
  }());
124
134
  exports.AuthClass = AuthClass;
@@ -36,9 +36,9 @@ exports.assertOAuthConfig = assertOAuthConfig;
36
36
  function assertIdentityPooIdConfig(cognitoConfig) {
37
37
  var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
38
38
  return (0, AssertError_1.asserts)(validConfig, {
39
- name: 'AuthIdentityPoolIdException',
40
- message: 'Auth IdentityPoolId not configured',
41
- recoverySuggestion: 'Make sure to call Amplify.configure in your app with a valid IdentityPoolId',
39
+ name: 'InvalidIdentityPoolIdException',
40
+ message: 'Invalid identity pool id provided.',
41
+ recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
42
42
  });
43
43
  }
44
44
  exports.assertIdentityPooIdConfig = assertIdentityPooIdConfig;
@@ -1,17 +1,14 @@
1
- import { APIConfig, LibraryAPIOptions } from './API/types';
2
1
  import { AnalyticsConfig } from './Analytics/types';
3
2
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
3
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
5
4
  export type ResourcesConfig = {
6
- API?: APIConfig;
7
5
  Analytics?: AnalyticsConfig;
8
6
  Auth?: AuthConfig;
9
7
  Storage?: StorageConfig;
10
8
  };
11
9
  export type LibraryOptions = {
12
- API?: LibraryAPIOptions;
13
10
  Auth?: LibraryAuthOptions;
14
11
  Storage?: LibraryStorageOptions;
15
12
  ssr?: boolean;
16
13
  };
17
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };
14
+ export { AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };