Types
This section provides a detailed reference for the core TypeScript types and interfaces used throughout the DID Space component library. Understanding these data structures is essential for correctly typing component props and managing state in your application.
DIDSpaceStatus#
An enum representing the various connection states of a DID Space. This is used by components like DIDSpaceConnection to display the current status visually.
DIDSpaceStatus Enum
export enum DIDSpaceStatus {
LOADING = 'loading',
CONNECTED = 'connected',
DISCONNECTED = 'disconnected',
/** Not available, related to subscription status, e.g., expired, overdue, insufficient usage, etc. */
UNAVAILABLE = 'unavailable',
}Member | Value | Description |
|---|---|---|
|
| The component is currently attempting to connect or fetch the space status. |
|
| A successful and active connection to the DID Space is established. |
|
| The component is not connected to the DID Space. |
|
| The DID Space cannot be accessed due to an issue like an expired subscription or insufficient usage. |
DIDSpaceGateway#
This interface defines the structure for an object containing all the necessary information about a DID Space gateway. It is a key prop for components like DIDSpaceConnection to render space details.
DIDSpaceGateway Interface
export interface DIDSpaceGateway {
did: string;
name: string;
url: string;
endpoint: string;
ownerDid: string;
protected?: boolean;
loading?: boolean;
}AuthorizeConnect#
This interface defines the configuration options for the authentication modal that appears when a user initiates a connection.
AuthorizeConnect Interface
export interface AuthorizeConnect {
open: boolean;
action: string;
checkFn: Function;
messages: {
title: string;
scan: string;
confirm: string;
success: React.ReactNode;
};
prefix?: string;
baseUrl?: string;
webWalletUrl?: string;
maxIdleTime?: number;
checkTimeout?: number;
extraParams?: Record<string, any>;
}Authentication Options#
These interfaces define the options available for customizing the authentication process when connecting to a DID Space.
BaseAuthOptions#
Provides a set of common options for any authentication request, used to configure callbacks and session parameters.
BaseAuthOptions Interface
export interface BaseAuthOptions {
action?: string;
checkFn?: Function;
extraParams?: Record<string, string>;
checkTimeout?: number;
onSuccess?: (response: Record<string, string>, decrypt: Function) => Promise<void>;
onClose?: () => void;
}GatewayAuthOptions#
Extends BaseAuthOptions with additional properties required for connecting specifically to a DID Space gateway.
GatewayAuthOptions Interface
export interface GatewayAuthOptions extends BaseAuthOptions {
spaceDid?: string;
spaceGatewayUrl?: string;
}This interface inherits all properties from BaseAuthOptions.
Type Aliases#
For convenience and backward compatibility, the following type aliases are provided. It is recommended to use the primary types in new code.
Compatibility Aliases
// For compatibility
export type SpaceGateway = DIDSpaceGateway;
export const SpaceStatus = DIDSpaceStatus;SpaceGatewayis an alias forDIDSpaceGateway.SpaceStatusis an alias for theDIDSpaceStatusenum.
Next Steps#
Now that you are familiar with the core data structures, you can explore how they are used as props in the main components: