Skip to content

Local native signing pilot

PressJet prepares a native contract template, opens an envelope for two people and records their electronic acceptances in order. The sender can open each invitation from the local dashboard or send it to a local test inbox. After the second acceptance, a separate Rust worker adds both visible names, certifies the PDF once and publishes it with signed evidence.

Use synthetic contracts and a test certificate. The HTTP listener binds to loopback, the PostgreSQL connection uses loopback or a Unix socket, and the email worker uses a loopback SMTP test server. The invitation proves access to the link. The organizational certificate seals the resulting PDF and evidence.

Start the pilot

Build the current workspace with cargo build --locked -p pressjet-server. Use a local PostgreSQL database dedicated to the pilot. The application initializes its tables on startup. Use one local signing identity and keep it stable while processing the pilot's pending agreements.

For a disposable database with Docker, start PostgreSQL on an unused local port.

docker run --rm -d --name pressjet-signing-db \
  -p 127.0.0.1:55432:5432 \
  -e POSTGRES_USER=pressjet -e POSTGRES_PASSWORD=local-pilot \
  -e POSTGRES_DB=pressjet_signing postgres:17-alpine
docker exec pressjet-signing-db pg_isready -U pressjet -d pressjet_signing

In the terminal for the API, set the database URL and sender configuration. You can use this key once to start a browser session, or issue an access link from your backend.

export PRESSJET_SIGNING_DATABASE_URL='host=127.0.0.1 port=55432 dbname=pressjet_signing user=pressjet password=local-pilot'
export PRESSJET_API_KEY="$(openssl rand -hex 32)"
export PRESSJET_SIGNING_LINK_SECRET="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
export PRESSJET_SIGNING_PROJECTS='{"default":{"project":"pilot","templates":["servicio"]}}'
export PRESSJET_TEMPLATE_DIR="$PWD/examples/signing"
export PRESSJET_PORT=8091 PRESSJET_WORKERS=1
target/debug/pressjet signing serve

Keep the same link secret when restarting the pilot. For multiple projects, configure secret keys with PRESSJET_API_KEYS_FILE and use the configured key IDs as keys in PRESSJET_SIGNING_PROJECTS. The project mapping grants signing access and lists the templates available to each key.

In a separate terminal, set the same database URL and give the worker its test PKCS#12 identity.

export PRESSJET_SIGNING_DATABASE_URL='host=127.0.0.1 port=55432 dbname=pressjet_signing user=pressjet password=local-pilot'
export PRESSJET_SIGNING_P12_BASE64="$(base64 -w0 spec/fixtures/test-signer.p12)"
export PRESSJET_SIGNING_P12_PASSPHRASE='pressjet-test'
export PRESSJET_WORKERS=1
target/debug/pressjet signing worker

Open the sign-in link from your account or use the project API key under Use a project API key at http://127.0.0.1:8091. Enter the contract terms and both test addresses together. Review the PDF and recipients, then send. In manual mode, the dashboard shows each invitation as its turn comes up. The signer reviews the contract, enters a name and confirms consent. The dashboard and the recipient page update as the agreement progresses, including when the PDF and evidence become available. Participant links last seven days and can download the final pair once it is available. The project key can recover an envelope by ID.

A template uses two visible, distinct boxes marked sig:cliente and sig:empresa. Each box must fit inside one page and use the standard PDF profile. The pilot fits the typed name into the box using a standard PDF font with support for Spanish accents. The signer page offers a PDF download for devices that lack inline PDF viewing.

Open signing from the PressJet workspace

Visit http://127.0.0.1:8091/workspace in the pilot. After signing in to the project, select Send for signature. The workspace and signing panel share the project's browser session. A signed-in user can move between them without entering a key or opening a separate link.

An existing panel link can land in the workspace by setting the query parameter next=workspace before its #login= fragment. Links without this parameter open the signing panel directly.

Open the panel from your application

