import { CreateEnvelopeParams, CreateEnvelopeResponse, GeneratePdfRequest, GetDocumentRequest, GetFileRequest, PdfGateDocument } from './types/index.js'; import { PdfGateSignatureVerificationError } from './types/classes.js'; import { verifySignature } from './webhooks/verifySignature.js'; import { AddFormFieldsRequest, AddFormFieldsResponse, CompressPdfRequest, CompressPdfResponse, CreateEmbedLinkParams, CreateEmbedLinkResponse, CreateRecipientParams, CreateRecipientResponse, CreateWebhookRequest, CreateWebhookResponse, DeleteDocumentRequest, DeleteDocumentResponse, DeleteWebhookParams, DeleteWebhookResponse, ExtractPdfDataRequest, FlattenPdfRequest, FlattenPdfResponse, GeneratePdfResponse, GetEnvelopeParams, GetEnvelopeResponse, VoidEnvelopeParams, VoidEnvelopeResponse, DeleteEnvelopeParams, DeleteEnvelopeResponse, GetRecipientParams, GetRecipientResponse, GetWebhookParams, GetWebhookResponse, ListRecipientsParams, ListRecipientsResponse, ProtectPdfRequest, ProtectPdfResponse, SendEnvelopeParams, SendEnvelopeResponse, UpdateRecipientParams, UpdateRecipientResponse, UploadFileRequest, UploadFileResponse, WatermarkPdfRequest, WatermarkPdfResponse } from './types/types.js'; export type { AddFormFieldsRequest, AddFormFieldsResponse, CreateEmbedLinkParams, CreateEmbedLinkResponse, CreateEnvelopeParams, CreateEnvelopeResponse, CreateRecipientParams, CreateRecipientResponse, CreateWebhookRequest, CreateWebhookResponse, DeleteDocumentRequest, DeleteDocumentResponse, DeleteWebhookParams, DeleteWebhookResponse, EnvelopeDocument, EnvelopeRecipient, FieldOverride, FlattenPdfRequest, FlattenPdfResponse, GetEnvelopeParams, GetEnvelopeResponse, GetRecipientParams, GetRecipientResponse, VoidEnvelopeParams, VoidEnvelopeResponse, DeleteEnvelopeParams, DeleteEnvelopeResponse, GetWebhookParams, GetWebhookResponse, ListRecipientsParams, ListRecipientsResponse, ManualField, SendEnvelopeParams, SendEnvelopeResponse, UpdateRecipientParams, UpdateRecipientResponse, } from './types/types.js'; export type { PdfGateEnvelope, PdfGateRecipient, EmbedLinkResponse, EnvelopeDocumentResponse, EnvelopeRecipientResponse, EnvelopeFieldResponse, WebhookResponse, WebhookEvent, } from './types/interfaces.js'; export { PdfGateSignatureVerificationError }; export { DocumentStatus, DocumentType, EnvelopeStatus, EnvelopeDocumentStatus, DocumentRecipientStatus, DocumentFieldType, PageSizeType, FileOrientation, EmulateMediaType, PdfStandardFont, WebhookStatus, WebhookEventType, } from './types/enums.js'; /** * Verify a PDFGate webhook signature against the raw request body. * * @param secret - Your PDFGate webhook signing secret. * @param signatureHeader - The `x-pdfgate-signature` header value. * @param payload - The raw request body exactly as received. * @throws {PdfGateSignatureVerificationError} If the signature is missing, expired, or invalid. */ export { verifySignature }; export default class PdfGate { private api; static verifySignature: typeof verifySignature; /** * Create a new PDFGate client. * * PDFGate uses two environments: * - **Sandbox** for `test_...` keys → `https://api-sandbox.pdfgate.com` * - **Production** for `live_...` keys → `https://api.pdfgate.com` * * Authentication is performed via the `Authorization: Bearer ` header. * * @see https://pdfgate.com/documentation * * @param apiKey - Your PDFGate API key (must start with `test_` or `live_`). * @throws {PdfGateApiError} If the API key format is invalid. */ constructor(apiKey: string); /** * Generate a PDF from a URL or raw HTML. * * **Endpoint:** `POST /v1/generate/pdf` * * You must provide **either**: * - `url` (render a public page), or * - `html` (render raw HTML). * * This SDK always requests a JSON response from this endpoint and returns a * **document JSON** object with metadata, including a temporary `fileUrl` * (pre-signed URL) when enabled. * * Notes from the API docs: * - `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * - `timeout` is in **milliseconds**, default/max 900000 (15 minutes). * - Supports options like page size/orientation, margins, header/footer, JS/CSS injection, * wait strategies, `pageRanges`, etc. * - `enableFormFields` enables interactive fields based on supported HTML tags * (and supports ``). * * @see https://pdfgate.com/documentation * * @param params - Generation options; must include `url` or `html`. * @returns A `PdfGateDocument`. * @throws {PdfGateApiError} If neither `url` nor `html` is provided. */ generatePdf(params: GeneratePdfRequest): Promise; /** * Flatten an interactive PDF into a static, non-editable PDF. * * **Endpoint:** `POST /forms/flatten` * * Provide: * - `documentId` (reference an existing stored document). * * If `documentId` is provided, PDFGate creates a **new** flattened document (does not overwrite). * This SDK always requests JSON and returns a `PdfGateDocument`. * * Provide `fieldNames` to flatten only those specific form fields; the rest of * the form stays interactive. Omit it to flatten the whole document. * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Flatten options; includes `documentId`, optional `fieldNames`, metadata, etc. * @returns A `PdfGateDocument`. */ flattenPdf(params: FlattenPdfRequest): Promise; /** * Add interactive form fields to a PDF. * * **Endpoint:** `POST /forms/fields` * * Provide: * - `documentId` (reference an existing stored document). * * Two complementary ways to add fields: * - `fieldOverrides`: customize placeholder fields detected in the PDF, keyed by field name. * - `fields`: place fields at explicit `x`/`y` positions on a given `page`. * * PDFGate creates a **new** document with the added fields (does not overwrite the original). * This SDK always requests JSON and returns a `PdfGateDocument`. * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Options; includes `documentId`, optional `fieldOverrides`, `fields`, metadata, etc. * @returns A `PdfGateDocument`. */ addFormFields(params: AddFormFieldsRequest): Promise; /** * Compress/optimize a PDF to reduce file size. * * **Endpoint:** `POST /compress/pdf` * * Provide: * - `documentId` (reference an existing stored document). * * Compression optimizes internal structures and stream compression without changing visual content. * Optionally enable `linearize` to help the first page render sooner over the network. * * This SDK always requests JSON and returns a `PdfGateDocument`. * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Compress options; includes `documentId`, optional `linearize`, metadata, etc. * @returns A `PdfGateDocument`. */ compressPdf(params: CompressPdfRequest): Promise; /** * Upload a raw PDF file so it can be referenced by other PDF operations. * * **Endpoint:** `POST /upload` * * Provide: * - `file` (multipart upload), or * - `url` (JSON body with a source URL). * * When both `file` and `url` are provided, `file` is prioritized and * the request is sent as multipart/form-data. * * This endpoint returns a JSON document response and the SDK returns a `PdfGateDocument`. * * Important: Accessing stored generated files requires enabling * “Save files” in the PDFGate Dashboard settings (disabled by default). * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Upload options; includes `file` and/or `url`, optional metadata, etc. * @returns A `PdfGateDocument`. */ uploadFile(params: UploadFileRequest): Promise; /** * Apply a text or image watermark to a PDF. * * **Endpoint:** `POST /watermark/pdf` * * Provide: * - `documentId` (reference an existing stored document). * * Watermark configuration highlights: * - `type` is required: `"text"` or `"image"`. * - For text watermarks: `text` required when `type="text"`. * - For image watermarks: upload `watermark` image file (`.png`, `.jpg`, `.jpeg`). * - This endpoint remains multipart because it can include image/font file uploads. * - Optional: `font` (standard PDF fonts), `fontFile` (`.ttf`/`.otf` overrides `font`), * `fontSize`, `fontColor`, `opacity` (0..1), `xPosition`, `yPosition`, `imageWidth`, `imageHeight`, `rotate` (0..360). * * This SDK always requests JSON and returns a `PdfGateDocument`. * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Watermark options; includes `documentId` plus watermark settings. * @returns A `PdfGateDocument`. */ watermarkPdf(params: WatermarkPdfRequest): Promise; /** * Protect a PDF using encryption + optional permission restrictions. * * **Endpoint:** `POST /protect/pdf` * * Provide: * - `documentId` (reference an existing stored document). * * Security options highlights: * - `algorithm`: `"AES256"` (default) or `"AES128"`. * - `userPassword`: password required to open the PDF (optional). * - `ownerPassword`: full control password; required in some cases (e.g., AES256 with `userPassword`). * - Restrictions: `disablePrint`, `disableCopy`, `disableEditing`. * - `encryptMetadata`: whether PDF metadata is encrypted (default `false`). * * The operation produces a new protected file and does not alter the original. * * This SDK always requests JSON and returns a `PdfGateDocument`. * * `preSignedUrlExpiresIn` is in **seconds** (min 60, max 86400). * * @see https://pdfgate.com/documentation * * @param params - Protect options; includes `documentId`, encryption/restriction settings, etc. * @returns A `PdfGateDocument`. */ protectPdf(params: ProtectPdfRequest): Promise; /** * Create an envelope from existing source documents for signing workflows. * * **Endpoint:** `POST /envelope` * * Provide: * - `requesterName` (who or what system created the envelope) * - `documents` (source documents + recipients for each document) * * Each recipient is given either as `email` and `name` or as the * `recipientId` of a stored recipient. Recipients marked `embedded` sign * inside your application via {@link createEmbedLink} and receive no emails. * Use `signingOrder` to make recipients sign in sequence. * * The SDK forwards the payload as-is, preserving the API's camelCase wire format, * and returns the envelope JSON response. * * @see https://pdfgate.com/documentation * * @param params - Envelope creation options. * @returns A `PdfGateEnvelope`. */ createEnvelope(params: CreateEnvelopeParams): Promise; /** * Send an envelope to its recipients so they can access the signing flow. * * **Endpoint:** `POST /envelope/{id}/send` * * This triggers PDFGate's recipient emails, secure signing links, and OTP verification flow. * Embedded recipients receive no email; create their signing links with * {@link createEmbedLink} after sending. On documents with a `signingOrder` * only the first recipients are emailed; later recipients are activated as * earlier ones sign. * * @see https://pdfgate.com/documentation * * @param params.id - The envelope ID to send. * @returns The updated `PdfGateEnvelope`. */ sendEnvelope(params: SendEnvelopeParams): Promise; /** * Retrieve the current state of an envelope. * * **Endpoint:** `GET /envelope/{id}` * * Use this to inspect the envelope status, document progress, and recipient statuses. * * @see https://pdfgate.com/documentation * * @param params.id - The envelope ID to retrieve. * @returns The current `PdfGateEnvelope`. */ getEnvelope(params: GetEnvelopeParams): Promise; /** * Void (cancel) an envelope in `created` or `in_progress` status. * * **Endpoint:** `POST /envelope/{id}/void` * * Recipients who have not signed yet are notified by email and their signing * links stop working. Documents already signed by all recipients are not * affected. The optional `reason` is visible to recipients. This action * cannot be undone. * * @see https://pdfgate.com/documentation * * @param params.id - The envelope ID to void. * @param params.reason - Optional reason, included in the cancellation email. * @returns The updated `PdfGateEnvelope` with `voided` status. */ voidEnvelope(params: VoidEnvelopeParams): Promise; /** * Permanently delete an envelope and the files it produced. * * **Endpoint:** `DELETE /envelope/{id}` * * The signed documents and audit logs are removed from storage, recipient * data is anonymized, and recipients lose access. Source documents are not * deleted. Only envelopes in `draft`, `completed`, `expired`, or `voided` * status can be deleted — void an active envelope first. This action cannot * be undone. * * @see https://pdfgate.com/documentation * * @param params.id - The envelope ID to delete. */ deleteEnvelope(params: DeleteEnvelopeParams): Promise; /** * Create a short-lived signing link for an embedded recipient. * * **Endpoint:** `POST /envelope/{id}/embed-link` * * Render the returned URL in an iframe inside your application. The envelope * must be in `in_progress` status and the link expires after 10 minutes, so * create it when the signer is ready (one link per signing session). On * documents with a `signingOrder` the link can only be created once it is * the recipient's turn; the `envelope.recipient.activated` webhook event * signals that moment. When the * session ends the iframe redirects to `returnUrl` with `event` * (`signing_complete`, `voided`, `expired` or `not_found`), `envelopeId`, * `documentId` and `recipientId` appended as query parameters; existing * `returnUrl` query parameters are preserved. * * @see https://pdfgate.com/documentation * * @param params.id - The envelope ID. * @param params.documentId - The envelope document ID (`sourceDocumentId`). * @param params.recipientId - The recipient ID of the embedded recipient. * @param params.returnUrl - URL the signing session redirects to when it ends. * @returns An `EmbedLinkResponse` with the signing `url` and its `expiresAt`. */ createEmbedLink(params: CreateEmbedLinkParams): Promise; /** * Store a recipient in your account so envelopes can reference them by * `recipientId`. * * **Endpoint:** `POST /recipient` * * Emails are not unique; every call creates a new recipient. List existing * recipients first when reuse is intended. * * @see https://pdfgate.com/documentation * * @param params.email - Recipient email. Stored lowercased and cannot be changed later. * @param params.name - Optional recipient name. * @param params.metadata - Optional custom key/value metadata. * @returns The created `PdfGateRecipient`. */ createRecipient(params: CreateRecipientParams): Promise; /** * List stored recipients with the given email. * * **Endpoint:** `GET /recipients` * * @see https://pdfgate.com/documentation * * @param params.email - Email to look up (case-insensitive). * @returns An object with the matching `recipients`. */ listRecipients(params: ListRecipientsParams): Promise; /** * Retrieve a stored recipient by ID. * * **Endpoint:** `GET /recipient/{id}` * * @see https://pdfgate.com/documentation * * @param params.id - The recipient ID. * @returns The `PdfGateRecipient`. */ getRecipient(params: GetRecipientParams): Promise; /** * Update a stored recipient's name or metadata. * * **Endpoint:** `PATCH /recipient/{id}` * * The email cannot be changed. Existing envelopes are not affected; they * keep the recipient name they were created with. * * @see https://pdfgate.com/documentation * * @param params.id - The recipient ID. * @param params.name - New recipient name. * @param params.metadata - Replacement custom key/value metadata. * @returns The updated `PdfGateRecipient`. */ updateRecipient(params: UpdateRecipientParams): Promise; /** * Extract form field data from a fillable PDF and return it as JSON. * * **Endpoint:** `POST /forms/extract-data` * * Provide: * - `documentId` (reference an existing stored document). * * The response is a JSON object mapping form field names to their values. * * @see https://pdfgate.com/documentation * * @typeParam ExtractPdfDataRequest. * @param params - Extraction request; includes `documentId`. * @returns A plain JSON object containing extracted PDF form data. */ extractPdfFormData(params: ExtractPdfDataRequest): Promise>; /** * Retrieve a stored document’s metadata (and optionally a fresh pre-signed download URL). * * **Endpoint:** `GET /document/{documentId}` * * Use this to fetch the document record (id, status, size, createdAt, etc.). * If you need a *new* pre-signed URL for downloading an existing stored file, * set `preSignedUrlExpiresIn` (seconds, min 60, max 86400). * * @see https://pdfgate.com/documentation * * @typeParam GetDocumentRequest. * @param params.id - The document ID. * @param params.preSignedUrlExpiresIn - Optional; pre-signed URL expiry in seconds. * @returns The `PdfGateDocument` object. */ getDocument(params: GetDocumentRequest): Promise; /** * Download a raw PDF file by document ID. * * **Endpoint:** `GET /file/{documentId}` * * Important: Accessing stored generated files requires enabling * “Save files” in the PDFGate Dashboard settings (disabled by default). * * @see https://pdfgate.com/documentation * * @typeParam GetFileRequest. * @param params.documentId - The document ID to download. * @returns The PDF bytes as a `Buffer`. */ getFile(params: GetFileRequest): Promise>; /** * Permanently delete a stored document. * * **Endpoint:** `DELETE /document/{documentId}` * * The document and its underlying stored file are removed. A document that is * referenced by a draft or in-progress envelope cannot be deleted until those * envelopes are completed or expired. * * @see https://pdfgate.com/documentation * * @param params.documentId - The document ID to delete. */ deleteDocument(params: DeleteDocumentRequest): Promise; /** * Register a webhook endpoint to receive PDFGate event notifications. * * **Endpoint:** `POST /webhook` * * Provide: * - `url` (a publicly accessible HTTPS URL; localhost is not supported) * - `eventTypes` (the events to subscribe to) * - `description` (optional) * * The response includes a `secret` (returned **only once**, at creation time) * used to verify webhook payloads via {@link verifySignature}. * * @see https://pdfgate.com/documentation * * @param params - Webhook creation options. * @returns The created `WebhookResponse`, including the signing `secret`. */ createWebhook(params: CreateWebhookRequest): Promise; /** * Retrieve a registered webhook by ID. * * **Endpoint:** `GET /webhook/{id}` * * The `secret` is not returned by this endpoint (only at creation time). * * @see https://pdfgate.com/documentation * * @param params.id - The webhook ID to retrieve. * @returns The `WebhookResponse`. */ getWebhook(params: GetWebhookParams): Promise; /** * Delete a registered webhook. * * **Endpoint:** `DELETE /webhook/{id}` * * @see https://pdfgate.com/documentation * * @param params.id - The webhook ID to delete. */ deleteWebhook(params: DeleteWebhookParams): Promise; } //# sourceMappingURL=index.d.ts.map