Classes
This section provides detailed documentation for the core classes exposed by the Blocklet SDK. These classes are fundamental building blocks for interacting with Blocklet Server functionalities, enabling developers to integrate features such as authentication, notifications, and more into their decentralized applications.
For an overview of how these services fit into the broader Blocklet SDK, refer to the Core Services section.
AuthService#
The AuthService
class provides a comprehensive set of functionalities for user authentication, authorization, and general user management within your Blocklet application. It allows you to interact with the Blocklet Server's underlying identity and access control system.
Constructor#
The AuthService
is instantiated with an optional httpEndpoint
.
new AuthService(httpEndpoint?: string);
Parameters
Name | Type | Description |
---|---|---|
|
| Optional. The GraphQL endpoint for Blocklet Server. If not provided, it defaults to |
Example
import { AuthService } from '@blocklet/sdk';
// Initialize AuthService with default endpoint
const authService = new AuthService();
// Initialize AuthService with a custom endpoint
const customAuthService = new AuthService('http://my-custom-blocklet-server:8080/api/gql');
Methods#
The AuthService
class exposes numerous methods for managing users, roles, permissions, sessions, and more. Due to the extensive list of functionalities, detailed documentation for each method, including parameters, return types, and examples, is provided in the dedicated Auth Service section.
Common methods include login
, getUser
, getUsers
, createRole
, hasPermission
, and many others for granular control over user and access management.
BlockletAuthenticator#
The BlockletAuthenticator
class is designed for handling DID Connect authentication flows specifically within Blocklet environments. It extends the @did-connect/authenticator
library, providing a secure and seamless way for users to connect their DID Wallet with your Blocklet application.
Constructor#
The BlockletAuthenticator
is instantiated with an optional options
object.
new BlockletAuthenticator(options?: object);
Parameters
Name | Type | Description |
---|---|---|
|
| Optional. Configuration options passed to the underlying |
Example
import { BlockletAuthenticator } from '@blocklet/sdk';
// Initialize BlockletAuthenticator with default options
const authenticator = new BlockletAuthenticator();
// Initialize BlockletAuthenticator with custom options, e.g., to configure behavior
const customAuthenticator = new BlockletAuthenticator({
// Custom options for the DID Connect authenticator
// For example, customizing the wallet object or other connect properties
});
Usage#
For detailed information on how to use BlockletAuthenticator
to manage authentication sessions, create handlers, and customize DID Connect flows, please refer to the DID Connect section.
WalletAuthenticator#
The WalletAuthenticator
class facilitates wallet-based authentication in Blocklet applications. It builds upon the @arcblock/did-auth
library, offering a robust solution for verifying user identities through their DID Wallet.
Constructor#
The WalletAuthenticator
is instantiated with an optional options
object.
new WalletAuthenticator(options?: object);
Parameters
Name | Type | Description |
---|---|---|
|
| Optional. Configuration options passed to the underlying |
Example
import { WalletAuthenticator } from '@blocklet/sdk';
// Initialize WalletAuthenticator with default options
const walletAuth = new WalletAuthenticator();
// Initialize WalletAuthenticator with custom options
const customWalletAuth = new WalletAuthenticator({
autoConnect: true, // Example: enable auto-connection for seamless experience
connectedDidOnly: false,
// Other options specific to @arcblock/did-auth
});
Usage#
To understand the full capabilities and implementation details of WalletAuthenticator
for integrating wallet-based authentication into your Blocklet, please visit the DID Connect section.
This section introduced the core classes available in the Blocklet SDK for building your applications. You can now explore the specific functionalities provided by their methods in the linked sections or proceed to learn about Functions for global utilities.