If people already sign in to your application, add a button that calls your backend. After checking the current user's project access, your backend calls POST /v1/signing/panel-links with the project's secret key. Redirect the browser to the returned URL. The panel shows the project and asks the user to enter. The access link lasts five minutes and can start one browser session. Its fragment carries the short-lived ticket. If the preview opens the panel without its sign-in link, paste the full link or the code after #login= into Sign-in link or code.

curl -sS -X POST http://127.0.0.1:8091/v1/signing/panel-links \
  -H "Authorization: Bearer $PRESSJET_API_KEY"

The session lasts eight hours and the browser keeps it across reloads. The panel uses an HttpOnly, SameSite cookie. Set PRESSJET_SIGNING_PANEL_ORIGIN to the exact HTTPS origin when running behind a reverse proxy. The local pilot uses its bound loopback origin and supports HTTPS preview proxies that forward browser metadata or the panel's same-origin request header. If you open the panel directly, entering a project key starts the same browser session.

Send automatic invitations to a local test inbox

Start Mailpit on unused loopback ports. Mailpit captures messages for testing.

docker run --rm -d --name pressjet-signing-inbox \
  -p 127.0.0.1:11025:1025 -p 127.0.0.1:18025:8025 axllent/mailpit:v1.30.6

Set PRESSJET_SIGNING_EMAIL=local in the API terminal before starting the server. Keep the same link secret if restarting. Use two distinct addresses ending in .test, for example cliente@example.test and empresa@example.test.

Start the mail worker in a third terminal with the same database URL and PRESSJET_SIGNING_LINK_SECRET as the API. Give it the origin of the signing page and the Mailpit SMTP port.

export PRESSJET_SIGNING_ORIGIN=http://127.0.0.1:8091
export PRESSJET_SIGNING_SMTP_PORT=11025
target/debug/pressjet signing mail

Review the contract, click Send for signature and open Mailpit at http://127.0.0.1:18025. The first invitation is queued with the envelope. The second is queued with the first acceptance. The worker queues both completion notices with publication of the two artifacts. Each recipient receives their own download link in the completion notice. It stays available for seven days from publication.

The sender sees SMTP acceptance, queued work or failed delivery in the dashboard. A temporary failure retries with the same Message-ID and link. If the SMTP server accepted a message and the worker lost the reply, the inbox may show a second copy of the same invitation. A repeated invitation returns the same signing receipt. Agreements already created in dashboard mode keep that setting.

HTTP entry points

Sender routes accept a configured project key or a browser panel session. Recipient routes use the token after the invitation URL fragment as an authorization bearer. Opening the page and reading the agreement are separate from the submission that records consent.

Method and path Purpose
GET /v1/signing/templates List template IDs, SHA-256 digests and textFields for simple text bindings. A null field list indicates structured data.
POST /v1/signing/revisions Prepare from templateId, templateSha256 and data. Send an Idempotency-Key. The response includes revisionId, pdfSha256, dimensions and field positions.
GET /v1/signing/revisions/{revisionId}/pdf Download the exact review bytes.
POST /v1/signing/envelopes Open an envelope with revisionId, pdfSha256 and two email addresses in recipients, client first.
GET /v1/signing/envelopes/{envelopeId} Read agreement and mail status, the manual invitation when configured, and final digests.
POST /v1/signing/envelopes/{envelopeId}/revoke Revoke an open request.
GET /v1/signing/envelopes/{envelopeId}/{pdf,evidence} Download either published artifact as the sender.
GET /v1/signing/invitation Retrieve the review metadata, consent and prior acceptance, if applicable.
POST /v1/signing/invitation Send the review ID and hash, action, consent, name and prior acceptance ID. Follow the exact request shape in the browser client.
GET /v1/signing/invitation/{original,pdf,evidence} Download the original review, final PDF or CMS evidence as the recipient.

The pilot stores PDFs and evidence in PostgreSQL. The final acceptance and closing job are committed together. Workers may retry the seal after a failed attempt. Only the worker with the current lease can publish, and publication commits the PDF, evidence and status together.

Bring your own interface

