User & Access Management


This section provides a detailed reference for mutations that manage users, roles, permissions, invitations, and access keys within a Blocklet. These operations are essential for controlling access and managing identities in your application.

For fetching user and access control data, please see the User & Access Management Queries documentation.

User Management

Mutations for creating, updating, deleting, and managing user profiles and attributes.

Role & Permission Management

Operations for defining roles and assigning granular permissions to control access to resources.

Invitation Management

Methods for creating and managing user invitations to join a team or transfer ownership.

Access Key Management

Functions for creating, updating, and deleting API access keys for programmatic access.

Tag Management

Mutations for creating, updating, and deleting tags used to organize users.

Passport Management

Operations related to issuing and configuring verifiable credentials (Passports).


User Management#

These mutations allow for comprehensive management of user accounts.

removeUser#

Permanently removes a user from a team.

Parameters

input
RequestTeamUserInput
required
An object containing teamDid and the user's did.
teamDid
string
required
The DID of the team.
user
UserInfoInput
required
User information.
did
string
required
The DID of the user to remove.

Example

removeUser

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.removeUser({
    input: {
      teamDid: 'zdfw...',
      user: {
        did: 'z8...',
      },
    },
  });
  console.log('User removed:', user.did);
} catch (error) {
  console.error('Error removing user:', error);
}

Response

Returns a ResponseUser object containing the details of the removed user.

Response

{
  "removeUser": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "fullName": "John Doe"
    }
  }
}

updateUserTags#

Updates the tags associated with a specific user.

Parameters

input
RequestUpdateUserTagsInput
required
An object containing teamDid, the user's did, and an array of tag IDs.
teamDid
string
required
The DID of the team.
did
string
required
The DID of the user.
tags
number[]
required
An array of tag IDs to associate with the user.

Example

updateUserTags

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.updateUserTags({
    input: {
      teamDid: 'zdfw...',
      did: 'z8...',
      tags: [1, 3],
    },
  });
  console.log('User tags updated:', user.tags);
} catch (error) {
  console.error('Error updating user tags:', error);
}

Response

Returns a ResponseUser object with the user's updated information.

Response

{
  "updateUserTags": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "tags": [
        { "id": 1, "title": "Developer" },
        { "id": 3, "title": "Early Adopter" }
      ]
    }
  }
}

updateUserExtra#

Updates the remark and extra (a JSON string) fields for a user.

Parameters

input
RequestUpdateUserExtraInput
required
An object containing teamDid, user DID, and the extra data.
teamDid
string
required
The DID of the team.
did
string
required
The DID of the user to update.
remark
string
A new remark for the user.
extra
string
A JSON string containing custom data.

Example

updateUserExtra

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.updateUserExtra({
    input: {
      teamDid: 'zdfw...',
      did: 'z8...',
      remark: 'Internal user account',
      extra: JSON.stringify({ department: 'Engineering' }),
    },
  });
  console.log('User extra data updated:', user.extra);
} catch (error) {
  console.error('Error updating user extra data:', error);
}

Response

Returns a ResponseUser object with the updated user details.

Response

{
  "updateUserExtra": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "remark": "Internal user account",
      "extra": {
        "department": "Engineering"
      }
    }
  }
}

updateUserApproval#

Sets the approval status of a user.

Parameters

input
RequestTeamUserInput
required
An object containing teamDid and user details including did and the new approved status.
teamDid
string
required
The DID of the team.
user
UserInfoInput
required
User information.
did
string
required
The DID of the user.
approved
boolean
required
The new approval status.

Example

updateUserApproval

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.updateUserApproval({
    input: {
      teamDid: 'zdfw...',
      user: {
        did: 'z8...',
        approved: true,
      },
    },
  });
  console.log('User approval status:', user.approved);
} catch (error) {
  console.error('Error updating user approval:', error);
}

Response

Returns a ResponseUser object with the updated approval status.

Response

{
  "updateUserApproval": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "approved": true
    }
  }
}

issuePassportToUser#

Issues a new passport (verifiable credential) to a user, typically assigning them a role.

Parameters

