di-wings
Version:
Aviary Tech's common library for decentralized identity
91 lines • 3.65 kB
TypeScript
import type { WorkflowConfig, ExchangeRequest, ExchangeResponse, ExchangeStateUpdate, IWorkflow, IExchange } from './types';
import type { IWorkflowRepository, IExchangeRepository } from './repositories';
import type { PrivateVerificationMethod, VerifiablePresentation } from '../common/interfaces';
export interface WorkflowServiceConfig {
workflowRepository: IWorkflowRepository;
exchangeRepository: IExchangeRepository;
verificationMethods?: PrivateVerificationMethod[];
defaultVerificationMethodId?: string;
}
/**
* WorkflowService implements the VC-API Workflow Service specification
* @see https://w3c-ccg.github.io/vc-api/#workflow-service
*/
export declare class WorkflowService {
private config;
constructor(config: WorkflowServiceConfig);
/**
* Gets all workflows (admin access)
*/
getAllWorkflows(): Promise<IWorkflow[]>;
/**
* Gets workflows for a specific user
*/
getUserWorkflows(userId: string): Promise<IWorkflow[]>;
/**
* Creates a new workflow instance
* @see https://w3c-ccg.github.io/vc-api/#create-workflow
*/
createWorkflow(config: WorkflowConfig, userId: string): Promise<IWorkflow>;
private validateWorkflowConfig;
/**
* Creates a new exchange for a workflow
* @see https://w3c-ccg.github.io/vc-api/#create-exchange
*/
createExchange(workflowId: string, ttl?: string, variables?: Record<string, any>[]): Promise<IExchange>;
/**
* Handles participation in an exchange
* @see https://w3c-ccg.github.io/vc-api/#participate-in-an-exchange
*/
participateInExchange(workflowId: string, exchangeId: string, exchangeData?: ExchangeRequest): Promise<{
response: ExchangeResponse;
stateUpdate: ExchangeStateUpdate;
}>;
private handleEmptyRequest;
private evaluateTemplate;
private getTemplateVariables;
private updateExchangeVariables;
private handleVerifiablePresentation;
getWorkflow(workflowId: string): Promise<IWorkflow>;
getExchange(workflowId: string, exchangeId: string): Promise<IExchange>;
validateVerifiablePresentation(vp: VerifiablePresentation): Promise<void>;
private validStateTransitions;
private validateStateTransition;
updateExchangeState(workflowId: string, exchangeId: string, update: ExchangeStateUpdate): Promise<void>;
private handleCredentialIssuance;
private handleVerifiablePresentationRequest;
/**
* Deletes a workflow by ID
*/
deleteWorkflow(workflowId: string): Promise<IWorkflow | null>;
private evaluateJSONata;
/**
* Get verification method for signing credentials
* @param criteria Selection criteria for choosing the verification method
* @returns PrivateVerificationMethod
*/
private getVerificationMethod;
/**
* Get all available verification methods
* @returns Array of verification method summaries
*/
getAvailableVerificationMethods(): Array<{
id: string;
controller: string;
type: string;
purpose?: string[];
}>;
/**
* Issue a credential with specified or automatically selected verification method
* @param credential The credential to sign
* @param options Issuance options including verification method selection
* @returns Promise<VerifiableCredential>
*/
issueCredential(credential: any, options?: {
verificationMethodId?: string;
issuerDid?: string;
proofPurpose?: string;
}): Promise<any>;
getWorkflowExchanges(workflowId: string): Promise<IExchange[]>;
}
//# sourceMappingURL=WorkflowService.d.ts.map