@schnsrw/casual-sheets 0.2.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/LICENSE +200 -0
- package/dist/embed.cjs +211 -0
- package/dist/embed.cjs.map +1 -0
- package/dist/embed.d.cts +193 -0
- package/dist/embed.d.ts +193 -0
- package/dist/embed.js +183 -0
- package/dist/embed.js.map +1 -0
- package/dist/index.cjs +899 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +864 -0
- package/dist/index.js.map +1 -0
- package/dist/signing.cjs +716 -0
- package/dist/signing.cjs.map +1 -0
- package/dist/signing.d.cts +141 -0
- package/dist/signing.d.ts +141 -0
- package/dist/signing.js +683 -0
- package/dist/signing.js.map +1 -0
- package/dist/types-s_O0u6Cg.d.cts +90 -0
- package/dist/types-s_O0u6Cg.d.ts +90 -0
- package/package.json +77 -0
- package/src/embed/EmbedTransport.ts +295 -0
- package/src/embed/EmbedTransport.unit.test.ts +161 -0
- package/src/embed/index.ts +40 -0
- package/src/embed/protocol.ts +161 -0
- package/src/index.ts +13 -0
- package/src/signing/SigningPane.tsx +374 -0
- package/src/signing/SigningProvider.tsx +126 -0
- package/src/signing/captures.tsx +316 -0
- package/src/signing/controller.ts +151 -0
- package/src/signing/controller.unit.test.ts +133 -0
- package/src/signing/index.ts +44 -0
- package/src/signing/types.ts +89 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing types — mirror the iframe-protocol envelopes from
|
|
3
|
+
* `docs/internal/13-iframe-protocol.md` so the SDK and iframe
|
|
4
|
+
* deliveries can hand the same payloads back and forth.
|
|
5
|
+
*
|
|
6
|
+
* Uniform across `app: 'docs' | 'sheet'`. Only the `anchor`
|
|
7
|
+
* discriminator changes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type SignatureMethod = 'drawn' | 'typed' | 'uploaded';
|
|
11
|
+
|
|
12
|
+
export type SignatureMode = 'sequential' | 'concurrent';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Doc-anchored field — paragraph id from the editor's `w14:paraId`,
|
|
16
|
+
* with an optional sub-paragraph search for placing the signature
|
|
17
|
+
* inside a phrase rather than a whole block.
|
|
18
|
+
*/
|
|
19
|
+
export interface DocAnchor {
|
|
20
|
+
kind: 'doc';
|
|
21
|
+
paraId: string;
|
|
22
|
+
search?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Sheet-anchored field — `sheet` name + A1-style `cell` ref. */
|
|
26
|
+
export interface SheetAnchor {
|
|
27
|
+
kind: 'sheet';
|
|
28
|
+
sheet: string;
|
|
29
|
+
cell: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SignatureAnchor = DocAnchor | SheetAnchor;
|
|
33
|
+
|
|
34
|
+
export interface SignatureField {
|
|
35
|
+
/** Per-field id supplied by the host; echoed on every progress event. */
|
|
36
|
+
fieldId: string;
|
|
37
|
+
/** Label rendered next to the field — "Employee signature", etc. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** Required fields must complete before `onComplete` fires. */
|
|
40
|
+
required: boolean;
|
|
41
|
+
/** Where the signature lands in the document. */
|
|
42
|
+
anchor: SignatureAnchor;
|
|
43
|
+
/** Allowed signature methods. */
|
|
44
|
+
methods: SignatureMethod[];
|
|
45
|
+
/** Optional signer identity the host knows about. */
|
|
46
|
+
signer?: { name?: string; email?: string };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Payload emitted when a signer completes one field. */
|
|
50
|
+
export interface SignedFieldPayload {
|
|
51
|
+
fieldId: string;
|
|
52
|
+
method: SignatureMethod;
|
|
53
|
+
/** Raw signature material — PNG for drawn, UTF-8 string-as-bytes for typed, host-attested bytes for uploaded. */
|
|
54
|
+
bytes: ArrayBuffer;
|
|
55
|
+
mime: string;
|
|
56
|
+
/** Client wall-clock at completion; host typically pairs with a server timestamp. */
|
|
57
|
+
signedAt: string;
|
|
58
|
+
/** Optional placement hint a host generating a flat PDF can use. */
|
|
59
|
+
placement?: { page: number; xPct: number; yPct: number };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Payload emitted when all required fields are signed. */
|
|
63
|
+
export interface SignatureCompletePayload {
|
|
64
|
+
fieldIds: string[];
|
|
65
|
+
/** Document bytes WITH stamps applied — note (v1): the editor
|
|
66
|
+
* returns the unmodified document and a `fields` map so the
|
|
67
|
+
* HOST stamps the final bytes. v2 lands editor-side stamping. */
|
|
68
|
+
bytes: ArrayBuffer;
|
|
69
|
+
fields: Record<string, SignedFieldPayload>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type CancelReason = 'signer_cancelled' | 'session_expired' | 'host_aborted';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Configuration the host hands the editor when opening a signing
|
|
76
|
+
* session. Maps 1:1 to the iframe `signature.request` envelope.
|
|
77
|
+
*/
|
|
78
|
+
export interface SigningSessionConfig {
|
|
79
|
+
fields: SignatureField[];
|
|
80
|
+
mode: SignatureMode;
|
|
81
|
+
/** Optional banner the editor renders at the top of the pane. */
|
|
82
|
+
banner?: string;
|
|
83
|
+
/** Fires once per field as the signer completes it. */
|
|
84
|
+
onFieldSigned?: (payload: SignedFieldPayload) => void | Promise<void>;
|
|
85
|
+
/** Fires after every required field is signed. */
|
|
86
|
+
onComplete?: (payload: SignatureCompletePayload) => void | Promise<void>;
|
|
87
|
+
/** Fires when either side aborts the session. */
|
|
88
|
+
onCancel?: (payload: { reason: CancelReason }) => void;
|
|
89
|
+
}
|