@m-ld/gateway
Version:
m-ld gateway for services
59 lines (58 loc) • 2.55 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { AppPrincipal, Attribution, ConstructRemotes, InitialApp, MeldClone, MeldReadState, MeldTransportSecurity } from '@m-ld/m-ld';
import { AuthKey } from './AuthKey.js';
import { UserKey, UserKeyConfig } from '../data/UserKey.js';
import { SignOptions } from 'jsonwebtoken';
import { KeyObject } from 'crypto';
import { BaseGatewayConfig } from './BaseGateway.js';
import { AbstractLevel } from 'abstract-level';
import { Who } from '../server/index.js';
import { RemotesAuthType } from '../server/Account.js';
export type BackendLevel = AbstractLevel<unknown, string, unknown>;
export declare abstract class CloneFactory {
clone(config: BaseGatewayConfig, dataDir: string, principal?: GatewayPrincipal): Promise<[MeldClone, BackendLevel]>;
/**
* Async initialisation of the factory
* @param address gateway server address
*/
abstract initialise(address: string): void | Promise<unknown>;
/**
* @param {MeldConfig} config
* @returns {ConstructRemotes | Promise<ConstructRemotes>}
*/
abstract remotes(config: BaseGatewayConfig): ConstructRemotes | Promise<ConstructRemotes>;
/**
* @returns the subset of configuration that can be re-used by other engines
* cloning the same domains
*/
reusableConfig(config: BaseGatewayConfig, remotesAuth: RemotesAuthType[], who?: Who): Promise<Partial<BaseGatewayConfig>>;
}
export declare class GatewayPrincipal implements AppPrincipal {
readonly '@id': string;
readonly authKey: AuthKey;
readonly userKey: UserKey;
readonly signer?: {
signData(data: Buffer): Buffer;
signJwt(payload: string | Buffer | object, options?: SignOptions): Promise<string>;
getSignHttpArgs(): [string, KeyObject];
};
/**
* @param id absolute principal IRI
* @param config
*/
constructor(id: string, config: UserKeyConfig);
/** We do not implement sign, it's delegated to the userKey */
sign: undefined;
}
export declare class GatewayApp implements InitialApp {
readonly principal?: GatewayPrincipal | undefined;
readonly transportSecurity?: MeldTransportSecurity;
constructor(domain: string, principal?: GatewayPrincipal | undefined);
sign: (data: Buffer) => Attribution;
/**
* @param {string} domain name
* @returns import('@m-ld/m-ld').MeldTransportSecurity['verify']
*/
static verify(domain: string): (data: Uint8Array, attr: Attribution, state: MeldReadState) => Promise<void>;
}