Amplify SDK
The Amplify SDK for Node.js is a set of APIs for authenticating, switching selected organization,
creating MBS apps and users, and Titanium SDK support.
Installation
npm i @axway/amplify-sdk --save
Usage
import AmplifySDK from '@axway/amplify-sdk';
const sdk = new AmplifySDK({ ...opts });
Auth
const accounts = await sdk.auth.list();
let account = await.sdk.auth.find('<client_id>:<email>');
account = await sdk.auth.login();
console.log(account.org);
console.log(account.user);
account = await sdk.auth.login({ clientSecret: 'mysecret' });
account = await sdk.auth.login({ secretFile: '/path/to/pem/file' });
account = await sdk.auth.login({
clientSecret: 'mysecret',
username: 'my@email.com',
password: '123456'
});
account = await sdk.auth.login({
secretFile: '/path/to/pem/file'
username: 'my@email.com',
password: '123456'
});
await sdk.auth.switchOrg(account, orgGuid);
console.log(`Active org is now ${account.org.name}`);
await sdk.auth.logout({ accounts: [ account ] });
const info = await sdk.auth.serverInfo();
console.log(info);
Orgs
const orgs = await sdk.org.list(account);
console.log(orgs);
const org = await sdk.org.find(account, 'org name/id/guid');
const { from, to, events } = await sdk.org.activity(account, 'org name/id/guid', {
from: '2021-01-01',
to: '2021-01-31'
});
const envs = await sdk.org.getEnvironments(account);
const family = await sdk.org.family(account, 'org name/id/guid');
await sdk.org.rename(account, 'org name/id/guid', 'new org name');
const usage = await sdk.org.usage(account, 'org name/id/guid', {
from: '2021-01-01',
to: '2021-01-31'
});
const { users } = await sdk.org.member.list(account, 'org name/id/guid');
const user = await sdk.org.member.find(account, 'org name/id/guid', 'user guid or email');
const roles = [ 'administrator' ];
await sdk.org.member.add(account, 'org name/id/guid', 'user guid or email', roles);
await sdk.org.member.update(account, 'org name/id/guid', 'user guid or email', roles);
await sdk.org.member.remove(account, 'org name/id/guid', 'user guid or email');
Roles
const orgRoles = await sdk.role.list(account);
const teamRoles = await sdk.role.list(account, { team: true });
Team
const { teams } = await sdk.team.list(account, 'org name/id/guid');
const { team } = await sdk.team.find(account, 'org name/id/guid', 'team name or guid');
await sdk.team.create(account, 'org name/id/guid', 'team name', {
desc: 'Tiger team',
default: false,
tags: [ 'foo', 'bar' ]
});
const { changes, team } = await sdk.team.update(account, 'org name/id/guid', 'team name or guid', {
desc: 'Tiger team',
default: false,
tags: [ 'foo', 'bar' ]
});
await sdk.team.remove(account, 'org name/id/guid', 'team name or guid');
const { users } = await sdk.team.member.list(account, 'org name/id/guid', 'team name or guid');
const user = await sdk.team.member.find(account, 'org name/id/guid', 'team name or guid', 'user guid or email');
const roles = [ 'administrator' ];
await sdk.team.member.add(account, 'org name/id/guid', 'team name or guid', 'user guid or email', roles);
await sdk.team.member.update(account, 'org name/id/guid', 'team name or guid', 'user guid or email', roles);
await sdk.team.member.remove(account, 'org name/id/guid', 'team name or guid', 'user guid or email');
User
const user = await sdk.user.find(account, 'org name/id/guid', 'user guid or email');
const activity = await sdk.user.activity(account, {
from: '2021-01-01',
to: '2021-01-31'
});
const { changes, user } = await sdk.user.update(account, {
firstname: 'Elite',
lastname: 'Coder',
phone: '555-1212'
});
Account Object
Account objects contain the user info, organization info, and authentication tokens.
account: {
auth {
authenticator: 'PKCE',
baseUrl: 'https://login.axway.com',
clientId: 'amplify-cli',
env: {
name: 'prod',
baseUrl: 'https://login.axway.com',
redirectLoginSuccess: 'https://platform.axway.com/'
},
expires: { access: 1587685009628, refresh: 1587700615628 },
realm: 'Broker',
tokens: {
access_token: '<SNIP>',
expires_in: 1800,
refresh_expires_in: 17406,
refresh_token: '<SNIP>',
token_type: 'bearer',
id_token: '<SNIP>',
'not-before-policy': 1571719187,
session_state: '<SNIP>',
scope: 'openid'
}
},
hash: 'amplify-cli:abcdef1234567890',
name: 'amplify-cli:user@domain.com',
org: {
guid: '<GUID>',
id: 12345,
name: 'Example Org'
},
orgs: [
{ },
{ }
],
user: {
axwayId: '<SNIP>',
email: '',
firstName: '',
guid: '',
lastName: '',
organization: '',
is2FAEnabled: true
},
sid: '<SNIP>'
}
Legal
This project is open source under the Apache Public License v2 and is developed by
Axway, Inc and the community. Please read the LICENSE
file included
in this distribution for more information.