@aws-amplify/core 6.0.1-console-preview.26f7c82.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 +3 -4
- package/lib/index.js +2 -1
- package/lib/libraryUtils.d.ts +1 -0
- 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.d.ts +1 -8
- package/lib/singleton/Auth/index.js +25 -27
- package/lib/singleton/Auth/types.d.ts +45 -37
- package/lib/singleton/Auth/utils/index.d.ts +4 -5
- package/lib/singleton/Auth/utils/index.js +28 -18
- package/lib/singleton/Storage/types.d.ts +6 -4
- package/lib/singleton/apis/clearCredentials.d.ts +1 -0
- package/lib/singleton/apis/clearCredentials.js +10 -0
- package/lib/singleton/index.d.ts +1 -0
- package/lib/singleton/index.js +3 -1
- 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 +3 -4
- package/lib-esm/index.js +1 -1
- package/lib-esm/libraryUtils.d.ts +1 -0
- 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.d.ts +1 -8
- package/lib-esm/singleton/Auth/index.js +25 -27
- package/lib-esm/singleton/Auth/types.d.ts +45 -37
- package/lib-esm/singleton/Auth/utils/index.d.ts +4 -5
- package/lib-esm/singleton/Auth/utils/index.js +28 -17
- package/lib-esm/singleton/Storage/types.d.ts +6 -4
- package/lib-esm/singleton/apis/clearCredentials.d.ts +1 -0
- package/lib-esm/singleton/apis/clearCredentials.js +6 -0
- package/lib-esm/singleton/index.d.ts +1 -0
- package/lib-esm/singleton/index.js +1 -0
- package/lib-esm/singleton/types.d.ts +2 -11
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/polyfills/URL/index.ts +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 +3 -1
- package/src/libraryUtils.ts +1 -0
- package/src/parseAWSExports.ts +8 -1
- package/src/providers/pinpoint/types/pinpoint.ts +1 -1
- package/src/singleton/Auth/index.ts +10 -20
- package/src/singleton/Auth/types.ts +54 -39
- package/src/singleton/Auth/utils/index.ts +51 -36
- package/src/singleton/Storage/types.ts +6 -4
- package/src/singleton/apis/clearCredentials.ts +8 -0
- package/src/singleton/index.ts +1 -0
- package/src/singleton/types.ts +14 -14
- package/polyfills/URL/index.js +0 -1
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.1-console-preview.
|
|
2
|
+
export const version = '6.0.1-console-preview.3b09ef9.0+3b09ef9';
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export {
|
|
|
23
23
|
AWSCredentialsAndIdentityId,
|
|
24
24
|
Identity,
|
|
25
25
|
OAuthConfig,
|
|
26
|
+
CognitoUserPoolConfig,
|
|
26
27
|
} from './singleton/Auth/types';
|
|
27
28
|
export {
|
|
28
29
|
AuthConfig,
|
|
@@ -33,11 +34,13 @@ export {
|
|
|
33
34
|
GetCredentialsOptions,
|
|
34
35
|
ResourcesConfig,
|
|
35
36
|
LibraryOptions,
|
|
37
|
+
AnalyticsConfig,
|
|
36
38
|
} from './singleton/types';
|
|
37
39
|
export {
|
|
38
40
|
Amplify,
|
|
39
41
|
fetchAuthSession,
|
|
40
42
|
AmplifyClass as AmplifyClassV6,
|
|
43
|
+
clearCredentials,
|
|
41
44
|
} from './singleton';
|
|
42
45
|
|
|
43
46
|
// AWSClients exports
|
|
@@ -66,7 +69,6 @@ export { UniversalStorage } from './UniversalStorage';
|
|
|
66
69
|
// Cache exports
|
|
67
70
|
import { BrowserStorageCache } from './Cache/BrowserStorageCache';
|
|
68
71
|
export { InMemoryCache } from './Cache/InMemoryCache';
|
|
69
|
-
export { CacheConfig } from './Cache/types';
|
|
70
72
|
export { BrowserStorageCache };
|
|
71
73
|
export { BrowserStorageCache as Cache }; // Maintain interoperability with React Native
|
|
72
74
|
|
package/src/libraryUtils.ts
CHANGED
package/src/parseAWSExports.ts
CHANGED
|
@@ -5,12 +5,19 @@ import { ConsoleLogger as Logger } from './Logger';
|
|
|
5
5
|
|
|
6
6
|
const logger = new Logger('Parser');
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* This utility generates an `AmplifyConfig` object from an `aws-exports.js` file generated by the Amplify CLI.
|
|
10
|
+
*
|
|
11
|
+
* @param config A configuration object from `aws-exports.js`.
|
|
12
|
+
*
|
|
13
|
+
* @returns An AmplifyConfig object.
|
|
14
|
+
*/
|
|
8
15
|
export const parseAWSExports = (config:Record<string,any>): AmplifyConfig => {
|
|
9
16
|
const amplifyConfig: AmplifyConfig = {};
|
|
10
17
|
// Analytics
|
|
11
18
|
if (config['aws_mobile_analytics_app_id']) {
|
|
12
19
|
const Analytics = {
|
|
13
|
-
|
|
20
|
+
Pinpoint: {
|
|
14
21
|
appId: config['aws_mobile_analytics_app_id'],
|
|
15
22
|
region: config['aws_mobile_analytics_app_region'],
|
|
16
23
|
},
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Observable, Observer } from 'rxjs';
|
|
4
|
-
|
|
5
3
|
import {
|
|
6
4
|
AWSCredentialsAndIdentityId,
|
|
7
5
|
AuthConfig,
|
|
@@ -25,13 +23,10 @@ export function isTokenExpired({
|
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export class AuthClass {
|
|
28
|
-
private authSessionObservers: Set<Observer<AuthSession>>;
|
|
29
26
|
private authConfig?: AuthConfig;
|
|
30
27
|
private authOptions?: LibraryAuthOptions;
|
|
31
28
|
|
|
32
|
-
constructor() {
|
|
33
|
-
this.authSessionObservers = new Set();
|
|
34
|
-
}
|
|
29
|
+
constructor() {}
|
|
35
30
|
|
|
36
31
|
/**
|
|
37
32
|
* Configure Auth category
|
|
@@ -56,6 +51,7 @@ export class AuthClass {
|
|
|
56
51
|
): Promise<AuthSession> {
|
|
57
52
|
let tokens: AuthTokens | undefined;
|
|
58
53
|
let credentialsAndIdentityId: AWSCredentialsAndIdentityId | undefined;
|
|
54
|
+
let userSub: string | undefined;
|
|
59
55
|
|
|
60
56
|
asserts(!!this.authConfig, {
|
|
61
57
|
name: AUTH_CONFING_EXCEPTION,
|
|
@@ -69,6 +65,8 @@ export class AuthClass {
|
|
|
69
65
|
(await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined;
|
|
70
66
|
|
|
71
67
|
if (tokens) {
|
|
68
|
+
userSub = tokens.accessToken?.payload?.sub;
|
|
69
|
+
|
|
72
70
|
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
73
71
|
credentialsAndIdentityId =
|
|
74
72
|
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId(
|
|
@@ -79,7 +77,7 @@ export class AuthClass {
|
|
|
79
77
|
forceRefresh: options.forceRefresh,
|
|
80
78
|
}
|
|
81
79
|
);
|
|
82
|
-
} else if (
|
|
80
|
+
} else if (this.authConfig.Cognito.allowGuestAccess) {
|
|
83
81
|
// getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
|
|
84
82
|
credentialsAndIdentityId =
|
|
85
83
|
await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId(
|
|
@@ -95,21 +93,13 @@ export class AuthClass {
|
|
|
95
93
|
tokens,
|
|
96
94
|
credentials: credentialsAndIdentityId?.credentials,
|
|
97
95
|
identityId: credentialsAndIdentityId?.identityId,
|
|
96
|
+
userSub,
|
|
98
97
|
};
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*/
|
|
106
|
-
listenSessionChanges(): Observable<AuthSession> {
|
|
107
|
-
return new Observable(observer => {
|
|
108
|
-
this.authSessionObservers.add(observer);
|
|
109
|
-
|
|
110
|
-
return () => {
|
|
111
|
-
this.authSessionObservers.delete(observer);
|
|
112
|
-
};
|
|
113
|
-
});
|
|
100
|
+
async clearCredentials(): Promise<void> {
|
|
101
|
+
if (this.authOptions?.credentialsProvider) {
|
|
102
|
+
return await this.authOptions.credentialsProvider.clearCredentials();
|
|
103
|
+
}
|
|
114
104
|
}
|
|
115
105
|
}
|
|
@@ -11,6 +11,7 @@ interface JwtPayloadStandardFields {
|
|
|
11
11
|
iat?: number; // issued at: https://tools.ietf.org/html/rfc7519#section-4.1.6
|
|
12
12
|
scope?: string; // scopes: https://tools.ietf.org/html/rfc6749#section-3.3
|
|
13
13
|
jti?: string; // JWT ID: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7
|
|
14
|
+
sub?: string; // JWT sub https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/** JSON type */
|
|
@@ -32,6 +33,7 @@ export type AuthSession = {
|
|
|
32
33
|
tokens?: AuthTokens;
|
|
33
34
|
credentials?: AWSCredentials;
|
|
34
35
|
identityId?: string;
|
|
36
|
+
userSub?: string;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
export type LibraryAuthOptions = {
|
|
@@ -69,66 +71,79 @@ export type AuthTokens = {
|
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
export type AuthConfig = StrictUnion<
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
| UserPoolConfigAndIdentityPoolConfig
|
|
76
|
-
| UserPoolConfigAndIdentityPoolConfigWithOAuth
|
|
74
|
+
| AuthIdentityPoolConfig
|
|
75
|
+
| AuthUserPoolConfig
|
|
76
|
+
| AuthUserPoolAndIdentityPoolConfig
|
|
77
77
|
>;
|
|
78
78
|
|
|
79
79
|
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
80
80
|
type StrictUnionHelper<T, TAll> = T extends any
|
|
81
81
|
? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>
|
|
82
82
|
: never;
|
|
83
|
-
type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
83
|
+
export type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
84
84
|
|
|
85
|
-
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 = {
|
|
86
94
|
identityPoolId: string;
|
|
87
|
-
|
|
88
|
-
userPoolId?: never;
|
|
89
|
-
clientMetadata?: never;
|
|
90
|
-
isMandatorySignInEnabled?: never;
|
|
95
|
+
allowGuestAccess?: boolean;
|
|
91
96
|
};
|
|
92
97
|
|
|
93
|
-
export type
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
export type AuthUserPoolConfig = {
|
|
99
|
+
Cognito: CognitoUserPoolConfig & {
|
|
100
|
+
identityPoolId?: never;
|
|
101
|
+
allowGuestAccess?: never;
|
|
102
|
+
};
|
|
98
103
|
};
|
|
99
104
|
|
|
100
|
-
export type
|
|
101
|
-
|
|
105
|
+
export type CognitoUserPoolConfig = {
|
|
106
|
+
userPoolClientId: string;
|
|
102
107
|
userPoolId: string;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
signUpVerificationMethod?: 'code' | 'link';
|
|
109
|
+
loginWith?: {
|
|
110
|
+
oauth?: OAuthConfig;
|
|
111
|
+
};
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
export type OAuthConfig = {
|
|
109
115
|
domain: string;
|
|
110
|
-
scopes: Array<
|
|
111
|
-
redirectSignIn: string
|
|
112
|
-
redirectSignOut: string
|
|
113
|
-
responseType:
|
|
116
|
+
scopes: Array<OAuthScope>;
|
|
117
|
+
redirectSignIn: Array<string>;
|
|
118
|
+
redirectSignOut: Array<string>;
|
|
119
|
+
responseType: 'code' | 'token';
|
|
120
|
+
providers?: Array<OAuthProviders | CustomProvider>;
|
|
114
121
|
};
|
|
115
122
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
userPoolId: string;
|
|
119
|
-
identityPoolId: string;
|
|
120
|
-
clientMetadata?: Record<string, string>;
|
|
121
|
-
isMandatorySignInEnabled?: boolean;
|
|
122
|
-
};
|
|
123
|
+
type OAuthProviders = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
|
|
124
|
+
type CustomProvider = { custom: string };
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
+
};
|
|
131
140
|
};
|
|
141
|
+
export type AuthUserPoolAndIdentityPoolConfig = {
|
|
142
|
+
Cognito: CognitoUserPoolAndIdentityPoolConfig;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type CognitoUserPoolAndIdentityPoolConfig = CognitoUserPoolConfig &
|
|
146
|
+
CognitoIdentityPoolConfig;
|
|
132
147
|
|
|
133
148
|
export type GetCredentialsOptions =
|
|
134
149
|
| GetCredentialsAuthenticatedUser
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Buffer } from 'buffer';
|
|
4
3
|
import { asserts } from '../../../Util/errors/AssertError';
|
|
4
|
+
|
|
5
5
|
import {
|
|
6
6
|
AuthConfig,
|
|
7
|
-
IdentityPoolConfig,
|
|
8
7
|
JWT,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
AuthUserPoolAndIdentityPoolConfig,
|
|
9
|
+
CognitoUserPoolWithOAuthConfig,
|
|
10
|
+
CognitoUserPoolConfig,
|
|
11
|
+
CognitoUserPoolAndIdentityPoolConfig,
|
|
12
|
+
CognitoIdentityPoolConfig,
|
|
13
|
+
StrictUnion,
|
|
13
14
|
} from '../types';
|
|
14
15
|
|
|
15
16
|
export function assertTokenProviderConfig(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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, {
|
|
25
34
|
name: 'AuthTokenConfigException',
|
|
26
35
|
message: 'Auth Token Provider not configured',
|
|
27
36
|
recoverySuggestion: 'Make sure to call Amplify.configure in your app',
|
|
@@ -29,16 +38,13 @@ export function assertTokenProviderConfig(
|
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
export function assertOAuthConfig(
|
|
32
|
-
|
|
33
|
-
): asserts
|
|
34
|
-
| UserPoolConfigAndIdentityPoolConfigWithOAuth
|
|
35
|
-
| UserPoolConfigWithOAuth {
|
|
36
|
-
assertTokenProviderConfig(authConfig);
|
|
41
|
+
cognitoConfig?: CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig
|
|
42
|
+
): asserts cognitoConfig is CognitoUserPoolWithOAuthConfig {
|
|
37
43
|
const validOAuthConfig =
|
|
38
|
-
!!
|
|
39
|
-
!!
|
|
40
|
-
!!
|
|
41
|
-
!!
|
|
44
|
+
!!cognitoConfig?.loginWith?.oauth?.domain &&
|
|
45
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&
|
|
46
|
+
!!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&
|
|
47
|
+
!!cognitoConfig?.loginWith?.oauth?.responseType;
|
|
42
48
|
|
|
43
49
|
return asserts(validOAuthConfig, {
|
|
44
50
|
name: 'OAuthNotConfigureException',
|
|
@@ -49,9 +55,13 @@ export function assertOAuthConfig(
|
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export function assertIdentityPooIdConfig(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
cognitoConfig?: StrictUnion<
|
|
59
|
+
| CognitoUserPoolConfig
|
|
60
|
+
| CognitoUserPoolAndIdentityPoolConfig
|
|
61
|
+
| CognitoIdentityPoolConfig
|
|
62
|
+
>
|
|
63
|
+
): asserts cognitoConfig is CognitoIdentityPoolConfig {
|
|
64
|
+
const validConfig = !!cognitoConfig?.identityPoolId;
|
|
55
65
|
return asserts(validConfig, {
|
|
56
66
|
name: 'AuthIdentityPoolIdException',
|
|
57
67
|
message: 'Auth IdentityPoolId not configured',
|
|
@@ -60,10 +70,11 @@ export function assertIdentityPooIdConfig(
|
|
|
60
70
|
});
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
function assertUserPoolAndIdentityPooConfig(
|
|
64
74
|
authConfig: AuthConfig
|
|
65
|
-
): asserts authConfig is
|
|
66
|
-
const validConfig =
|
|
75
|
+
): asserts authConfig is AuthUserPoolAndIdentityPoolConfig {
|
|
76
|
+
const validConfig =
|
|
77
|
+
!!authConfig?.Cognito.identityPoolId && !!authConfig?.Cognito.userPoolId;
|
|
67
78
|
return asserts(validConfig, {
|
|
68
79
|
name: 'AuthUserPoolAndIdentityPoolException',
|
|
69
80
|
message: 'Auth UserPool and IdentityPool not configured',
|
|
@@ -77,13 +88,12 @@ export function decodeJWT(token: string): JWT {
|
|
|
77
88
|
if (tokenSplitted.length !== 3) {
|
|
78
89
|
throw new Error('Invalid token');
|
|
79
90
|
}
|
|
80
|
-
|
|
81
|
-
const payloadString = tokenSplitted[1];
|
|
82
|
-
const payload = JSON.parse(
|
|
83
|
-
Buffer.from(payloadString, 'base64').toString('utf8')
|
|
84
|
-
);
|
|
85
|
-
|
|
86
91
|
try {
|
|
92
|
+
const payloadStringb64 = tokenSplitted[1];
|
|
93
|
+
const payloadArrayBuffer = base64ToBytes(payloadStringb64);
|
|
94
|
+
const decodeString = new TextDecoder().decode(payloadArrayBuffer);
|
|
95
|
+
const payload = JSON.parse(decodeString);
|
|
96
|
+
|
|
87
97
|
return {
|
|
88
98
|
toString: () => token,
|
|
89
99
|
payload,
|
|
@@ -92,3 +102,8 @@ export function decodeJWT(token: string): JWT {
|
|
|
92
102
|
throw new Error('Invalid token payload');
|
|
93
103
|
}
|
|
94
104
|
}
|
|
105
|
+
|
|
106
|
+
function base64ToBytes(base64: string): Uint8Array {
|
|
107
|
+
const binString = atob(base64);
|
|
108
|
+
return Uint8Array.from(binString, m => m.codePointAt(0) || 0);
|
|
109
|
+
}
|
|
@@ -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/index.ts
CHANGED
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
|
};
|
package/polyfills/URL/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e={128:e=>{"use strict";e.exports=require("react-native-url-polyfill/auto")}},r={};var o,t={};"test"!==(null===(o=null===process||void 0===process?void 0:process.env)||void 0===o?void 0:o.NODE_ENV)&&function o(t){var s=r[t];if(void 0!==s)return s.exports;var v=r[t]={exports:{}};return e[t](v,v.exports,o),v.exports}(128);var s=exports;for(var v in t)s[v]=t[v];t.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})();
|