input
RequestIssuePassportToUserInput
required
An object containing teamDid, userDid, role, and display details.
teamDid
string
required
The DID of the team.
userDid
string
required
The DID of the user to receive the passport.
role
string
required
The role to assign with this passport.
display
PassportDisplayInput
Display information for the passport.
type
string
required
Display type (e.g., 'text').
content
string
required
The content to display.
notify
boolean
Whether to send a notification to the user.

Example

issuePassportToUser

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.issuePassportToUser({
    input: {
      teamDid: 'zdfw...',
      userDid: 'z8...',
      role: 'guest',
      display: {
        type: 'text',
        content: 'Guest Access Pass',
      },
      notify: true,
    },
  });
  console.log('Passport issued to user:', user.did);
} catch (error) {
  console.error('Error issuing passport:', error);
}

Response

Returns a ResponseUser object, which may include the newly issued passport in the user's passports array.

Response

{
  "issuePassportToUser": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "passports": [
        {
          "id": "...",
          "role": "guest"
        }
      ]
    }
  }
}

revokeUserPassport#

Revokes a previously issued passport from a user.

Parameters

input
RequestRevokeUserPassportInput
required
An object containing teamDid, userDid, and the passportId to revoke.
teamDid
string
required
The DID of the team.
userDid
string
required
The DID of the user.
passportId
string
required
The ID of the passport to revoke.

Example

revokeUserPassport

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.revokeUserPassport({
    input: {
      teamDid: 'zdfw...',
      userDid: 'z8...',
      passportId: 'z...',
    },
  });
  console.log('User passport revoked.');
} catch (error) {
  console.error('Error revoking passport:', error);
}

Response

Returns a ResponseUser object reflecting the change in the user's passports.

Response

{
  "revokeUserPassport": {
    "code": "ok",
    "user": {
      "did": "z8..."
    }
  }
}

enableUserPassport#

Re-enables a passport that was previously revoked.

Parameters

input
RequestRevokeUserPassportInput
required
An object containing teamDid, userDid, and the passportId to enable.
teamDid
string
required
The DID of the team.
userDid
string
required
The DID of the user.
passportId
string
required
The ID of the passport to re-enable.

Example

enableUserPassport

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.enableUserPassport({
    input: {
      teamDid: 'zdfw...',
      userDid: 'z8...',
      passportId: 'z...',
    },
  });
  console.log('User passport re-enabled.');
} catch (error) {
  console.error('Error enabling passport:', error);
}

Response

Returns a ResponseUser object with the user's updated passport status.

Response

{
  "enableUserPassport": {
    "code": "ok",
    "user": {
      "did": "z8..."
    }
  }
}

removeUserPassport#

Permanently removes a passport from a user's record.

Parameters

input
RequestRevokeUserPassportInput
required
An object containing teamDid, userDid, and the passportId to remove.
teamDid
string
required
The DID of the team.
userDid
string
required
The DID of the user.
passportId
string
required
The ID of the passport to remove.

Example

removeUserPassport

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.removeUserPassport({
    input: {
      teamDid: 'zdfw...',
      userDid: 'z8...',
      passportId: 'z...',
    },
  });
  console.log('User passport permanently removed.');
} catch (error) {
  console.error('Error removing passport:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "removeUserPassport": {
    "code": "ok"
  }
}

updateUserInfo#

Updates a user's general information, such as fullName, email, and avatar.

Parameters

input
RequestUpdateUserInfoInput
required
An object containing teamDid and a user object with the fields to update.
teamDid
string
required
The DID of the team.
user
UserInfoInput
required
An object with the user fields to update.
did
string
required
The DID of the user.
fullName
string
The user's full name.
email
string
The user's email address.

Example

updateUserInfo

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { user } = await client.updateUserInfo({
    input: {
      teamDid: 'zdfw...',
      user: {
        did: 'z8...',
        fullName: 'Johnathan Doe',
        email: 'john.doe.new@example.com',
      },
    },
  });
  console.log('User info updated:', user.fullName);
} catch (error) {
  console.error('Error updating user info:', error);
}

Response

Returns a ResponseUser object with the updated user information.

