Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@airwallex/components-sdk
Advanced tools
- [Airwallex.js](https://www.airwallex.com/docs/js) - [Installation](#installation) - [Initialization](#initialization) - [Create an Element](#create-an-element) - [Method parameters](#method-parameters) - [`options` object properties:](#options-object-pr
Use @airwallex/components-sdk
Install with Yarn
yarn add @airwallex/components-sdk
Or, with NPM
npm install @airwallex/components-sdk
import { init } from '@airwallex/components-sdk';
const options = {
locale: 'en',
env: 'prod',
authCode: 'x4D7A7wOSQvoygpwqweZpG0GFHTcQfVPBTZoKV7EibgH',
clientId: 'BIjjMYsYTPuRqnkEloSvvf',
codeVerifier:
'~wh344Lea1FsCMVH39Fn9R2~nqq2uyD4wbvG9XCzWRxd0sZh9MFiF9gSVkM0C-ZvrdtjBFA6Cw1EvCpJcIjaeXg1-BXCfZd25ZmvuYZAqZtjJQA3NAa~7X1sgEfbMZJwQ',
};
await init(options);
Option | Type | Required? | Default value | Description |
---|---|---|---|---|
env | string | NO | prod | The Airwallex environment. Options include: staging , demo and prod . |
locale | string | NO | en | Language. Options include: de , en , es , fr , it , ja , ko and zh . |
clientId | string | YES | - | Unique Client ID issued by Airwallex. More on Airwallex WebApp - Developer - API Keys . |
authCode | string | YES | - | Auth code to authenticate the connected account retrieved from /api/v1/accounts/{id}/authorize Embedded Component Authorization API. |
codeVerifier | string | YES | - | Serves as proof key for code exchange (see RFC 7636 Section 4). A random string used for generating a codeChallenge. |
Call createElement(elementName, options)
to create an element object.
Parameter | Type | Required? | Description |
---|---|---|---|
type | string | YES | The elements name of element. Supported values are kyc , paymentsKyb , kycRfi , paymentEnablementRfi , transactionRfi , scaManagement , scaVerify , scaSetup . |
options | Record<string, unknown> | NO | Options for creating an Element, which differ for each element type. |
options
object properties:Element type | Property | Required? | Default value | Type | Description |
---|---|---|---|---|---|
kyc , paymentsKyb , kycRfi , paymentEnablementRfi , transactionRfi | hideHeader | NO | false | boolean | Used to hide the page's header. |
hideNav | NO | false | boolean | Used to hide the page's navigation, which is heavily tied to the progression of the onboarding exercise. It is important to note that the user can review completed items, and edit if they need to adjust content. In addition, the user has another option to edit the form on the final review page. | |
theme | NO | - | Theme Object | Contact your Account Manager for details. | |
scaSetup ,scaVerify | userEmail | Yes | - | string | Used to recovery 2fa method |
scaSessionCode | No | - | string | It must be provided when initialising the embedded scaVerify component for a one-time SCA token | |
contactEmail | No | - | string | Platfrom customer service email address | |
theme | No | - | Theme Object | Contact your Account Manager for details. | |
############################## |
import { createElement } from '@airwallex/components-sdk';
const options = {
hideHeader: true,
hideNav: true,
};
const element = await createElement('kyc', options);
element
objectexport type EVENT_TYPE = 'ready' | 'success' | 'error' | 'cancel'
interface Element {
/**
* Mount element to your HTML DOM element
*/
mount(domElement: string | HTMLElement): void;
/**
* Using this function to unmount the element, opposite to mount function
* The element instance is still kept
*/
unmount(): void;
/**
* Using this function to destroy the element instance
*/
destroy(): void;
/**
* Listen to event
*/
on(eventCode: EVENT_TYPE, handler: (eventData: Record<string, unknown>) => void): void;
}
Mount the element to your page.
// type
element.mount: (domElement: string | HTMLElement) => void
// There are two ways to mount element:
// 1. call with container dom id
element.mount('container-dom-id');
// 2.find the created DOM in existing HTML and call with container DOM element
const containerElement = document.getElementById("container-dom-id");
element.mount(containerElement);
Using this function to unmount the element, opposite to mount function. The element instance is still kept.
element.unmount();
Using this function to destroy the element instance.
element.destroy();
Using this function to listen to element events.
element.on('success', () => {
// Handle success event
});
The Onboarding component
might emit the following events during its lifecycle.
ready
This event will be fired when:
{ type: 'consent'}
. Use this event to decide when to remove loading status from your page.{type: 'kyc', kycStatus: 'INIT'}
, which represents the account's onboarding status. Use kycStatus
to render your own status pages and handle re-entry scenarios.Type
type kycEventData = {
type: 'kyc',
kycStatus: 'INIT' | 'SUBMITTED' | 'SUCCESS' | 'FAILURE'
};
type consentEventData = {
type: 'consent'
};
element.on('ready', (data: kycEventData | consentEventData) => void);
Example
element.on('ready', (data: kycEventData | consentEventData) => {
// Handle ready event
});
success
This event fires when the onboarding flow is completed successfully.
Type
element.on('success', () => void);
Example
element.on('success', () => {
// Handle success event
});
cancel
This event fires when the element is exited by cancellation.
Type
element.on('cancel', () => void);
Example
element.on('cancel', () => {
// Handle cancel event
});
error
This event fires when an error occurs within the element.
Type
type errorCode = 'API_ERROR' | 'SUBMIT_FAILED' | 'UNKNOWN';
type ErrorData = { code: errorCode, message?: string }
element.on('error', (data: ErrorData) => void);
Example
element.on('error', (data: ErrorData) => {
// Handle error event
});
ready
This event will be fired when the Payments Kyb element is ready for starting the Kyb application. If PERMISSION_DENIED error takes place, this event will not be triggered.
data
Type
{
kybStatus: 'PENDING_REVIEW' | 'IN_REVIEW' | 'REJECTED' | 'ACCEPTED' | 'APPROVED',
kycStatus: 'INIT' | 'SUBMITTED' | 'SUCCESS' | 'FAILED'
}
success
This event fires when the initial KYB case is submitted successfully.
data
Type
{
storeList: Array<StoreObject>
}
reserveOptionsOffered
This is only for when the reserve selection is available for the accounts. Contact Account Manager for more detail.
data
Type
{
reserveOptions: UserReserveSelection
}
selectReserve
This is what the user selects for the reserve option. Only for when the reserve selection is available for the accounts. Contact Account Manager for more detail.
data
Type
{
selected: UserReserveSelection
}
cancel
This event fires when the element is exited by cancellation.
Type
element.on('cancel', () => void);
Example
element.on('cancel', () => {
// Handle cancel event
});
error
See Errors section below
data
Type
{ code: string, message?: string }
ready
This event will be fired when:
{type: 'kycRfi' | 'paymentEnablementRfi' | 'transactionRfi'}
Type
type RfiEventData = {
type: 'kycRfi' | 'paymentEnablementRfi' | 'transactionRfi',
};
element.on('ready', (data: RfiEventData) => void);
Example
element.on('ready', (data: RfiEventData) => {
// Handle ready event
});
success
This event fires when the rfi flow is completed successfully.
Type
type RfiSuccessEventData = {
rfiId: string;
};
element.on('success', (data: RfiSuccessEventData) => void);
Example
element.on('success', (data: RfiSuccessEventData) => {
// Handle success event
});
cancel
This event fires when the element is exited by cancellation.
Type
element.on('cancel', () => void);
Example
element.on('cancel', () => {
// Handle cancel event
});
error
This event fires when an error occurs within the element.
Type
type errorCode = 'API_ERROR' | 'SUBMIT_FAILED' | 'INVALID_KYC_STATUS' | 'INVALID_RFI_STATUS' | 'UNKNOWN';
type ErrorData = { code: errorCode, message?: string }
element.on('error', (data: ErrorData) => void);
Example
element.on('error', (data: ErrorData) => {
// Handle error event
});
ready
This event will be fired when: sca page is ready.
Type
element.on('ready', () => void);
Example
element.on('ready', () => {
// Handle ready event
});
scaSetupSucceed
This event will be fired when SCA has been successfully configured by users:
Type
element.on('scaSetupSucceed', (
data: {
mobileInfo?: {
/** countryCode is represented as pure number codes string, such as '44'. */
countryCode: string;
nationalNumber: string;
}
}) => void);
Example
element.on('scaSetupSucceed', () => {
// Handle event
});
verificationSucceed
This event triggers when the SCA flow is authenticated successfully
Type
element.on('verificationSucceed', ({token}: {token:string}) => void);
Example
element.on('verificationSucceed', ({token}: {token:string}) => {
// Handle success event
});
verificationFailed
This event triggers when the SCA flow authentication fails.
Type
element.on('verificationFailed', ({reason}:{reason:string}) => void);
Example
element.on('verificationFailed', () => {
// Handle event
});
resetPasscodeSucceed
This event triggers when the user successfully resets their passcode
Type
element.on('resetPasscodeSucceed', () => void);
Example
element.on('resetPasscodeSucceed', () => {
// Handle event
});
cancel
This event fires when the element is exited by cancellation.
Type
element.on('cancel', () => void);
Example
element.on('cancel', () => {
// Handle cancel event
});
error
This event fires when an error occurs within the element.
Type
element.on('error', (data: { code: string, message?: string }) => void);
Example
element.on('error', (data: { code: string, message?: string }) => {
// Handle error event
});
We can configure the Elements to reflect your brand's color palette and logo. Contact your Airwallex Account Manager to enable customization in line with your business requirements.
FAQs
- [Airwallex.js](https://www.airwallex.com/docs/js) - [Installation](#installation) - [Initialization](#initialization) - [Create an Element](#create-an-element) - [Method parameters](#method-parameters) - [`options` object properties:](#options-object-pr
The npm package @airwallex/components-sdk receives a total of 5,195 weekly downloads. As such, @airwallex/components-sdk popularity was classified as popular.
We found that @airwallex/components-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.