import * as cedar from '@cedar-policy/cedar-wasm/nodejs'; import { MAY_CLAIM_IRI } from '@docknetwork/vc-delegation-engine'; export interface VerificationResult { verified: boolean; credentialResults?: any[]; delegationResult?: { decision: string; summaries?: any[]; authorizations?: any[]; failures?: any[]; }; error?: any; } export interface CedarPolicies { staticPolicies: string; } export interface VerifiablePresentation { '@context': any[]; type: string[]; proof?: any; verifiableCredential?: any[]; } export interface DelegationCredential { '@context': any[]; id: string; type: string[]; issuer: string; issuanceDate: string; previousCredentialId: string | null; rootCredentialId: string; credentialSubject: { id: string; [key: string]: any; }; proof?: any; } export interface VerifyDelegationOptions { challenge?: string; domain?: string; unsignedPresentation?: boolean; failOnUnauthorizedClaims?: boolean; policies?: CedarPolicies; } export interface KeyPair { type: string; id?: string; controller?: string; publicKeyJwk?: any; privateKeyJwk?: any; publicKeyBase58?: string; privateKeyBase58?: string; } /** * W3C Credentials V1 context URL */ export declare const W3C_CREDENTIALS_V1 = "https://www.w3.org/2018/credentials/v1"; /** * Re-export MAY_CLAIM_IRI for use in credentials */ export { MAY_CLAIM_IRI }; /** * Namespace used by the vc-delegation-engine for delegation properties */ export declare const DELEGATION_ENGINE_NS = "https://ld.truvera.io/credentials/delegation#"; /** * Base delegation context terms required for delegation credentials. * These terms define the JSON-LD mappings needed for the vc-delegation-engine * to properly process delegation chains. * * Use this as a base and extend with your own application-specific terms: * @example * const myContext = [ * W3C_CREDENTIALS_V1, * { * ...DELEGATION_CONTEXT_TERMS, * // Add your custom terms here * MyCredentialType: 'https://example.org/MyCredentialType', * myField: 'https://example.org/myField', * }, * ]; */ export declare const DELEGATION_CONTEXT_TERMS: { '@version': number; '@protected': boolean; DelegationCredential: string; mayClaim: { '@id': "https://rdf.dock.io/alpha/2021#mayClaim"; '@container': string; }; rootCredentialId: { '@id': string; '@type': string; }; previousCredentialId: { '@id': string; '@type': string; }; }; /** * Default context for verifiable presentations */ export declare const PRESENTATION_CONTEXT: string[]; /** * Issues a delegation credential that grants authority to a delegate * @param keyPair - The key pair to sign the credential * @param params - Delegation parameters * @returns Signed delegation credential */ export declare function issueDelegationCredential(keyPair: KeyPair, credential: any): Promise; /** * Issues a credential as a delegate (with delegation chain reference) * @param keyPair - The delegate's key pair to sign the credential * @param params - Credential parameters * @returns Signed credential */ export declare function issueDelegatedCredential(keyPair: KeyPair, credential: any): Promise; /** * Creates and signs a verifiable presentation with delegation credentials * @param keyPair - The key pair to sign the presentation * @param params - Presentation parameters * @returns Signed verifiable presentation */ export declare function createSignedPresentation(keyPair: KeyPair, params: { credentials: any[]; holderDid: string; challenge: string; domain: string; context?: any[]; }): Promise; /** * Verifies a verifiable presentation with optional delegation chain validation * Uses the credential-sdk's verifyPresentation which automatically: * 1. Verifies the presentation signature * 2. Verifies all credentials * 3. Detects delegation credentials * 4. Validates the delegation chain * 5. Applies Cedar policies if provided * * @param vp - The verifiable presentation to verify * @param options - Verification options * @returns Verification result with delegation info if applicable */ export declare function verifyDelegatablePresentation(vp: VerifiablePresentation, options?: VerifyDelegationOptions): Promise; /** * Creates a Cedar policy for delegation verification * @param config - Policy configuration * @returns Cedar policy object */ export declare function createCedarPolicy(config: { maxDepth?: number; rootIssuer: string; requiredClaims?: Record; }): CedarPolicies; /** * Creates an unsigned verifiable presentation (for testing) * @param credentials - Array of credentials to include * @param proof - Optional proof object * @param context - Optional context * @returns Verifiable presentation object */ export declare function createUnsignedPresentation(credentials: any[], proof?: any, context?: any[]): VerifiablePresentation; /** * Re-export cedar for use in tests and external code */ export { cedar }; /** * Service class for delegatable credentials operations */ declare class DelegatableCredentialsService { name: string; rpcMethods: (((params: { keyPair: KeyPair; id: string; issuerDid: string; delegateDid: string; mayClaim: string[]; context: any[]; types: string[]; additionalSubjectProperties?: Record; previousCredentialId?: string | null; rootCredentialId?: string; }) => Promise) | ((params: { keyPair: KeyPair; id: string; issuerDid: string; subjectDid: string; claims: Record; rootCredentialId: string; previousCredentialId: string; context: any[]; types: string[]; }) => Promise) | ((params: { keyPair: KeyPair; credentials: any[]; holderDid: string; challenge: string; domain: string; context?: any[]; }) => Promise) | ((params: { presentation: VerifiablePresentation; challenge?: string; domain?: string; unsignedPresentation?: boolean; failOnUnauthorizedClaims?: boolean; policies?: CedarPolicies; }) => Promise) | ((params: { maxDepth?: number; rootIssuer: string; requiredClaims?: Record; }) => CedarPolicies))[]; /** * Issues a delegation credential */ issueDelegation(params: { keyPair: KeyPair; id: string; issuerDid: string; delegateDid: string; mayClaim: string[]; context: any[]; types: string[]; additionalSubjectProperties?: Record; previousCredentialId?: string | null; rootCredentialId?: string; }): Promise; /** * Issues a credential as a delegate */ issueDelegatedCredential(params: { keyPair: KeyPair; id: string; issuerDid: string; subjectDid: string; claims: Record; rootCredentialId: string; previousCredentialId: string; context: any[]; types: string[]; }): Promise; /** * Creates and signs a verifiable presentation */ createPresentation(params: { keyPair: KeyPair; credentials: any[]; holderDid: string; challenge: string; domain: string; context?: any[]; }): Promise; /** * Verifies a verifiable presentation with delegation chain */ verifyPresentation(params: { presentation: VerifiablePresentation; challenge?: string; domain?: string; unsignedPresentation?: boolean; failOnUnauthorizedClaims?: boolean; policies?: CedarPolicies; }): Promise; /** * Creates a Cedar policy for delegation verification */ createPolicy(params: { maxDepth?: number; rootIssuer: string; requiredClaims?: Record; }): CedarPolicies; } export declare const delegatableCredentialsService: DelegatableCredentialsService; //# sourceMappingURL=delegatable-credentials.d.ts.map