@arbidocs/react 0.4.158 → 0.4.159
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/dist/{store-CoLuVSxI.d.ts → ProductionDialog-BvRVGdvH.d.ts} +33 -33
- package/dist/{store-BEXGdE1y.d.cts → ProductionDialog-Dhf9MXH-.d.cts} +33 -33
- package/dist/annotations/freeze/index.cjs +15 -15
- package/dist/annotations/freeze/index.d.cts +6 -1
- package/dist/annotations/freeze/index.d.ts +6 -1
- package/dist/annotations/freeze/index.js +3 -3
- package/dist/annotations/index.cjs +56 -56
- package/dist/annotations/index.d.cts +9 -4
- package/dist/annotations/index.d.ts +9 -4
- package/dist/annotations/index.js +2 -2
- package/dist/bundle-COMT7X3A.js +4 -0
- package/dist/{bundle-N2JIJ2T6.js.map → bundle-COMT7X3A.js.map} +1 -1
- package/dist/bundle-UWCOLMAA.cjs +13 -0
- package/dist/{bundle-T6BEVYHE.cjs.map → bundle-UWCOLMAA.cjs.map} +1 -1
- package/dist/{chunk-SSOPIPEX.cjs → chunk-LRBOMQ6Q.cjs} +4 -3
- package/dist/chunk-LRBOMQ6Q.cjs.map +1 -0
- package/dist/{chunk-COWZGCL5.js → chunk-NBIW7AEE.js} +4 -3
- package/dist/chunk-NBIW7AEE.js.map +1 -0
- package/dist/{chunk-ZJMUNGOY.js → chunk-R66GNDO7.js} +42 -4
- package/dist/chunk-R66GNDO7.js.map +1 -0
- package/dist/{chunk-L2PXZWJM.cjs → chunk-RDF2Q45F.cjs} +75 -20
- package/dist/chunk-RDF2Q45F.cjs.map +1 -0
- package/dist/{chunk-IHTBAY57.js → chunk-S33P6THG.js} +59 -4
- package/dist/chunk-S33P6THG.js.map +1 -0
- package/dist/{chunk-QJXFRP5R.cjs → chunk-UP6PIBVF.cjs} +46 -8
- package/dist/chunk-UP6PIBVF.cjs.map +1 -0
- package/dist/document-tools/index.cjs +157 -27
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +110 -13
- package/dist/document-tools/index.d.ts +110 -13
- package/dist/document-tools/index.js +137 -21
- package/dist/document-tools/index.js.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.js +2 -2
- package/dist/{model-DIwXRuGC.d.cts → model-D63gedpb.d.cts} +5 -0
- package/dist/{model-DIwXRuGC.d.ts → model-D63gedpb.d.ts} +5 -0
- package/dist/ui/index.cjs +9 -9
- package/dist/ui/index.js +1 -1
- package/package.json +3 -3
- package/dist/bundle-N2JIJ2T6.js +0 -4
- package/dist/bundle-T6BEVYHE.cjs +0 -13
- package/dist/chunk-COWZGCL5.js.map +0 -1
- package/dist/chunk-IHTBAY57.js.map +0 -1
- package/dist/chunk-L2PXZWJM.cjs.map +0 -1
- package/dist/chunk-QJXFRP5R.cjs.map +0 -1
- package/dist/chunk-SSOPIPEX.cjs.map +0 -1
- package/dist/chunk-ZJMUNGOY.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { fetchDocumentFile, fetchDocumentPdf, DocumentFetchError, useDocumentTools } from '../chunk-2HNEVAXO.js';
|
|
2
2
|
export { DocumentFetchError, DocumentToolsProvider, certificateLink, clientUpload, contentDispositionFileName, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, uploadQueryString, useDocumentTools, useOptionalDocumentTools } from '../chunk-2HNEVAXO.js';
|
|
3
|
+
import { mergeLayers, AnnotationStoreOfflineError } from '../chunk-S33P6THG.js';
|
|
4
|
+
import { parseLayer, emptyLayer, LAYER_SCHEMA_VERSION } from '../chunk-NBIW7AEE.js';
|
|
3
5
|
import { parseVersionRef } from '../chunk-NNWMHMEC.js';
|
|
4
6
|
import '../chunk-WUTL62MC.js';
|
|
5
|
-
import { mergeLayers, AnnotationStoreOfflineError } from '../chunk-IHTBAY57.js';
|
|
6
|
-
import { parseLayer, emptyLayer, LAYER_SCHEMA_VERSION } from '../chunk-COWZGCL5.js';
|
|
7
|
-
import '../chunk-QRCMKEE6.js';
|
|
8
7
|
import '../chunk-YNNAJJ5Z.js';
|
|
8
|
+
import '../chunk-QRCMKEE6.js';
|
|
9
9
|
import '../chunk-47CCGUWR.js';
|
|
10
10
|
import '../chunk-SN5YV6FF.js';
|
|
11
11
|
import '../chunk-CPPBN2JB.js';
|
|
12
12
|
import { useMemo, useState, useCallback, useEffect, useSyncExternalStore } from 'react';
|
|
13
13
|
import { onlineManager, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
14
|
-
import { unlockIdentityWithPassword, signMessage } from '@arbidocs/client';
|
|
14
|
+
import { unlockIdentityWithPassword, signMessage, getUserEncryptionKeypair, sealedBoxDecrypt, sealedBoxEncrypt, initSodium } from '@arbidocs/client';
|
|
15
15
|
|
|
16
16
|
// src/document-tools/production.ts
|
|
17
17
|
var PRODUCTIONS_FOLDER = "Productions";
|
|
@@ -103,7 +103,7 @@ async function buildProduction(client, documents, choices, options) {
|
|
|
103
103
|
if (items.length === 0) {
|
|
104
104
|
throw new Error("None of these documents has a PDF version to number yet.");
|
|
105
105
|
}
|
|
106
|
-
const { buildBundle } = await import('../bundle-
|
|
106
|
+
const { buildBundle } = await import('../bundle-COMT7X3A.js');
|
|
107
107
|
const result = await buildBundle(items, {
|
|
108
108
|
layout: choices.layout,
|
|
109
109
|
bates: {
|
|
@@ -157,8 +157,8 @@ var MarkupStoreError = class extends Error {
|
|
|
157
157
|
status;
|
|
158
158
|
};
|
|
159
159
|
var detailOf = (error, fallback) => {
|
|
160
|
-
const
|
|
161
|
-
return typeof
|
|
160
|
+
const detail3 = error?.detail;
|
|
161
|
+
return typeof detail3 === "string" ? detail3 : fallback;
|
|
162
162
|
};
|
|
163
163
|
async function call(request) {
|
|
164
164
|
try {
|
|
@@ -601,8 +601,8 @@ function isLegibleSignatureBox(rect) {
|
|
|
601
601
|
var SIGNATURES_PATH = "/v1/document/{document_ext_id}/signatures";
|
|
602
602
|
var SIGNATURES_KEY = ["get", SIGNATURES_PATH];
|
|
603
603
|
function errorDetail(error, fallback) {
|
|
604
|
-
const
|
|
605
|
-
return typeof
|
|
604
|
+
const detail3 = error?.detail;
|
|
605
|
+
return typeof detail3 === "string" ? detail3 : fallback;
|
|
606
606
|
}
|
|
607
607
|
async function fetchDocumentSignatures(client, documentRef) {
|
|
608
608
|
const { docId, version } = parseVersionRef(documentRef);
|
|
@@ -633,14 +633,14 @@ var SigningError = class extends Error {
|
|
|
633
633
|
this.reason = reason;
|
|
634
634
|
}
|
|
635
635
|
};
|
|
636
|
-
function signingErrorReason(
|
|
637
|
-
if (/still being prepared/i.test(
|
|
638
|
-
if (/no longer the current version/i.test(
|
|
636
|
+
function signingErrorReason(detail3) {
|
|
637
|
+
if (/still being prepared/i.test(detail3)) return "preparing";
|
|
638
|
+
if (/no longer the current version/i.test(detail3)) return "stale";
|
|
639
639
|
return "failed";
|
|
640
640
|
}
|
|
641
641
|
function signingError(error, fallback) {
|
|
642
|
-
const
|
|
643
|
-
return new SigningError(
|
|
642
|
+
const detail3 = errorDetail(error, fallback);
|
|
643
|
+
return new SigningError(detail3, signingErrorReason(detail3));
|
|
644
644
|
}
|
|
645
645
|
var PREPARE_RETRIES = 3;
|
|
646
646
|
var PREPARE_RETRY_DELAY_MS = 1500;
|
|
@@ -759,9 +759,18 @@ var FIELD_TYPE_LABELS = {
|
|
|
759
759
|
var DEFAULT_FIELD_SIZE = {
|
|
760
760
|
signature: { width: 0.28, height: 0.05 },
|
|
761
761
|
initials: { width: 0.1, height: 0.04 },
|
|
762
|
-
date: { width: 0.
|
|
763
|
-
name: { width: 0.28, height: 0.
|
|
762
|
+
date: { width: 0.22, height: 0.028 },
|
|
763
|
+
name: { width: 0.28, height: 0.028 }
|
|
764
|
+
};
|
|
765
|
+
var SIGNER_PROGRESS_LABELS = {
|
|
766
|
+
invited: "Invited",
|
|
767
|
+
registered: "Not opened yet",
|
|
768
|
+
viewed: "Viewed",
|
|
769
|
+
signed: "Signed",
|
|
770
|
+
declined: "Declined"
|
|
764
771
|
};
|
|
772
|
+
var EMAIL = /^[^@\s<>,;]{1,64}@[^@\s<>,;]{1,255}\.[^@\s<>,;]{1,63}$/;
|
|
773
|
+
var isEmailSigner = (signer) => EMAIL.test(signer.trim());
|
|
765
774
|
var MARK_FIELD_TYPES = ["signature", "initials"];
|
|
766
775
|
var REQUESTS_KEY = ["signature-requests"];
|
|
767
776
|
function detail(error, fallback) {
|
|
@@ -791,9 +800,10 @@ function sendBlocker(fields) {
|
|
|
791
800
|
}
|
|
792
801
|
return null;
|
|
793
802
|
}
|
|
794
|
-
function fieldsFromSuggestions(suggestions, assign) {
|
|
803
|
+
function fieldsFromSuggestions(suggestions, assign, members = /* @__PURE__ */ new Map()) {
|
|
795
804
|
return suggestions.flatMap((s) => {
|
|
796
|
-
const
|
|
805
|
+
const email = s.signer_email?.toLowerCase();
|
|
806
|
+
const signer = email ? members.get(email) ?? email : assign[s.group];
|
|
797
807
|
if (!signer) return [];
|
|
798
808
|
return [
|
|
799
809
|
{
|
|
@@ -805,11 +815,17 @@ function fieldsFromSuggestions(suggestions, assign) {
|
|
|
805
815
|
width: s.width,
|
|
806
816
|
height: s.height,
|
|
807
817
|
signer,
|
|
808
|
-
required: true
|
|
818
|
+
required: s.required ?? true
|
|
809
819
|
}
|
|
810
820
|
];
|
|
811
821
|
});
|
|
812
822
|
}
|
|
823
|
+
function splitSuggestions(suggestions) {
|
|
824
|
+
return {
|
|
825
|
+
placed: suggestions.filter((s) => s.source === "anchor"),
|
|
826
|
+
extras: suggestions.filter((s) => s.source !== "anchor")
|
|
827
|
+
};
|
|
828
|
+
}
|
|
813
829
|
async function fetchDocumentSignatureRequests(client, documentId) {
|
|
814
830
|
const { data, error } = await client.GET("/v1/document/{document_ext_id}/signature-requests", {
|
|
815
831
|
params: { path: { document_ext_id: documentId } }
|
|
@@ -980,7 +996,7 @@ function useSignerCandidates(enabled = true) {
|
|
|
980
996
|
queryFn: async () => {
|
|
981
997
|
const { data, error } = await client.GET("/v1/workspace/users");
|
|
982
998
|
if (!data) throw new Error(detail(error, "The workspace members could not be read"));
|
|
983
|
-
const people = data.filter((m) => m.user.external_id.startsWith("usr-")
|
|
999
|
+
const people = data.filter((m) => m.user.external_id.startsWith("usr-")).map((m) => ({
|
|
984
1000
|
externalId: m.user.external_id,
|
|
985
1001
|
name: [m.user.given_name, m.user.family_name].filter(Boolean).join(" ") || m.user.email,
|
|
986
1002
|
email: m.user.email,
|
|
@@ -995,7 +1011,107 @@ function useSignerCandidates(enabled = true) {
|
|
|
995
1011
|
staleTime: 6e4
|
|
996
1012
|
});
|
|
997
1013
|
}
|
|
1014
|
+
async function inviteSigners(client, documentId, emails) {
|
|
1015
|
+
if (!emails.length) return;
|
|
1016
|
+
const { error, response } = await client.POST("/v1/workspace/users", {
|
|
1017
|
+
body: {
|
|
1018
|
+
emails,
|
|
1019
|
+
role: "guest",
|
|
1020
|
+
confirm_invite: true,
|
|
1021
|
+
resource_type: "document",
|
|
1022
|
+
resource_ext_id: documentId
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
if (response.status === 409) {
|
|
1026
|
+
throw new Error("Share the document with the workspace before asking others to sign it.");
|
|
1027
|
+
}
|
|
1028
|
+
if (error && response.status !== 404) {
|
|
1029
|
+
throw new Error(detail(error, "The signers could not be invited"));
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
function useInviteSigners() {
|
|
1033
|
+
const { client } = useDocumentTools();
|
|
1034
|
+
const invalidate = useInvalidateRequests();
|
|
1035
|
+
const queryClient = useQueryClient();
|
|
1036
|
+
return useMutation({
|
|
1037
|
+
mutationFn: ({ documentId, emails }) => inviteSigners(client, documentId, emails),
|
|
1038
|
+
onSuccess: async () => {
|
|
1039
|
+
await invalidate();
|
|
1040
|
+
await queryClient.invalidateQueries({ queryKey: [...REQUESTS_KEY, "candidates"] });
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
var INFORMAL_SIGNATURE_NOTE = "Informal signature: for verified signing, use Request signatures.";
|
|
1045
|
+
var KEY = ["saved-signature"];
|
|
1046
|
+
async function keypair(source = getUserEncryptionKeypair) {
|
|
1047
|
+
await initSodium();
|
|
1048
|
+
const pair = await source();
|
|
1049
|
+
if (!pair) throw new Error("Sign in again to use your saved signature.");
|
|
1050
|
+
return pair;
|
|
1051
|
+
}
|
|
1052
|
+
function detail2(error, fallback) {
|
|
1053
|
+
const d = error?.detail;
|
|
1054
|
+
return typeof d === "string" ? d : fallback;
|
|
1055
|
+
}
|
|
1056
|
+
async function fetchSavedSignature(client, source) {
|
|
1057
|
+
const { data, error } = await client.GET("/v1/user/signature");
|
|
1058
|
+
if (!data) throw new Error(detail2(error, "Your saved signature could not be read"));
|
|
1059
|
+
if (!data.sealed) return null;
|
|
1060
|
+
const pair = await keypair(source);
|
|
1061
|
+
const json = new TextDecoder().decode(sealedBoxDecrypt(data.sealed, pair.secretKey));
|
|
1062
|
+
return JSON.parse(json);
|
|
1063
|
+
}
|
|
1064
|
+
async function storeSavedSignature(client, signature, source) {
|
|
1065
|
+
const pair = await keypair(source);
|
|
1066
|
+
const sealed = sealedBoxEncrypt(
|
|
1067
|
+
Uint8Array.from(new TextEncoder().encode(JSON.stringify(signature))),
|
|
1068
|
+
pair.publicKey
|
|
1069
|
+
);
|
|
1070
|
+
const { error, response } = await client.PUT("/v1/user/signature", { body: { sealed } });
|
|
1071
|
+
if (!response.ok) throw new Error(detail2(error, "Your signature could not be saved"));
|
|
1072
|
+
}
|
|
1073
|
+
async function deleteSavedSignature(client) {
|
|
1074
|
+
const { error, response } = await client.DELETE("/v1/user/signature");
|
|
1075
|
+
if (!response.ok) throw new Error(detail2(error, "Your saved signature could not be deleted"));
|
|
1076
|
+
}
|
|
1077
|
+
function useSavedSignature(enabled = true) {
|
|
1078
|
+
const { client } = useDocumentTools();
|
|
1079
|
+
return useQuery({
|
|
1080
|
+
queryKey: KEY,
|
|
1081
|
+
queryFn: () => fetchSavedSignature(client),
|
|
1082
|
+
enabled,
|
|
1083
|
+
staleTime: 6e4,
|
|
1084
|
+
retry: false
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
function useStoreSavedSignature() {
|
|
1088
|
+
const { client } = useDocumentTools();
|
|
1089
|
+
const queryClient = useQueryClient();
|
|
1090
|
+
return useMutation({
|
|
1091
|
+
mutationFn: (signature) => storeSavedSignature(client, signature),
|
|
1092
|
+
onSuccess: (_, signature) => queryClient.setQueryData(KEY, signature)
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
function useDeleteSavedSignature() {
|
|
1096
|
+
const { client } = useDocumentTools();
|
|
1097
|
+
const queryClient = useQueryClient();
|
|
1098
|
+
return useMutation({
|
|
1099
|
+
mutationFn: () => deleteSavedSignature(client),
|
|
1100
|
+
onSuccess: () => queryClient.setQueryData(KEY, null)
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
function pngBytes(base64) {
|
|
1104
|
+
const raw = atob(base64);
|
|
1105
|
+
const out = new Uint8Array(raw.length);
|
|
1106
|
+
for (let i = 0; i < raw.length; i++) out[i] = raw.charCodeAt(i);
|
|
1107
|
+
return out;
|
|
1108
|
+
}
|
|
1109
|
+
function pngSize(base64) {
|
|
1110
|
+
const bytes = pngBytes(base64.slice(0, 64));
|
|
1111
|
+
const view = new DataView(bytes.buffer);
|
|
1112
|
+
return { width: view.getUint32(16), height: view.getUint32(20) };
|
|
1113
|
+
}
|
|
998
1114
|
|
|
999
|
-
export { DEFAULT_FIELD_SIZE, FIELD_TYPE_LABELS, LEGACY_LAYER_PREFIX, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, MarkupDownloadError, MarkupStoreError, PRODUCTIONS_FOLDER, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, SignatureVerificationError, SigningError, VERIFY_PATH, addToMarkup, buildProduction, canAnnotate, copyOpenThreads, createMarkupStore, currentHasMarkup, documentBytesKey, fetchDocumentSignatureRequests, fetchDocumentSignatures, fetchMarkupPdf, fetchProductionPdf, fetchSignatureVerification, fieldsFromSuggestions, fieldsInSigningOrder, forgetLegacyLayer, frozenCopyName, hasNoRendition, initialsOf, intentText, isLegibleSignatureBox, isPdfDocument, isSignatureReference, isSignedVersion, marksByVersion, matchSignedCopy, migrateLegacyLayer, newFieldId, openThreadsOf, productionDocumentName, productionFileName, productionFolder, productionIndexCsv, productionTitle, readLegacyLayer, redactionLogName, saveProductionFiles, saveSignatureRequest, sendBlocker, sha256Hex, signDocument, signSignatureRequest, suggestSignatureFields, toAppearance, uploadFrozenCopy, useDeclineSignatureRequest, useDocumentBytes, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useIsOnline, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
1115
|
+
export { DEFAULT_FIELD_SIZE, FIELD_TYPE_LABELS, INFORMAL_SIGNATURE_NOTE, LEGACY_LAYER_PREFIX, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, MarkupDownloadError, MarkupStoreError, PRODUCTIONS_FOLDER, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, SIGNER_PROGRESS_LABELS, SignatureVerificationError, SigningError, VERIFY_PATH, addToMarkup, buildProduction, canAnnotate, copyOpenThreads, createMarkupStore, currentHasMarkup, deleteSavedSignature, documentBytesKey, fetchDocumentSignatureRequests, fetchDocumentSignatures, fetchMarkupPdf, fetchProductionPdf, fetchSavedSignature, fetchSignatureVerification, fieldsFromSuggestions, fieldsInSigningOrder, forgetLegacyLayer, frozenCopyName, hasNoRendition, initialsOf, intentText, inviteSigners, isEmailSigner, isLegibleSignatureBox, isPdfDocument, isSignatureReference, isSignedVersion, marksByVersion, matchSignedCopy, migrateLegacyLayer, newFieldId, openThreadsOf, pngBytes, pngSize, productionDocumentName, productionFileName, productionFolder, productionIndexCsv, productionTitle, readLegacyLayer, redactionLogName, saveProductionFiles, saveSignatureRequest, sendBlocker, sha256Hex, signDocument, signSignatureRequest, splitSuggestions, storeSavedSignature, suggestSignatureFields, toAppearance, uploadFrozenCopy, useDeclineSignatureRequest, useDeleteSavedSignature, useDocumentBytes, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useInviteSigners, useIsOnline, useSaveSignatureRequest, useSavedSignature, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useStoreSavedSignature, useVoidSignatureRequest, versionsWithMarkup };
|
|
1000
1116
|
//# sourceMappingURL=index.js.map
|
|
1001
1117
|
//# sourceMappingURL=index.js.map
|