anon-identity
Version:
Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure
82 lines • 2.46 kB
TypeScript
import { VerifiablePresentation } from '../types';
import { VerificationError } from './verification-errors';
export interface AttributeConstraint {
name: string;
required: boolean;
expectedValue?: any;
allowedValues?: any[];
minValue?: number;
maxValue?: number;
pattern?: string;
}
export interface CredentialRequirement {
type: string[];
issuer?: string;
trustedIssuers?: string[];
attributes: AttributeConstraint[];
maxAge?: number;
}
export interface PresentationRequestOptions {
credentialRequirements: CredentialRequirement[];
purpose: string;
challenge?: string;
domain?: string;
expiresAt?: Date;
allowPartialMatch?: boolean;
}
export interface PresentationRequestObject {
id: string;
type: ['PresentationRequest'];
from: string;
purpose: string;
challenge: string;
domain?: string;
credentialRequirements: CredentialRequirement[];
createdAt: Date;
expiresAt?: Date;
allowPartialMatch: boolean;
}
export interface ValidationResult {
valid: boolean;
matchedRequirements: CredentialRequirement[];
unmatchedRequirements: CredentialRequirement[];
errors: VerificationError[];
score: number;
}
export declare class PresentationRequest {
private serviceProviderDID;
constructor(serviceProviderDID: string);
/**
* Create a presentation request with specific requirements
*/
createRequest(options: PresentationRequestOptions): Promise<PresentationRequestObject>;
/**
* Validate a presentation against a request
*/
validateAgainstRequest(presentation: VerifiablePresentation, request: PresentationRequestObject): Promise<ValidationResult>;
/**
* Create a simple request for specific credential types
*/
createSimpleRequest(credentialTypes: string[], purpose: string, requiredAttributes?: string[], optionalAttributes?: string[]): Promise<PresentationRequestObject>;
/**
* Validate challenge in presentation
*/
private validateChallenge;
/**
* Validate domain in presentation
*/
private validateDomain;
/**
* Find credentials that match a requirement
*/
private findMatchingCredentials;
/**
* Validate attributes against constraints
*/
private validateAttributes;
/**
* Generate a secure challenge
*/
private generateChallenge;
}
//# sourceMappingURL=presentation-request.d.ts.map