Skip to content

Commit

Permalink
release(required): Parsing custom oAuth in amplify_outputs (#13474)
Browse files Browse the repository at this point in the history
* update parseAmplify logic

* revert custom oAuth from gen1 config

* update bundle size
  • Loading branch information
ashika112 authored Jun 6, 2024
1 parent 9a365bc commit 7c6d55b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
8 changes: 4 additions & 4 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"name": "[Analytics] record (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ record }",
"limit": "17.08 kB"
"limit": "17.09 kB"
},
{
"name": "[Analytics] record (Kinesis)",
Expand All @@ -317,7 +317,7 @@
"name": "[Analytics] identifyUser (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ identifyUser }",
"limit": "15.57 kB"
"limit": "15.59 kB"
},
{
"name": "[Analytics] enable",
Expand Down Expand Up @@ -383,7 +383,7 @@
"name": "[Auth] confirmSignIn (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ confirmSignIn }",
"limit": "28.26 kB"
"limit": "28.27 kB"
},
{
"name": "[Auth] updateMFAPreference (Cognito)",
Expand All @@ -401,7 +401,7 @@
"name": "[Auth] verifyTOTPSetup (Cognito)",
"path": "./dist/esm/auth/index.mjs",
"import": "{ verifyTOTPSetup }",
"limit": "12.59 kB"
"limit": "12.6 kB"
},
{
"name": "[Auth] updatePassword (Cognito)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/__mocks__/configMocks/amplify_outputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"user_pool_client_id": "mock-cup-client-id",
"identity_pool_id": "mock-idp-id",
"oauth": {
"identity_providers": ["FACEBOOK", "SIGN_IN_WITH_APPLE", "GOOGLE"],
"identity_providers": ["FACEBOOK", "SIGN_IN_WITH_APPLE", "GOOGLE", "Auth0"],
"domain": "mock-oauth-domain",
"scopes": ["phone"],
"redirect_sign_in_uri": ["mock-sign-in-uri"],
Expand Down
18 changes: 6 additions & 12 deletions packages/core/__mocks__/configMocks/amplifyconfiguration.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,25 @@
"aws_user_files_s3_bucket_region": "us-west-2",
"aws_user_pools_id": "mock-cup-id",
"aws_user_pools_web_client_id": "mock-cup-client-id",
"geo": {
"geo": {
"amazon_location_service": {
"search_indices": {
"items": [
"mock-geo-search-item",
"mock-geo-search-item-alt"
],
"items": ["mock-geo-search-item", "mock-geo-search-item-alt"],
"default": "mock-geo-search-item"
},
"geofenceCollections": {
"items": [
"mock-geo-fence-item",
"mock-geo-fence-item-alt"
],
"items": ["mock-geo-fence-item", "mock-geo-fence-item-alt"],
"default": "mock-geo-fence-item"
},
"region": "us-west-2"
}
}
},
"aws_appsync_graphqlEndpoint": "mock-data-url",
"aws_appsync_apiKey": "mock-data-api-key",
"aws_appsync_region": "us-west-2",
"aws_appsync_authenticationType": "API_KEY",
"Notifications": {
"InAppMessaging": {
"InAppMessaging": {
"AWSPinpoint": {
"appId": "mock-pinpoint-app-id",
"region": "us-west-2"
Expand All @@ -66,4 +60,4 @@
}
}
}
}
}
18 changes: 15 additions & 3 deletions packages/core/__tests__/parseAWSExports.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseAWSExports } from '../src/parseAWSExports';
import { OAuthScope } from '../src/singleton/Auth/types';
import { OAuthProvider, OAuthScope } from '../src/singleton/Auth/types';
import { ResourcesConfig } from '../src/singleton/types';

// TODO: Add API category tests
Expand Down Expand Up @@ -91,7 +91,13 @@ describe('parseAWSExports', () => {
email: false,
oauth: {
domain: oAuthDomain,
providers: ['Google', 'Apple', 'Facebook', 'Amazon'],
providers: [
'Google',
'Apple',
'Facebook',
'Amazon',
'Auth0',
] as OAuthProvider[],
redirectSignIn: [oAuthSigninUrl],
redirectSignOut: [oAuthSignoutUrl],
responseType: oAuthResponseType,
Expand Down Expand Up @@ -172,7 +178,13 @@ describe('parseAWSExports', () => {
responseType: oAuthResponseType,
},
aws_cognito_verification_mechanisms: ['EMAIL'],
aws_cognito_social_providers: ['GOOGLE', 'APPLE', 'FACEBOOK', 'AMAZON'],
aws_cognito_social_providers: [
'GOOGLE',
'APPLE',
'FACEBOOK',
'AMAZON',
'Auth0',
],
aws_mandatory_sign_in: 'enable',
aws_mobile_analytics_app_id: appId,
aws_mobile_analytics_app_region: region,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/parseAmplifyOutputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ const providerNames: Record<string, OAuthProvider> = {
};

function getOAuthProviders(providers: string[] = []): OAuthProvider[] {
return providers.map(provider => providerNames[provider]);
return providers.reduce<OAuthProvider[]>((oAuthProviders, provider) => {
if (providerNames[provider] !== undefined) {
oAuthProviders.push(providerNames[provider]);
}

return oAuthProviders;
}, []);
}

function getMfaStatus(
Expand Down

0 comments on commit 7c6d55b

Please sign in to comment.