firma-web 0.0.0-stage → 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.
@@ -0,0 +1,13 @@
1
+ export * from './types/index.ts';
2
+ export { P12SignerAdapter, parseP12, validateP12, buildCertificateInfo, extractSubject } from './core/p12-signer.ts';
3
+ export { signPdf } from './core/pdf-signer.ts';
4
+ export { validatePdfSignatures } from './core/pdf-validator.ts';
5
+ export { FirmaCertValidatorElement, registerCertValidator } from './components/firma-cert-validator.ts';
6
+ export { FirmaPdfValidatorElement, registerPdfValidator } from './components/firma-pdf-validator.ts';
7
+ export { FirmaSignModalElement, registerSignModal } from './components/firma-sign-modal.ts';
8
+ export { FirmaStudioElement, registerFirmaStudio } from './components/firma-studio.ts';
9
+ /**
10
+ * Registra todos los Web Components (<firma-sign-modal>, <firma-cert-validator>,
11
+ * <firma-pdf-validator> y <firma-studio>) para usarlos en Angular, React o HTML.
12
+ */
13
+ export declare function registerFirmaComponents(): void;
@@ -0,0 +1,90 @@
1
+ export interface CertificateSubject {
2
+ commonName: string;
3
+ organization?: string;
4
+ organizationalUnit?: string;
5
+ country?: string;
6
+ locality?: string;
7
+ state?: string;
8
+ serialNumber?: string;
9
+ identification?: string;
10
+ email?: string;
11
+ }
12
+ export interface CertificateInfo {
13
+ subject: CertificateSubject;
14
+ issuer: CertificateSubject;
15
+ serialHex: string;
16
+ validFrom: Date;
17
+ validTo: Date;
18
+ isExpired: boolean;
19
+ isNotYetValid: boolean;
20
+ isValidNow: boolean;
21
+ daysRemaining: number;
22
+ fingerprintSha256: string;
23
+ keyUsage: string[];
24
+ rawPem: string;
25
+ }
26
+ export interface ValidationResult {
27
+ valid: boolean;
28
+ certificate?: CertificateInfo;
29
+ errors: string[];
30
+ warnings: string[];
31
+ }
32
+ /**
33
+ * Interfaz extensible para proveedores de firma (.p12/.pfx en navegador,
34
+ * o un futuro adaptador para token USB PKCS#11 mediante puente local).
35
+ */
36
+ export interface SignerAdapter {
37
+ readonly kind: 'p12' | 'token' | string;
38
+ getCertificateInfo(): Promise<CertificateInfo>;
39
+ signPkcs7Detached(contentBytes: Uint8Array, signingTime?: Date): Promise<Uint8Array>;
40
+ }
41
+ export interface SignatureStampOptions {
42
+ /** Número de página (base 1). */
43
+ page: number;
44
+ /** Coordenada X normalizada (0..1) desde el borde izquierdo de la página. */
45
+ xRatio: number;
46
+ /** Coordenada Y normalizada (0..1) desde el borde superior de la página. */
47
+ yRatio: number;
48
+ /** Ancho de la estampa en puntos PDF (por defecto ~190). */
49
+ width?: number;
50
+ /** Alto de la estampa en puntos PDF (por defecto ~64). */
51
+ height?: number;
52
+ /** Razón de la firma (ej. "Aprobación", "Firma electrónica"). */
53
+ reason?: string;
54
+ /** Ubicación (ej. "Quito, Ecuador"). */
55
+ location?: string;
56
+ /** Mostrar código QR en la estampa visual. */
57
+ showQr?: boolean;
58
+ /** Fecha/hora de firma a estampar (por defecto Date.now()). */
59
+ signingTime?: Date;
60
+ }
61
+ export interface SignPdfOptions {
62
+ stamp?: SignatureStampOptions;
63
+ /** Tamaño reservado en bytes para el bloque PKCS#7 (por defecto 8192). */
64
+ signatureLength?: number;
65
+ /** Nombre del campo de firma en el PDF. */
66
+ fieldName?: string;
67
+ }
68
+ export interface PdfSignatureValidationResult {
69
+ signatureIndex: number;
70
+ fieldName?: string;
71
+ reason?: string;
72
+ location?: string;
73
+ signingTime?: Date;
74
+ byteRange: [number, number, number, number];
75
+ /** Indica si el hash del documento coincide exactamente con el firmado en PKCS#7. */
76
+ integrityValid: boolean;
77
+ /** Indica si el certificado estaba vigente al momento de la firma (o actualmente si no hay fecha). */
78
+ certificateValid: boolean;
79
+ /** Indica si la firma es válida globalmente (integridad + estructura + vigencia). */
80
+ valid: boolean;
81
+ certificate?: CertificateInfo;
82
+ errors: string[];
83
+ warnings: string[];
84
+ }
85
+ export interface FirmaSignedEventDetail {
86
+ signedPdf: Uint8Array;
87
+ fileName: string;
88
+ certificate: CertificateInfo;
89
+ stamp: SignatureStampOptions;
90
+ }
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "firma-web",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Librería agnóstica (Angular/React/Web) para firma electrónica PDF con .p12/.pfx, estampa visual con QR y validación.",
6
+ "main": "./dist/firma-web.umd.cjs",
7
+ "module": "./dist/firma-web.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/firma-web.js",
13
+ "require": "./dist/firma-web.umd.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "vite build",
22
+ "test": "vitest run",
23
+ "typecheck": "tsc --noEmit",
24
+ "prepublishOnly": "npm run typecheck && npm run test && npm run build"
25
+ },
26
+ "dependencies": {
27
+ "node-forge": "^1.3.1",
28
+ "pdf-lib": "^1.17.1",
29
+ "pdfjs-dist": "^4.10.38",
30
+ "qrcode": "^1.5.4"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node-forge": "^1.3.11",
34
+ "@types/qrcode": "^1.5.5",
35
+ "typescript": "^5.7.2",
36
+ "vite": "^6.0.3",
37
+ "vite-plugin-dts": "^4.3.0",
38
+ "vitest": "^2.1.8"
39
+ }
40
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.