Response

{
  "updateUserInfo": {
    "code": "ok",
    "user": {
      "did": "z8...",
      "fullName": "Johnathan Doe",
      "email": "john.doe.new@example.com"
    }
  }
}

Role & Permission Management#

These mutations are used to define roles and manage the permissions associated with them.

createRole#

Creates a new role within a team.

Parameters

input
RequestCreateRoleInput
required
An object containing teamDid, name, title, and optionally permissions.
teamDid
string
required
The DID of the team.
name
string
required
A unique name for the role (e.g., 'editor').
title
string
required
A human-readable title for the role (e.g., 'Editor').
description
string
A brief description of the role.
permissions
string[]
An array of permission names to grant to this role.

Example

createRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { role } = await client.createRole({
    input: {
      teamDid: 'zdfw...',
      name: 'editor',
      title: 'Editor',
      description: 'Can create and edit content',
      permissions: ['content:create', 'content:edit'],
    },
  });
  console.log('Role created:', role.name);
} catch (error) {
  console.error('Error creating role:', error);
}

Response

Returns a ResponseRole object containing the details of the newly created role.

Response

{
  "createRole": {
    "code": "ok",
    "role": {
      "name": "editor",
      "title": "Editor",
      "grants": ["content:create", "content:edit"]
    }
  }
}

updateRole#

Updates the details of an existing role.

Parameters

input
RequestTeamRoleInput
required
An object containing teamDid and a role object with the fields to update.
teamDid
string
required
The DID of the team.
role
RoleUpdateInput
required
An object with the role fields to update.
name
string
required
The name of the role to update.
title
string
The new title for the role.
description
string
The new description for the role.

Example

updateRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { role } = await client.updateRole({
    input: {
      teamDid: 'zdfw...',
      role: {
        name: 'editor',
        title: 'Content Editor',
      },
    },
  });
  console.log('Role updated:', role.title);
} catch (error) {
  console.error('Error updating role:', error);
}

Response

Returns a ResponseRole object with the updated role information.

Response

{
  "updateRole": {
    "code": "ok",
    "role": {
      "name": "editor",
      "title": "Content Editor"
    }
  }
}

deleteRole#

Permanently deletes a role.

Parameters

input
RequestDeleteRoleInput
required
An object containing teamDid and the name of the role to delete.
teamDid
string
required
The DID of the team.
name
string
required
The name of the role to delete.

Example

deleteRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deleteRole({
    input: {
      teamDid: 'zdfw...',
      name: 'editor',
    },
  });
  console.log('Role "editor" deleted.');
} catch (error) {
  console.error('Error deleting role:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "deleteRole": {
    "code": "ok"
  }
}

createPermission#

Creates a new permission that can be granted to roles.

Parameters

input
RequestCreatePermissionInput
required
An object containing teamDid, name, and description.
teamDid
string
required
The DID of the team.
name
string
required
A unique name for the permission (e.g., 'content:publish').
description
string
A brief description of the permission.

Example

createPermission

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { permission } = await client.createPermission({
    input: {
      teamDid: 'zdfw...',
      name: 'content:publish',
      description: 'Allows publishing content',
    },
  });
  console.log('Permission created:', permission.name);
} catch (error) {
  console.error('Error creating permission:', error);
}

Response

Returns a ResponsePermission object with the details of the new permission.

Response

{
  "createPermission": {
    "code": "ok",
    "permission": {
      "name": "content:publish",
      "description": "Allows publishing content"
    }
  }
}

updatePermission#

Updates the description of an existing permission.

Parameters

input
RequestTeamPermissionInput
required
An object containing teamDid and the permission details to update.
teamDid
string
required
The DID of the team.
permission
PermissionInput
required
An object with the permission name and new description.
name
string
required
The name of the permission to update.
description
string
required
The new description for the permission.

Example

updatePermission

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { permission } = await client.updatePermission({
    input: {
      teamDid: 'zdfw...',
      permission: {
        name: 'content:publish',
        description: 'Allows publishing content to the live site.',
      },
    },
  });
  console.log('Permission updated:', permission.description);
} catch (error) {
  console.error('Error updating permission:', error);
}

