Embedded signing
Signer Flow with secure elements
The signer's steps in your own UI, around three small frames from the signing server: identity, document, and consent with Sign.
- @signnative/ui
- MIT
- Client only · mock server here
- Prototype · ADR 0033 proposed
A prototype for ADR 0033 (proposed). No signing server serves secure elements yet, so every example here runs against a mock server in your browser, with a synthetic document. Nothing is sent and nothing is signed.
Your code cannot verify, consent or sign: those happen only inside the frames, on a press by the person. The flow reads the outcome back from the server before it says “signed”.
The CSS variables this sets
:root {
--signing-accent: #3157e8;
--sig-accent: #3157e8;
--sig-accent-soft: color-mix(in oklab, #3157e8 14%, white);
--sig-radius: 8px;
--radius-control: 8px;
--radius-panel: 12px;
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}In the signer page kit, set the accent with accentProps(accent) on the element around the surface; it sets data-signing-accent and --signing-accent. The secure elements take the same values as a checked appearance object instead.
Link from the sender
The person opens the document in the identity frame, fills in, signs in your UI, and agrees in the consent frame.
Loading the document…
Mock server: waiting for the person.
import { useEffect, useMemo } from "react";
import { SignerFlow, createMockElementsAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
// A signing server simulated in the browser. Use your own adapter for a real server.
const adapter = useMemo(() => createMockElementsAdapter({ frames: "srcdoc", verification: "sender_link" }), []);
useEffect(() => () => adapter.dispose(), [adapter]);
return <SignerFlow adapter={adapter} headingLevel={3} onSigned={() => console.log(adapter.server.state())} />;
}
Email code
The code is typed into the identity frame only. The mock accepts 123456; no email is sent.
Loading the document…
Mock server: waiting for the person.
import { useEffect, useMemo } from "react";
import { SignerFlow, createMockElementsAdapter } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockElementsAdapter({ frames: "srcdoc", verification: "email_otp" }), []);
useEffect(() => () => adapter.dispose(), [adapter]);
return <SignerFlow adapter={adapter} headingLevel={3} />;
}
Elements in your theme
The frames take a short list of named, checked values instead of CSS. This one follows the Theme control above.
Loading the document…
Mock server: waiting for the person.
import { useEffect, useMemo } from "react";
import { SignerFlow, createMockElementsAdapter, type ElementAppearance } from "@signnative/ui";
import "@signnative/ui/styles.css";
const appearance: ElementAppearance = { accent: "#1d7a4c", radius: "12px", fontFamily: "Georgia, serif" };
export function Example() {
const adapter = useMemo(() => createMockElementsAdapter({ frames: "srcdoc", appearance }), []);
useEffect(() => () => adapter.dispose(), [adapter]);
return (
<div style={{ ["--sig-accent" as string]: "#1d7a4c", ["--sig-radius" as string]: "12px" }}>
<SignerFlow adapter={adapter} />
</div>
);
}
One secure element
SecureElement on its own: a frame the host places and sizes, and hears events from. Here the document element.
Loading the element…
import { useEffect, useMemo, useState } from "react";
import { SecureElement, createMockElementsAdapter, type ElementEvent } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const adapter = useMemo(() => createMockElementsAdapter({ frames: "srcdoc" }), []);
useEffect(() => () => adapter.dispose(), [adapter]);
const [last, setLast] = useState<ElementEvent | null>(null);
const instance = "document-1";
return (
<div>
<SecureElement element="document" instance={instance} title="Document from the signing service" source={adapter.element("document", instance, {})} onEvent={setLast} />
<p>{last?.type}</p>
</div>
);
}
Error: an address that is not allowed
Elements load only from https, or http on localhost. Anything else shows an error and no frame.
This signing element has an address that is not allowed.
import { SecureElement } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
return (
<SecureElement
element="consent"
instance="consent-1"
title="Consent"
source={{ kind: "url", origin: "http://elements.example.test", url: "http://elements.example.test/elements/consent" }}
/>
);
}
Installation
npx shadcn@latest add …
Not published yet
API
className and children are left out: every component that takes them passes them on.
SignerFlow
| Name | Type | Default | Description |
|---|---|---|---|
| adapter | ElementsSignerAdapter | Your connection to a signing server: getView, saveDraft and element. No sign, verify or consent. | |
| onSigned | () => void | Called after the server's view says the person signed. | |
| onDeclined | () => void | Called after the server's view says the person declined. | |
| labels | Partial<SignerFlowLabels> | English | Every text, for translation. |
| headingLevel | 2 | 3 | 2 | Level of the envelope title. |
SecureElement
| Name | Type | Default | Description |
|---|---|---|---|
| element | "identity" | "document" | "consent" | Which element. Each has a minimum size and refuses its actions when smaller. | |
| source | SecureElementSource | { kind: "url", origin, url } from a signing server, or { kind: "mock", html } for demos and tests. | |
| instance | string | Unique per mounted frame. Messages for another instance are ignored. | |
| title | string | The frame's accessible name. | |
| onEvent | (event: ElementEvent) => void | Accepted events only: ready, height, verified, viewed, signed, declined, error. |
createMockElementsAdapter
| Name | Type | Default | Description |
|---|---|---|---|
| verification | "sender_link" | "email_otp" | "sender_link" | How the signer shows who they are. |
| frames | "url" | "srcdoc" | "url" | srcdoc: small pages in sandboxed frames, for demos. url: made-up addresses, for tests. |
| appearance | ElementAppearance | {} | Named, checked style values for the elements: accent, radius, fontFamily and more. |
| code | string | "123456" | email_otp: the code the mock accepts. Never a real code. |
| title | string | "Synthetic NDA (test)" | Envelope title. |
| fields | SignerField[] | Fields to fill in. Default: one required text field. |
Accessibility
- Each frame has an accessible name (title). Inside a frame, the element's own page handles focus and labels.
- The flow sets aria-busy while it loads, saves and confirms, and announces the outcome in a status line.