import { Signer } from "@owf/crypto"; import { z } from "zod"; import { IdentityException } from "@owf/identity-common"; //#region src/entitlements.d.ts /** * All standard WRP entitlements defined in ETSI TS 119 475 */ declare const WRP_ENTITLEMENTS: { readonly SERVICE_PROVIDER: "https://uri.etsi.org/19475/Entitlement/Service_Provider"; readonly QEAA_PROVIDER: "https://uri.etsi.org/19475/Entitlement/QEAA_Provider"; readonly NON_Q_EAA_PROVIDER: "https://uri.etsi.org/19475/Entitlement/Non_Q_EAA_Provider"; readonly PUB_EAA_PROVIDER: "https://uri.etsi.org/19475/Entitlement/PUB_EAA_Provider"; readonly PID_PROVIDER: "https://uri.etsi.org/19475/Entitlement/PID_Provider"; readonly QCERT_FOR_ESEAL_PROVIDER: "https://uri.etsi.org/19475/Entitlement/QCert_for_ESeal_Provider"; readonly QCERT_FOR_ESIG_PROVIDER: "https://uri.etsi.org/19475/Entitlement/QCert_for_ESig_Provider"; readonly RQSEALCDS_PROVIDER: "https://uri.etsi.org/19475/Entitlement/rQSealCDs_Provider"; readonly RQSIGCDS_PROVIDER: "https://uri.etsi.org/19475/Entitlement/rQSigCDs_Provider"; readonly ESIG_ESEAL_CREATION_PROVIDER: "https://uri.etsi.org/19475/Entitlement/ESig_ESeal_Creation_Provider"; }; /** * Payment Service Provider Sub-entitlements (A.3.1) * As defined in ETSI TS 119 495 */ declare const PSP_SUB_ENTITLEMENTS: { /** Account Servicing Payment Service Provider */ readonly ACCOUNT_SERVICING: "https://uri.etsi.org/19475/SubEntitlement/psp/psp-as"; /** Payment Initiation Service Provider */ readonly PAYMENT_INITIATION: "https://uri.etsi.org/19475/SubEntitlement/psp/psp-pi"; /** Account Information Service Provider */ readonly ACCOUNT_INFORMATION: "https://uri.etsi.org/19475/SubEntitlement/psp/psp-ai"; /** Payment Service Provider issuing card-based payment instruments */ readonly CARD_BASED: "https://uri.etsi.org/19475/SubEntitlement/psp/psp-ic"; /** Unspecified Payment Service Provider */ readonly UNSPECIFIED: "https://uri.etsi.org/19475/SubEntitlement/psp/unspecified"; }; /** * Identifier type URIs for legal person semantic identifiers */ declare const IDENTIFIER_TYPES: { /** Economic Operator Registration and Identification Number (EORI-No) */ readonly EORI: "http://data.europa.eu/eudi/id/EORI-No"; /** Legal Entity Identifier (LEI) */ readonly LEI: "http://data.europa.eu/eudi/id/LEI"; /** European Unique Identifier (EUID) */ readonly EUID: "http://data.europa.eu/eudi/id/EUID"; /** Value Added Tax Identification Number (VATIN) */ readonly VATIN: "http://data.europa.eu/eudi/id/VATIN"; /** Taxpayer Identification Number (TIN) */ readonly TIN: "http://data.europa.eu/eudi/id/TIN"; /** Excise Number */ readonly EXCISE: "http://data.europa.eu/eudi/id/Excise"; }; /** * Check if a given URI is a valid WRP entitlement */ declare function isValidEntitlement(uri: string): boolean; /** * Check if a given URI is a PSP sub-entitlement */ declare function isPSPSubEntitlement(uri: string): boolean; /** * Check if entitlements include an attestation provider role */ declare function hasAttestationProviderEntitlement(entitlements: string[]): boolean; //#endregion //#region src/schemas.d.ts /** * Multilingual string schema (B.2.6 Class MultiLangString) */ declare const MultiLangStringSchema: z.ZodObject<{ lang: z.ZodString; value: z.ZodString; }, z.core.$strip>; /** * Supervisory Authority schema for Data Protection Authority */ declare const SupervisoryAuthoritySchema: z.ZodObject<{ email: z.ZodOptional; phone: z.ZodOptional; uri: z.ZodOptional; }, z.core.$strip>; /** * Claim schema for credential attribute specification (B.2.10 Class Claim) */ declare const ClaimSchema: z.ZodObject<{ path: z.ZodArray; values: z.ZodOptional>>; }, z.core.$strip>; /** * Credential schema for attestations (B.2.9 Class Credential) */ declare const CredentialSchema: z.ZodObject<{ format: z.ZodString; meta: z.ZodRecord; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>; /** * Status schema for WRPRC validity */ declare const StatusSchema: z.ZodObject<{ status_list: z.ZodObject<{ idx: z.ZodNumber; uri: z.ZodURL; }, z.core.$strip>; }, z.core.$strip>; /** * Intermediary information when WRP acts through an intermediary */ declare const IntermediarySchema: z.ZodObject<{ sub: z.ZodString; name: z.ZodString; }, z.core.$strip>; /** * WRPRC Payload schema according to ETSI TS 119 475 clause 5.2.4 */ declare const WRPRCPayloadSchema: z.ZodObject<{ name: z.ZodString; sub_ln: z.ZodOptional; sub_gn: z.ZodOptional; sub_fn: z.ZodOptional; sub: z.ZodString; country: z.ZodString; registry_uri: z.ZodURL; srv_description: z.ZodOptional>>>; entitlements: z.ZodArray; privacy_policy: z.ZodOptional; info_uri: z.ZodOptional; support_uri: z.ZodOptional>; supervisory_authority: z.ZodOptional; phone: z.ZodOptional; uri: z.ZodOptional; }, z.core.$strip>>; policy_id: z.ZodOptional>; certificate_policy: z.ZodOptional; status: z.ZodOptional; }, z.core.$strip>>; purpose: z.ZodOptional>>; credentials: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>>; provides_attestations: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>, z.ZodArray]>>; intermediary: z.ZodOptional>; }, z.core.$strip>; /** * JWT Header schema according to ETSI TS 119 475 clause 5.2.2 */ declare const WRPRCJWTHeaderSchema: z.ZodObject<{ typ: z.ZodLiteral<"rc-wrp+jwt">; alg: z.ZodEnum<{ ES256: "ES256"; ES384: "ES384"; ES512: "ES512"; RS256: "RS256"; RS384: "RS384"; RS512: "RS512"; }>; x5c: z.ZodArray; kid: z.ZodOptional; iat: z.ZodNumber; }, z.core.$strip>; /** * CWT Header schema according to ETSI TS 119 475 clause 5.2.3 */ declare const WRPRCCWTHeaderSchema: z.ZodObject<{ typ: z.ZodLiteral<"rc-wrp+cwt">; alg: z.ZodNumber; x5chain: z.ZodArray, Uint8Array>>; iat: z.ZodNumber; }, z.core.$strip>; /** * Schema for legal person WRPRC subject */ declare const LegalPersonSubjectSchema: z.ZodObject<{ sub: z.ZodString; name: z.ZodString; sub_ln: z.ZodString; country: z.ZodString; registry_uri: z.ZodURL; srv_description: z.ZodOptional>>>; entitlements: z.ZodArray; privacy_policy: z.ZodOptional; info_uri: z.ZodOptional; support_uri: z.ZodOptional>; supervisory_authority: z.ZodOptional; phone: z.ZodOptional; uri: z.ZodOptional; }, z.core.$strip>>; policy_id: z.ZodOptional>; certificate_policy: z.ZodOptional; status: z.ZodOptional; }, z.core.$strip>>; purpose: z.ZodOptional>>; credentials: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>>; provides_attestations: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>, z.ZodArray]>>; intermediary: z.ZodOptional>; }, z.core.$strip>; /** * Schema for natural person WRPRC subject */ declare const NaturalPersonSubjectSchema: z.ZodObject<{ sub: z.ZodString; name: z.ZodString; sub_gn: z.ZodString; sub_fn: z.ZodString; country: z.ZodString; registry_uri: z.ZodURL; srv_description: z.ZodOptional>>>; entitlements: z.ZodArray; privacy_policy: z.ZodOptional; info_uri: z.ZodOptional; support_uri: z.ZodOptional>; supervisory_authority: z.ZodOptional; phone: z.ZodOptional; uri: z.ZodOptional; }, z.core.$strip>>; policy_id: z.ZodOptional>; certificate_policy: z.ZodOptional; status: z.ZodOptional; }, z.core.$strip>>; purpose: z.ZodOptional>>; credentials: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>>; provides_attestations: z.ZodOptional; claim: z.ZodOptional; values: z.ZodOptional>>; }, z.core.$strip>>>; }, z.core.$strip>>, z.ZodArray]>>; intermediary: z.ZodOptional>; }, z.core.$strip>; //#endregion //#region src/types.d.ts /** Multilingual string with language tag (B.2.6 Class MultiLangString) */ type MultiLangString = z.infer; /** Supervisory Authority (Data Protection Authority) */ type SupervisoryAuthority = z.infer; /** Claim specification for credential attributes (B.2.10 Class Claim) */ type Claim = z.infer; /** Credential specification for attestations (B.2.9 Class Credential) */ type Credential = z.infer; /** Status reference for WRPRC validity */ type Status = z.infer; /** Intermediary information */ type Intermediary = z.infer; /** WRPRC Payload */ type WRPRCPayload = z.infer; /** Legal person subject payload */ type LegalPersonSubject = z.infer; /** Natural person subject payload */ type NaturalPersonSubject = z.infer; /** JWT Header for WRPRC */ type WRPRCJWTHeader = z.infer; /** CWT Header for WRPRC */ type WRPRCCWTHeader = z.infer; /** Signed JWT WRPRC (compact JWS format) */ interface SignedWRPRC { /** The compact JWS string */ jws: string; /** Decoded header */ header: WRPRCJWTHeader; /** Decoded payload */ payload: WRPRCPayload; } /** Options for signing a WRPRC */ interface SignOptions { /** The WRPRC payload to sign */ payload: WRPRCPayload; /** Algorithm (default: ES256) */ algorithm?: 'ES256' | 'ES384' | 'ES512' | 'RS256' | 'RS384' | 'RS512'; /** PEM-encoded certificates for x5c header (each element is a single PEM certificate) */ certificates: string[]; /** Key ID (optional) */ keyId?: string; /** Signer function for signing the JWS */ signer: Signer; } /** Input for creating a legal person WRPRC */ interface LegalPersonWRPRCInput { /** Trade name (for display) */ name: string; /** Legal name of the organization */ legalName: string; /** Semantic identifier (e.g., "LEIXG-529900T8BM49AURSDO55") */ identifier: string; /** Country code (ISO 3166-1 Alpha-2) */ country: string; /** URL to the national registry API endpoint */ registryUri: string; /** List of entitlement URIs */ entitlements: string[]; } /** Input for creating a natural person WRPRC */ interface NaturalPersonWRPRCInput { /** Trade name (for display) */ name: string; /** Given name(s) */ givenName: string; /** Family name */ familyName: string; /** Semantic identifier (e.g., "TINIT-RSSMRA85T10A562S") */ identifier: string; /** Country code (ISO 3166-1 Alpha-2) */ country: string; /** URL to the national registry API endpoint */ registryUri: string; /** List of entitlement URIs */ entitlements: string[]; } //#endregion //#region src/builders.d.ts /** * Builder for creating WRPRC payloads with a fluent API */ declare class WRPRCBuilder { private payload; /** * Set the trade name (display name) of the WRP */ name(value: string): this; /** * Set the legal name for a legal person WRP */ legalName(value: string): this; /** * Set the given name for a natural person WRP */ givenName(value: string): this; /** * Set the family name for a natural person WRP */ familyName(value: string): this; /** * Set the WRP identifier (semantic identifier) * * @param identifier - The semantic identifier following ETSI EN 319 412-1 * Format: PREFIX (3 chars) + COUNTRY (2 chars) + "-" + ID * Examples: "LEIXG-529900T8BM49AURSDO55", "TINIT-RSSMRA85T10A562S" */ identifier(identifier: string): this; /** * Set the country code (ISO 3166-1 Alpha-2) */ country(code: string): this; /** * Set the URL to the national registry API endpoint */ registryUri(uri: string): this; /** * Add a service description in a specific language */ serviceDescription(description: string, lang?: string): this; /** * Add multiple service descriptions (one array per service, with multiple languages) */ addServiceDescriptions(descriptions: MultiLangString[]): this; /** * Add an entitlement * * @param entitlement - The entitlement URI or key from WRP_ENTITLEMENTS */ addEntitlement(entitlement: string | (typeof WRP_ENTITLEMENTS)[keyof typeof WRP_ENTITLEMENTS]): this; /** * Set all entitlements (replaces existing) */ entitlements(entitlements: string[]): this; /** * Set the privacy policy URL */ privacyPolicy(uri: string): this; /** * Set the info URI (general-purpose web address) */ infoUri(uri: string): this; /** * Set the support URI for data requests */ supportUri(uri: string): this; /** * Set the supervisory authority (Data Protection Authority) */ supervisoryAuthority(authority: SupervisoryAuthority): this; /** * Set the policy ID(s) */ policyId(ids: string[]): this; /** * Set the certificate policy URL */ certificatePolicy(uri: string): this; /** * Set the issued-at timestamp (Unix timestamp) * If not set, will default to current time when building */ issuedAt(timestamp: number | Date): this; /** * Set the status reference for certificate validity */ status(status: Status): this; /** * Add a purpose description */ addPurpose(description: string, lang?: string): this; /** * Set all purposes (replaces existing) */ purposes(purposes: MultiLangString[]): this; /** * Add a credential that the WRP intends to request */ addCredential(credential: Credential): this; /** * Add a provided attestation as either a credential object or schema metadata string. * * The final payload must use one format consistently: all credentials or all strings. */ addProvidedAttestation(attestation: Credential | string): this; /** * Set intermediary information */ intermediary(intermediary: Intermediary): this; /** * Build the WRPRC payload * * @throws WRPRCException if the payload is invalid */ build(): WRPRCPayload; } /** * Builder for creating Credential objects */ declare class CredentialBuilder { private credential; /** * Set the credential format * * @param format - The format identifier (e.g., "dc+sd-jwt", "mso_mdoc") */ format(format: string): this; /** * Set the credential metadata * * @param meta - Metadata object per credential format specification */ meta(meta: Record): this; /** * Set SD-JWT credential metadata (vct_values) */ sdJwtMeta(vctValues: string[]): this; /** * Set mDL/mDoc credential metadata (doctype_value) */ mdocMeta(doctypeValue: string): this; /** * Add a claim to request */ addClaim(claim: Claim): this; /** * Add a simple path claim */ addPathClaim(...path: string[]): this; /** * Build the Credential object */ build(): Credential; } /** * Create a new WRPRCBuilder */ declare function wrprc(): WRPRCBuilder; /** * Create a new CredentialBuilder */ declare function credential(): CredentialBuilder; /** * Create a WRPRC payload for a legal person */ declare function createLegalPersonWRPRC(input: LegalPersonWRPRCInput): WRPRCPayload; /** * Create a WRPRC payload for a natural person */ declare function createNaturalPersonWRPRC(input: NaturalPersonWRPRCInput): WRPRCPayload; /** * Create a simple service provider WRPRC */ declare function createServiceProviderWRPRC(name: string, legalName: string, identifier: string, country: string, registryUri: string): WRPRCPayload; //#endregion //#region src/signer.d.ts /** * Sign a WRPRC payload to create a JWT * * @param options - Signing options including payload, algorithm, certificates, and signer * @returns Signed WRPRC with JWS string and decoded parts */ declare function signWRPRC(options: SignOptions): Promise; /** * Decode a signed WRPRC JWT (without verification) * * @param jws - The compact JWS string * @returns Decoded WRPRC with header and payload */ declare function decodeWRPRC(jws: string): SignedWRPRC; /** * Parse a WRPRC JWT without validation (for inspection purposes) * * @param jws - The compact JWS string * @returns Decoded parts without validation */ declare function parseWRPRC(jws: string): { header: unknown; payload: unknown; signature: string; }; /** * Create a WRPRC with automatic timestamp * * @param payload - Partial payload (iat will be set automatically if not provided) * @returns Complete payload with timestamp */ declare function createWRPRCPayload(payload: WRPRCPayload): WRPRCPayload; //#endregion //#region src/validator.d.ts /** * A single validation error */ interface ValidationError { /** Path to the invalid field */ path: string[]; /** Error message */ message: string; /** Error code */ code: string; } /** * Result of WRPRC validation */ interface ValidationResult { /** Whether the WRPRC is valid */ valid: boolean; /** List of validation errors (empty if valid) */ errors: ValidationError[]; /** Warnings that don't invalidate the certificate but should be noted */ warnings: ValidationError[]; } /** * Validate a WRPRC payload against the schema */ declare function validateWRPRCPayload(payload: unknown): ValidationResult; /** * Validate a JWT header for WRPRC */ declare function validateWRPRCJWTHeader(header: unknown): ValidationResult; /** * Validate a complete WRPRC (header + payload) */ declare function validateWRPRC(header: unknown, payload: unknown): ValidationResult; /** * Check if payload represents a legal person */ declare function isLegalPersonWRPRC(payload: WRPRCPayload): boolean; /** * Check if payload represents a natural person */ declare function isNaturalPersonWRPRC(payload: WRPRCPayload): boolean; /** * Validate as legal person WRPRC */ declare function validateLegalPersonWRPRC(payload: unknown): ValidationResult; /** * Validate as natural person WRPRC */ declare function validateNaturalPersonWRPRC(payload: unknown): ValidationResult; /** * Assert that a WRPRC payload is valid, throws WRPRCException if not */ declare function assertValidWRPRCPayload(payload: unknown): asserts payload is WRPRCPayload; /** * Assert that a WRPRC is valid (header + payload), throws WRPRCException if not */ declare function assertValidWRPRC(header: unknown, payload: unknown): void; //#endregion //#region src/wrprc-exception.d.ts /** * WRPRCException is a custom error class for WRPRC-related exceptions. */ declare class WRPRCException extends IdentityException { constructor(message: string, details?: unknown); } //#endregion export { type Claim, ClaimSchema, type Credential, CredentialBuilder, CredentialSchema, IDENTIFIER_TYPES, type Intermediary, IntermediarySchema, type LegalPersonSubject, LegalPersonSubjectSchema, type LegalPersonWRPRCInput, type MultiLangString, MultiLangStringSchema, type NaturalPersonSubject, NaturalPersonSubjectSchema, type NaturalPersonWRPRCInput, PSP_SUB_ENTITLEMENTS, type SignOptions, type SignedWRPRC, type Status, StatusSchema, type SupervisoryAuthority, SupervisoryAuthoritySchema, WRPRCBuilder, type WRPRCCWTHeader, WRPRCCWTHeaderSchema, WRPRCException, type WRPRCJWTHeader, WRPRCJWTHeaderSchema, type WRPRCPayload, WRPRCPayloadSchema, WRP_ENTITLEMENTS, assertValidWRPRC, assertValidWRPRCPayload, createLegalPersonWRPRC, createNaturalPersonWRPRC, createServiceProviderWRPRC, createWRPRCPayload, credential, decodeWRPRC, hasAttestationProviderEntitlement, isLegalPersonWRPRC, isNaturalPersonWRPRC, isPSPSubEntitlement, isValidEntitlement, parseWRPRC, signWRPRC, validateLegalPersonWRPRC, validateNaturalPersonWRPRC, validateWRPRC, validateWRPRCJWTHeader, validateWRPRCPayload, wrprc }; //# sourceMappingURL=index.d.cts.map