Response

Returns a ResponsePermission object with the updated permission details.

Response

{
  "updatePermission": {
    "code": "ok",
    "permission": {
      "name": "content:publish",
      "description": "Allows publishing content to the live site."
    }
  }
}

deletePermission#

Permanently deletes a permission. This will also revoke it from any roles that have it.

Parameters

input
RequestDeletePermissionInput
required
An object containing teamDid and the name of the permission to delete.
teamDid
string
required
The DID of the team.
name
string
required
The name of the permission to delete.

Example

deletePermission

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deletePermission({
    input: {
      teamDid: 'zdfw...',
      name: 'content:publish',
    },
  });
  console.log('Permission deleted.');
} catch (error) {
  console.error('Error deleting permission:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "deletePermission": {
    "code": "ok"
  }
}

grantPermissionForRole#

Grants a specific permission to a role.

Parameters

input
RequestGrantPermissionForRoleInput
required
An object containing teamDid, the roleName, and the grantName (permission).
teamDid
string
required
The DID of the team.
roleName
string
required
The name of the role.
grantName
string
required
The name of the permission to grant.

Example

grantPermissionForRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.grantPermissionForRole({
    input: {
      teamDid: 'zdfw...',
      roleName: 'editor',
      grantName: 'content:publish',
    },
  });
  console.log('Permission granted.');
} catch (error) {
  console.error('Error granting permission:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "grantPermissionForRole": {
    "code": "ok"
  }
}

revokePermissionFromRole#

Revokes a specific permission from a role.

Parameters

input
RequestRevokePermissionFromRoleInput
required
An object containing teamDid, the roleName, and the grantName (permission).
teamDid
string
required
The DID of the team.
roleName
string
required
The name of the role.
grantName
string
required
The name of the permission to revoke.

Example

revokePermissionFromRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.revokePermissionFromRole({
    input: {
      teamDid: 'zdfw...',
      roleName: 'editor',
      grantName: 'content:publish',
    },
  });
  console.log('Permission revoked.');
} catch (error) {
  console.error('Error revoking permission:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "revokePermissionFromRole": {
    "code": "ok"
  }
}

updatePermissionsForRole#

Sets the complete list of permissions for a role, replacing any existing permissions.

Parameters

input
RequestUpdatePermissionsForRoleInput
required
An object containing teamDid, roleName, and an array of permission names.
teamDid
string
required
The DID of the team.
roleName
string
required
The name of the role.
grantNames
string[]
required
An array of permission names to set for the role.

Example

updatePermissionsForRole

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { role } = await client.updatePermissionsForRole({
    input: {
      teamDid: 'zdfw...',
      roleName: 'editor',
      grantNames: ['content:create', 'content:edit', 'content:delete'],
    },
  });
  console.log('Role permissions updated:', role.grants);
} catch (error) {
  console.error('Error updating role permissions:', error);
}

Response

Returns a ResponseRole object with the updated list of permissions.

Response

{
  "updatePermissionsForRole": {
    "code": "ok",
    "role": {
      "name": "editor",
      "grants": ["content:create", "content:edit", "content:delete"]
    }
  }
}

Invitation Management#

These mutations are used to manage user invitations.

createMemberInvitation#

Creates an invitation for a new member to join a team with a specific role.

Parameters

input
RequestCreateInvitationInput
required
An object containing teamDid, role, and other invitation details.
teamDid
string
required
The DID of the team.
role
string
required
The role to assign to the invited member.
remark
string
A remark or note for the invitation.

Example

createMemberInvitation

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { inviteInfo } = await client.createMemberInvitation({
    input: {
      teamDid: 'zdfw...',
      role: 'guest',
      remark: 'Invitation for new team member',
    },
  });
  console.log('Invitation created:', inviteInfo.inviteId);
} catch (error) {
  console.error('Error creating invitation:', error);
}

Response

Returns a ResponseCreateInvitation object containing details about the created invitation.

Response

{
  "createMemberInvitation": {
    "code": "ok",
    "inviteInfo": {
      "inviteId": "...",
      "role": "guest"
    }
  }
}

