npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@airwallex/login-widget

v1.2.1

Published

airwallex login widget

Readme

Airwallex Login Widget

Installation

npm install @airwallex/login-widget

Get Started

Initialize the widget:

import { LoginWidget } from '@airwallex/login-widget';

// Must initialize before creating any login widgets.
// These options will apply to all the login widgets.
LoginWidget.init({
  // The URL of the logo to display in the login widget.
  // The recommended size of the image is 72x72 px.
  logoUrl: 'https://your_website_logo_url',
  // The environment of the widget.
  env: 'production',
  // 'en' or 'zh', these are the supported languages right now
  locale: 'en',
});

Create a widget instance:

import { LoginWidget } from '@airwallex/login-widget';

const loginWidget = new LoginWidget({
  // These are optional when instantiating the widget,
  // but are required before authenticating.
  // You could set them later using the widget's `update` method
  authSummaryText: 'your_auth_summary_justification_text',
  resourceId: 'the_unique_resource_id_to_be_authenticated',
  // You could also customize the labels
  labels: { emailLabel: 'User name' },
  enableDisclaimer: true,
});

Listen to the cancel event, so that when the user clicks the exit button, you could unmount the widget

loginWidget.on('cancel', () => {
  loginWidget.unmount();
});

Also remember to listen to the auth success event

loginWidget.on('auth_success', ({ signedToken }) => {
  // Do something with the token
});

You will have to create a mask yourself, and mount the widget on top of it:

<div class="mask">
  <div id="widget-container"></div>
</div>
loginWidget.mount('#widget-container');

Tips

For better experience mobile responsive friendly, recommend set <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> in html head.

LoginWidget

LoginWidget.init

type: (initOptions?: WidgetInitOptions) => void;

interface WidgetInitOptions {
  /**
   * The URL of the logo to display in the login widget.
   * The recommended size of the image is 72x72 px.
   */
  logoUrl?: string | undefined;
  /**
   * The environment of the login widget
   * @default 'production'
   */
  env?: Environment;
  /**
   * The language of the login widget.
   * @default 'en'
   */
  locale?: Language | undefined;
}

type Language = 'en' | 'zh';

type Environment = 'staging' | 'demo' | 'production';

LoginWidget.constructor

type: constructor(options?: LoginWidgetOptions);

interface LoginWidgetOptions {
  authSummaryText: string;
  resourceId: string;
  labels?: LoginWidgetOptionsLabels | undefined;
}

interface LoginWidgetOptionsLabels {
  authButton?: string;
  authCode?: string;
  emailLabel?: string;
  forgotPassword?: string;
  loginButton?: string;
  loginSubTitle?: string;
  loginTitle?: string;
  mfaTitle?: string;
  passwordLabel?: string;
  supportLink?: string;
}

LoginWidget.prototype.on

LoginWidget.prototype.on('ready', () => void)

Emitted when widget is ready to use.

LoginWidget.prototype.on('cancel', () => void)

Emitted when the user clicks the exit button.

LoginWidget.prototype.on('blur', (ev: LoginWidgetFieldEvent) => void)

Emitted when the user blurs the field.

LoginWidget.prototype.on('change', (ev: LoginWidgetFieldEvent) => void)

Emitted when the user changes the value of a field.

LoginWidget.prototype.on('focus', (ev: LoginWidgetFieldEvent) => void)

Emitted when the user focuses the field.

interface LoginWidgetFiledEvent {
  /**
   * Whether the input of the field is valid.
   */
  complete: boolean;
  /**
   * The name of the field.
   */
  field: FieldName;
}

type FieldName = 'username' | 'password' | 'authcode';

LoginWidget.prototype.on('login_success', () => void)

Emitted when the user login successfully.

LoginWidget.prototype.on('auth_success', (ev: LoginWidgetAuthSuccessEvent) => void)

Emitted when authentication is successful.

interface LoginWidgetAuthSuccessEvent {
  signedToken: string;
}

LoginWidget.prototype.on('error', (ev: LoginWidgetErrorEvent) => void)

Emitted when error occurs.

interface LoginWidgetErrorEvent {
  errorCode: string;
  message: string;
}

const ERROR_CODE_MAP = {
  BAD_CREDENTIAL: 'User name or password is incorrect',
  INVALID_AUTH_CODE: 'Invalid authorization code',
  INVALID_RESOURCE_ID: 'Invalid resource ID',
  TWO_FACTOR_AUTHENTICATION_NOT_ENABLED: 'Two-factor authentication is not enabled',
  UNKNOWN_ERROR: 'Unknown error',
  USER_AUTH_LOCKED: 'User has been locked due to multiple failed authentication attempts',
  USER_LOGIN_LOCKED: 'User has been locked due to multiple failed login attempts',
};

LoginWidget.prototype.removeEventListener

Unsubscribe the event.

type: (eventType, listenerToBeRemoved) => void;

LoginWidget.prototype.mount

Append the widget to the given DOM element.

If the DOM element could not be found, will throw an error.

type: (domElement: string | HTMLElement) => void;

domElement is either a CSS Selector or a DOM element.

LoginWidget.prototype.update

You could also update the widget on the fly.

Every option used to initialize the widget could also be used to update the widget.

type: (options: LoginWidgetUpdateOptions) => void;

interface LoginWidgetUpdateOptions {
  authSummaryText?: string | undefined;
  resourceId?: string | undefined;
  labels?: LoginWidgetOptionsLabels | undefined;
  enableDisclaimer?: boolean | undefined;
}

LoginWidget.prototype.unmount

Remove the widget from the DOM.

All event listeners will NOT be removed, they must be removed manually.

type: () => void;

The Customizable Parts

Customizable Parts in Login Page

Customizable Parts in Auth Page