A customer can host their own sender dashboard, signer page, or both. The signing API owns document preparation, recipient authorization, turn order, consent, receipts, retries and publication. Use the same endpoints for the built-in and custom experiences.

Sender dashboard

Call the sender endpoints from your backend with the project secret. Authenticate your users in your own application and grant them access to the corresponding PressJet project. Keep the key on the backend.

  1. List templates, then call POST /v1/signing/revisions with the template ID, template hash and the contract data. Reuse the same Idempotency-Key and request bytes on a retry.
  2. Fetch the returned pdfUrl through your backend for the sender to review. Show the returned fields on the preview if your UI displays field positions.
  3. Create the envelope with the returned revisionId and pdfSha256, plus the two recipients. The envelope status gives you the current turn, email status and final digests. For manual delivery, use invitation.url for a custom page and the API-relative invitation.path for the built-in page.

Signer page

Set signerUi on the project grant. All keys for one project use the same URL. PressJet stores the URL and its exact origin on the envelope when it is created. Invitations and completion emails go to that page. Configure the URL with HTTPS for a hosted UI, or with HTTP for local loopback testing. Set the URL to the signer page and omit the query string and fragment.

export PRESSJET_SIGNING_PROJECTS='{
  "default": {
    "project": "pilot",
    "templates": ["servicio"],
    "signerUi": "http://127.0.0.1:8092/"
  }
}'

The invitation token is in the URL fragment. Read it in the browser and pass it as Authorization: Bearer <token> on the signer endpoints. Fetch the original PDF and show the consent wording returned by the API. On confirmation, submit the server-provided IDs and hash with the signer's name and consent. For a rejection send action: "decline", consent: false and null for the name and consent version. The prior acceptance ID, when provided, identifies the earlier receipt that the signer saw.

const token = location.hash.slice(1);
const headers = { Authorization: `Bearer ${token}` };
const api = "http://127.0.0.1:8091/v1/signing/invitation";
const review = await (await fetch(api, { headers, credentials: "omit" })).json();

// Send this only after the signer has reviewed the PDF and expressly confirmed.
const decision = {
  action: "accept",
  revisionId: review.revisionId,
  pdfSha256: review.pdfSha256,
  priorAcceptanceId: review.priorAcceptance?.receiptId ?? null,
  name: signerName,
  consent: true,
  consentVersion: review.consentVersion
};
const receipt = await fetch(api, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify(decision),
  credentials: "omit"
});

The signer API allows browser requests from the configured origin and checks it against the envelope. Use the same bearer for /original, /pdf and /evidence. Poll the invitation status or offer refresh until it is available. Keep the token out of application logs and third-party scripts. Sender endpoints are intended for server calls.

The sample signer UI runs on a separate origin and points to the pilot API on port 8091. From the repository root, start it and create a new envelope using the config above. For a different API origin, set the API URL in the example script and its connect-src in the HTML. The sample's layout and browser logic belong to the client. All authority comes from the API.

python3 -m http.server 8092 --bind 127.0.0.1 --directory examples/signing/custom-ui

Verify and test

With the dependencies of scripts/verify_recipient_pdf.py and OpenSSL installed, check both downloaded files against a trusted public PEM certificate. The optional original checks the bytes the participants reviewed.

python3 scripts/verify_signing_agreement.py signed-agreement.pdf signing-evidence.p7m \
  --trust-anchor root.pem --original agreement.pdf

The integration test uses a local disposable database, synthetic addresses, an ephemeral certificate, OpenSSL and Poppler. It tests concurrent retries, project boundaries, the original PDF hash, a restart with closing work pending, the visible names and the signed agreement evidence.

python3 scripts/check-native-signing.py --binary target/debug/pressjet
python3 scripts/check-native-signing.py --email --binary target/debug/pressjet
python3 scripts/check-native-signing.py --email --custom-ui --binary target/debug/pressjet

The email test uses a local SMTP fixture that rejects the first attempt temporarily. It signs from the received links, checks the two completion notices and verifies the downloaded files.