createTransferInvitation#

Creates an invitation to transfer ownership of the node.

Parameters

input
RequestCreateTransferNodeInvitationInput
required
An object containing teamDid and a remark.
teamDid
string
required
The DID of the team.
remark
string
A remark for the transfer invitation.

Example

createTransferInvitation

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { inviteInfo } = await client.createTransferInvitation({
    input: {
      teamDid: 'zdfw...',
      remark: 'Transferring node ownership',
    },
  });
  console.log('Transfer invitation created:', inviteInfo.inviteId);
} catch (error) {
  console.error('Error creating transfer invitation:', error);
}

Response

Returns a ResponseCreateTransferNodeInvitation object with details of the invitation.

Response

{
  "createTransferInvitation": {
    "code": "ok",
    "inviteInfo": {
      "inviteId": "...",
      "role": "owner"
    }
  }
}

deleteInvitation#

Permanently deletes an invitation.

Parameters

input
RequestDeleteInvitationInput
required
An object containing teamDid and the inviteId to delete.
teamDid
string
required
The DID of the team.
inviteId
string
required
The ID of the invitation to delete.

Example

deleteInvitation

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deleteInvitation({
    input: {
      teamDid: 'zdfw...',
      inviteId: '...',
    },
  });
  console.log('Invitation deleted.');
} catch (error) {
  console.error('Error deleting invitation:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "deleteInvitation": {
    "code": "ok"
  }
}

Access Key Management#

These mutations are used to manage API access keys for programmatic access.

createAccessKey#

Creates a new access key.

Parameters

input
RequestCreateAccessKeyInput
required
An object containing teamDid, remark, and other key details.
teamDid
string
required
The DID of the team.
remark
string
A remark to identify the key's purpose.
authType
string
Authentication type (e.g., 'role').

Example

createAccessKey

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { data } = await client.createAccessKey({
    input: {
      teamDid: 'zdfw...',
      remark: 'Key for CI/CD pipeline',
      authType: 'role',
    },
  });
  console.log('Access Key created:', data.accessKeyId);
  console.log('Secret:', data.accessKeySecret); // Save this secret securely
} catch (error) {
  console.error('Error creating access key:', error);
}

Response

Returns a ResponseCreateAccessKey object containing the new key's ID and secret. The secret is only returned on creation.

Response

{
  "createAccessKey": {
    "code": "ok",
    "data": {
      "accessKeyId": "...",
      "accessKeySecret": "...",
      "remark": "Key for CI/CD pipeline"
    }
  }
}

updateAccessKey#

Updates the details of an existing access key, such as its remark or expiration.

Parameters

input
RequestUpdateAccessKeyInput
required
An object containing teamDid, accessKeyId, and the fields to update.
teamDid
string
required
The DID of the team.
accessKeyId
string
required
The ID of the access key to update.
remark
string
The new remark for the key.

Example

updateAccessKey

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { data } = await client.updateAccessKey({
    input: {
      teamDid: 'zdfw...',
      accessKeyId: '...',
      remark: 'Updated remark for CI/CD pipeline',
    },
  });
  console.log('Access Key updated:', data.remark);
} catch (error) {
  console.error('Error updating access key:', error);
}

Response

Returns a ResponseUpdateAccessKey object with the updated key details.

Response

{
  "updateAccessKey": {
    "code": "ok",
    "data": {
      "accessKeyId": "...",
      "remark": "Updated remark for CI/CD pipeline"
    }
  }
}

deleteAccessKey#

Permanently deletes an access key.

Parameters

input
RequestDeleteAccessKeyInput
required
An object containing teamDid and the accessKeyId to delete.
teamDid
string
required
The DID of the team.
accessKeyId
string
required
The ID of the access key to delete.

Example

deleteAccessKey

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deleteAccessKey({
    input: {
      teamDid: 'zdfw...',
      accessKeyId: '...',
    },
  });
  console.log('Access Key deleted.');
} catch (error) {
  console.error('Error deleting access key:', error);
}

Response

Returns a ResponseDeleteAccessKey object indicating success or failure.

