How to use the @aws-amplify/core.Logger function in @aws-amplify/core

To help you get started, we’ve selected a few @aws-amplify/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / aws-amplify-angular / src / providers / auth.decorator.ts View on Github external
import { Subject } from 'rxjs/Subject';
import Amplify, { Logger, Hub } from '@aws-amplify/core';
import { AuthState } from './auth.state';
import * as _ from 'lodash';

const logger = new Logger('AuthDecorator');

function check(authState: Subject, Auth) {
	// check for current authenticated user to init authState
	Auth.currentAuthenticatedUser()
		.then(user => {
			logger.debug('has authenticated user', user);
			authState.next({ state: 'signedIn', user });
		})
		.catch(err => {
			logger.debug('no authenticated user', err);
			authState.next({ state: 'signedOut', user: null });
		});
}

function listen(authState: Subject) {
	const config = Amplify.configure(null);
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-sign-in / amplify-sign-in.tsx View on Github external
import { FormFieldTypes } from '../../components/amplify-auth-fields/amplify-auth-fields-interface';
import { AuthState, ChallengeName } from '../../common/types/auth-types';

import {
  HEADER_TEXT,
  SUBMIT_BUTTON_TEXT,
  CREATE_ACCOUNT_TEXT,
  NO_ACCOUNT_TEXT,
  FORGOT_PASSWORD_TEXT,
  RESET_PASSWORD_TEXT,
} from '../../common/constants';

import { Logger, isEmpty } from '@aws-amplify/core';
import { Auth } from '@aws-amplify/auth';

const logger = new Logger('SignIn');

@Component({
  tag: 'amplify-sign-in',
  shadow: false,
})
export class AmplifySignIn {
  /** Fires when sign in form is submitted */
  @Prop() handleSubmit: (Event) => void = event => this.signIn(event);
  /** Engages when invalid actions occur, such as missing field, etc. */
  @Prop() validationErrors: string;
  /** Used for header text in sign in component */
  @Prop() headerText: string = HEADER_TEXT;
  /** Used for the submit button text in sign in component */
  @Prop() submitButtonText: string = SUBMIT_BUTTON_TEXT;
  /** (Optional) Overrides default styling */
  @Prop() overrideStyle: boolean = false;
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-authenticator / amplify-authenticator.tsx View on Github external
import { Component, State, Prop, h } from '@stencil/core';
import { AuthState, CognitoUserInterface } from '../../common/types/auth-types';
import { AuthStateTunnel } from '../../data/auth-state';

import { Logger } from '@aws-amplify/core';

const logger = new Logger('Authenticator');

@Component({
  tag: 'amplify-authenticator',
  shadow: false,
})
export class AmplifyAuthenticator {
  /** Initial starting state of the Authenticator component. E.g. If `signup` is passed the default component is set to AmplifySignUp */
  @Prop() initialAuthState: AuthState = AuthState.SignIn;
  /** Used as a flag in order to trigger the content displayed */
  @State() authState: AuthState = AuthState.Loading;

  @State() authData: CognitoUserInterface;

  componentWillLoad() {
    this.authState = this.initialAuthState;
  }
github aws-amplify / amplify-js / packages / predictions / src / types / Providers / AbstractIdentifyPredictionsProvider.ts View on Github external
import { AbstractPredictionsProvider } from '.';
import {
    IdentifyEntityInput, IdentifyFacesInput, isIdentifyEntityInput,
    isIdentifyFacesInput, IdentifyTextInput, isIdentifyTextInput
} from '../Predictions';
import { Logger } from '@aws-amplify/core';
const logger = new Logger('AbstractIdentifyPredictionsProvider');

export abstract class AbstractIdentifyPredictionsProvider extends AbstractPredictionsProvider {

    getCategory(): string {
        return 'Identify';
    }

    identify(input: IdentifyTextInput | IdentifyEntityInput | IdentifyFacesInput): Promise {
        if (isIdentifyTextInput(input)) {
            logger.debug('identifyText');
            return this.identifyText(input);
        } else if (isIdentifyEntityInput(input)) {
            logger.debug('identifyEntity');
            return this.identifyEntity(input);
        } else if (isIdentifyFacesInput(input)) {
            logger.debug('identifyFaces');
github aws-amplify / amplify-js / packages / aws-amplify / src / index.ts View on Github external
ClientDevice,
	Signer,
	I18n,
	ServiceWorker,
} from '@aws-amplify/core';

export default Amplify;

Amplify.Auth = Auth;
Amplify.Analytics = Analytics;
Amplify.API = API;
Amplify.Storage = Storage;
Amplify.I18n = I18n;
Amplify.Cache = Cache;
Amplify.PubSub = PubSub;
Amplify.Logger = Logger;
Amplify.ServiceWorker = ServiceWorker;
Amplify.Interactions = Interactions;
Amplify.UI = UI;
Amplify.XR = XR;
Amplify.Predictions = Predictions;

export {
	Auth,
	Analytics,
	Storage,
	API,
	PubSub,
	I18n,
	Logger,
	Hub,
	Cache,
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-forgot-password / amplify-forgot-password.tsx View on Github external
import { Component, Prop, State, h } from '@stencil/core';
import { FormFieldTypes } from '../amplify-auth-fields/amplify-auth-fields-interface';
import { AuthState } from '../../common/types/auth-types';
import { RESET_YOUR_PASSWORD, SEND_CODE, BACK_TO_SIGN_IN, NO_AUTH_MODULE_FOUND } from '../../common/constants';
import { CodeDeliveryType } from './amplify-forgot-password-interface';

import { Auth } from '@aws-amplify/auth';
import { Logger } from '@aws-amplify/core';

const logger = new Logger('ForgotPassword');

@Component({
  tag: 'amplify-forgot-password',
  shadow: false,
})
export class AmplifyForgotPassword {
  /** The header text of the forgot password section */
  @Prop() headerText: string = RESET_YOUR_PASSWORD;
  /** The text displayed inside of the submit button for the form */
  @Prop() submitButtonText: string = SEND_CODE;
  /** The form fields displayed inside of the forgot password form */
  @Prop() formFields: FormFieldTypes;
  /** (Optional) Overrides default styling */
  @Prop() overrideStyle: boolean = false;
  /** The function called when making a request to reset password */
  @Prop() handleSend: (event: Event) => void = event => this.send(event);
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-confirm-sign-in / amplify-confirm-sign-in.tsx View on Github external
import { Component, Prop, State, h } from '@stencil/core';
import { FormFieldTypes } from '../../components/amplify-auth-fields/amplify-auth-fields-interface';
import { AuthState, MfaOption, CognitoUserInterface, ChallengeName } from '../../common/types/auth-types';
import { BACK_TO_SIGN_IN, CONFIRM, CONFIRM_SMS_CODE, CONFIRM_TOTP_CODE } from '../../common/constants';
import { Logger, isEmpty } from '@aws-amplify/core';
import { Auth } from '@aws-amplify/auth';

const logger = new Logger('ConfirmSignIn');

@Component({
  tag: 'amplify-confirm-sign-in',
  shadow: false,
})
export class AmplifyConfirmSignIn {
  /** Fires when confirm sign in form is submitted */
  @Prop() handleSubmit: (Event) => void = event => this.confirm(event);
  /** Engages when invalid actions occur, such as missing field, etc. */
  @Prop() validationErrors: string;
  /** Used for header text in confirm sign in component */
  @Prop() headerText: string = CONFIRM_SMS_CODE;
  /** Used for the submit button text in confirm sign in component */
  @Prop() submitButtonText: string = CONFIRM;
  /** (Optional) Overrides default styling */
  @Prop() overrideStyle: boolean = false;
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-sign-out / amplify-sign-out.tsx View on Github external
import { Component, Prop, h } from '@stencil/core';
import { SIGN_OUT, NO_AUTH_MODULE_FOUND } from '../../common/constants';
import { AuthState } from '../../common/types/auth-types';
import { Logger } from '@aws-amplify/core';
import { Auth } from '@aws-amplify/auth';

const logger = new Logger('SignOut');

@Component({
  tag: 'amplify-sign-out',
  shadow: false,
})
export class AmplifySignOut {
  /** Passed from the Authenticator component in order to change Authentication state */
  @Prop() handleAuthStateChange: (nextAuthState: AuthState, data?: object) => void;
  /** (Optional) Overrides default styling */
  @Prop() overrideStyle: boolean = false;
  /** Text inside of the Sign Out button */
  @Prop() buttonText: string = SIGN_OUT;

  async signOut(event) {
    if (event) event.preventDefault();
github aws-amplify / amplify-js / packages / aws-amplify-react-native / src / Auth / withOAuth.js View on Github external
*     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */
import * as React from 'react';
import { Linking } from 'react-native';

import { Logger, Hub } from '@aws-amplify/core';
import {
	default as Auth,
	CognitoHostedUIIdentityProvider,
} from '@aws-amplify/auth';

const logger = new Logger('withOAuth');

export default Comp => {
	let listeners = [];

	return class WithOAuth extends React.Component {
		constructor(props) {
			super(props);
			this._isMounted = false;
			const config = this._getOAuthConfig();

			const { urlOpener = defaultUrlOpener } = config;

			this.urlOpener = urlOpener;

			this.hostedUISignIn = this.hostedUISignIn.bind(this);
			this.signOut = this.signOut.bind(this);