Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@aws-amplify/ui-components
Advanced tools
Amplify UI Components is an open-source UI component library that encapsulates cloud-connected workflows inside of framework-agnostic UI components.
Framework | Package | Version | READMEs | Quick Start |
---|---|---|---|---|
React | @aws-amplify/ui-react | README.md | React | |
Angular | @aws-amplify/ui-angular | README.md | Angular | |
Vue | @aws-amplify/ui-vue | README.md | Vue | |
Web Components | @aws-amplify/ui-components | README.md | Web Components |
In this Quick Start guide you will set up an Authenticator component and the cloud resources required to use it inside of your app.
Prerequisites
Frameworks
yarn add aws-amplify @aws-amplify/ui-react
import React from 'react';
import Amplify from 'aws-amplify';
import { AmplifyAuthenticator, AmplifySignOut } from '@aws-amplify/ui-react';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
const App = () => {
<AmplifyAuthenticator>
<div>
My App
<AmplifySignOut />
</div>
</AmplifyAuthenticator>;
};
yarn add aws-amplify @aws-amplify/ui-angular
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AmplifyUIAngularModule } from '@aws-amplify/ui-angular';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
@NgModule({
declarations: [AppComponent],
imports: [AmplifyUIAngularModule, BrowserModule],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
app.component.html
<amplify-authenticator>
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
yarn add aws-amplify @aws-amplify/ui-vue
main.ts
import Vue from 'vue';
import App from './App.vue';
import '@aws-amplify/ui-vue';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
new Vue({
render: h => h(App),
}).$mount('#app');
App.vue
<template>
<amplify-authenticator>
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
</template>
yarn add aws-amplify @aws-amplify/ui-components
app.js
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
import {
applyPolyfills,
defineCustomElements,
} from '@aws-amplify/ui-components/loader';
applyPolyfills().then(() => {
defineCustomElements(window);
});
index.html
<!DOCTYPE html>
<html lang="en">
<body>
<amplify-authenticator>
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
<script src="app.js"></script>
</body>
</html>
Amplify UI Components use slots to allow for component customization. Component customization and slot usage is exemplified below.
Slots
You can override the components listed above and pass them into these slots to preserve the authenticator state flow.
Name | Description |
---|---|
"sign-in" | Content placed inside of the sign in workflow for when a user wants to sign into their account |
"confirm-sign-in" | Content placed inside of the confirm sign in workflow for when a user needs to confirm the account they signed in with |
"sign-up" | Content placed inside of the sign up workflow for when a user wants to register a new account |
"confirm-sign-up" | Content placed inside of the confirm sign up workflow for when a user needs to confirm the account they signed up with |
"forgot-password" | Content placed inside of the forgot password workflow for when a user wants to reset their password |
"require-new-password" | Content placed inside of the require new password workflow for when a user is required to update their password |
"verify-contact" | Content placed inside of the verify-contact workflow for when a user must verify their contact information |
"totp-setup" | Content placed inside of the totp-setup workflow for when a user opts to use TOTP MFA |
"greetings" | Content placed inside of the greetings navigation for when a user is signed in |
Frameworks
import {
AmplifyAuthenticator,
AmplifySignIn,
AmplifySignUp,
} from '@aws-amplify/ui-react';
const App = () => {
<AmplifyAuthenticator>
<AmplifySignIn headerText="My Custom Sign In Header" slot="sign-in" />
<AmplifySignUp headerText="My Custom Sign Up Header" slot="sign-up" />
<div>
My App
<AmplifySignOut />
</div>
</AmplifyAuthenticator>;
};
Alternatively, you can use the withAuthenticator
higher-order component (HoC):
import { withAuthenticator } from '@aws-amplify/ui-react';
...
export default withAuthenticator(App);
// or
export default withAuthenticator(App, { /* ...amplifyAuthenticatorSettings */ })
});
<amplify-authenticator>
<amplify-sign-in header-text="My Custom Sign In Header" slot="sign-in" />
<amplify-sign-up header-text="My Custom Sign In Header" slot="sign-up" />
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
<amplify-authenticator>
<amplify-sign-in header-text="My Custom Sign In Header" slot="sign-in" />
<amplify-sign-up header-text="My Custom Sign In Header" slot="sign-up" />
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
<amplify-authenticator>
<amplify-sign-in header-text="My Custom Sign In Header" slot="sign-in" />
<amplify-sign-up header-text="My Custom Sign In Header" slot="sign-up" />
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
Theming for the UI components can be achieved by using CSS Variables. You can enable theming in your app by overriding the below mentioned CSS variable values. To do that, add the following code in root css file.
:root{
--amplify-primary-color: #ff6347;
--amplify-primary-tint: #ff7359;
--amplify-primary-shade: #e0573e;
}
Custom Properties | Default Value |
---|---|
--amplify-font-family | 'Amazon Ember', 'Helvetica Neue Light', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif' |
--amplify-text-xxs | 0.75rem |
--amplify-text-xs | 0.81rem |
--amplify-text-sm | 0.875rem |
--amplify-text-md | 1rem |
--amplify-text-lg | 1.5rem |
--amplify-text-xl | 2rem |
--amplify-text-xxl | 2.5rem |
Custom Properties | Default Value |
---|---|
--amplify-primary-color | #ff9900 |
--amplify-primary-contrast | var(--amplify-white) |
--amplify-primary-tint | #ffac31 |
--amplify-primary-shade | #e88b01 |
--amplify-secondary-color | #152939 |
--amplify-secondary-contrast | var(--amplify-white) |
--amplify-secondary-tint | #31465f |
--amplify-secondary-shade | #1F2A37 |
--amplify-tertiary-color | #5d8aff |
--amplify-tertiary-contrast | var(--amplify-white) |
--amplify-tertiary-tint | #7da1ff |
--amplify-tertiary-shade | #537BE5 |
--amplify-grey | #828282 |
--amplify-light-grey | #c4c4c4 |
--amplify-white | #ffffff |
--amplify-red | #dd3f5b |
--amplify-blue | #099ac8 |
usernameAlias
The amplify-authenticator
component has the ability to sign in or sign up with email
or phone_number
instead of default username
. To achieve this, you first need to setup the userpool to allow email or phone number as the username using the cli workflow or through the Cognito Console. To reflect this in the amplify-authenticator
component, you can use the usernameAlias
property. It can take one of the three values - email
, phone_number
or username
. Default is set to username
.
Usage:
// react
<AmplifyAuthenticator usernameAlias="email" />
// angular, vue or web components
<amplify-authenticator username-alias="phone_number" />
federated
The amplify-authenticator
component supports Federated Sign In through Cognito Identity Pools (IDP) with external providers like Amazon, Auth0, Facebook, & Google.
The federated
prop implements the FederatedConfig
:
export interface FederatedConfig {
auth0Config?: {
audience?: string;
clientID: string;
domain: string;
responseType: string;
redirectUri: string;
returnTo?: string;
scope?: string;
};
amazonClientId?: string;
facebookAppId?: string;
googleClientId?: string;
oauthConfig?: {
[key: string]: any;
};
}
Usage:
const federated = {
amazonClientId: "your_amazon_client_id",
facebookAppId: "your_facebook_app_id",
googleClientId: "your_google_client_id",
oauthConfig: {
redirectSignIn: "http://localhost:1234/",
redirectSignOut: "http://localhost:1234/",
}
}
// react
<AmplifyAuthenticator federated={federated} />
// angular, vue, or web components
<amplify-authenticator federated={federated} />
- yarn add aws-amplify-react
+ yarn add @aws-amplify/ui-react
- import { Authenticator } from 'aws-amplify-react';
+ import { AmplifyAuthenticator } from '@aws-amplify/ui-react';
const App = () => (
+ <AmplifyAuthenticator>
- <Authenticator>
<div>
My App
+ <AmplifySignOut />
</div>
+ </AmplifyAuthenticator>;
- </Authenticator>
);
If you're using the withAuthenticator
higher-order component (HoC):
- import { withAuthenticator } from 'aws-amplify-react';
+ import { withAuthenticator } from '@aws-amplify/ui-react';
...
export default withAuthenticator(App);
Note: If you were providing additional options to withAuthenticator
(e.g. includeGreetings
, authenticatorComponents
, federated
, theme
), these have changed:
- yarn add aws-amplify-angular
+ yarn add @aws-amplify/ui-angular
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
- import { AmplifyAngularModule, AmplifyService } from 'aws-amplify-angular';
+ import { AmplifyUIAngularModule } from '@aws-amplify/ui-angular';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
@NgModule({
declarations: [AppComponent],
- imports: [AmplifyAngularModule, BrowserModule],
+ imports: [AmplifyUIAngularModule, BrowserModule],
- providers: [AmplifyService],
+ providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
- yarn add aws-amplify-vue
+ yarn add @aws-amplify/ui-vue
main.ts
import Vue from 'vue';
import App from "./App.vue";
- import Amplify, * as AmplifyModules from 'aws-amplify'
- import { AmplifyPlugin } from 'aws-amplify-vue'
+ import '@aws-amplify/ui-vue';
+ import Amplify from 'aws-amplify';
+ import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
new Vue({
render: h => h(App),
}).$mount('#app');
FAQs
Core Amplify UI Component Library
We found that @aws-amplify/ui-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.