Response

{
  "deleteAccessKey": {
    "code": "ok"
  }
}

verifyAccessKey#

Verifies if an access key is valid and has access to a specific resource.

Parameters

input
RequestVerifyAccessKeyInput
required
An object containing teamDid, accessKeyId, and resource details.
teamDid
string
required
The DID of the team.
accessKeyId
string
required
The ID of the access key to verify.
resourceType
string
The type of the resource (e.g., 'blocklet').
resourceId
string
The ID of the resource.
componentDid
string
The DID of the component associated with the resource.

Example

verifyAccessKey

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { data } = await client.verifyAccessKey({
    input: {
      teamDid: 'zdfw...',
      accessKeyId: '...',
    },
  });
  console.log('Access key is valid:', data);
} catch (error) {
  console.error('Access key verification failed:', error);
}

Response

Returns a ResponseAccessKey object with the key's details if verification is successful.

Response

{
  "verifyAccessKey": {
    "code": "ok",
    "data": {
      "accessKeyId": "...",
      "remark": "Key for CI/CD pipeline"
    }
  }
}

Tag Management#

These mutations are used to manage user tags.

createTag#

Creates a new tag.

Parameters

input
RequestTagInput
required
An object containing teamDid and the tag details to create.
teamDid
string
required
The DID of the team.
tag
TagInput
required
An object with the tag details.
title
string
required
The title of the tag.
description
string
A description for the tag.
color
string
A hex color code for the tag.

Example

createTag

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { tag } = await client.createTag({
    input: {
      teamDid: 'zdfw...',
      tag: {
        title: 'VIP',
        description: 'Very Important Person',
        color: '#FFD700',
      },
    },
  });
  console.log('Tag created:', tag.title);
} catch (error) {
  console.error('Error creating tag:', error);
}

Response

Returns a ResponseTag object with the details of the newly created tag.

Response

{
  "createTag": {
    "code": "ok",
    "tag": {
      "id": 4,
      "title": "VIP",
      "color": "#FFD700"
    }
  }
}

updateTag#

Updates an existing tag.

Parameters

input
RequestTagInput
required
An object containing teamDid and a tag object with the id and fields to update.
teamDid
string
required
The DID of the team.
tag
TagInput
required
An object with the tag ID and fields to update.
id
number
required
The ID of the tag to update.
title
string
The new title for the tag.
color
string
The new color for the tag.

Example

updateTag

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { tag } = await client.updateTag({
    input: {
      teamDid: 'zdfw...',
      tag: {
        id: 4,
        color: '#E5C100',
      },
    },
  });
  console.log('Tag updated:', tag.color);
} catch (error) {
  console.error('Error updating tag:', error);
}

Response

Returns a ResponseTag object with the updated tag information.

Response

{
  "updateTag": {
    "code": "ok",
    "tag": {
      "id": 4,
      "title": "VIP",
      "color": "#E5C100"
    }
  }
}

deleteTag#

Permanently deletes a tag.

Parameters

input
RequestTagInput
required
An object containing teamDid and the tag id to delete.
teamDid
string
required
The DID of the team.
tag
TagInput
required
An object containing the ID of the tag to delete.
id
number
required
The ID of the tag to delete.

Example

deleteTag

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deleteTag({
    input: {
      teamDid: 'zdfw...',
      tag: {
        id: 4,
      },
    },
  });
  console.log('Tag deleted.');
} catch (error) {
  console.error('Error deleting tag:', error);
}

Response

Returns a ResponseTag object of the deleted tag.

Response

{
  "deleteTag": {
    "code": "ok",
    "tag": {
      "id": 4
    }
  }
}

Passport Management#

These mutations are used to manage passport issuance and trust configurations.

createPassportIssuance#

Creates a new passport issuance configuration for a team.

Parameters

input
RequestCreatePassportIssuanceInput
required
An object containing teamDid, ownerDid, name, and display details.
teamDid
string
required
The DID of the team.
ownerDid
string
required
The DID of the owner of this issuance.
name
string
required
The name of the passport issuance.
display
PassportDisplayInput
Display information for the passport.
type
string
required
Display type.
content
string
required
Display content.

