@aws-amplify/core 6.0.1-console-preview.096eee3.0 → 6.0.1-console-preview.3b09ef9.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 (45) hide show
  1. package/lib/Cache/StorageCache.js +2 -2
  2. package/lib/I18n/I18n.js +4 -5
  3. package/lib/Platform/version.d.ts +1 -1
  4. package/lib/Platform/version.js +1 -1
  5. package/lib/index.d.ts +2 -3
  6. package/lib/libraryUtils.d.ts +1 -1
  7. package/lib/parseAWSExports.d.ts +7 -0
  8. package/lib/parseAWSExports.js +8 -1
  9. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  10. package/lib/singleton/Auth/index.js +1 -1
  11. package/lib/singleton/Auth/types.d.ts +43 -37
  12. package/lib/singleton/Auth/utils/index.d.ts +4 -5
  13. package/lib/singleton/Auth/utils/index.js +20 -15
  14. package/lib/singleton/Storage/types.d.ts +6 -4
  15. package/lib/singleton/types.d.ts +2 -11
  16. package/lib/tsconfig.tsbuildinfo +1 -1
  17. package/lib-esm/Cache/StorageCache.js +2 -2
  18. package/lib-esm/I18n/I18n.js +4 -5
  19. package/lib-esm/Platform/version.d.ts +1 -1
  20. package/lib-esm/Platform/version.js +1 -1
  21. package/lib-esm/index.d.ts +2 -3
  22. package/lib-esm/libraryUtils.d.ts +1 -1
  23. package/lib-esm/parseAWSExports.d.ts +7 -0
  24. package/lib-esm/parseAWSExports.js +8 -1
  25. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  26. package/lib-esm/singleton/Auth/index.js +1 -1
  27. package/lib-esm/singleton/Auth/types.d.ts +43 -37
  28. package/lib-esm/singleton/Auth/utils/index.d.ts +4 -5
  29. package/lib-esm/singleton/Auth/utils/index.js +20 -14
  30. package/lib-esm/singleton/Storage/types.d.ts +6 -4
  31. package/lib-esm/singleton/types.d.ts +2 -11
  32. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +2 -2
  34. package/src/Cache/StorageCache.ts +2 -1
  35. package/src/I18n/I18n.ts +2 -2
  36. package/src/Platform/version.ts +1 -1
  37. package/src/index.ts +2 -1
  38. package/src/libraryUtils.ts +1 -1
  39. package/src/parseAWSExports.ts +8 -1
  40. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  41. package/src/singleton/Auth/index.ts +1 -1
  42. package/src/singleton/Auth/types.ts +52 -39
  43. package/src/singleton/Auth/utils/index.ts +41 -29
  44. package/src/singleton/Storage/types.ts +6 -4
  45. package/src/singleton/types.ts +14 -14
@@ -50,52 +50,58 @@ export type AuthTokens = {
50
50
  idToken?: JWT;
51
51
  accessToken: JWT;
52
52
  };
53
- export type AuthConfig = StrictUnion<IdentityPoolConfig | UserPoolConfig | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfigAndIdentityPoolConfigWithOAuth>;
53
+ export type AuthConfig = StrictUnion<AuthIdentityPoolConfig | AuthUserPoolConfig | AuthUserPoolAndIdentityPoolConfig>;
54
54
  type UnionKeys<T> = T extends T ? keyof T : never;
55
55
  type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
