Skip to content

Account Gator WEB SDK

The Account Gator WEB SDK enables secure consent collection for accessing user's account transactions via account aggregator framework or bank statements.

Requirements

The Web SDK works on Google Chrome, Safari, Firefox, Opera and other popular modern browsers.

Variables

The following variables will be referenced throughout this documentation:

Variable Description Format Source
client_id Unique identifier for your organisation Alphanumeric string Provided by Credeau during onboarding
auth_token Secret token for API authentication Alphanumeric string Provided by Credeau during onboarding
user_id Unique identifier for an end user Alphanumeric string Provided by Credeau during onboarding
redirect_url URL to redirect to post process Like, https://yourdomain.com/redirection/path Set by client as per requirement
template_name Account Aggregator template name Either BANK_STATEMENT_PERIODIC or BANK_STATEMENT_ONETIME Set by client as per requirement
customer_mobile_number End user's mobile number Like, 9999999999 Provided by customer during journey

⚠️ Note

Keep these credentials secure and never share them publicly. These credentials are unique to your organization and will be used to authenticate all API requests.

Adding Dependency

Add the SDK to your application using one of the following methods.

1. Install & Configure the AWS CLI

Installation Steps

aws configure --profile credeau

The above takes the following as input -

AWS Access Key ID [None]: <provided by credeau>
AWS Secret Access Key [None]: <provided by credeau>
Default region name [None]: ap-south-1
Default output format [None]: json

2. Login to NPN repository

aws codeartifact login \
    --tool npm \
    --domain "credeau" \
    --domain-owner "068267901648" \
    --repository "account-gator-web" \
    --region ap-south-1 \
    --profile credeau

This command:

  • fetches auth token
  • updates ~/.npmrc
  • enables npm install

⚠️ Note

The authentication token generated by this command expires in 12 Hrs.

3. Install the SDK

latest:

npm install @credeau/accountgator

or, Specific version

npm install @credeau/accountgator@1.0.0

Usage

ESM / bundler

import { openAccountGator } from "@credeau/accountgator";

const result = await openAccountGator({
    client_id: "<client_id>",
    user_id: "<user_id>",
    auth_token: "<auth_token>",
    redirect_url: "<redirect_url>",
    is_redirecting: true/false, // Optional; default=true if not passed
    template_name: "<template_name>",
    mobile_number: "<customer_mobile_number>",
});

console.log(result);

// Values can be access by `result.<field>`, for example:
// result.success
// result.aa_session_id
// result.error
// result.timeout

Script Tag

<button id="link">Link bank account</button>

<script src="./dist/accountgator.js"></script>
<script>
    const params = {
        client_id: "<client_id>",
        user_id: "<user_id>",
        auth_token: "<auth_token>",
        redirect_url: "<redirect_url>",
        is_redirecting: true/false,  // Optional; default=true if not passed
        template_name: "<template_name>",
        mobile_number: "<customer_mobile_number>"
    };

    document.getElementById("link").onclick = async () => {
        try {
            const result = await accountGatorSDK.openAccountGator(params);
            // Use `result` to drive your app flow (redirect, show success UI, etc.)
            console.log("AccountGator result:", result);
            // Values can be access by `result.<field>`, for example:
            // result.success
            // result.aa_session_id
            // result.error
            // result.timeout
        } catch (e) {
            console.error("AccountGator error:", e);
        }
    };
</script>

Output

The SDK returns the following keys as output -

  • success (str) - Boolean as string indicating if the consent was successfully provided or not.
  • aa_session_id (str) - Session ID for the Account Aggregator transaction, further used to fetch insights & reports.
  • error (str) - Error message indicating if any error occured during the consent session.
  • timeout (str) - Boolean as string indicating if the process timed out or not.

When is_redirecting is set to true, the SDK will redirect to the passed URL in redirect_url with SDK output keys appended as query parameters.

💡 Example:

If, redirect_url is set to 'https://yourdomain.com/user/journey' and is_redirecting to true, then the SDK will redirect the browser window to the following URL -

'https://yourdomain.com/user/journey?success=true&aa_session_id=f310805cedd0485ba18b6f10bb8b1843&error=null&timeout=false'

And, the values can be used within the page from here.

Using the values from query parameters -

const params = new URLSearchParams(window.location.search);

const success = params.get("success"); // "true" | "false" | null
const aa_session_id = params.get("aa_session_id"); // string | null
const error = params.get("error"); // string | null
const timeout = params.get("timeout"); // "true" | "false" | null