@f-o-t/e-signature 1.6.0 → 1.6.1
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/appearance.d.ts +28 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/batch.d.ts +61 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/detect-position.d.ts +13 -0
- package/dist/detect-position.d.ts.map +1 -0
- package/dist/icp-brasil.d.ts +60 -0
- package/dist/icp-brasil.d.ts.map +1 -0
- package/dist/index-eavt9jtf.js +687 -0
- package/dist/index-eavt9jtf.js.map +15 -0
- package/dist/index-r24hmh0q.js +6 -0
- package/dist/index-r24hmh0q.js.map +9 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +10 -0
- package/dist/plugins/react/index.d.ts +58 -0
- package/dist/plugins/react/index.d.ts.map +1 -0
- package/dist/plugins/react/index.js +86 -0
- package/dist/plugins/react/index.js.map +10 -0
- package/dist/plugins/worker/index.d.ts +22 -0
- package/dist/plugins/worker/index.d.ts.map +1 -0
- package/dist/plugins/worker/index.js +37 -0
- package/dist/plugins/worker/index.js.map +10 -0
- package/dist/plugins/worker-entry/index.d.ts +16 -0
- package/dist/plugins/worker-entry/index.d.ts.map +1 -0
- package/dist/plugins/worker-entry/index.js +24 -0
- package/dist/plugins/worker-entry/index.js.map +10 -0
- package/dist/schemas.d.ts +48 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/sign-pdf.d.ts +39 -0
- package/dist/sign-pdf.d.ts.map +1 -0
- package/dist/timestamp.d.ts +32 -0
- package/dist/timestamp.d.ts.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +35 -7
- package/CHANGELOG.md +0 -260
- package/bunfig.toml +0 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual Signature Appearance
|
|
3
|
+
*
|
|
4
|
+
* Draws certificate information and QR code on the PDF page
|
|
5
|
+
* following the ICP-Brasil standard visual signature layout.
|
|
6
|
+
*/
|
|
7
|
+
import type { CertificateInfo } from "@f-o-t/digital-certificate";
|
|
8
|
+
import type { PdfDocument, PdfImage, PdfPage } from "@f-o-t/pdf/plugins/editing";
|
|
9
|
+
import type { QrCodeConfig, SignatureAppearance } from "./types.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Draw the visual signature appearance on a PDF page.
|
|
12
|
+
*
|
|
13
|
+
* Includes optional QR code and certificate information text
|
|
14
|
+
* inside a bordered rectangle following ICP-Brasil layout.
|
|
15
|
+
*/
|
|
16
|
+
export declare function drawSignatureAppearance(doc: PdfDocument, page: PdfPage, appearance: SignatureAppearance, certInfo: CertificateInfo | null, options: {
|
|
17
|
+
reason?: string;
|
|
18
|
+
location?: string;
|
|
19
|
+
qrCode?: QrCodeConfig;
|
|
20
|
+
pdfData: Uint8Array;
|
|
21
|
+
preEmbeddedQr?: PdfImage;
|
|
22
|
+
}): void;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-compute the QR code image and embed it once into the PDF document.
|
|
25
|
+
* Call this before an appearances loop so all appearances share a single XObject.
|
|
26
|
+
*/
|
|
27
|
+
export declare function precomputeSharedQrImage(doc: PdfDocument, certInfo: CertificateInfo | null, pdfData: Uint8Array, qrConfig?: QrCodeConfig): PdfImage;
|
|
28
|
+
//# sourceMappingURL=appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACT,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAIpE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACpC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,eAAe,GAAG,IAAI,EAChC,OAAO,EAAE;IACN,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,aAAa,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACD,IAAI,CA8DN;AAgGD;;;GAGG;AACH,wBAAgB,uBAAuB,CACpC,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,eAAe,GAAG,IAAI,EAChC,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,YAAY,GACvB,QAAQ,CAIV"}
|
package/dist/batch.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PdfSignOptions } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Input for a single PDF in a batch signing operation.
|
|
4
|
+
*/
|
|
5
|
+
export type BatchSignInput = {
|
|
6
|
+
/** Filename for identification in events */
|
|
7
|
+
filename: string;
|
|
8
|
+
/** PDF content as Uint8Array or ReadableStream */
|
|
9
|
+
pdf: Uint8Array | ReadableStream<Uint8Array>;
|
|
10
|
+
/** Per-file option overrides merged with base options */
|
|
11
|
+
options?: Partial<PdfSignOptions>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Events emitted during batch signing.
|
|
15
|
+
*/
|
|
16
|
+
export type BatchSignEvent = {
|
|
17
|
+
type: "file_start";
|
|
18
|
+
fileIndex: number;
|
|
19
|
+
filename: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "file_complete";
|
|
22
|
+
fileIndex: number;
|
|
23
|
+
filename: string;
|
|
24
|
+
signed: Uint8Array;
|
|
25
|
+
} | {
|
|
26
|
+
type: "file_error";
|
|
27
|
+
fileIndex: number;
|
|
28
|
+
filename: string;
|
|
29
|
+
error: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "batch_complete";
|
|
32
|
+
totalFiles: number;
|
|
33
|
+
errorCount: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Sign multiple PDFs sequentially, yielding progress events.
|
|
37
|
+
*
|
|
38
|
+
* Yields control between each signing operation to prevent blocking
|
|
39
|
+
* the event loop under bulk load.
|
|
40
|
+
*
|
|
41
|
+
* @param files - Array of PDFs with filename and optional per-file options
|
|
42
|
+
* @param options - Base signing options (per-file options override these)
|
|
43
|
+
* @yields BatchSignEvent for each file start, completion, error, and batch complete
|
|
44
|
+
*/
|
|
45
|
+
export declare function signPdfBatch(files: BatchSignInput[], options: PdfSignOptions): AsyncGenerator<BatchSignEvent>;
|
|
46
|
+
/**
|
|
47
|
+
* Sign multiple PDFs sequentially, collecting all results.
|
|
48
|
+
*
|
|
49
|
+
* Convenience wrapper around {@link signPdfBatch} that collects all events
|
|
50
|
+
* into an array of results.
|
|
51
|
+
*
|
|
52
|
+
* @param files - Array of PDFs with filename and optional per-file options
|
|
53
|
+
* @param options - Base signing options
|
|
54
|
+
* @returns Array of results with signed PDF bytes or error per file
|
|
55
|
+
*/
|
|
56
|
+
export declare function signPdfBatchToArray(files: BatchSignInput[], options: PdfSignOptions): Promise<{
|
|
57
|
+
filename: string;
|
|
58
|
+
signed?: Uint8Array;
|
|
59
|
+
error?: string;
|
|
60
|
+
}[]>;
|
|
61
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC1B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,GAAG,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7C,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GACrB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3D;IACG,IAAI,EAAE,eAAe,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACrB,GACD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAuB,YAAY,CAChC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,GACvB,cAAc,CAAC,cAAc,CAAC,CAsChC;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACtC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,GACvB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAoBtE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DetectedPosition, DetectPositionOptions } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Detect the best position to place a digital signature on a PDF.
|
|
4
|
+
*
|
|
5
|
+
* Uses weighted scoring across three signal types:
|
|
6
|
+
* - Signer name match (weight 3)
|
|
7
|
+
* - Horizontal line patterns (weight 2)
|
|
8
|
+
* - Signature keywords (weight 1)
|
|
9
|
+
*
|
|
10
|
+
* Returns null if the PDF cannot be parsed.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectSigningPosition(pdfData: Uint8Array, options?: DetectPositionOptions): DetectedPosition | null;
|
|
13
|
+
//# sourceMappingURL=detect-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-position.d.ts","sourceRoot":"","sources":["../src/detect-position.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAoB1E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAClC,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,qBAA0B,GACnC,gBAAgB,GAAG,IAAI,CAqIzB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICP-Brasil Attributes for PAdES Signatures
|
|
3
|
+
*
|
|
4
|
+
* Implements the id-aa-signingCertificateV2 (RFC 5035) and
|
|
5
|
+
* id-aa-ets-sigPolicyId attributes required by ICP-Brasil.
|
|
6
|
+
*
|
|
7
|
+
* Uses @f-o-t/asn1 for ASN.1 construction and @f-o-t/crypto for hashing.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Clear the cached signature policy data.
|
|
11
|
+
* Useful for testing or forcing a re-download.
|
|
12
|
+
*/
|
|
13
|
+
export declare function clearPolicyCache(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Build the id-aa-signingCertificateV2 attribute value (DER-encoded).
|
|
16
|
+
*
|
|
17
|
+
* This attribute links the signature to the specific certificate used to
|
|
18
|
+
* create it, preventing substitution attacks.
|
|
19
|
+
*
|
|
20
|
+
* ASN.1 structure (RFC 5035):
|
|
21
|
+
*
|
|
22
|
+
* SigningCertificateV2 ::= SEQUENCE {
|
|
23
|
+
* certs SEQUENCE OF ESSCertIDv2
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* ESSCertIDv2 ::= SEQUENCE {
|
|
27
|
+
* hashAlgorithm AlgorithmIdentifier DEFAULT {algorithm id-sha256},
|
|
28
|
+
* certHash Hash,
|
|
29
|
+
* issuerSerial IssuerSerial OPTIONAL
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* IssuerSerial ::= SEQUENCE {
|
|
33
|
+
* issuer GeneralNames,
|
|
34
|
+
* serialNumber CertificateSerialNumber
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* @param certDer - DER-encoded X.509 certificate
|
|
38
|
+
* @returns DER-encoded SigningCertificateV2 value
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildSigningCertificateV2(certDer: Uint8Array): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Build the id-aa-ets-sigPolicyId attribute value (DER-encoded).
|
|
43
|
+
*
|
|
44
|
+
* Downloads the ICP-Brasil PAdES signature policy and extracts the
|
|
45
|
+
* embedded signPolicyHash to build the attribute.
|
|
46
|
+
*
|
|
47
|
+
* @returns DER-encoded SignaturePolicyIdentifier value
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildSignaturePolicy(): Promise<Uint8Array>;
|
|
50
|
+
/**
|
|
51
|
+
* Attribute OID constants for external use
|
|
52
|
+
*/
|
|
53
|
+
export declare const ICP_BRASIL_OIDS: {
|
|
54
|
+
readonly signingCertificateV2: "1.2.840.113549.1.9.16.2.47";
|
|
55
|
+
readonly signaturePolicy: "1.2.840.113549.1.9.16.2.15";
|
|
56
|
+
};
|
|
57
|
+
export declare class SignaturePolicyError extends Error {
|
|
58
|
+
constructor(message: string);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=icp-brasil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icp-brasil.d.ts","sourceRoot":"","sources":["../src/icp-brasil.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8CH;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAuCzE;AA2ED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,CA8BhE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAMX,qBAAa,oBAAqB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI7B"}
|