@sphereon/ssi-sdk.uni-resolver-registrar-api
Version:
162 lines (156 loc) • 6.38 kB
text/typescript
import { DIDDocument } from '@sphereon/did-uni-client';
import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
import { JsonWebKey } from '@sphereon/ssi-types';
import { IDataStoreORM, IDIDManager, IKeyManager, IResolver, IAgentContext, TAgent } from '@veramo/core';
import { VerificationMethod } from 'did-resolver';
import express, { Router, Express } from 'express';
type IRequiredPlugins = IDataStoreORM & IDIDManager & IKeyManager & IResolver;
type IRequiredContext = IAgentContext<IRequiredPlugins>;
interface DidRegistrationCreateRequest {
did?: string;
jobId: string;
options: DidRegistrationOptions;
secret: DidRegistrationSecret;
didDocument?: DIDDocument;
}
interface DidRegistrationUpdateRequest {
did: string;
jobId: string;
options: DidRegistrationOptions;
secret: DidRegistrationSecret;
didDocumentOperation: DidDocumentOperation[];
didDocument?: DIDDocument[];
}
interface DidRegistrationDeactivateRequest {
did: string;
jobId?: string;
options?: DidRegistrationOptions;
secret?: DidRegistrationSecret;
}
type DidDocumentOperation = 'setDidDocument' | 'addToDidDocument' | 'removeFromDidDocument' | string;
interface DidRegistrationOptions {
network?: string;
storeSecrets?: boolean;
returnSecrets?: boolean;
[x: string]: any;
}
interface DidRegistrationSecret {
seed?: string;
verificationMethod?: CreateVerificationMethod[];
[x: string]: any;
}
interface CreateVerificationMethod extends VerificationMethod {
privateKeyBase58?: string;
privateKeyBase64?: string;
privateKeyJwk?: JsonWebKey;
privateKeyHex?: string;
privateKeyMultibase?: string;
purpose?: ('authentication' | 'assertionMethod' | 'capabilityDelegation' | 'capabilityInvocation')[];
}
interface CreateState {
jobId: string;
didState: DidState;
didRegistrationMetadata?: Record<string, any>;
didDocumentMetadata?: Record<string, any>;
}
type DidStateValue = 'finished' | 'failed' | 'action' | 'wait' | 'exists';
type DidStateAction = 'redirect' | 'getVerificationMethod' | 'signPayload' | 'decryptPayload';
interface DidState {
state: DidStateValue;
action?: DidStateAction;
wait?: string;
waitTime?: number;
did: string;
secret?: DidRegistrationSecret;
didDocument?: DIDDocument;
}
interface IDidWebServiceOpts {
globalAuth?: GenericAuthArgs;
endpointOpts?: IGlobalDidWebEndpointOpts;
enableFeatures?: DidWebServiceFeatures[];
}
interface IDidAPIOpts {
endpointOpts?: IDidAPIEndpointOpts;
enableFeatures?: DidApiFeatures[];
}
interface IDidAPIEndpointOpts {
basePath?: string;
globalAuth?: GenericAuthArgs;
createDid?: ICreateDidEndpointOpts;
resolveDid?: IResolveEndpointOpts;
deactivateDid?: ISingleEndpointOpts;
getDidMethods?: ISingleEndpointOpts;
}
interface IGlobalDidWebEndpointOpts extends ISingleEndpointOpts {
hostname?: string;
disableWellKnown?: boolean;
disableSubPaths?: boolean;
}
interface ICreateDidEndpointOpts extends ISingleEndpointOpts {
kms?: string;
storeSecrets?: boolean;
noErrorOnExistingDid?: boolean;
defaultMethod?: string;
}
interface IResolveEndpointOpts extends ISingleEndpointOpts {
mode?: 'local' | 'hybrid' | 'global';
}
type DidWebServiceFeatures = 'did-web-global-resolution';
type DidApiFeatures = 'did-resolve' | 'did-persist';
declare function createDidEndpoint(router: Router, context: IRequiredContext, opts?: ICreateDidEndpointOpts): void;
declare function getDidMethodsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
declare function resolveDidEndpoint(router: Router, context: IRequiredContext, opts?: IResolveEndpointOpts): void;
/**
* @param router
* @param context
* @param opts
*/
declare function deleteDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
declare function deactivateDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
/**
* Endpoint that eases DID web resolution, by mapping did-web paths to stored agent DIDs.
*
* Typically, you will have a reverse proxy or load balancer in front of this endpoint.
*
* Some examples of how did:web behaves:
* did:web:example.com resolves to https://example.com/.well-known/did.json
* did:web:example.com:sub:paths resolves to https://example.com/sub/paths/did.json
*
* This endpoint translate both forms by looking at the paths that end in /did.json.
*
* @param router
* @param context
* @param opts
*/
declare function didWebDomainEndpoint(router: Router, context: IRequiredContext, opts?: IGlobalDidWebEndpointOpts): void;
declare class UniResolverApiServer {
get router(): express.Router;
private readonly _express;
private readonly _agent;
private readonly _opts?;
private readonly _router;
constructor(args: {
agent: TAgent<IRequiredPlugins>;
expressSupport: ExpressSupport;
opts?: IDidAPIOpts;
});
get agent(): TAgent<IRequiredPlugins>;
get opts(): IDidAPIOpts | undefined;
get express(): Express;
}
declare class DidWebServer {
get router(): express.Router | undefined;
private readonly _express;
private readonly _agent;
private readonly _opts?;
private readonly _router;
constructor(args: {
agent: TAgent<IRequiredPlugins>;
expressSupport: ExpressSupport;
opts?: IDidWebServiceOpts;
});
get agent(): TAgent<IRequiredPlugins> | undefined;
get opts(): IDidWebServiceOpts | undefined;
get express(): Express | undefined;
}
export { type CreateState, type CreateVerificationMethod, type DidApiFeatures, type DidDocumentOperation, type DidRegistrationCreateRequest, type DidRegistrationDeactivateRequest, type DidRegistrationOptions, type DidRegistrationSecret, type DidRegistrationUpdateRequest, type DidState, type DidStateAction, type DidStateValue, DidWebServer, type DidWebServiceFeatures, type ICreateDidEndpointOpts, type IDidAPIEndpointOpts, type IDidAPIOpts, type IDidWebServiceOpts, type IGlobalDidWebEndpointOpts, type IRequiredContext, type IRequiredPlugins, type IResolveEndpointOpts, UniResolverApiServer, createDidEndpoint, deactivateDidEndpoint, deleteDidEndpoint, didWebDomainEndpoint, getDidMethodsEndpoint, resolveDidEndpoint };