Skip to content

Helper

Installation

Include the latest version.

<script src="https://omega-gundam-agent-sdk.s3-ap-northeast-1.amazonaws.com/production/js/latest/omega-agent-helper.js"></script>

To load a specific version, replace latest with the version number.

<script src="https://omega-gundam-agent-sdk.s3-ap-northeast-1.amazonaws.com/production/js/1.0/omega-agent-helper.js"></script>

Usage

Use helper to create token for testing.

Careful! Private key must not be placed under version control.

const { Constants } = window['omega'];
const { createToken } = window['omega-helper'];

const appId = 'APP_ID';
const privateKey = 'PRIVATE_KEY';

// set token to expire in 600 seconds
const expSeconds = 600;

// set privileges for token
const privileges = [Constants.Privilege.MANAGE];

// set gne for token, empty string is root 
const gne = 'GNE';

// set dictionary count limit for token
const apiVars = {
    '/api/d/dictionaries': {
        total_count: 5,
    },
};

// create a new token
const token = createToken({ 
    appId, 
    privateKey, 
    expSeconds, 
    privileges,
    gne,
    apiVars,
});

Methods

Create a token for testing.

const token = createToken({
    appId: 'APP_ID',
    appSubgroupId: 'APP_SUBGROUP_ID',
    subject: 'SUBJECT',
    subjectName: 'SUBJECT_NAME',
    privateKey: 'PRIVATE_KEY',
    expSeconds: 1800,
    privileges: [
        Constants.Privilege.MANAGE,
    ],
    meta: {},
    queryCheck: {},
    headerCheck: {},
    formCheck: {},
    gne: 'GNE',
    apiVars: {
        '/api/d/dictionaries': {
            total_count: 5,
        },
    },
    custom: {},
});