-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: relax config for AmplifyOutputs #13234
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"$schema": "adipisicing cillum", | ||
"version": "1", | ||
"auth": { | ||
"aws_region": "non proident exercitation anim fugiat", | ||
"user_pool_id": "sit velit dolor magna est", | ||
"user_pool_client_id": "voluptate", | ||
"identity_pool_id": "Lorem", | ||
"oauth": { | ||
"identity_providers": ["FACEBOOK", "SIGN_IN_WITH_APPLE", "GOOGLE"], | ||
"domain": "proident dolore do mollit ad", | ||
"scopes": ["incididunt proident"], | ||
"redirect_sign_in_uri": ["Duis", "ipsum velit in dolore"], | ||
"redirect_sign_out_uri": [ | ||
"Excepteur pariatur cillum officia", | ||
"incididunt in Ut Excepteur commodo" | ||
], | ||
"response_type": "token" | ||
}, | ||
"standard_required_attributes": [ | ||
"address", | ||
"locale", | ||
"family_name", | ||
"sub", | ||
"email" | ||
], | ||
"username_attributes": ["phone_number", "email"], | ||
"user_verification_types": ["email", "email"], | ||
"unauthenticated_identities_enabled": true, | ||
"mfa_configuration": "OPTIONAL", | ||
"mfa_methods": ["TOTP", "TOTP", "SMS", "TOTP", "TOTP"] | ||
}, | ||
"data": { | ||
"aws_region": "regasd", | ||
"url": "dolore dolor do cillum nulla", | ||
"api_key": "non", | ||
"default_authorization_type": "API_KEY", | ||
"authorization_types": [] | ||
}, | ||
"geo": { | ||
"aws_region": "tempor", | ||
"search_indices": { | ||
"items": [ | ||
"commodo Lorem", | ||
"reprehenderit consequat", | ||
"amet", | ||
"aliquip deserunt", | ||
"ea dolor in proident" | ||
], | ||
"default": "exercitation fugiat ut dolor sed" | ||
}, | ||
"geofence_collections": { | ||
"items": [ | ||
"fugiat ea irure dolor", | ||
"Ut", | ||
"culpa ut enim exercitation", | ||
"labore", | ||
"ex pariatur est ullamco" | ||
], | ||
"default": "ullamco incididunt aliquip" | ||
} | ||
}, | ||
"custom": { | ||
"occaecat_4_": -51806024, | ||
"dolorc": 87599986 | ||
}, | ||
"notifications": { | ||
"aws_region": "labore nisi ad", | ||
"amazon_pinpoint_app_id": "in dolor veniam reprehenderit", | ||
"channels": ["EMAIL"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,11 @@ import { NotificationsConfig } from './singleton/Notifications/types'; | |
import { | ||
AmplifyOutputs, | ||
AmplifyOutputsAnalyticsProperties, | ||
AmplifyOutputsAuthMFAConfiguration, | ||
AmplifyOutputsAuthProperties, | ||
AmplifyOutputsDataProperties, | ||
AmplifyOutputsGeoProperties, | ||
AmplifyOutputsNotificationsProperties, | ||
AmplifyOutputsOAuthIdentityProvider, | ||
AmplifyOutputsStorageProperties, | ||
AuthType, | ||
} from './singleton/AmplifyOutputs/types'; | ||
import { | ||
AnalyticsConfig, | ||
|
@@ -130,34 +127,27 @@ function parseAuth( | |
domain: oauth.domain, | ||
redirectSignIn: oauth.redirect_sign_in_uri, | ||
redirectSignOut: oauth.redirect_sign_out_uri, | ||
responseType: oauth.response_type, | ||
responseType: oauth.response_type === 'token' ? 'token' : 'code', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: What might this be other than responseType: oauth.response_type ?? 'code', There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to show both options to make it more readable |
||
scopes: oauth.scopes, | ||
providers: getOAuthProviders(oauth.identity_providers), | ||
}, | ||
}; | ||
} | ||
|
||
if (username_attributes?.includes('EMAIL')) { | ||
if (username_attributes?.includes('email')) { | ||
authConfig.Cognito.loginWith = { | ||
...authConfig.Cognito.loginWith, | ||
email: true, | ||
}; | ||
} | ||
|
||
if (username_attributes?.includes('PHONE_NUMBER')) { | ||
if (username_attributes?.includes('phone_number')) { | ||
authConfig.Cognito.loginWith = { | ||
...authConfig.Cognito.loginWith, | ||
phone: true, | ||
}; | ||
} | ||
|
||
if (username_attributes?.includes('USERNAME')) { | ||
authConfig.Cognito.loginWith = { | ||
...authConfig.Cognito.loginWith, | ||
username: true, | ||
}; | ||
} | ||
|
||
if (standard_required_attributes) { | ||
authConfig.Cognito.userAttributes = standard_required_attributes.reduce( | ||
(acc, curr) => ({ ...acc, [curr]: { required: true } }), | ||
|
@@ -240,7 +230,7 @@ function parseNotifications( | |
return undefined; | ||
} | ||
|
||
const { aws_region, channels, pinpoint_app_id } = | ||
const { aws_region, channels, amazon_pinpoint_app_id } = | ||
amplifyOutputsNotificationsProperties; | ||
|
||
const hasInAppMessaging = channels.includes('IN_APP_MESSAGING'); | ||
|
@@ -257,7 +247,7 @@ function parseNotifications( | |
if (hasInAppMessaging) { | ||
notificationsConfig.InAppMessaging = { | ||
Pinpoint: { | ||
appId: pinpoint_app_id, | ||
appId: amazon_pinpoint_app_id, | ||
region: aws_region, | ||
}, | ||
}; | ||
|
@@ -266,7 +256,7 @@ function parseNotifications( | |
if (hasPushNotification) { | ||
notificationsConfig.PushNotification = { | ||
Pinpoint: { | ||
appId: pinpoint_app_id, | ||
appId: amazon_pinpoint_app_id, | ||
region: aws_region, | ||
}, | ||
}; | ||
|
@@ -309,36 +299,31 @@ export function parseAmplifyOutputs( | |
return resourcesConfig; | ||
} | ||
|
||
const authModeNames: Record<AuthType, GraphQLAuthMode> = { | ||
const authModeNames: Record<string, GraphQLAuthMode> = { | ||
AMAZON_COGNITO_USER_POOLS: 'userPool', | ||
API_KEY: 'apiKey', | ||
AWS_IAM: 'iam', | ||
AWS_LAMBDA: 'lambda', | ||
OPENID_CONNECT: 'oidc', | ||
}; | ||
|
||
function getGraphQLAuthMode(authType: AuthType): GraphQLAuthMode { | ||
function getGraphQLAuthMode(authType: string): GraphQLAuthMode { | ||
return authModeNames[authType]; | ||
} | ||
|
||
const providerNames: Record< | ||
AmplifyOutputsOAuthIdentityProvider, | ||
OAuthProvider | ||
> = { | ||
const providerNames: Record<string, OAuthProvider> = { | ||
GOOGLE: 'Google', | ||
LOGIN_WITH_AMAZON: 'Amazon', | ||
FACEBOOK: 'Facebook', | ||
SIGN_IN_WITH_APPLE: 'Apple', | ||
}; | ||
|
||
function getOAuthProviders( | ||
providers: AmplifyOutputsOAuthIdentityProvider[] = [], | ||
): OAuthProvider[] { | ||
function getOAuthProviders(providers: string[] = []): OAuthProvider[] { | ||
return providers.map(provider => providerNames[provider]); | ||
} | ||
|
||
function getMfaStatus( | ||
mfaConfiguration: AmplifyOutputsAuthMFAConfiguration, | ||
mfaConfiguration: string, | ||
): CognitoUserPoolConfigMfaStatus { | ||
if (mfaConfiguration === 'OPTIONAL') return 'optional'; | ||
if (mfaConfiguration === 'REQUIRED') return 'on'; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for this <3