anon-identity
Version:
Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure
81 lines • 2.12 kB
TypeScript
import { VerificationResult } from './service-provider';
export interface Session {
id: string;
holderDID: string;
credentialIds: string[];
attributes: Record<string, any>;
createdAt: Date;
expiresAt: Date;
lastAccessedAt: Date;
metadata?: Record<string, any>;
}
export interface SessionValidation {
valid: boolean;
session?: Session;
reason?: string;
}
export interface SessionManagerOptions {
defaultSessionDuration?: number;
maxSessionDuration?: number;
cleanupInterval?: number;
}
export declare class SessionManager {
private sessions;
private credentialToSessions;
private cleanupTimer?;
private options;
constructor(options?: SessionManagerOptions);
/**
* Create a new session from a verification result
*/
createSession(verificationResult: VerificationResult, metadata?: Record<string, any>): Promise<Session>;
/**
* Validate an existing session
*/
validateSession(sessionId: string): Promise<SessionValidation>;
/**
* Revoke all sessions associated with a credential
*/
revokeSessions(credentialId: string): Promise<void>;
/**
* Set or update session expiry
*/
setSessionExpiry(sessionId: string, duration: number): Promise<void>;
/**
* Get session by ID
*/
getSession(sessionId: string): Session | undefined;
/**
* Get all active sessions
*/
getAllSessions(): Session[];
/**
* Get sessions by holder DID
*/
getSessionsByHolder(holderDID: string): Session[];
/**
* Manually remove a session
*/
removeSession(sessionId: string): void;
/**
* Clear all sessions
*/
clearAllSessions(): void;
/**
* Stop the cleanup timer
*/
destroy(): void;
/**
* Generate a secure session ID
*/
private generateSessionId;
/**
* Start the cleanup timer to remove expired sessions
*/
private startCleanupTimer;
/**
* Clean up expired sessions
*/
private cleanupExpiredSessions;
}
//# sourceMappingURL=session-manager.d.ts.map