56
- type StrictUnion<T> = StrictUnionHelper<T, T>;
57
- export type IdentityPoolConfig = {
56
+ export type StrictUnion<T> = StrictUnionHelper<T, T>;
57
+ export type AuthIdentityPoolConfig = {
58
+ Cognito: CognitoIdentityPoolConfig & {
59
+ userPoolClientId?: never;
60
+ userPoolId?: never;
61
+ loginWith?: never;
62
+ };
63
+ };
64
+ export type CognitoIdentityPoolConfig = {
58
65
  identityPoolId: string;
59
- userPoolWebClientId?: never;
60
- userPoolId?: never;
61
- clientMetadata?: never;
62
- isMandatorySignInEnabled?: never;
66
+ allowGuestAccess?: boolean;
63
67
  };
64
- export type UserPoolConfig = {
65
- userPoolWebClientId: string;
66
- userPoolId: string;
67
- identityPoolId?: never;
68
- clientMetadata?: Record<string, string>;
68
+ export type AuthUserPoolConfig = {
69
+ Cognito: CognitoUserPoolConfig & {
70
+ identityPoolId?: never;
71
+ allowGuestAccess?: never;
72
+ };
69
73
  };
70
- export type UserPoolConfigWithOAuth = {
71
- userPoolWebClientId: string;
74
+ export type CognitoUserPoolConfig = {
75
+ userPoolClientId: string;
72
76
  userPoolId: string;
73
- identityPoolId?: never;
74
- clientMetadata?: Record<string, string>;
75
- oauth: OAuthConfig;
77
+ signUpVerificationMethod?: 'code' | 'link';
78
+ loginWith?: {
79
+ oauth?: OAuthConfig;
80
+ };
76
81
  };
77
82
  export type OAuthConfig = {
78
83
  domain: string;
79
- scopes: Array<string>;
80
- redirectSignIn: string;
81
- redirectSignOut: string;
82
- responseType: string;
83
- };
84
- export type UserPoolConfigAndIdentityPoolConfig = {
85
- userPoolWebClientId: string;
86
- userPoolId: string;
87
- identityPoolId: string;
88
- clientMetadata?: Record<string, string>;
89
- isMandatorySignInEnabled?: boolean;
90
- };
91
- export type UserPoolConfigAndIdentityPoolConfigWithOAuth = {
92
- userPoolWebClientId: string;
93
- userPoolId: string;
94
- identityPoolId: string;
95
- clientMetadata?: Record<string, string>;
96
- isMandatorySignInEnabled?: boolean;
97
- oauth: OAuthConfig;
98
- };
84
+ scopes: Array<OAuthScope>;
85
+ redirectSignIn: Array<string>;
86
+ redirectSignOut: Array<string>;
87
+ responseType: 'code' | 'token';
88
+ providers?: Array<OAuthProviders | CustomProvider>;
89
+ };
90
+ type OAuthProviders = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
91
+ type CustomProvider = {
92
+ custom: string;
93
+ };
94
+ type CustomScope = string & {};
95
+ type OAuthScope = 'email' | 'openid' | 'phone' | 'email' | 'profile' | 'aws.cognito.signin.user.admin' | CustomScope;
96
+ export type CognitoUserPoolWithOAuthConfig = CognitoUserPoolConfig & {
97
+ loginWith: {
98
+ oauth: OAuthConfig;
99
+ };
100
+ };
101
+ export type AuthUserPoolAndIdentityPoolConfig = {
102
+ Cognito: CognitoUserPoolAndIdentityPoolConfig;
103
+ };
104
+ export type CognitoUserPoolAndIdentityPoolConfig = CognitoUserPoolConfig & CognitoIdentityPoolConfig;
99
105
  export type GetCredentialsOptions = GetCredentialsAuthenticatedUser | GetCredentialsUnauthenticatedUser;
100
106
  type GetCredentialsAuthenticatedUser = {
101
107
  authenticated: true;
@@ -1,6 +1,5 @@
1
- import { AuthConfig, IdentityPoolConfig, JWT, UserPoolConfig, UserPoolConfigAndIdentityPoolConfig, UserPoolConfigAndIdentityPoolConfigWithOAuth, UserPoolConfigWithOAuth } from '../types';
2
- export declare function assertTokenProviderConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfig;
3
- export declare function assertOAuthConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth;
4
- export declare function assertIdentityPooIdConfig(authConfig: AuthConfig): asserts authConfig is IdentityPoolConfig;
5
- export declare function assertUserPoolAndIdentityPooConfig(authConfig: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfig;
1
+ import { JWT, CognitoUserPoolWithOAuthConfig, CognitoUserPoolConfig, CognitoUserPoolAndIdentityPoolConfig, CognitoIdentityPoolConfig, StrictUnion } from '../types';
2
+ export declare function assertTokenProviderConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoUserPoolAndIdentityPoolConfig | CognitoUserPoolConfig;
3
+ export declare function assertOAuthConfig(cognitoConfig?: CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig): asserts cognitoConfig is CognitoUserPoolWithOAuthConfig;
4
+ export declare function assertIdentityPooIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
6
5
  export declare function decodeJWT(token: string): JWT;
@@ -1,37 +1,43 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { asserts } from '../../../Util/errors/AssertError';
4
- export function assertTokenProviderConfig(authConfig) {
5
- var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.userPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.userPoolWebClientId);
6
- return asserts(validConfig, {
4
+ export function assertTokenProviderConfig(cognitoConfig) {
5
+ var assertionValid = true; // assume valid until otherwise proveed
6
+ if (!cognitoConfig) {
7
+ assertionValid = false;
8
+ }
9
+ else {
10
+ assertionValid =
11
+ !!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
12
+ }
13
+ return asserts(assertionValid, {
7
14
  name: 'AuthTokenConfigException',
8
15
  message: 'Auth Token Provider not configured',
9
16
  recoverySuggestion: 'Make sure to call Amplify.configure in your app',
10
17
  });
11
18
  }
12
- export function assertOAuthConfig(authConfig) {
13
- var _a, _b, _c, _d;
14
- assertTokenProviderConfig(authConfig);
15
- var validOAuthConfig = !!((_a = authConfig.oauth) === null || _a === void 0 ? void 0 : _a.domain) &&
16
- !!((_b = authConfig.oauth) === null || _b === void 0 ? void 0 : _b.redirectSignOut) &&
17
- !!((_c = authConfig.oauth) === null || _c === void 0 ? void 0 : _c.redirectSignIn) &&
18
- !!((_d = authConfig.oauth) === null || _d === void 0 ? void 0 : _d.responseType);
19
+ export function assertOAuthConfig(cognitoConfig) {
20
+ var _a, _b, _c, _d, _e, _f, _g, _h;
21
+ var validOAuthConfig = !!((_b = (_a = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _a === void 0 ? void 0 : _a.oauth) === null || _b === void 0 ? void 0 : _b.domain) &&
22
+ !!((_d = (_c = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _c === void 0 ? void 0 : _c.oauth) === null || _d === void 0 ? void 0 : _d.redirectSignOut) &&
23
+ !!((_f = (_e = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _e === void 0 ? void 0 : _e.oauth) === null || _f === void 0 ? void 0 : _f.redirectSignIn) &&
24
+ !!((_h = (_g = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _g === void 0 ? void 0 : _g.oauth) === null || _h === void 0 ? void 0 : _h.responseType);
19
25
  return asserts(validOAuthConfig, {
20
26
  name: 'OAuthNotConfigureException',
21
27
  message: 'oauth param not configured',
22
28
  recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app',
23
29
  });
24
30
  }
25
- export function assertIdentityPooIdConfig(authConfig) {
26
- var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.identityPoolId);
31
+ export function assertIdentityPooIdConfig(cognitoConfig) {
32
+ var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
27
33
  return asserts(validConfig, {
28
34
  name: 'AuthIdentityPoolIdException',
29
35
  message: 'Auth IdentityPoolId not configured',
30
36
  recoverySuggestion: 'Make sure to call Amplify.configure in your app with a valid IdentityPoolId',
31
37
  });
32
38
  }
33
- export function assertUserPoolAndIdentityPooConfig(authConfig) {
34
- var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.identityPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.userPoolId);
39
+ function assertUserPoolAndIdentityPooConfig(authConfig) {
40
+ var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.identityPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.userPoolId);
35
41
  return asserts(validConfig, {
36
42
  name: 'AuthUserPoolAndIdentityPoolException',
37
43
  message: 'Auth UserPool and IdentityPool not configured',
@@ -1,15 +1,17 @@
1
1
  export type StorageAccessLevel = 'guest' | 'protected' | 'private';
2
2
  export interface StorageConfig {
3
- bucket?: string;
4
- region?: string;
5
- dangerouslyConnectToHttpEndpointForTesting?: string;
3
+ S3: {
4
+ bucket?: string;
5
+ region?: string;
6
+ dangerouslyConnectToHttpEndpointForTesting?: string;
7
+ };
6
8
  }
7
9
  type StoragePrefixResolver = (params: {
8
10
  accessLevel: StorageAccessLevel;
9
11
  targetIdentityId?: string;
10
12
  }) => Promise<string>;
11
13
  export interface LibraryStorageOptions {
12
- AWSS3: {
14
+ S3: {
13
15
  prefixResolver?: StoragePrefixResolver;
14
16
  defaultAccessLevel?: StorageAccessLevel;
15
17
  isObjectLockEnabled?: boolean;
@@ -1,18 +1,9 @@
1
1
  import { AnalyticsConfig } from './Analytics/types';
2
- import { AuthConfig, LibraryAuthOptions, UserPoolConfig, IdentityPoolConfig, UserPoolConfigAndIdentityPoolConfig, GetCredentialsOptions } from './Auth/types';
2
+ import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions } from './Auth/types';
3
3
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
4
- import { CacheConfig } from '../Cache/types';
5
- import { I18nOptions } from '../I18n/types';
6
4
  export type ResourcesConfig = {
7
- API?: {};
8
5
  Analytics?: AnalyticsConfig;
9
6
  Auth?: AuthConfig;
10
- Cache?: CacheConfig;
11
- DataStore?: {};
12
- I18n?: I18nOptions;
13
- Interactions?: {};
14
- Notifications?: {};
15
- Predictions?: {};
16
7
  Storage?: StorageConfig;
17
8
  ssr?: boolean;
18
9
  };
@@ -20,4 +11,4 @@ export type LibraryOptions = {
20
11
  Auth?: LibraryAuthOptions;
21
12
  Storage?: LibraryStorageOptions;
22
13
  };
23
- export { AuthConfig, UserPoolConfig, IdentityPoolConfig, UserPoolConfigAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, };
14
+ export { AuthConfig, AuthUserPoolConfig as UserPoolConfig, AuthIdentityPoolConfig as IdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig as UserPoolConfigAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, };