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.
- package/dist/components/firma-cert-validator.d.ts +15 -0
- package/dist/components/firma-pdf-validator.d.ts +14 -0
- package/dist/components/firma-sign-modal.d.ts +53 -0
- package/dist/components/firma-studio.d.ts +9 -0
- package/dist/components/styles.d.ts +1 -0
- package/dist/core/p12-signer.d.ts +23 -0
- package/dist/core/pdf-signer.d.ts +2 -0
- package/dist/core/pdf-validator.d.ts +2 -0
- package/dist/firma-web.js +25821 -0
- package/dist/firma-web.umd.cjs +631 -0
- package/dist/index.d.ts +13 -0
- package/dist/types/index.d.ts +90 -0
- package/package.json +38 -4
- package/README.md +0 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CertificateInfo } from '../types/index.ts';
|
|
2
|
+
export declare function renderCertSummaryHtml(cert: CertificateInfo): string;
|
|
3
|
+
declare const BaseElement: typeof HTMLElement;
|
|
4
|
+
export declare class FirmaCertValidatorElement extends BaseElement {
|
|
5
|
+
private fileBytes;
|
|
6
|
+
private fileName;
|
|
7
|
+
private lastResult;
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
private handleValidate;
|
|
11
|
+
private renderResult;
|
|
12
|
+
private render;
|
|
13
|
+
}
|
|
14
|
+
export declare function registerCertValidator(): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PdfSignatureValidationResult } from '../types/index.ts';
|
|
2
|
+
declare const BaseElement: typeof HTMLElement;
|
|
3
|
+
export declare class FirmaPdfValidatorElement extends BaseElement {
|
|
4
|
+
private results;
|
|
5
|
+
private fileName;
|
|
6
|
+
private errorMsg;
|
|
7
|
+
constructor();
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
inspectPdf(bytes: Uint8Array, fileName?: string): Promise<PdfSignatureValidationResult[]>;
|
|
10
|
+
private renderResults;
|
|
11
|
+
private render;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerPdfValidator(): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SignerAdapter } from '../types/index.ts';
|
|
2
|
+
declare const BaseElement: typeof HTMLElement;
|
|
3
|
+
export declare class FirmaSignModalElement extends BaseElement {
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
private p12Bytes;
|
|
6
|
+
private externalAdapter;
|
|
7
|
+
private activeAdapter;
|
|
8
|
+
private certInfo;
|
|
9
|
+
private pdfBytes;
|
|
10
|
+
private pdfFileName;
|
|
11
|
+
private pdfDocProxy;
|
|
12
|
+
private currentPage;
|
|
13
|
+
private totalPages;
|
|
14
|
+
private xRatio;
|
|
15
|
+
private yRatio;
|
|
16
|
+
private stampWidth;
|
|
17
|
+
private stampHeight;
|
|
18
|
+
private pagePdfWidth;
|
|
19
|
+
private pagePdfHeight;
|
|
20
|
+
private lastSignedPdf;
|
|
21
|
+
private isSigning;
|
|
22
|
+
private dragging;
|
|
23
|
+
private dragOffsetX;
|
|
24
|
+
private dragOffsetY;
|
|
25
|
+
constructor();
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
attributeChangedCallback(name: string): void;
|
|
28
|
+
get open(): boolean;
|
|
29
|
+
set open(val: boolean);
|
|
30
|
+
openModal(): void;
|
|
31
|
+
closeModal(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Permite inyectar un adaptador personalizado (por ejemplo, un Token USB PKCS#11)
|
|
34
|
+
* en lugar de cargar un archivo .p12/.pfx.
|
|
35
|
+
*/
|
|
36
|
+
setSignerAdapter(adapter: SignerAdapter): Promise<void>;
|
|
37
|
+
loadPdfBytes(bytes: Uint8Array, fileName?: string): Promise<void>;
|
|
38
|
+
private syncVisibility;
|
|
39
|
+
private handleValidateCert;
|
|
40
|
+
private updateCertStatus;
|
|
41
|
+
private updateSignStatus;
|
|
42
|
+
private updateSignButtonState;
|
|
43
|
+
private updateDownloadButton;
|
|
44
|
+
private renderPdfPage;
|
|
45
|
+
private positionStampOverlay;
|
|
46
|
+
private updateStampPreviewText;
|
|
47
|
+
private handleSign;
|
|
48
|
+
private downloadSignedPdf;
|
|
49
|
+
private render;
|
|
50
|
+
private bindEvents;
|
|
51
|
+
}
|
|
52
|
+
export declare function registerSignModal(): void;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const BaseElement: typeof HTMLElement;
|
|
2
|
+
export declare class FirmaStudioElement extends BaseElement {
|
|
3
|
+
constructor();
|
|
4
|
+
connectedCallback(): void;
|
|
5
|
+
private switchTab;
|
|
6
|
+
private render;
|
|
7
|
+
}
|
|
8
|
+
export declare function registerFirmaStudio(): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BASE_STYLES = "\n :host {\n --firma-primary: #1d4ed8;\n --firma-primary-hover: #1e40af;\n --firma-bg: #ffffff;\n --firma-surface: #f8fafc;\n --firma-border: #cbd5e1;\n --firma-text: #0f172a;\n --firma-muted: #475569;\n --firma-success: #15803d;\n --firma-success-bg: #dcfce7;\n --firma-error: #b91c1c;\n --firma-error-bg: #fee2e2;\n --firma-warn: #a16207;\n --firma-warn-bg: #fef9c3;\n --firma-radius: 10px;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;\n color: var(--firma-text);\n box-sizing: border-box;\n }\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n .card {\n background: var(--firma-bg);\n border: 1px solid var(--firma-border);\n border-radius: var(--firma-radius);\n padding: 18px;\n box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);\n }\n\n .title {\n margin: 0 0 6px 0;\n font-size: 1.1rem;\n font-weight: 700;\n color: var(--firma-text);\n }\n\n .subtitle {\n margin: 0 0 16px 0;\n font-size: 0.875rem;\n color: var(--firma-muted);\n }\n\n .field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin-bottom: 12px;\n }\n\n .field label {\n font-size: 0.82rem;\n font-weight: 600;\n color: var(--firma-text);\n }\n\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"file\"] {\n width: 100%;\n padding: 8px 10px;\n border: 1px solid var(--firma-border);\n border-radius: 7px;\n font-size: 0.875rem;\n background: #fff;\n color: var(--firma-text);\n }\n\n input:focus {\n outline: 2px solid rgba(29, 78, 216, 0.25);\n border-color: var(--firma-primary);\n }\n\n .row {\n display: flex;\n gap: 10px;\n flex-wrap: wrap;\n align-items: center;\n }\n\n .btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n padding: 8px 14px;\n border-radius: 7px;\n font-size: 0.875rem;\n font-weight: 600;\n cursor: pointer;\n border: 1px solid transparent;\n transition: background 0.15s, opacity 0.15s;\n }\n\n .btn:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n }\n\n .btn-primary {\n background: var(--firma-primary);\n color: #fff;\n }\n\n .btn-primary:hover:not(:disabled) {\n background: var(--firma-primary-hover);\n }\n\n .btn-secondary {\n background: var(--firma-surface);\n color: var(--firma-text);\n border-color: var(--firma-border);\n }\n\n .btn-secondary:hover:not(:disabled) {\n background: #e2e8f0;\n }\n\n .alert {\n padding: 10px 12px;\n border-radius: 7px;\n font-size: 0.85rem;\n margin-top: 10px;\n }\n\n .alert-success {\n background: var(--firma-success-bg);\n color: var(--firma-success);\n border: 1px solid #86efac;\n }\n\n .alert-error {\n background: var(--firma-error-bg);\n color: var(--firma-error);\n border: 1px solid #fca5a5;\n }\n\n .alert-warn {\n background: var(--firma-warn-bg);\n color: var(--firma-warn);\n border: 1px solid #fde047;\n }\n\n .kv-grid {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));\n gap: 8px 14px;\n margin-top: 10px;\n padding: 10px;\n background: var(--firma-surface);\n border-radius: 7px;\n border: 1px solid #e2e8f0;\n font-size: 0.82rem;\n }\n\n .kv-item span {\n display: block;\n font-size: 0.72rem;\n color: var(--firma-muted);\n text-transform: uppercase;\n letter-spacing: 0.03em;\n }\n\n .kv-item strong {\n word-break: break-word;\n }\n\n .badge {\n display: inline-block;\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 0.75rem;\n font-weight: 700;\n }\n\n .badge-ok {\n background: var(--firma-success-bg);\n color: var(--firma-success);\n }\n\n .badge-bad {\n background: var(--firma-error-bg);\n color: var(--firma-error);\n }\n";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as forge } from 'node-forge';
|
|
2
|
+
import { CertificateInfo, CertificateSubject, SignerAdapter, ValidationResult } from '../types/index.ts';
|
|
3
|
+
export declare function uint8ToBinaryString(bytes: Uint8Array): string;
|
|
4
|
+
export declare function binaryStringToUint8(str: string): Uint8Array;
|
|
5
|
+
export declare function extractSubject(attrs: forge.pki.CertificateField[]): CertificateSubject;
|
|
6
|
+
export declare function buildCertificateInfo(cert: forge.pki.Certificate, referenceDate?: Date): CertificateInfo;
|
|
7
|
+
export interface ParsedP12 {
|
|
8
|
+
privateKey: forge.pki.rsa.PrivateKey;
|
|
9
|
+
certificate: forge.pki.Certificate;
|
|
10
|
+
caChain: forge.pki.Certificate[];
|
|
11
|
+
certificateInfo: CertificateInfo;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseP12(p12Bytes: ArrayBuffer | Uint8Array, password: string): ParsedP12;
|
|
14
|
+
export declare function validateP12(p12Bytes: ArrayBuffer | Uint8Array, password: string): ValidationResult;
|
|
15
|
+
export declare class P12SignerAdapter implements SignerAdapter {
|
|
16
|
+
readonly kind: "p12";
|
|
17
|
+
private readonly parsed;
|
|
18
|
+
private constructor();
|
|
19
|
+
static fromBytes(p12Bytes: ArrayBuffer | Uint8Array, password: string): P12SignerAdapter;
|
|
20
|
+
static fromFile(file: Blob, password: string): Promise<P12SignerAdapter>;
|
|
21
|
+
getCertificateInfo(): Promise<CertificateInfo>;
|
|
22
|
+
signPkcs7Detached(contentBytes: Uint8Array, signingTime?: Date): Promise<Uint8Array>;
|
|
23
|
+
}
|