Example

createPassportIssuance

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  const { info } = await client.createPassportIssuance({
    input: {
      teamDid: 'zdfw...',
      ownerDid: 'z8...',
      name: 'Community Contributor',
      display: {
        type: 'text',
        content: 'Community Contributor Badge',
      },
    },
  });
  console.log('Passport issuance created:', info.id);
} catch (error) {
  console.error('Error creating passport issuance:', error);
}

Response

Returns a ResponseCreatePassportIssuance object with details of the new issuance configuration.

Response

{
  "createPassportIssuance": {
    "code": "ok",
    "info": {
      "id": "...",
      "name": "Community Contributor"
    }
  }
}

deletePassportIssuance#

Deletes a passport issuance configuration.

Parameters

input
RequestDeleteTeamSessionInput
required
An object containing teamDid and the sessionId (issuance ID) to delete.
teamDid
string
required
The DID of the team.
sessionId
string
required
The ID of the passport issuance to delete.

Example

deletePassportIssuance

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.deletePassportIssuance({
    input: {
      teamDid: 'zdfw...',
      sessionId: '...',
    },
  });
  console.log('Passport issuance deleted.');
} catch (error) {
  console.error('Error deleting passport issuance:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "deletePassportIssuance": {
    "code": "ok"
  }
}

configPassportIssuance#

Enables or disables passport issuance for a team.

Parameters

input
RequestConfigPassportIssuanceInput
required
An object containing teamDid and a boolean enable flag.
teamDid
string
required
The DID of the team.
enable
boolean
required
Set to true to enable, false to disable.

Example

configPassportIssuance

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.configPassportIssuance({
    input: {
      teamDid: 'zdfw...',
      enable: true,
    },
  });
  console.log('Passport issuance enabled.');
} catch (error) {
  console.error('Error configuring passport issuance:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "configPassportIssuance": {
    "code": "ok"
  }
}

configTrustedPassports#

Configures a list of trusted passport issuers and their role mappings.

Parameters

input
RequestConfigTrustedPassportsInput
required
An object containing teamDid and the list of trusted passports.
teamDid
string
required
The DID of the team.
trustedPassports
TrustedPassportInput[]
required
An array of trusted passport configurations.
issuerDid
string
required
The DID of the trusted issuer.
mappings
TrustedPassportMappingInput[]
required
Role mapping rules.
from
TrustedPassportMappingFromInput
required
Source passport details.
passport
string
required
The name or type of the source passport.
to
TrustedPassportMappingToInput
required
Target role details.
role
string
required
The local role to map to.

Example

configTrustedPassports

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.configTrustedPassports({
    input: {
      teamDid: 'zdfw...',
      trustedPassports: [
        {
          issuerDid: 'z...', // DID of another trusted blocklet
          mappings: [
            {
              from: { passport: 'developer_badge' },
              to: { role: 'developer' },
            },
          ],
        },
      ],
    },
  });
  console.log('Trusted passports configured.');
} catch (error) {
  console.error('Error configuring trusted passports:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "configTrustedPassports": {
    "code": "ok"
  }
}

configTrustedFactories#

Configures a list of trusted NFT factories.

Parameters

input
RequestConfigTrustedFactoriesInput
required
An object containing teamDid and the list of trusted factories.
teamDid
string
required
The DID of the team.
trustedFactories
TrustedFactoryInput[]
required
An array of trusted factory configurations.
factoryAddress
string
required
The address of the NFT factory.
remark
string
A remark for the factory.

Example

configTrustedFactories

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient();

try {
  await client.configTrustedFactories({
    input: {
      teamDid: 'zdfw...',
      trustedFactories: [
        {
          factoryAddress: '0x...',
          remark: 'Official Community NFT Factory',
        },
      ],
    },
  });
  console.log('Trusted factories configured.');
} catch (error) {
  console.error('Error configuring trusted factories:', error);
}

Response

Returns a GeneralResponse object indicating success or failure.

Response

{
  "configTrustedFactories": {
    "code": "ok"
  }
}