@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.
- package/lib/Cache/StorageCache.js +2 -2
- package/lib/I18n/I18n.js +4 -5
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/libraryUtils.d.ts +1 -1
- package/lib/parseAWSExports.d.ts +7 -0
- package/lib/parseAWSExports.js +8 -1
- package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
- package/lib/singleton/Auth/index.js +1 -1
- package/lib/singleton/Auth/types.d.ts +43 -37
- package/lib/singleton/Auth/utils/index.d.ts +4 -5
- package/lib/singleton/Auth/utils/index.js +20 -15
- package/lib/singleton/Storage/types.d.ts +6 -4
- package/lib/singleton/types.d.ts +2 -11
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/Cache/StorageCache.js +2 -2
- package/lib-esm/I18n/I18n.js +4 -5
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/index.d.ts +2 -3
- package/lib-esm/libraryUtils.d.ts +1 -1
- package/lib-esm/parseAWSExports.d.ts +7 -0
- package/lib-esm/parseAWSExports.js +8 -1
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
- package/lib-esm/singleton/Auth/index.js +1 -1
- package/lib-esm/singleton/Auth/types.d.ts +43 -37
- package/lib-esm/singleton/Auth/utils/index.d.ts +4 -5
- package/lib-esm/singleton/Auth/utils/index.js +20 -14
- package/lib-esm/singleton/Storage/types.d.ts +6 -4
- package/lib-esm/singleton/types.d.ts +2 -11
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Cache/StorageCache.ts +2 -1
- package/src/I18n/I18n.ts +2 -2
- package/src/Platform/version.ts +1 -1
- package/src/index.ts +2 -1
- package/src/libraryUtils.ts +1 -1
- package/src/parseAWSExports.ts +8 -1
- package/src/providers/pinpoint/types/pinpoint.ts +1 -1
- package/src/singleton/Auth/index.ts +1 -1
- package/src/singleton/Auth/types.ts +52 -39
- package/src/singleton/Auth/utils/index.ts +41 -29
- package/src/singleton/Storage/types.ts +6 -4
- package/src/singleton/types.ts +14 -14
|
@@ -71,66 +71,79 @@ export type AuthTokens = {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
export type AuthConfig = StrictUnion<
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
| UserPoolConfigAndIdentityPoolConfig
|
|
78
|
-
| UserPoolConfigAndIdentityPoolConfigWithOAuth
|
|
74
|
+
| AuthIdentityPoolConfig
|
|
75
|
+
| AuthUserPoolConfig
|
|
76
|
+
| AuthUserPoolAndIdentityPoolConfig
|
|
79
77
|
>;
|
|
80
78
|
|
|
81
79
|
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
82
80
|
type StrictUnionHelper<T, TAll> = T extends any
|
|
83
81
|
? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>
|
|
84
82
|
: never;
|
|
85
|
-
type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
83
|
+
export type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
86
84
|
|
|
87
|
-
export type
|
|
85
|
+
export type AuthIdentityPoolConfig = {
|
|
86
|
+
Cognito: CognitoIdentityPoolConfig & {
|
|
87
|
+
userPoolClientId?: never;
|
|
88
|
+
userPoolId?: never;
|
|
89
|
+
loginWith?: never;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type CognitoIdentityPoolConfig = {
|
|
88
94
|
identityPoolId: string;
|
|
89
|
-
|
|
90
|
-
userPoolId?: never;
|
|
91
|
-
clientMetadata?: never;
|
|
92
|
-
isMandatorySignInEnabled?: never;
|
|
95
|
+
allowGuestAccess?: boolean;
|
|
93
96
|
};
|
|
94
97
|
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
export type AuthUserPoolConfig = {
|
|
99
|
+
Cognito: CognitoUserPoolConfig & {
|
|
100
|
+
identityPoolId?: never;
|
|
101
|
+
allowGuestAccess?: never;
|
|
102
|
+
};
|
|
100
103
|
};
|
|
101
104
|
|
|
102
|
-
export type
|
|
103
|
-
|
|
105
|
+
export type CognitoUserPoolConfig = {
|
|
106
|
+
userPoolClientId: string;
|
|
104
107
|
userPoolId: string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
signUpVerificationMethod?: 'code' | 'link';
|
|
109
|
+
loginWith?: {
|
|
110
|
+
oauth?: OAuthConfig;
|
|
111
|
+
};
|
|
108
112
|
};
|
|
109
113
|
|
|
110
114
|
export type OAuthConfig = {
|
|
111
115
|
domain: string;
|
|
112
|
-
scopes: Array<
|
|
113
|
-
redirectSignIn: string
|
|
114
|
-
redirectSignOut: string
|
|
115
|
-
responseType:
|
|
116
|
+
scopes: Array<OAuthScope>;
|
|
117
|
+
redirectSignIn: Array<string>;
|
|
118
|
+
redirectSignOut: Array<string>;
|
|
119
|
+
responseType: 'code' | 'token';
|
|
120
|
+
providers?: Array<OAuthProviders | CustomProvider>;
|
|
116
121
|
};
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
userPoolId: string;
|
|
121
|
-
identityPoolId: string;
|
|
122
|
-
clientMetadata?: Record<string, string>;
|
|
123
|
-
isMandatorySignInEnabled?: boolean;
|
|
124
|
-
};
|
|
123
|
+
type OAuthProviders = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
|
|
124
|
+
type CustomProvider = { custom: string };
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
type CustomScope = string & {};
|
|
127
|
+
type OAuthScope =
|
|
128
|
+
| 'email'
|
|
129
|
+
| 'openid'
|
|
130
|
+
| 'phone'
|
|
131
|
+
| 'email'
|
|
132
|
+
| 'profile'
|
|
133
|
+
| 'aws.cognito.signin.user.admin'
|
|
134
|
+
| CustomScope;
|
|
135
|
+
|
|
136
|
+
export type CognitoUserPoolWithOAuthConfig = CognitoUserPoolConfig & {
|
|
137
|
+
loginWith: {
|
|
138
|
+
oauth: OAuthConfig;
|
|
139
|
+
};
|
|
133
140
|
};
|
|
141
|
+
export type AuthUserPoolAndIdentityPoolConfig = {
|
|
142
|
+
Cognito: CognitoUserPoolAndIdentityPoolConfig;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type CognitoUserPoolAndIdentityPoolConfig = CognitoUserPoolConfig &
|
|
146
|
+
CognitoIdentityPoolConfig;
|
|
134
147
|
|
|
135
148
|
export type GetCredentialsOptions =
|
|
136
149
|
| GetCredentialsAuthenticatedUser
|
|
@@ -1,26 +1,36 @@
|
|
|
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
|
+
|
|
4
5
|
import {
|
|
5
6
|
AuthConfig,
|
|
6
|
-
IdentityPoolConfig,
|
|
7
7
|
JWT,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
AuthUserPoolAndIdentityPoolConfig,
|
|
9
|
+
CognitoUserPoolWithOAuthConfig,
|
|
10
|
+
CognitoUserPoolConfig,
|
|
11
|
+
CognitoUserPoolAndIdentityPoolConfig,
|
|
12
|
+
CognitoIdentityPoolConfig,
|
|
13
|
+
StrictUnion,
|
|
12
14
|
} from '../types';
|
|
13
15
|
|
|
14
16
|
export function assertTokenProviderConfig(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
cognitoConfig?: StrictUnion<
|
|
18
|
+
| CognitoUserPoolConfig
|
|
19
|
+
| CognitoUserPoolAndIdentityPoolConfig
|
|
20
|
+
| CognitoIdentityPoolConfig
|
|
21
|
+
>
|
|
22
|
+
): asserts cognitoConfig is
|
|
23
|
+
| CognitoUserPoolAndIdentityPoolConfig
|
|
24
|
+
| CognitoUserPoolConfig {
|
|
25
|
+
let assertionValid = true; // assume valid until otherwise proveed
|
|
26
|
+
if (!cognitoConfig) {
|
|
27
|
+
assertionValid = false;
|
|
28
|
+
} else {
|
|
29
|
+
assertionValid =
|
|
30
|
+
!!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return asserts(assertionValid, {
|
|
24
34
|
name: 'AuthTokenConfigException',
|
|
25
35
|
message: 'Auth Token Provider not configured',
|
|
26
36
|
recoverySuggestion: 'Make sure to call Amplify.configure in your app',
|
|
@@ -28,16 +38,13 @@ export function assertTokenProviderConfig(
|
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
export function assertOAuthConfig(
|
|
31
|
-
|
|
32
|
-
): asserts
|
|
33
|
-
| UserPoolConfigAndIdentityPoolConfigWithOAuth
|
|
34
|
-
| UserPoolConfigWithOAuth {
|
|
35
|
-
assertTokenProviderConfig(authConfig);
|
|
41
|
+
cognitoConfig?: CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig
|
|
42
|
+
): asserts cognitoConfig is CognitoUserPoolWithOAuthConfig {
|
|
36
43
|
const validOAuthConfig =
|
|
37
|
-
!!
|
|
38
|
-
!!
|
|
39
|
-
!!
|
|
40
|
-
!!
|
|
44
|
+
!!cognitoConfig?.loginWith?.oauth?.domain &&
|
|
45
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&
|
|
46
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&
|
|
47
|
+
!!cognitoConfig?.loginWith?.oauth?.responseType;
|
|
41
48
|
|
|
42
49
|
return asserts(validOAuthConfig, {
|
|
43
50
|
name: 'OAuthNotConfigureException',
|
|
@@ -48,9 +55,13 @@ export function assertOAuthConfig(
|
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export function assertIdentityPooIdConfig(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
cognitoConfig?: StrictUnion<
|
|
59
|
+
| CognitoUserPoolConfig
|
|
60
|
+
| CognitoUserPoolAndIdentityPoolConfig
|
|
61
|
+
| CognitoIdentityPoolConfig
|
|
62
|
+
>
|
|
63
|
+
): asserts cognitoConfig is CognitoIdentityPoolConfig {
|
|
64
|
+
const validConfig = !!cognitoConfig?.identityPoolId;
|
|
54
65
|
return asserts(validConfig, {
|
|
55
66
|
name: 'AuthIdentityPoolIdException',
|
|
56
67
|
message: 'Auth IdentityPoolId not configured',
|
|
@@ -59,10 +70,11 @@ export function assertIdentityPooIdConfig(
|
|
|
59
70
|
});
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
function assertUserPoolAndIdentityPooConfig(
|
|
63
74
|
authConfig: AuthConfig
|
|
64
|
-
): asserts authConfig is
|
|
65
|
-
const validConfig =
|
|
75
|
+
): asserts authConfig is AuthUserPoolAndIdentityPoolConfig {
|
|
76
|
+
const validConfig =
|
|
77
|
+
!!authConfig?.Cognito.identityPoolId && !!authConfig?.Cognito.userPoolId;
|
|
66
78
|
return asserts(validConfig, {
|
|
67
79
|
name: 'AuthUserPoolAndIdentityPoolException',
|
|
68
80
|
message: 'Auth UserPool and IdentityPool not configured',
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
export type StorageAccessLevel = 'guest' | 'protected' | 'private';
|
|
5
5
|
|
|
6
6
|
export interface StorageConfig {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
S3: {
|
|
8
|
+
bucket?: string;
|
|
9
|
+
region?: string;
|
|
10
|
+
dangerouslyConnectToHttpEndpointForTesting?: string;
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
type StoragePrefixResolver = (params: {
|
|
@@ -16,7 +18,7 @@ type StoragePrefixResolver = (params: {
|
|
|
16
18
|
|
|
17
19
|
// TODO[AllanZhengYP]: need to finalize the decision whether to move defaultAccessLevel to StorageConfig
|
|
18
20
|
export interface LibraryStorageOptions {
|
|
19
|
-
|
|
21
|
+
S3: {
|
|
20
22
|
prefixResolver?: StoragePrefixResolver;
|
|
21
23
|
defaultAccessLevel?: StorageAccessLevel;
|
|
22
24
|
isObjectLockEnabled?: boolean;
|
package/src/singleton/types.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { AnalyticsConfig } from './Analytics/types';
|
|
|
5
5
|
import {
|
|
6
6
|
AuthConfig,
|
|
7
7
|
LibraryAuthOptions,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
AuthUserPoolConfig,
|
|
9
|
+
AuthIdentityPoolConfig,
|
|
10
|
+
AuthUserPoolAndIdentityPoolConfig,
|
|
11
11
|
GetCredentialsOptions,
|
|
12
12
|
} from './Auth/types';
|
|
13
13
|
import {
|
|
@@ -15,19 +15,18 @@ import {
|
|
|
15
15
|
StorageAccessLevel,
|
|
16
16
|
StorageConfig,
|
|
17
17
|
} from './Storage/types';
|
|
18
|
-
import { CacheConfig } from '../Cache/types';
|
|
19
18
|
import { I18nOptions } from '../I18n/types';
|
|
20
19
|
|
|
21
20
|
export type ResourcesConfig = {
|
|
22
|
-
API?: {};
|
|
21
|
+
// API?: {};
|
|
23
22
|
Analytics?: AnalyticsConfig;
|
|
24
23
|
Auth?: AuthConfig;
|
|
25
|
-
Cache?: CacheConfig;
|
|
26
|
-
DataStore?: {};
|
|
27
|
-
I18n?: I18nOptions;
|
|
28
|
-
Interactions?: {};
|
|
29
|
-
Notifications?: {};
|
|
30
|
-
Predictions?: {};
|
|
24
|
+
// Cache?: CacheConfig;
|
|
25
|
+
// DataStore?: {};
|
|
26
|
+
// I18n?: I18nOptions;
|
|
27
|
+
// Interactions?: {};
|
|
28
|
+
// Notifications?: {};
|
|
29
|
+
// Predictions?: {};
|
|
31
30
|
Storage?: StorageConfig;
|
|
32
31
|
ssr?: boolean;
|
|
33
32
|
};
|
|
@@ -39,10 +38,11 @@ export type LibraryOptions = {
|
|
|
39
38
|
|
|
40
39
|
export {
|
|
41
40
|
AuthConfig,
|
|
42
|
-
UserPoolConfig,
|
|
43
|
-
IdentityPoolConfig,
|
|
44
|
-
UserPoolConfigAndIdentityPoolConfig,
|
|
41
|
+
AuthUserPoolConfig as UserPoolConfig,
|
|
42
|
+
AuthIdentityPoolConfig as IdentityPoolConfig,
|
|
43
|
+
AuthUserPoolAndIdentityPoolConfig as UserPoolConfigAndIdentityPoolConfig,
|
|
45
44
|
GetCredentialsOptions,
|
|
46
45
|
StorageAccessLevel,
|
|
47
46
|
StorageConfig,
|
|
47
|
+
AnalyticsConfig,
|
|
48
48
|
};
|