@owf/eudi-jades 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -0
- package/dist/index.d.mts +1001 -0
- package/dist/index.mjs +924 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/constants.ts","../src/jades-exception.ts","../src/schemas.ts","../src/utils.ts","../src/token.ts","../src/verifier.ts"],"sourcesContent":["/**\n * JAdES Constants\n *\n * Algorithm definitions and OIDs as per ETSI TS 119 182-1.\n */\n\n/**\n * Supported signature algorithms with their hash algorithms.\n */\nexport const ALGORITHMS = {\n // RSA PKCS#1 v1.5\n RS256: { hash: 'SHA-256', family: 'RSA' },\n RS384: { hash: 'SHA-384', family: 'RSA' },\n RS512: { hash: 'SHA-512', family: 'RSA' },\n\n // RSA-PSS\n PS256: { hash: 'SHA-256', family: 'RSA-PSS' },\n PS384: { hash: 'SHA-384', family: 'RSA-PSS' },\n PS512: { hash: 'SHA-512', family: 'RSA-PSS' },\n\n // ECDSA\n ES256: { hash: 'SHA-256', family: 'ECDSA', namedCurve: 'P-256' },\n ES384: { hash: 'SHA-384', family: 'ECDSA', namedCurve: 'P-384' },\n ES512: { hash: 'SHA-512', family: 'ECDSA', namedCurve: 'P-521' },\n} as const\n\n/**\n * Commitment type OIDs as per RFC 5035.\n */\nexport enum CommitmentOIDs {\n /** Proof of origin */\n proofOfOrigin = '1.2.840.113549.1.9.16.6.1',\n /** Proof of receipt */\n proofOfReceipt = '1.2.840.113549.1.9.16.6.2',\n /** Proof of delivery */\n proofOfDelivery = '1.2.840.113549.1.9.16.6.3',\n /** Proof of sender */\n proofOfSender = '1.2.840.113549.1.9.16.6.4',\n /** Proof of approval */\n proofOfApproval = '1.2.840.113549.1.9.16.6.5',\n /** Proof of creation */\n proofOfCreation = '1.2.840.113549.1.9.16.6.6',\n}\n\n/**\n * JAdES baseline profiles as per ETSI TS 119 182-1.\n */\nexport enum JAdESProfile {\n /** Basic - Baseline: basic signature format */\n B_B = 'B-B',\n /** Basic with Time: signatures with timestamp */\n B_T = 'B-T',\n /** Basic Long-Term: signatures with validation data for long-term preservation */\n B_LT = 'B-LT',\n /** Basic Long-Term with Archive timestamps */\n B_LTA = 'B-LTA',\n}\n\n/**\n * Detached signature mechanism identifiers as per ETSI TS 119 182-1 Section 5.2.8.\n */\nexport const DETACHED_MECHANISM_IDS = {\n /** HTTP Headers mechanism */\n httpHeaders: 'http://uri.etsi.org/19182/HttpHeaders',\n /** Object digest mechanism */\n objectDigest: 'http://uri.etsi.org/19182/ObjectIdByURIHash',\n} as const\n\n/**\n * Critical header parameters that must be understood.\n * ETSI TS 119 182-1 specifies these parameters as critical.\n */\nexport const CRITICAL_PARAMETERS = [\n 'x5t#o',\n 'sigX5ts',\n 'sigT',\n 'sigD',\n 'sigPl',\n 'sigPId',\n 'srCms',\n 'srAts',\n 'adoTst',\n 'b64',\n] as const\n","/**\n * JAdES Exception\n *\n * Custom exception for JAdES-related errors.\n */\n\nexport class JAdESException extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'JAdESException'\n Object.setPrototypeOf(this, JAdESException.prototype)\n }\n}\n","/**\n * JAdES Zod Schemas\n *\n * Zod schemas for JAdES (JSON Advanced Electronic Signatures) as per ETSI TS 119 182-1.\n * Types are derived from these schemas via z.infer<>.\n *\n * @see https://www.etsi.org/deliver/etsi_ts/119100_119199/11918201/01.02.01_60/ts_11918201v010201p.pdf\n */\n\nimport { z } from 'zod'\nimport { ALGORITHMS } from './constants'\n\n// ============================================================================\n// Algorithm Schema\n// ============================================================================\n\n/**\n * Supported signature algorithms.\n */\nexport const SignAlgSchema = z.enum([\n 'ES256',\n 'ES384',\n 'ES512',\n 'RS256',\n 'RS384',\n 'RS512',\n 'PS256',\n 'PS384',\n 'PS512',\n])\n\n// ============================================================================\n// X.509 Certificate Schemas\n// ============================================================================\n\n/**\n * X.509 Certificate Thumbprint with algorithm specification.\n * ETSI TS 119 182-1 Section 5.2.2.2\n */\nexport const X5tOSchema = z.object({\n /** Digest algorithm identifier (e.g., 'S384', 'S512') */\n digAlg: z.string().min(1),\n /** Base64url-encoded digest value */\n digVal: z.string().min(1),\n})\n\n// ============================================================================\n// Commitment Reference Schema\n// ============================================================================\n\n/**\n * Commitment reference as per ETSI TS 119 182-1 Section 5.2.5.\n */\nexport const CommitmentReferenceSchema = z.object({\n /** Commitment type identifier (OID or URI) */\n commId: z.string().min(1),\n /** Commitment qualifiers */\n commQuals: z.array(z.object({}).passthrough()).optional(),\n})\n\n// ============================================================================\n// Signature Policy Schema\n// ============================================================================\n\n/**\n * Signature policy hash.\n */\nexport const SignaturePolicyHashSchema = z.object({\n hashAlgo: z.string().min(1),\n hashVal: z.string().min(1),\n})\n\n/**\n * Signature policy descriptor.\n * ETSI TS 119 182-1 Section 5.2.4\n */\nexport const SignaturePolicySchema = z.object({\n /** Policy identifier */\n sigPolicyId: z.string().optional(),\n /** Policy hash */\n sigPolicyHash: SignaturePolicyHashSchema.optional(),\n /** Policy qualifiers */\n sigPolicyQualifiers: z.array(z.object({}).passthrough()).optional(),\n})\n\n// ============================================================================\n// Signer Identifier Schema\n// ============================================================================\n\n/**\n * Issuer and serial number for signer identification.\n */\nexport const IssuerSerialSchema = z.object({\n issuer: z.string().min(1),\n serialNumber: z.string().min(1),\n})\n\n/**\n * Signer identifier.\n * ETSI TS 119 182-1 Section 5.2.3\n */\nexport const SignerIdentifierSchema = z.object({\n /** Issuer and serial number */\n issuerSerial: IssuerSerialSchema.optional(),\n /** Subject key identifier */\n subjectKeyIdentifier: z.string().optional(),\n})\n\n// ============================================================================\n// Detached Signature Descriptor Schema\n// ============================================================================\n\n/**\n * Detached signature descriptor.\n * ETSI TS 119 182-1 Section 5.2.8\n */\nexport const SigDSchema = z.object({\n /** Mechanism identifier */\n mId: z.string().min(1),\n /** Parameters (tuple of 2 strings) */\n pars: z.tuple([z.string(), z.string()]),\n /** Hash algorithm */\n hashM: z.string().optional(),\n /** Canonicalization algorithm */\n ctM: z.string().optional(),\n})\n\n// ============================================================================\n// Timestamp Schemas (for B-T, B-LT, B-LTA profiles)\n// ============================================================================\n\n/**\n * Timestamp token value.\n */\nexport const TstTokenValueSchema = z.object({\n val: z.string().min(1),\n})\n\n/**\n * Timestamp tokens container.\n */\nexport const TstTokensSchema = z.object({\n tstTokens: z.array(TstTokenValueSchema).min(1),\n})\n\n/**\n * Signature timestamp container (for B-T profile).\n */\nexport const SigTstSchema = z.object({\n sigTst: TstTokensSchema,\n})\n\n/**\n * X.509 certificate values (for B-LT profile).\n */\nexport const XValsSchema = z.object({\n xVals: z.array(\n z.object({\n x509Cert: z.string().min(1),\n })\n ),\n})\n\n/**\n * Revocation values (for B-LT profile).\n */\nexport const RValsSchema = z.object({\n rVals: z.object({\n crlVals: z.array(z.string()),\n ocspVals: z.array(z.string()),\n }),\n})\n\n/**\n * Archive timestamp (for B-LTA profile).\n */\nexport const ArcTstSchema = z.object({\n arcTst: TstTokensSchema.extend({\n canonAlg: z.string().optional(),\n }),\n})\n\n/**\n * ETSI Unsigned properties for different JAdES profiles.\n */\nexport const EtsiUSchema = z.union([\n // B-T: Just timestamp\n z.array(SigTstSchema),\n // B-LT: timestamp + validation data\n z.tuple([SigTstSchema, XValsSchema, RValsSchema]),\n // B-LTA: timestamp + validation data + archive timestamp\n z.tuple([SigTstSchema, XValsSchema, RValsSchema, ArcTstSchema]),\n])\n\n// ============================================================================\n// Protected Header Schema\n// ============================================================================\n\n/**\n * JAdES Protected Header parameters as per ETSI TS 119 182-1.\n */\nexport const ProtectedHeaderSchema = z\n .object({\n /** Signature algorithm (required for signing) */\n alg: SignAlgSchema.optional(),\n\n /** Content type */\n cty: z.string().optional(),\n\n /** Key ID - ETSI TS 119 182-1 Section 5.1.4 */\n kid: z.string().optional(),\n\n /** X.509 URL - ETSI TS 119 182-1 Section 5.1.5 */\n x5u: z.string().url().optional(),\n\n /** X.509 Certificate Chain - ETSI TS 119 182-1 Section 5.1.8 */\n x5c: z.array(z.string().min(1)).min(1).optional(),\n\n /** X.509 Certificate SHA-256 Thumbprint - ETSI TS 119 182-1 Section 5.1.7 */\n 'x5t#S256': z.string().min(1).optional(),\n\n /** X.509 Certificate Thumbprint with Other Algorithm - ETSI TS 119 182-1 Section 5.2.2.2 */\n 'x5t#o': X5tOSchema.optional(),\n\n /** X.509 Certificate Thumbprints for Chain - ETSI TS 119 182-1 Section 5.2.2.3 */\n sigX5ts: z.array(X5tOSchema).min(2).optional(),\n\n /** Signer's commitment reference - ETSI TS 119 182-1 Section 5.2.5 */\n srCms: z.array(CommitmentReferenceSchema).optional(),\n\n /** Signer's attributes reference */\n srAts: z.array(z.object({}).passthrough()).optional(),\n\n /** Signature policy - ETSI TS 119 182-1 Section 5.2.4 */\n sigPl: SignaturePolicySchema.optional(),\n\n /** Signer identifier */\n sigPId: SignerIdentifierSchema.optional(),\n\n /** Signing time - ETSI TS 119 182-1 Section 5.2.1 (ISO 8601) */\n sigT: z.string().optional(),\n\n /** Detached signature descriptor - ETSI TS 119 182-1 Section 5.2.8 */\n sigD: SigDSchema.optional(),\n\n /** Base64url encoding flag - RFC 7797 Section 3 */\n b64: z.literal(false).optional(),\n\n /** Critical headers */\n crit: z.array(z.string()).optional(),\n\n /** Issued at timestamp (Unix seconds) */\n iat: z.number().int().positive().optional(),\n\n /** Signed at timestamp (Unix seconds) */\n signedAt: z.number().int().positive().optional(),\n\n /** JWT ID */\n jti: z.string().optional(),\n\n /** Token type */\n typ: z.string().optional(),\n\n /** ADO timestamps */\n adoTst: z.array(z.object({}).passthrough()).optional(),\n })\n .passthrough()\n\n/**\n * Protected header schema for signing (alg required).\n */\nexport const ProtectedHeaderForSigningSchema = ProtectedHeaderSchema.extend({\n alg: SignAlgSchema,\n}).refine(\n (header) => {\n // At least one certificate header must be present\n return !!(header['x5t#S256'] || header.x5c || header['x5t#o'] || header.sigX5ts)\n },\n {\n message:\n 'JAdES signature requires at least one certificate header: x5t#S256, x5c, x5t#o, or sigX5ts',\n }\n)\n\n// ============================================================================\n// Unprotected Header Schema\n// ============================================================================\n\n/**\n * JAdES Unprotected Header parameters.\n */\nexport const UnprotectedHeaderSchema = z\n .object({\n /** ETSI unsigned properties */\n etsiU: EtsiUSchema.optional(),\n /** Disclosures (for SD-JWT) */\n disclosures: z.array(z.string()).optional(),\n /** Key ID */\n kid: z.string().optional(),\n /** Key binding JWT */\n kb_jwt: z.string().optional(),\n })\n .passthrough()\n\n// ============================================================================\n// JWS Serialization Schemas\n// ============================================================================\n\n/**\n * Signature entry in General JWS.\n */\nexport const JWSSignatureSchema = z.object({\n /** Base64url-encoded protected header */\n protected: z.string().min(1),\n /** Base64url-encoded signature */\n signature: z.string().min(1),\n /** Unprotected header */\n header: UnprotectedHeaderSchema.optional(),\n})\n\n/**\n * General JWS structure with multiple signatures.\n */\nexport const GeneralJWSSchema = z.object({\n /** Base64url-encoded payload */\n payload: z.string(),\n /** Array of signature objects */\n signatures: z.array(JWSSignatureSchema).min(1),\n})\n\n/**\n * Flattened JWS structure (single signature).\n */\nexport const FlattenedJWSSchema = z.object({\n /** Base64url-encoded protected header */\n protected: z.string().min(1),\n /** Base64url-encoded payload */\n payload: z.string(),\n /** Base64url-encoded signature */\n signature: z.string().min(1),\n /** Unprotected header */\n header: UnprotectedHeaderSchema.optional(),\n})\n\n/**\n * Compact JWS representation.\n */\nexport const CompactJWSSchema = z.object({\n /** Base64url-encoded protected header */\n protected: z.string().min(1),\n /** Base64url-encoded payload */\n payload: z.string(),\n /** Base64url-encoded signature */\n signature: z.string().min(1),\n})\n\n// ============================================================================\n// Sign/Verify Options Schemas\n// ============================================================================\n\n/**\n * Sign options for JAdES signing.\n */\nexport const SignOptionsSchema = z.object({\n /** Signature algorithm */\n alg: SignAlgSchema,\n /** Key ID */\n kid: z.string().optional(),\n /** X.509 certificates (PEM or base64 DER) */\n certificates: z.array(z.string()).optional(),\n})\n\n/**\n * Verify options for JAdES verification.\n */\nexport const VerifyOptionsSchema = z.object({\n /** Whether to skip signature validation (decode only) */\n skipSignatureValidation: z.boolean().optional(),\n})\n","/**\n * JAdES Utility Functions\n *\n * Helper functions for certificate handling and header generation.\n */\n\nimport { base64urlEncode, base64urlDecode } from '@owf/identity-common'\nimport { parseCertificate, parseCertificateChain, sha256 } from '@owf/crypto'\nimport { JAdESException } from './jades-exception'\nimport type { X5tO } from './types'\n\n/**\n * Parse PEM-encoded certificate chain and return base64 DER strings.\n *\n * @param pem - One or more PEM-encoded certificates\n * @returns Array of base64-encoded DER certificate strings\n */\nexport function parseCerts(pem: string): string[] {\n return parseCertificateChain(pem)\n}\n\n/**\n * Generate x5c header value from PEM certificates.\n * The certificates are converted to base64-encoded DER format.\n *\n * ETSI TS 119 182-1 Section 5.1.8\n *\n * @param certs - PEM-encoded certificate(s) or array of base64 DER certs\n * @returns Array of base64-encoded DER certificate strings\n */\nexport function generateX5c(certs: string | string[]): string[] {\n if (typeof certs === 'string') {\n return parseCertificateChain(certs)\n }\n return certs\n}\n\n/**\n * Generate x5t#S256 header value (SHA-256 thumbprint of certificate).\n *\n * ETSI TS 119 182-1 Section 5.1.7\n *\n * @param certDer - Base64-encoded DER certificate\n * @returns Base64url-encoded SHA-256 thumbprint\n */\nexport async function generateX5tS256(certDer: string): Promise<string> {\n const certBytes = base64ToUint8Array(certDer)\n const hashBuffer = await globalThis.crypto.subtle.digest('SHA-256', certBytes)\n return uint8ArrayToBase64Url(new Uint8Array(hashBuffer))\n}\n\n/**\n * Generate x5t#o header value (certificate thumbprint with specified algorithm).\n *\n * ETSI TS 119 182-1 Section 5.2.2.2\n *\n * @param certDer - Base64-encoded DER certificate\n * @param algorithm - Hash algorithm ('SHA-384' or 'SHA-512')\n * @returns X5tO object with algorithm identifier and digest value\n */\nexport async function generateX5tO(\n certDer: string,\n algorithm: 'SHA-384' | 'SHA-512' = 'SHA-512'\n): Promise<X5tO> {\n const algMap = {\n 'SHA-384': 'S384',\n 'SHA-512': 'S512',\n } as const\n\n const certBytes = base64ToUint8Array(certDer)\n const hashBuffer = await globalThis.crypto.subtle.digest(algorithm, certBytes)\n\n return {\n digAlg: algMap[algorithm],\n digVal: uint8ArrayToBase64Url(new Uint8Array(hashBuffer)),\n }\n}\n\n/**\n * Generate sigX5ts header value (certificate chain thumbprints).\n *\n * ETSI TS 119 182-1 Section 5.2.2.3\n *\n * @param certsDer - Array of base64-encoded DER certificates\n * @param algorithm - Hash algorithm ('SHA-384' or 'SHA-512')\n * @returns Array of X5tO objects\n */\nexport async function generateSigX5ts(\n certsDer: string[],\n algorithm: 'SHA-384' | 'SHA-512' = 'SHA-512'\n): Promise<X5tO[]> {\n if (certsDer.length < 2) {\n throw new JAdESException('sigX5ts requires at least 2 certificates')\n }\n\n return Promise.all(certsDer.map((cert) => generateX5tO(cert, algorithm)))\n}\n\n/**\n * Generate a JAdES-compliant kid from X.509 certificate.\n *\n * According to ETSI TS 119 182-1 Section 5.1.4, the kid should be\n * the base64 encoding of DER-encoded IssuerSerial sequence.\n *\n * This implementation generates a SHA-256 thumbprint of the certificate\n * as a simpler approach that uniquely identifies the certificate.\n *\n * @param certDer - Base64-encoded DER certificate\n * @returns Base64url-encoded key identifier\n */\nexport async function generateKid(certDer: string): Promise<string> {\n // Use SHA-256 thumbprint as kid for simplicity\n return generateX5tS256(certDer)\n}\n\n/**\n * Encode an object as a base64url JSON string.\n *\n * @param obj - Object to encode\n * @returns Base64url-encoded JSON string\n */\nexport function encodeJSON(obj: object): string {\n return base64urlEncode(JSON.stringify(obj))\n}\n\n/**\n * Decode a base64url JSON string to an object.\n *\n * @param encoded - Base64url-encoded JSON string\n * @returns Decoded object\n */\nexport function decodeJSON<T = unknown>(encoded: string): T {\n return JSON.parse(base64urlDecode(encoded)) as T\n}\n\n/**\n * Get current ISO 8601 timestamp for sigT header.\n *\n * @returns ISO 8601 timestamp string\n */\nexport function getSigningTime(): string {\n return new Date().toISOString().replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Validate that the protected header has at least one certificate header.\n * As per ETSI TS 119 182-1 Section 5.1.7, a JAdES signature shall have\n * at least one of: x5t#S256, x5c, x5t#o, sigX5ts.\n *\n * @param header - Protected header object\n * @returns true if valid\n * @throws JAdESException if no certificate header is present\n */\nexport function validateCertificateHeaders(header: Record<string, unknown>): boolean {\n const hasCertHeader = !!(header['x5t#S256'] || header.x5c || header['x5t#o'] || header.sigX5ts)\n\n if (!hasCertHeader) {\n throw new JAdESException(\n 'JAdES signature requires at least one certificate header: x5t#S256, x5c, x5t#o, or sigX5ts'\n )\n }\n\n return true\n}\n\n// Helper functions for base64/base64url conversion\n\nfunction base64ToUint8Array(base64: string): Uint8Array {\n // Handle both standard base64 and base64url\n const normalized = base64.replace(/-/g, '+').replace(/_/g, '/')\n const padded = normalized.padEnd(normalized.length + ((4 - (normalized.length % 4)) % 4), '=')\n const binaryString = atob(padded)\n const bytes = new Uint8Array(binaryString.length)\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i)\n }\n return bytes\n}\n\nfunction uint8ArrayToBase64Url(bytes: Uint8Array): string {\n let binary = ''\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i])\n }\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n}\n","/**\n * JAdES Token\n *\n * Main class for creating JAdES-compliant signatures.\n * Implements ETSI TS 119 182-1 standard for JSON Advanced Electronic Signatures.\n *\n * @example\n * ```typescript\n * import { Token, parseCerts, generateX5c } from '@owf/eudi-jades'\n * import { ES256 } from '@owf/crypto'\n *\n * const payload = { hello: 'world' }\n * const token = new Token(payload)\n *\n * const certs = parseCerts(pemCertificate)\n * token.setProtectedHeader({\n * alg: 'ES256',\n * x5c: generateX5c(certs),\n * })\n *\n * const signer = await ES256.getSigner(privateKey)\n * await token.sign(signer)\n *\n * const compactJws = token.toString()\n * const generalJws = token.toJSON()\n * ```\n */\n\nimport { base64urlEncode } from '@owf/identity-common'\nimport { CRITICAL_PARAMETERS, DETACHED_MECHANISM_IDS } from './constants'\nimport { JAdESException } from './jades-exception'\nimport {\n ProtectedHeaderForSigningSchema,\n ProtectedHeaderSchema,\n SignAlgSchema, \n} from './schemas'\nimport type {\n GeneralJWS,\n ProtectedHeaderParams,\n SigD,\n UnprotectedHeaderParams,\n X5tO,\n} from './types'\nimport { encodeJSON } from './utils'\n\n/**\n * JAdES Token class for creating conformant JAdES signatures.\n */\nexport class Token<T extends Record<string, unknown> = Record<string, unknown>> {\n private protectedHeader: ProtectedHeaderParams = {}\n private unprotectedHeader: UnprotectedHeaderParams = {}\n private readonly payload: T | undefined\n private encodedPayload: string\n private signature: string | undefined\n\n /**\n * Create a new JAdES Token.\n *\n * @param payload - The payload to sign. If undefined, creates a detached signature.\n */\n constructor(payload?: T) {\n this.payload = payload\n this.encodedPayload =\n payload === undefined ? '' : base64urlEncode(JSON.stringify(payload))\n }\n\n /**\n * Set the protected header parameters.\n *\n * @param header - Protected header parameters\n * @returns this for method chaining\n */\n setProtectedHeader(header: ProtectedHeaderParams): this {\n // Validate algorithm if provided\n if (header.alg) {\n const algResult = SignAlgSchema.safeParse(header.alg)\n if (!algResult.success) {\n throw new JAdESException(`Invalid algorithm: ${header.alg}`)\n }\n }\n\n // Validate header structure\n const result = ProtectedHeaderSchema.safeParse(header)\n if (!result.success) {\n const errors = result.error.issues.map((e) => e.message).join(', ')\n throw new JAdESException(`Invalid protected header: ${errors}`)\n }\n\n this.protectedHeader = { ...this.protectedHeader, ...header }\n return this\n }\n\n /**\n * Set the unprotected header parameters.\n *\n * @param header - Unprotected header parameters\n * @returns this for method chaining\n */\n setUnprotectedHeader(header: UnprotectedHeaderParams): this {\n this.unprotectedHeader = { ...this.unprotectedHeader, ...header }\n return this\n }\n\n /**\n * Set X.509 certificate chain (x5c header).\n *\n * ETSI TS 119 182-1 Section 5.1.8\n *\n * @param certs - Array of base64-encoded DER certificates\n * @returns this for method chaining\n */\n setX5c(certs: string[]): this {\n this.protectedHeader.x5c = certs\n return this\n }\n\n /**\n * Set X.509 certificate URL (x5u header).\n *\n * ETSI TS 119 182-1 Section 5.1.5\n *\n * @param uri - URI to certificate resource\n * @returns this for method chaining\n */\n setX5u(uri: string): this {\n this.protectedHeader.x5u = uri\n return this\n }\n\n /**\n * Set X.509 certificate SHA-256 thumbprint (x5t#S256 header).\n *\n * ETSI TS 119 182-1 Section 5.1.7\n *\n * @param thumbprint - Base64url-encoded SHA-256 thumbprint\n * @returns this for method chaining\n */\n setX5tS256(thumbprint: string): this {\n this.protectedHeader['x5t#S256'] = thumbprint\n return this\n }\n\n /**\n * Set X.509 certificate thumbprint with other algorithm (x5t#o header).\n *\n * ETSI TS 119 182-1 Section 5.2.2.2\n *\n * @param x5tO - X5tO object with algorithm and digest value\n * @returns this for method chaining\n */\n setX5tO(x5tO: X5tO): this {\n this.protectedHeader['x5t#o'] = x5tO\n return this\n }\n\n /**\n * Set signing time (sigT header).\n *\n * ETSI TS 119 182-1 Section 5.2.1\n *\n * @param time - ISO 8601 timestamp (defaults to current time)\n * @returns this for method chaining\n */\n setSigningTime(time?: string): this {\n this.protectedHeader.sigT = time ?? new Date().toISOString().replace(/\\.\\d{3}Z$/, 'Z')\n return this\n }\n\n /**\n * Set signedAt timestamp in protected header.\n *\n * @param sec - Unix timestamp in seconds (defaults to current time)\n * @returns this for method chaining\n */\n setSignedAt(sec?: number): this {\n this.protectedHeader.signedAt = sec ?? Math.floor(Date.now() / 1000)\n return this\n }\n\n /**\n * Set issued at timestamp (iat) in protected header.\n *\n * @param sec - Unix timestamp in seconds (defaults to current time)\n * @returns this for method chaining\n */\n setIssuedAt(sec?: number): this {\n this.protectedHeader.iat = sec ?? Math.floor(Date.now() / 1000)\n return this\n }\n\n /**\n * Set key ID (kid header).\n *\n * @param kid - Key identifier\n * @returns this for method chaining\n */\n setKid(kid: string): this {\n this.protectedHeader.kid = kid\n return this\n }\n\n /**\n * Set content type (cty header).\n *\n * @param cty - Content type\n * @returns this for method chaining\n */\n setContentType(cty: string): this {\n this.protectedHeader.cty = cty\n return this\n }\n\n /**\n * Set token type (typ header).\n *\n * @param typ - Token type\n * @returns this for method chaining\n */\n setType(typ: string): this {\n this.protectedHeader.typ = typ\n return this\n }\n\n /**\n * Set b64 header parameter.\n *\n * ETSI TS 119 182-1 Section 5.1.10\n * RFC 7797 Section 3\n *\n * @param b64 - If true (default), payload is base64url encoded. If false, payload is unencoded.\n * @returns this for method chaining\n */\n setB64(b64: boolean): this {\n if (b64) {\n delete this.protectedHeader.b64\n } else {\n this.protectedHeader.b64 = false\n }\n return this\n }\n\n /**\n * Configure detached signature mode.\n *\n * ETSI TS 119 182-1 Section 5.2.8\n *\n * @param sigD - Detached signature descriptor\n * @returns this for method chaining\n */\n setDetached(sigD: SigD): this {\n this.protectedHeader.sigD = sigD\n this.encodedPayload = ''\n\n // If using HttpHeaders mechanism, b64 must be false\n if (sigD.mId === DETACHED_MECHANISM_IDS.httpHeaders) {\n this.setB64(false)\n }\n\n return this\n }\n\n /**\n * Get the signing input (data to be signed).\n *\n * @returns The signing input string (header.payload)\n */\n getSigningInput(): string {\n const encodedHeader = this.getEncodedProtectedHeader()\n return `${encodedHeader}.${this.encodedPayload}`\n }\n\n /**\n * Get the hash of the signing input for external signing.\n *\n * @param algorithm - Hash algorithm (defaults to algorithm from header)\n * @returns Promise resolving to hash bytes\n */\n async getHash(algorithm?: string): Promise<Uint8Array> {\n const alg = algorithm ?? this.getHashAlgorithm()\n const signingInput = this.getSigningInput()\n const encoder = new TextEncoder()\n const hashBuffer = await globalThis.crypto.subtle.digest(alg, encoder.encode(signingInput))\n return new Uint8Array(hashBuffer)\n }\n\n /**\n * Set the signature (for external signing).\n *\n * @param signature - Base64url-encoded signature\n * @returns this for method chaining\n */\n setSignature(signature: string): this {\n this.signature = signature\n return this\n }\n\n /**\n * Sign the token using the provided signer function.\n *\n * @param signer - Async function that signs data and returns base64url signature\n * @returns Promise resolving to this for method chaining\n */\n async sign(signer: (data: string) => Promise<string>): Promise<this> {\n this.validateBeforeSign()\n const signingInput = this.getSigningInput()\n this.signature = await signer(signingInput)\n return this\n }\n\n /**\n * Export to compact JWS serialization.\n *\n * @returns Compact JWS string (header.payload.signature)\n */\n toString(): string {\n if (!this.signature) {\n throw new JAdESException('Token not signed yet')\n }\n return `${this.getEncodedProtectedHeader()}.${this.encodedPayload}.${this.signature}`\n }\n\n /**\n * Export to General JWS JSON serialization.\n *\n * @returns GeneralJWS object\n */\n toJSON(): GeneralJWS {\n if (!this.signature) {\n throw new JAdESException('Token not signed yet')\n }\n\n const result: GeneralJWS = {\n payload: this.encodedPayload,\n signatures: [\n {\n protected: this.getEncodedProtectedHeader(),\n signature: this.signature,\n },\n ],\n }\n\n // Add unprotected header if present\n if (Object.keys(this.unprotectedHeader).length > 0) {\n result.signatures[0].header = this.unprotectedHeader\n }\n\n return result\n }\n\n /**\n * Export to flattened JWS JSON serialization.\n *\n * @returns Flattened JWS object\n */\n toFlattenedJSON(): {\n protected: string\n payload: string\n signature: string\n header?: UnprotectedHeaderParams\n } {\n if (!this.signature) {\n throw new JAdESException('Token not signed yet')\n }\n\n const result: {\n protected: string\n payload: string\n signature: string\n header?: UnprotectedHeaderParams\n } = {\n protected: this.getEncodedProtectedHeader(),\n payload: this.encodedPayload,\n signature: this.signature,\n }\n\n if (Object.keys(this.unprotectedHeader).length > 0) {\n result.header = this.unprotectedHeader\n }\n\n return result\n }\n\n /**\n * Get the protected header object.\n */\n getProtectedHeader(): ProtectedHeaderParams {\n return { ...this.protectedHeader }\n }\n\n /**\n * Get the unprotected header object.\n */\n getUnprotectedHeader(): UnprotectedHeaderParams {\n return { ...this.unprotectedHeader }\n }\n\n /**\n * Get the payload.\n */\n getPayload(): T | undefined {\n return this.payload\n }\n\n // Private methods\n\n private getEncodedProtectedHeader(): string {\n const header = this.buildFinalHeader()\n return encodeJSON(header)\n }\n\n private buildFinalHeader(): ProtectedHeaderParams {\n const header = { ...this.protectedHeader }\n\n // Add critical parameters\n const critParams = CRITICAL_PARAMETERS.filter((param) => param in header)\n if (critParams.length > 0) {\n header.crit = critParams\n }\n\n return header\n }\n\n private validateBeforeSign(): void {\n // Validate complete header for signing (alg required + certificate headers)\n const result = ProtectedHeaderForSigningSchema.safeParse(this.protectedHeader)\n if (!result.success) {\n const errors = result.error.issues.map((e) => e.message).join(', ')\n throw new JAdESException(`Invalid protected header for signing: ${errors}`)\n }\n }\n\n private getHashAlgorithm(): string {\n const algMap: Record<string, string> = {\n RS256: 'SHA-256',\n RS384: 'SHA-384',\n RS512: 'SHA-512',\n PS256: 'SHA-256',\n PS384: 'SHA-384',\n PS512: 'SHA-512',\n ES256: 'SHA-256',\n ES384: 'SHA-384',\n ES512: 'SHA-512',\n }\n\n const alg = this.protectedHeader.alg\n if (!alg || !algMap[alg as string]) {\n throw new JAdESException(`Unsupported algorithm: ${alg as string}`)\n }\n\n return algMap[alg as string]\n }\n}\n","/**\n * JAdES Verifier\n *\n * Functions for verifying JAdES signatures.\n */\n\nimport { base64urlDecode } from '@owf/identity-common'\nimport { JAdESException } from './jades-exception'\nimport { GeneralJWSSchema, ProtectedHeaderSchema } from './schemas'\nimport type { GeneralJWS, ProtectedHeaderParams, UnprotectedHeaderParams } from './types'\n\n/**\n * Result of JAdES signature verification.\n */\nexport interface VerifyResult<T = unknown> {\n /** Decoded protected header */\n header: ProtectedHeaderParams\n /** Decoded payload */\n payload: T\n /** Unprotected header (if present) */\n unprotectedHeader?: UnprotectedHeaderParams\n /** Whether the signature is valid */\n valid: boolean\n}\n\n/**\n * Verify a JAdES signature in compact serialization.\n *\n * @param jws - Compact JWS string\n * @param verifier - Async function that verifies signature\n * @returns Promise resolving to verification result\n */\nexport async function verifyCompact<T = unknown>(\n jws: string,\n verifier: (data: string, signature: string) => Promise<boolean>\n): Promise<VerifyResult<T>> {\n const parts = jws.split('.')\n\n if (parts.length !== 3) {\n throw new JAdESException('Invalid JWS format: expected 3 parts')\n }\n\n const [encodedHeader, encodedPayload, signature] = parts\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const valid = await verifier(signingInput, signature)\n\n if (!valid) {\n throw new JAdESException('Invalid signature')\n }\n\n // Parse and validate header with Zod\n const rawHeader = JSON.parse(base64urlDecode(encodedHeader))\n const headerResult = ProtectedHeaderSchema.safeParse(rawHeader)\n if (!headerResult.success) {\n const errors = headerResult.error.issues.map((e) => e.message).join(', ')\n throw new JAdESException(`Invalid protected header: ${errors}`)\n }\n const header = headerResult.data as ProtectedHeaderParams\n\n const payload = encodedPayload ? (JSON.parse(base64urlDecode(encodedPayload)) as T) : ({} as T)\n\n return {\n header,\n payload,\n valid,\n }\n}\n\n/**\n * Verify a JAdES signature in General JWS JSON serialization.\n *\n * @param generalJws - General JWS object\n * @param verifier - Async function that verifies signature\n * @param signatureIndex - Index of signature to verify (default: 0)\n * @returns Promise resolving to verification result\n */\nexport async function verifyGeneral<T = unknown>(\n generalJws: GeneralJWS,\n verifier: (data: string, signature: string) => Promise<boolean>,\n signatureIndex = 0\n): Promise<VerifyResult<T>> {\n // Validate General JWS structure with Zod\n const jwsResult = GeneralJWSSchema.safeParse(generalJws)\n if (!jwsResult.success) {\n const errors = jwsResult.error.issues.map((e) => e.message).join(', ')\n throw new JAdESException(`Invalid General JWS structure: ${errors}`)\n }\n\n const sig = generalJws.signatures[signatureIndex]\n\n if (!sig) {\n throw new JAdESException(`Signature at index ${signatureIndex} not found`)\n }\n\n const signingInput = `${sig.protected}.${generalJws.payload}`\n const valid = await verifier(signingInput, sig.signature)\n\n if (!valid) {\n throw new JAdESException('Invalid signature')\n }\n\n // Parse and validate header with Zod\n const rawHeader = JSON.parse(base64urlDecode(sig.protected))\n const headerResult = ProtectedHeaderSchema.safeParse(rawHeader)\n if (!headerResult.success) {\n const errors = headerResult.error.issues.map((e) => e.message).join(', ')\n throw new JAdESException(`Invalid protected header: ${errors}`)\n }\n const header = headerResult.data as ProtectedHeaderParams\n\n const payload = generalJws.payload\n ? (JSON.parse(base64urlDecode(generalJws.payload)) as T)\n : ({} as T)\n\n return {\n header,\n payload,\n unprotectedHeader: sig.header,\n valid,\n }\n}\n\n/**\n * Verify a JAdES signature (auto-detects format).\n *\n * @param jws - JWS string or GeneralJWS object\n * @param verifier - Async function that verifies signature\n * @returns Promise resolving to verification result\n */\nexport async function verify<T = unknown>(\n jws: string | GeneralJWS,\n verifier: (data: string, signature: string) => Promise<boolean>\n): Promise<VerifyResult<T>> {\n if (typeof jws === 'string') {\n // Try to parse as JSON first (General JWS)\n try {\n const parsed = JSON.parse(jws) as GeneralJWS\n if (parsed.signatures && Array.isArray(parsed.signatures)) {\n return verifyGeneral<T>(parsed, verifier)\n }\n } catch {\n // Not JSON, treat as compact\n }\n return verifyCompact<T>(jws, verifier)\n }\n\n return verifyGeneral<T>(jws, verifier)\n}\n\n/**\n * Decode a JWS without verifying the signature.\n * Use this only for inspection - always verify before trusting the content.\n *\n * @param jws - JWS string or GeneralJWS object\n * @returns Decoded header and payload\n */\nexport function decode<T = unknown>(jws: string | GeneralJWS): {\n header: ProtectedHeaderParams\n payload: T\n unprotectedHeader?: UnprotectedHeaderParams\n} {\n if (typeof jws === 'string') {\n // Try JSON first\n try {\n const parsed = JSON.parse(jws) as GeneralJWS\n if (parsed.signatures && Array.isArray(parsed.signatures)) {\n const sig = parsed.signatures[0]\n return {\n header: JSON.parse(base64urlDecode(sig.protected)) as ProtectedHeaderParams,\n payload: parsed.payload\n ? (JSON.parse(base64urlDecode(parsed.payload)) as T)\n : ({} as T),\n unprotectedHeader: sig.header,\n }\n }\n } catch {\n // Compact format\n }\n\n const parts = jws.split('.')\n if (parts.length !== 3) {\n throw new JAdESException('Invalid JWS format')\n }\n\n return {\n header: JSON.parse(base64urlDecode(parts[0])) as ProtectedHeaderParams,\n payload: parts[1] ? (JSON.parse(base64urlDecode(parts[1])) as T) : ({} as T),\n }\n }\n\n const sig = jws.signatures[0]\n return {\n header: JSON.parse(base64urlDecode(sig.protected)) as ProtectedHeaderParams,\n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AAM,MAAM,IAAI,WAAW;AAC3B,QAAO;EACL,QAAQ,KAAK,MAAM,gBAAgB,IAAI,UAAU,CAAC;EAClD,SAAS,IAAI,UAAW,KAAK,MAAM,gBAAgB,IAAI,QAAQ,CAAC,GAAU,EAAE;EAC5E,mBAAmB,IAAI;EACxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@owf/eudi-jades",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "JAdES (JSON Advanced Electronic Signatures) implementation based on ETSI TS 119 182-1 standard",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"exports": "./src/index.ts",
|
|
10
|
+
"homepage": "https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/eudi-jades",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/openwallet-foundation-labs/identity-common-ts",
|
|
14
|
+
"directory": "packages/eudi-jades"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"module": "./dist/index.mjs",
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.mjs",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"jades",
|
|
27
|
+
"etsi",
|
|
28
|
+
"electronic-signature",
|
|
29
|
+
"jws",
|
|
30
|
+
"jwt",
|
|
31
|
+
"eudi",
|
|
32
|
+
"ts-119-182"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsdown src/index.ts --format esm --dts --sourcemap"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@owf/crypto": "workspace:*",
|
|
39
|
+
"@owf/identity-common": "workspace:*",
|
|
40
|
+
"zod": "^4.3.6"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {}
|
|
43
|
+
}
|