Node.js client library for using Identity service.
This library is not distributed on npm
registry. It is available on github packages published here In order to add it as a dependency,
Add .npmrc
in the root of your project
@byjutech:registry=https://npm.pkg.github.com
Then run the following command:
npm install @byjutech/identity-js --save
import { identity } from '@byjutech/identity-js'
const idOpts = {
serviceBaseUrl: 'https://identity-staging.tllms.com',
oauth2: {
client: {
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
secret: 'xxx-xxx-xxx'
},
auth: {
tokenHost: 'https://hydra-auth-staging.tllms.com',
tokenPath: '/oauth2/token',
revokePath: '/oauth2/revoke',
authorizePath: '/oauth2/auth'
},
// http: { } // wreck options
},
scope: 'openid offline identities.read identities.create accounts.read accounts.create accounts.patch premiumaccounts.read'
}
const service = identity(idOpts)
const query = "+xx-xxxxxxxxxx"
const result = await service.find(query)
const service = identity(idOpts)
const identityId = "xxxx-xxxxxxxxxx-xxxxxxx-xxxx"
const result = await service.get(query)
const service = identity(idOpts)
const request = {
phone: "+xx-xxxxxxxxxx",
accounts: [ // Optional
{
first_name: "Bruce",
last_name: "Wayne"
}
]
}
const createRes = await service.create(request)
const service = identity(idOpts)
const request = {
first_name: "Jason",
last_name: "Todd",
premium_account_id: "acc_123"
}
const createRes = await service.accounts.add(identity_id, request)
const service = identity(idOpts)
const createRes = await service.accounts.get(account_id)
const service = identity(idOpts)
const request = {
current_grade: "8",
first_name: "Jason",
last_name: "Todd",
nickname: "Todd",
premium_account_id: "acc_123"
}
const createRes = await service.accounts.patch(account_id, request)
const service = identity(idOpts)
const createRes = await service.premiumAccounts.get(premium_account_id)