@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 userDid = 'xxxxxxxx';
const notification = {
title: 'xxx',
body: 'xxx',
attachments: [
{
type: 'asset',
data: {
did: 'xxx',
chainHost: 'https://chainhost',
},
},
],
actions: [
{
name: 'xxx',
title: 'Go To Website',
link: 'https://arcblock.io',
},
],
};
const content = { message: 'this is a message' };
const actions = [];
await Notification.sendToUser(userDid, notification);
await Notification.sendToUser(userDid, [notification, anotherNotification]);
await Notification.sendToUser([userDid, anotherUserDid], notification);
await Notification.sendToUser([userDid, anotherUserDid], [notification, anotherNotification]);
Api
notification.sendToUser(receiver, notification)
Send notification to an account
- receiver
string | array<string>
required - notification
object | array<object>
required
- notification.title
string
- notification.body
string
- notification.attachment
array<object>
- attachment.type
enum
'asset', 'vc', 'token' required - attachment.data
object
- type: text
- type
string
- message
string
- type: asset
- did
string
did - chainHost
string
uri
- type: vc
- credential
object
- tag
string
- type: token
- address
string
did - amount
string
- symbol
string
- senderDid
string
did - chainHost
string
- notification.actions
array<object>
- name
string
required - title
string
- color
string
- bgColor
string
- link
string
uri