Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する

Overview

Reference

The Blocklet SDK is a library for building applications, also known as Blocklets, that run on Blocklet Server. It acts as a bridge between your application and the server's core functionalities, offering a comprehensive set of tools for tasks ranging from user authentication to inter-component communication. The SDK is available as an npm package for easy installation.

This SDK simplifies development by offering a high-level API over the underlying GraphQL interface of Blocklet Server. This abstraction allows you to focus on your application's logic instead of the complexities of direct server interaction.

For a quick path to a working example, refer to the Get Started guide.

Role in Blocklet Development#

The Blocklet SDK is integral to the development lifecycle. It enables your Blocklet to:

  • Access Server APIs: Perform administrative operations, manage users and permissions, and configure node settings.
  • Handle User Authentication: Securely integrate with DID Connect for a decentralized user login experience.
  • Manage Notifications: Send and receive various types of notifications, keeping users and other services informed.
  • Facilitate Component Communication: Interact with other Blocklets or components running on the same server instance.
  • Access Environment Configuration: Retrieve runtime environment variables and dynamic application settings provided by Blocklet Server.

Architecture Overview#

The Blocklet SDK is positioned between your application code and Blocklet Server, abstracting the communication layer. The diagram below illustrates this relationship:

Server-Side Interactions

Blocklet Environment

User Side

Calls SDK functions

GraphQL Queries/Mutations

Authentication

Manages

Accesses

Interacts with

User's Browser

DID Wallet

Your Blocklet Application

@blocklet/sdk

Blocklet Server

Other Blocklets/Components

Data & Services


Core Features#

The Blocklet SDK is organized into several key modules, each providing a specific set of functionalities.

Module

Description

AuthService

Manages user authentication, sessions, and role-based access control.

NotificationService

Enables sending notifications to users via various channels.

WalletHandlers & WalletAuthenticator

Utilities for handling DID Wallet interactions and authentication flows.

createConnectHandlers

Manages authentication flows specific to Blocklets within the DID Connect framework.

Database

Provides an interface for Blocklet-specific data storage using a NeDB-like API.

getWallet

Accesses the Blocklet's internal wallet for cryptographic operations.

env & config

Provides runtime access to environment variables and dynamic configurations.

middlewares

A collection of Express.js middleware for auth, CSRF protection, and sitemaps.

Component

Facilitates communication and data exchange between different components.

Security

Includes utilities for data encryption and decryption.


By providing a streamlined interface to these core services, the Blocklet SDK helps you build decentralized applications more efficiently. To start building your first Blocklet, proceed to the Get Started chapter.