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

Types


This section provides a detailed reference for the key TypeScript types and interfaces used throughout the DID Space component library. A solid understanding of these data structures is essential for effectively configuring the props of components like DIDSpaceConnect and DIDSpaceConnection.

DIDSpaceGateway#

The DIDSpaceGateway interface represents the core information about a specific DID Space instance. It is used to display space details and to establish connections.

Property

Type

Description

did

string

The DID of the space itself.

name

string

The display name of the space.

url

string

The base URL for the space's web application (e.g., https://spaces.example.io/app).

endpoint

string

The specific API endpoint URL for the space.

ownerDid

string

The DID of the space's owner.

protected

boolean (optional)

Indicates if the space requires special authentication.

loading

boolean (optional)

A flag to indicate if the gateway information is currently being loaded.


DIDSpaceStatus#

The DIDSpaceStatus enum defines the possible connection states for a DID Space, which is often used to conditionally render UI elements.

Status

Value

Description

LOADING

'loading'

The connection status is currently being determined.

CONNECTED

'connected'

A valid connection to the DID Space is established.

DISCONNECTED

'disconnected'

Not connected to the DID Space.

UNAVAILABLE

'unavailable'

The space is unavailable due to subscription issues like expiration, overdue payments, or insufficient usage.


AuthorizeConnect#

This interface defines the properties for configuring the connection modal that appears when a user initiates a connection.

Property

Type

Description

open

boolean

Controls the visibility of the connection modal. true to show, false to hide.

action

string

A string identifying the type of action being requested (e.g., 'connect', 'login').

checkFn

Function

A function used to poll or check the status of the connection attempt.

messages

object

An object containing the text and content to display in the modal.

prefix

string (optional)

A URL prefix for constructing QR code URLs.

baseUrl

string (optional)

The base URL for the authentication service.

webWalletUrl

string (optional)

The URL for the web wallet to be used for authentication.

maxIdleTime

number (optional)

The maximum idle time in milliseconds before the session is considered expired.

checkTimeout

number (optional)

The timeout in milliseconds for the checkFn polling.

extraParams

Record<string, any> (optional)

An object containing any extra parameters to be passed during the authentication request.

Messages Object#

The messages object within AuthorizeConnect has the following structure:

Property

Type

Description

title

string

The title text displayed at the top of the modal.

scan

string

The instructional text for scanning the QR code.

confirm

string

The text shown while waiting for confirmation on the wallet.

success

React.ReactNode

The content (e.g., a component or string) displayed upon successful connection.


Authentication Options#

These interfaces provide a way to configure authentication callbacks and parameters for connection flows.

BaseAuthOptions#

This is the foundational interface for authentication options.

Property

Type

Description

action

string (optional)

Specifies the authentication action type.

checkFn

Function (optional)

A custom function to verify the authentication status.

extraParams

Record<string, string> (optional)

Additional parameters to include in the authentication request.

checkTimeout

number (optional)

Timeout in milliseconds for the checkFn.

onSuccess

(response: Record<string, string>, decrypt: Function) => Promise<void> (optional)

A callback function that executes upon successful authentication. It receives the response and a decrypt function.

onClose

() => void (optional)

A callback function that executes when the authentication modal is closed.

GatewayAuthOptions#

This interface extends BaseAuthOptions with properties specific to connecting to a particular DID Space gateway.

Property

Type

Description

spaceDid

string (optional)

The DID of the target DID Space.

spaceGatewayUrl

string (optional)

The URL of the target DID Space gateway.


Type Aliases#

For backward compatibility, the library provides the following type aliases:

  • SpaceGateway is an alias for DIDSpaceGateway.
  • SpaceStatus is an alias for DIDSpaceStatus.


With a clear understanding of these data types, you are now better equipped to implement the components. For practical examples and prop configurations, please see the documentation for DIDSpaceConnect and DIDSpaceConnection.