@colixsystems/widget-sdk 0.218.0 → 0.219.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/README.md +38 -1
- package/dist/contract.cjs +110 -7
- package/dist/contract.js +110 -7
- package/dist/hooks.js +1 -144
- package/dist/index.d.ts +234 -0
- package/dist/index.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/signing-hooks.js +449 -0
- package/dist/signing-state.js +140 -0
- package/package.json +1 -1
- package/src/contract.js +110 -7
package/dist/index.d.ts
CHANGED
|
@@ -4567,3 +4567,237 @@ export function pressableLift(state?: {
|
|
|
4567
4567
|
export function styleGroup(
|
|
4568
4568
|
name: string,
|
|
4569
4569
|
): { dataSet: Record<string, string> } | undefined;
|
|
4570
|
+
|
|
4571
|
+
/* ---------------------------------------------------------------------------
|
|
4572
|
+
* Signing files with BankID, and signing rounds. All read `ctx.filestore`.
|
|
4573
|
+
* Rows are snake_case verbatim.
|
|
4574
|
+
* ------------------------------------------------------------------------- */
|
|
4575
|
+
|
|
4576
|
+
/** Why a name cannot be shown on a signed document; `characters` lists what cannot be shown. */
|
|
4577
|
+
export interface SignatureNameRefusal {
|
|
4578
|
+
reason: "empty" | "too_long" | "unsupported_characters" | "mixed_scripts";
|
|
4579
|
+
characters: string[];
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
/** What a sign order answers when started, polled or cancelled. */
|
|
4583
|
+
export interface FileSignOrderAnswer {
|
|
4584
|
+
status: "pending" | "complete" | "failed" | "cancelled";
|
|
4585
|
+
signature_id?: string;
|
|
4586
|
+
qr?: string | null;
|
|
4587
|
+
auto_start_token?: string | null;
|
|
4588
|
+
hint_code?: string | null;
|
|
4589
|
+
message?: string;
|
|
4590
|
+
signer_name?: string | null;
|
|
4591
|
+
signed_at?: string | null;
|
|
4592
|
+
name_refusal?: SignatureNameRefusal;
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4595
|
+
export interface FileSignatureVerdict {
|
|
4596
|
+
valid: boolean;
|
|
4597
|
+
checks: Record<string, boolean>;
|
|
4598
|
+
reason: string | null;
|
|
4599
|
+
signer_name: string | null;
|
|
4600
|
+
personal_number: string | null;
|
|
4601
|
+
signed_at: string | null;
|
|
4602
|
+
content_status: "unchanged" | "changed" | "unavailable";
|
|
4603
|
+
signed_by_others_since: number | null;
|
|
4604
|
+
seal: Record<string, unknown>;
|
|
4605
|
+
}
|
|
4606
|
+
|
|
4607
|
+
/**
|
|
4608
|
+
* Drive a BankID signing flow for one file. Pass `existingSignatureId` for a
|
|
4609
|
+
* file the user has already signed to show that state and `verify()` it
|
|
4610
|
+
* without opening a new order. A null `fileId` makes every action a no-op.
|
|
4611
|
+
*/
|
|
4612
|
+
export function useFileSignature(
|
|
4613
|
+
fileId: string | null | undefined,
|
|
4614
|
+
existingSignatureId?: string | null,
|
|
4615
|
+
): {
|
|
4616
|
+
status: "pending" | "complete" | "failed" | "cancelled" | null;
|
|
4617
|
+
/** PNG data-URL of the animated BankID QR code while there is one to scan. */
|
|
4618
|
+
qr: string | null;
|
|
4619
|
+
/** Opens BankID on this device; null once the user has signed or the order has ended. */
|
|
4620
|
+
autoStartToken: string | null;
|
|
4621
|
+
message: string | null;
|
|
4622
|
+
signerName: string | null;
|
|
4623
|
+
signedAt: string | null;
|
|
4624
|
+
/** Where the order stands. "sealing": signed, and being added to the document. */
|
|
4625
|
+
hintCode: string | null;
|
|
4626
|
+
/** Set when the order failed because the signer's name cannot be shown. */
|
|
4627
|
+
nameRefusal: SignatureNameRefusal | null;
|
|
4628
|
+
verdict: FileSignatureVerdict | null;
|
|
4629
|
+
loading: boolean;
|
|
4630
|
+
error: PermissionError | null;
|
|
4631
|
+
initiate(): Promise<FileSignOrderAnswer | null>;
|
|
4632
|
+
refresh(): Promise<void>;
|
|
4633
|
+
/** Resolves to what became of the order, which is not always "cancelled". */
|
|
4634
|
+
cancel(): Promise<FileSignOrderAnswer | undefined>;
|
|
4635
|
+
verify(): Promise<FileSignatureVerdict | null>;
|
|
4636
|
+
};
|
|
4637
|
+
|
|
4638
|
+
export interface FileSignatureSummary {
|
|
4639
|
+
signature_id: string;
|
|
4640
|
+
subject_file_id: string;
|
|
4641
|
+
signer_name: string | null;
|
|
4642
|
+
signed_at: string | null;
|
|
4643
|
+
}
|
|
4644
|
+
|
|
4645
|
+
/** The signed-in user's own latest signature per file they have signed; other files are absent. */
|
|
4646
|
+
export function useFileSignatures(fileIds: string[] | null | undefined): {
|
|
4647
|
+
signaturesByFileId: Record<string, FileSignatureSummary>;
|
|
4648
|
+
loading: boolean;
|
|
4649
|
+
error: Error | null;
|
|
4650
|
+
refetch(): Promise<void>;
|
|
4651
|
+
};
|
|
4652
|
+
|
|
4653
|
+
export interface FileRosterEntry {
|
|
4654
|
+
app_user_id: string;
|
|
4655
|
+
name: string;
|
|
4656
|
+
signed: boolean;
|
|
4657
|
+
signature_id: string | null;
|
|
4658
|
+
signer_name: string | null;
|
|
4659
|
+
signed_at: string | null;
|
|
4660
|
+
}
|
|
4661
|
+
|
|
4662
|
+
/**
|
|
4663
|
+
* Who is expected to sign a file, for someone who manages the file's folder:
|
|
4664
|
+
* everyone who can open the folder, or the signers of the file's signing round
|
|
4665
|
+
* in the order of their places on the signature page. `error` is set for a user who does not manage the folder.
|
|
4666
|
+
*/
|
|
4667
|
+
export function useFileRoster(
|
|
4668
|
+
fileId: string | null | undefined,
|
|
4669
|
+
options?: { limit?: number; offset?: number; enabled?: boolean },
|
|
4670
|
+
): {
|
|
4671
|
+
roster: FileRosterEntry[];
|
|
4672
|
+
total: number;
|
|
4673
|
+
signedCount: number;
|
|
4674
|
+
loading: boolean;
|
|
4675
|
+
error: Error | null;
|
|
4676
|
+
refetch(): Promise<void>;
|
|
4677
|
+
};
|
|
4678
|
+
|
|
4679
|
+
/** One entry of a refused signing-round action: which signer, and why. */
|
|
4680
|
+
export interface SigningRefusalEntry {
|
|
4681
|
+
field?: string;
|
|
4682
|
+
message: string;
|
|
4683
|
+
code?: string;
|
|
4684
|
+
app_user_id?: string;
|
|
4685
|
+
reason?: SignatureNameRefusal["reason"];
|
|
4686
|
+
characters?: string[];
|
|
4687
|
+
}
|
|
4688
|
+
|
|
4689
|
+
/** A refusal: the server's `code` and `message`, the refused signers, and the seconds to wait. */
|
|
4690
|
+
export type SigningRoundError = PermissionError & {
|
|
4691
|
+
errors: SigningRefusalEntry[];
|
|
4692
|
+
retryAfter: number | null;
|
|
4693
|
+
};
|
|
4694
|
+
|
|
4695
|
+
export interface SigningRoundPlace {
|
|
4696
|
+
position: number;
|
|
4697
|
+
signed: boolean;
|
|
4698
|
+
signed_at: string | null;
|
|
4699
|
+
}
|
|
4700
|
+
|
|
4701
|
+
export interface SigningRoundSummary {
|
|
4702
|
+
id: string;
|
|
4703
|
+
status: "DRAFT" | "OPEN" | "COMPLETED";
|
|
4704
|
+
signer_count: number;
|
|
4705
|
+
/** For someone who manages the folder; null for a signer. */
|
|
4706
|
+
signed_count: number | null;
|
|
4707
|
+
/** The user's own place when they are one of the signers. */
|
|
4708
|
+
my_place: SigningRoundPlace | null;
|
|
4709
|
+
/** The round is open and the user's place is unsigned. Signers sign in any order. */
|
|
4710
|
+
can_sign: boolean;
|
|
4711
|
+
}
|
|
4712
|
+
|
|
4713
|
+
export interface FileSigningOverview {
|
|
4714
|
+
file_id: string;
|
|
4715
|
+
can_manage: boolean;
|
|
4716
|
+
/**
|
|
4717
|
+
* The user manages the folder, the file is a shared PDF and has no round.
|
|
4718
|
+
* About the file and the user only: offer "prepare" when this AND
|
|
4719
|
+
* `roundsEnabled` are true. Preparing can still be refused.
|
|
4720
|
+
*/
|
|
4721
|
+
can_prepare: boolean;
|
|
4722
|
+
/** Null without a round, and for a user who is neither a manager nor one of its signers. */
|
|
4723
|
+
round: SigningRoundSummary | null;
|
|
4724
|
+
/** "signing_round": the file cannot be changed. "signed": its content cannot be replaced. */
|
|
4725
|
+
locked: "signing_round" | "signed" | null;
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4728
|
+
/**
|
|
4729
|
+
* What the signed-in user may know about the signing round of each file, in
|
|
4730
|
+
* one batched read. A file the user cannot see has no entry. `roundsEnabled`
|
|
4731
|
+
* is false when the workspace cannot start signing rounds, null until known.
|
|
4732
|
+
*/
|
|
4733
|
+
export function useSigningRounds(fileIds: string[] | null | undefined): {
|
|
4734
|
+
byFileId: Record<string, FileSigningOverview>;
|
|
4735
|
+
roundsEnabled: boolean | null;
|
|
4736
|
+
loading: boolean;
|
|
4737
|
+
error: SigningRoundError | null;
|
|
4738
|
+
refresh(): Promise<void>;
|
|
4739
|
+
};
|
|
4740
|
+
|
|
4741
|
+
export interface SigningRoundSigner {
|
|
4742
|
+
name: string;
|
|
4743
|
+
position: number;
|
|
4744
|
+
/** Present for every place when the user manages the folder; otherwise for their own place only. */
|
|
4745
|
+
app_user_id?: string;
|
|
4746
|
+
signed?: boolean;
|
|
4747
|
+
signed_at?: string | null;
|
|
4748
|
+
/** The name BankID verified on this place. Managers only. */
|
|
4749
|
+
signed_as?: string | null;
|
|
4750
|
+
}
|
|
4751
|
+
|
|
4752
|
+
export interface SigningRound {
|
|
4753
|
+
id: string;
|
|
4754
|
+
file_id: string;
|
|
4755
|
+
status: "DRAFT" | "OPEN" | "COMPLETED" | "CANCELLED";
|
|
4756
|
+
prepared_size_bytes: number;
|
|
4757
|
+
original_version: number | null;
|
|
4758
|
+
created_by_id?: string | null;
|
|
4759
|
+
created_at: string;
|
|
4760
|
+
updated_at: string;
|
|
4761
|
+
confirmed_at: string | null;
|
|
4762
|
+
completed_at: string | null;
|
|
4763
|
+
cancelled_at: string | null;
|
|
4764
|
+
/** When an unconfirmed draft stops being usable; null once confirmed. */
|
|
4765
|
+
expires_at: string | null;
|
|
4766
|
+
signers: SigningRoundSigner[];
|
|
4767
|
+
}
|
|
4768
|
+
|
|
4769
|
+
export interface SigningRoundPreparedFile {
|
|
4770
|
+
url: string;
|
|
4771
|
+
sha256: string;
|
|
4772
|
+
expires_at: string;
|
|
4773
|
+
size_bytes: number;
|
|
4774
|
+
}
|
|
4775
|
+
|
|
4776
|
+
/**
|
|
4777
|
+
* One file's current signing round and the actions of someone who manages the
|
|
4778
|
+
* file's folder. `confirm()` opens the round for the document `preparedFile()`
|
|
4779
|
+
* last returned and rejects with code `PREVIEW_REQUIRED` without it. A refused
|
|
4780
|
+
* action sets `error` and rejects with it; code `SIGNING_ROUNDS_NOT_ENABLED`
|
|
4781
|
+
* means the workspace cannot start signing rounds.
|
|
4782
|
+
*
|
|
4783
|
+
* One action runs at a time: while `busy` is true another one rejects at once
|
|
4784
|
+
* with code `ACTION_IN_PROGRESS` and is not queued. `round` is never a
|
|
4785
|
+
* cancelled round; `cancel()` resolves to the round it ended. When `fileId`
|
|
4786
|
+
* or the signed-in user changes, `round` is null and `loading` true until the
|
|
4787
|
+
* new answer arrives.
|
|
4788
|
+
*/
|
|
4789
|
+
export function useSigningRound(fileId: string | null | undefined): {
|
|
4790
|
+
round: SigningRound | null;
|
|
4791
|
+
loading: boolean;
|
|
4792
|
+
error: SigningRoundError | null;
|
|
4793
|
+
refresh(): Promise<void>;
|
|
4794
|
+
/** `signerIds` in the order their places appear on the signature page. Resolves to the DRAFT. */
|
|
4795
|
+
prepare(signerIds: string[]): Promise<SigningRound>;
|
|
4796
|
+
preparedFile(): Promise<SigningRoundPreparedFile>;
|
|
4797
|
+
/** Resolves to the OPEN round. */
|
|
4798
|
+
confirm(): Promise<SigningRound>;
|
|
4799
|
+
/** Resolves to the round it ended, with status "CANCELLED". */
|
|
4800
|
+
cancel(): Promise<SigningRound>;
|
|
4801
|
+
/** An action is running; another one is refused with `ACTION_IN_PROGRESS`. */
|
|
4802
|
+
busy: boolean;
|
|
4803
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,6 @@ export {
|
|
|
48
48
|
useFilestoreCreateFolder,
|
|
49
49
|
useFilestoreCopy,
|
|
50
50
|
useFilestoreDelete,
|
|
51
|
-
useFileSignature,
|
|
52
51
|
useFileSignatures,
|
|
53
52
|
useFileRoster,
|
|
54
53
|
useFolderPermissions,
|
|
@@ -131,6 +130,7 @@ export {
|
|
|
131
130
|
useInactiveUsers,
|
|
132
131
|
} from "./stats-hooks.js";
|
|
133
132
|
// sc-11025 — one source, bound to how each platform says the app is in front.
|
|
133
|
+
export { useFileSignature, useSigningRounds, useSigningRound } from "./signing-hooks.js";
|
|
134
134
|
export { useOnlineMembers, useOnlineVisibility } from "./presence.js";
|
|
135
135
|
// sc-6607 — `<Overlay>` is one shared component (./overlay-view.js) bound to
|
|
136
136
|
// each platform's primitives, so a widget's modal escapes its container box
|
package/dist/index.native.js
CHANGED
|
@@ -48,7 +48,6 @@ export {
|
|
|
48
48
|
useFilestoreCreateFolder,
|
|
49
49
|
useFilestoreCopy,
|
|
50
50
|
useFilestoreDelete,
|
|
51
|
-
useFileSignature,
|
|
52
51
|
useFileSignatures,
|
|
53
52
|
useFileRoster,
|
|
54
53
|
useFolderPermissions,
|
|
@@ -129,6 +128,7 @@ export {
|
|
|
129
128
|
useInactiveUsers,
|
|
130
129
|
} from "./stats-hooks.js";
|
|
131
130
|
// sc-11025 — see the note on the web mirror in ./index.js.
|
|
131
|
+
export { useFileSignature, useSigningRounds, useSigningRound } from "./signing-hooks.js";
|
|
132
132
|
export { useOnlineMembers, useOnlineVisibility } from "./presence.native.js";
|
|
133
133
|
// sc-6607 — see the note on the web mirror in ./index.js.
|
|
134
134
|
export { Overlay } from "./overlay.native.js";
|