@blocklet/sdk
Blocklet SDK for blocklet developer
Install
yarn add @blocklet/sdk
or
npm install @blocklet/sdk
Auth SDK
Usage
const Auth = require('@blocklet/sdk/service/auth');
const client = new Auth();
const userDid = 'xxxxxxxx';
const { user } = await client.getUser(userDid);
Api
client.getUser(did)
Get user by user did
client.getUsers()
Get all users of the team
client.updateUserRole(did, role)
client.getPermissionsByRole(role)
Get all permissions of a role
client.getRoles()
Get all roles of the team
client.getPermissions()
Get all permissions of the team
Notification SDK
Usage
const Notification = require('@blocklet/sdk/service/notification');
const userDid1 = 'xxxxxxxx';
const userDid2 = 'xxxxxxxx';
const type = 'text';
const content = { message: 'this is a message' };
const actions = [{ name: 'xxx', title: 'Go To Website', link: 'https://arcblock.io' }];
await Notification.sendToUser(userDid1, type, content, { actions });
await Notification.sendToUsers([userDid1, userDid2], type, content, { actions });
Api
notification.sendToUser(did, type, content, options)
Send notification to an account
- did
string
required - type
enum
'text', 'asset', 'vc', 'token' required - content
object
- type: text
- type
string
- message
string
- type: asset
- did
string
did - chainHost
string
uri - chainId
string
- type: vc
- credential
object
- tag
string
- type: token
- address
string
did - amount
string
- symbol
string
- senderDid
string
did - chainHost
string
- chainId
string
- options
object
- actions
array<object>
- name
string
required - title
string
- color
string
- bgColor
string
- link
string
uri
notification.sendToUsers(didList, type, content, actions)
Send notification to multiple accounts
- didList
array<string>
required - type Same as
notification.sendToUser
- content Same as
notification.sendToUser
- options Same as
notification.sendToUser