import type { DidResolver } from '@enbox/dids'; import type { DwnServerConfig } from './config.js'; import type { LocalNodePairingManager } from './local-node-pairing.js'; import type { MessageProcessedHook } from './message-processed-hook.js'; import type { ProcessHandlers } from './process-handlers.js'; import type { Server } from 'bun'; import type { WsData } from './http-api.js'; import { Dwn } from '@enbox/dwn-sdk-js'; import { OpenAuthHandler } from './registration/open-auth-handler.js'; import { RegistrationManager } from './registration/registration-manager.js'; /** * Options for the DwnServer constructor. * This is different to DwnServerConfig in that the DwnServerConfig defines configuration that come from environment variables so (more) user facing. * Where as DwnServerOptions wraps DwnServerConfig with additional overrides that can be used for testing. */ export type DwnServerOptions = { /** * A custom DID resolver to use in the DWN. * Mainly for testing purposes. Ignored if `dwn` is provided. */ didResolver?: DidResolver; dwn?: Dwn; config?: DwnServerConfig; /** * Hooks invoked after every `dwn.processMessage()` call. * The built-in DeliveryService hook is always prepended automatically * when forwarding or delivery is enabled. Additional hooks provided here * are appended after the DeliveryService hook. */ messageProcessedHooks?: MessageProcessedHook[]; /** * An externally created RegistrationManager to use as the tenant gate and * registration endpoint handler. When a pre-built `dwn` is provided, the * server cannot create its own RegistrationManager (because it doesn't * control the DWN's TenantGate). Pass one here to enable registration * endpoints (`POST /registration`, etc.) with a pre-built DWN. */ registrationManager?: RegistrationManager; /** * An externally created OpenAuthHandler for the built-in provider-auth * endpoints (`/provider-auth/authorize`, `/provider-auth/token`, * `/provider-auth/refresh`). When a pre-built `dwn` is provided, the * server skips creating this handler. Pass one here to enable the * open-auth flow with a pre-built DWN. */ openAuthHandler?: OpenAuthHandler; /** * Pairing/session manager used by the local-node profile. * Shell-specific wrappers use this to approve or deny pairing requests. */ localNodePairingManager?: LocalNodePairingManager; }; /** * State of the DwnServer, either Stopped or Started, to help short-circuit start and stop logic. */ declare enum DwnServerState { Stopped = 0, Started = 1 } export declare class DwnServer { #private; serverState: DwnServerState; processHandlers: ProcessHandlers; /** * A custom DID resolver to use in the DWN. * Mainly for testing purposes. Ignored if `dwn` is provided. */ didResolver?: DidResolver; dwn?: Dwn; config: DwnServerConfig; /** * @param options.dwn - Dwn instance to use as an override. * @param options.registrationManager - External RegistrationManager to use with a pre-built DWN. * @param options.openAuthHandler - External OpenAuthHandler to use with a pre-built DWN. */ constructor(options?: DwnServerOptions); /** * Starts the DWN server. */ start(): Promise; /** * Stops the DWN server. */ stop(): Promise; get httpServer(): Server; get localNodePairingManager(): LocalNodePairingManager; /** * Revokes a local-node pairing token and immediately closes any live WebSocket connections authenticated by it. */ revokeLocalNodePairingToken(token: string): Promise; /** * Gets the RegistrationManager for testing purposes. */ get registrationManager(): RegistrationManager; } export {}; //# sourceMappingURL=dwn-server.d.ts.map