Core Services
The Blocklet SDK provides a suite of essential services that enable your Blocklet to interact seamlessly with the underlying Blocklet Server functionalities. These services abstract away complex interactions, allowing you to focus on building your decentralized application.
This section offers an overview of the primary services:
- Auth Service: Manages user authentication, authorization, and profile information.
- DID Connect: Facilitates secure user connections and interactions with DID Wallet.
- Notifications: Handles sending and receiving various types of messages and managing event subscriptions.
- Component Interaction: Enables communication and resource management between different Blocklet components.
Overview of Blocklet SDK Core Services#
The following diagram illustrates how the Blocklet SDK's core services interact with your Blocklet application and the Blocklet Server:
Auth Service#
The AuthService
provides comprehensive functionalities for managing user identities, authentication flows, and access control within your Blocklet. It allows you to integrate login, handle user profiles, and manage roles and permissions.
Key Capabilities:
- User Management: Retrieve user information, update user profiles, and manage user approval statuses.
- Roles and Permissions (RBAC): Define custom roles, assign permissions, and check user authorization.
- Session Management: Control user login sessions and refresh tokens.
- Access Keys: Programmatically create and verify access keys for secure API interactions.
For detailed API documentation and usage examples, refer to the Auth Service section.
DID Connect#
The Blocklet SDK integrates with DID Connect to provide secure and decentralized authentication. The BlockletAuthenticator
class, built on @did-connect/authenticator
, streamlines the process of connecting users via their DID Wallet, ensuring a seamless and trustless login experience.
Key Capabilities:
- DID Wallet Integration: Directly interact with DID Wallet for user authentication requests.
- Authentication Flows: Handle various DID Connect authentication challenges.
- Session Establishment: Securely establish user sessions post-authentication.
For detailed information on implementing DID Connect in your Blocklet, see the DID Connect documentation.
Notifications#
The Blocklet SDK offers robust notification and event bus capabilities, enabling real-time communication within your Blocklet application and across the Blocklet Server ecosystem. You can send messages to individual users, broadcast to application channels, or publish events to a global event bus.
Key Capabilities:
- User-Specific Messages: Send direct notifications to specific users (e.g., in-app alerts, emails).
- Application Broadcasts: Publish messages to a public channel accessible by all connected clients of your Blocklet.
- Event Bus: Subscribe to and publish custom events, facilitating inter-Blocklet communication and internal system event handling.
- Real-time Updates: Leverage WebSockets for instant message delivery.
For a comprehensive guide on using the notification and event bus features, visit the Notifications section.
Component Interaction#
Blocklet applications are often composed of multiple distinct components. The Blocklet SDK provides utilities for these components to communicate with each other, manage shared resources, and understand their operational context. This enables modular and scalable application architectures.
Key Capabilities:
- Inter-Component Communication: Make HTTP requests to other running components within the same Blocklet Server instance.
- URL Generation: Construct absolute or relative URLs for resources exposed by your Blocklet or its components.
- Component Discovery: Retrieve information about mounted components, including their endpoints and status.
- Resource Management: Access directories for exported resources and releases.
- Lifecycle Management: Wait for components to reach a running state.
To learn more about how to manage and interact with Blocklet components, refer to the Component Interaction documentation.
This section provided a high-level overview of the core services available in the Blocklet SDK. To dive deeper into specific functionalities and learn how to implement them in your Blocklet, proceed to the Auth Service documentation.