@arbidocs/react 0.4.127 → 0.4.129
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/artifacts/index.cjs +20 -2
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +17 -1
- package/dist/artifacts/index.d.ts +17 -1
- package/dist/artifacts/index.js +17 -2
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-GX75JCPR.cjs → chunk-65WT5PHA.cjs} +361 -189
- package/dist/chunk-65WT5PHA.cjs.map +1 -0
- package/dist/{chunk-ECOSGMTW.js → chunk-6AWF4HFU.js} +14 -6
- package/dist/chunk-6AWF4HFU.js.map +1 -0
- package/dist/chunk-6JSXDLIQ.js +101 -0
- package/dist/chunk-6JSXDLIQ.js.map +1 -0
- package/dist/{chunk-F7KQVVD2.cjs → chunk-BOJHNPNJ.cjs} +14 -6
- package/dist/chunk-BOJHNPNJ.cjs.map +1 -0
- package/dist/{chunk-EKRRORFO.js → chunk-C44GO33B.js} +105 -46
- package/dist/chunk-C44GO33B.js.map +1 -0
- package/dist/{chunk-5PQO46PE.js → chunk-J3BYHBKW.js} +358 -189
- package/dist/chunk-J3BYHBKW.js.map +1 -0
- package/dist/{chunk-TBELZWGV.cjs → chunk-OC7F5SNA.cjs} +108 -44
- package/dist/chunk-OC7F5SNA.cjs.map +1 -0
- package/dist/chunk-S7J5SCTZ.cjs +110 -0
- package/dist/chunk-S7J5SCTZ.cjs.map +1 -0
- package/dist/document-tools/index.cjs +72 -124
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +16 -4
- package/dist/document-tools/index.d.ts +16 -4
- package/dist/document-tools/index.js +30 -106
- package/dist/document-tools/index.js.map +1 -1
- package/dist/{index-B1O2cqOo.d.cts → index-2Y2MVegs.d.cts} +85 -6
- package/dist/{index-B1O2cqOo.d.ts → index-2Y2MVegs.d.ts} +85 -6
- package/dist/index.cjs +250 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -8
- package/dist/index.d.ts +33 -8
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/shell/index.cjs +6 -6
- package/dist/shell/index.js +1 -1
- package/dist/ui/index.cjs +152 -128
- package/dist/ui/index.d.cts +2 -1
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +3 -3
- package/dist/viewers/index.cjs +91 -0
- package/dist/viewers/index.cjs.map +1 -1
- package/dist/viewers/index.d.cts +62 -1
- package/dist/viewers/index.d.ts +62 -1
- package/dist/viewers/index.js +90 -1
- package/dist/viewers/index.js.map +1 -1
- package/package.json +8 -3
- package/dist/chunk-5PQO46PE.js.map +0 -1
- package/dist/chunk-ECOSGMTW.js.map +0 -1
- package/dist/chunk-EKRRORFO.js.map +0 -1
- package/dist/chunk-F7KQVVD2.cjs.map +0 -1
- package/dist/chunk-GX75JCPR.cjs.map +0 -1
- package/dist/chunk-TBELZWGV.cjs.map +0 -1
|
@@ -91,7 +91,11 @@ interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {
|
|
|
91
91
|
doc_ext_ids?: string[];
|
|
92
92
|
} | undefined>;
|
|
93
93
|
}
|
|
94
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at
|
|
96
|
+
* once: revoking straight after `click()` can cancel the download (Safari, and large files
|
|
97
|
+
* elsewhere) before the browser has read the blob.
|
|
98
|
+
*/
|
|
95
99
|
declare function downloadBlob(blob: Blob, fileName: string): void;
|
|
96
100
|
/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */
|
|
97
101
|
declare function clientUpload(client: DocumentToolsClient): ({ file, query }: DocumentUploadRequest) => Promise<{
|
|
@@ -137,13 +141,21 @@ declare class DocumentFetchError extends Error {
|
|
|
137
141
|
readonly status: number;
|
|
138
142
|
constructor(message: string, status: number);
|
|
139
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987
|
|
146
|
+
* `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.
|
|
147
|
+
*/
|
|
148
|
+
declare function contentDispositionFileName(header: string | null | undefined): string | undefined;
|
|
140
149
|
/**
|
|
141
150
|
* The PDF of a document version: `GET /v1/document/{id}/view?version=` with
|
|
142
151
|
* `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).
|
|
143
152
|
*/
|
|
144
153
|
declare function fetchDocumentPdf(client: DocumentToolsClient, documentRef: string, options?: DocumentFetchOptions): Promise<Blob>;
|
|
145
|
-
/**
|
|
146
|
-
|
|
154
|
+
/**
|
|
155
|
+
* The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the
|
|
156
|
+
* server names the file (`Content-Disposition`), the result is a `File` carrying that name.
|
|
157
|
+
*/
|
|
158
|
+
declare function fetchDocumentFile(client: DocumentToolsClient, documentRef: string, options?: DocumentFetchOptions): Promise<Blob | File>;
|
|
147
159
|
|
|
148
160
|
/**
|
|
149
161
|
* Production sets: number the selected documents with Bates labels (optionally a QR code back to
|
|
@@ -789,4 +801,4 @@ interface SignerCandidate {
|
|
|
789
801
|
*/
|
|
790
802
|
declare function useSignerCandidates(enabled?: boolean): _tanstack_react_query.UseQueryResult<NoInfer<SignerCandidate[]>, Error>;
|
|
791
803
|
|
|
792
|
-
export { type AdoptedSignature, type AnnotatableState, type BuildProductionOptions, type BuiltProduction, type CopyMatch, DEFAULT_FIELD_SIZE, type DocumentChange, DocumentFetchError, type DocumentFetchOptions, type DocumentToolsClient, type DocumentToolsEnvironment, type DocumentToolsNoticeKind, type DocumentToolsNoticeOptions, type DocumentToolsNotify, DocumentToolsProvider, type DocumentToolsProviderProps, type DocumentToolsUser, type DocumentUploadQuery, type DocumentUploadRequest, FIELD_TYPE_LABELS, type FrozenCopySource, LEGACY_LAYER_PREFIX, type LegacyPrompt, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, type MarkupDocument, MarkupDownloadError, type MarkupSnapshot, type MarkupStore, MarkupStoreError, type MarkupStoreOptions, type OlderMarkupNote, PRODUCTIONS_FOLDER, type ProductionSource, type ProductionUpload, type ResolvedDocumentToolsEnvironment, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, type SaveSignatureRequestVars, type SignDocumentResponse, type SignDocumentVars, type SignRequestSignResponse, type SignRequestVars, type SignatureAppearance, type SignatureField, type SignatureFieldType, type SignatureRecord, type SignatureRequest, type SignatureRequestSigner, type SignatureStatusResponse, type SignatureVerification, SignatureVerificationError, type SignerCandidate, type SignerDetails, SigningError, type SigningErrorReason, type SuggestedSignatureField, VERIFY_PATH, type VerifiedSignature, type VersionInfo, addToMarkup, buildProduction, canAnnotate, certificateLink, clientUpload, copyOpenThreads, createMarkupStore, currentHasMarkup, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, 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, uploadQueryString, useDeclineSignatureRequest, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useDocumentTools, useIsOnline, useOptionalDocumentTools, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
804
|
+
export { type AdoptedSignature, type AnnotatableState, type BuildProductionOptions, type BuiltProduction, type CopyMatch, DEFAULT_FIELD_SIZE, type DocumentChange, DocumentFetchError, type DocumentFetchOptions, type DocumentToolsClient, type DocumentToolsEnvironment, type DocumentToolsNoticeKind, type DocumentToolsNoticeOptions, type DocumentToolsNotify, DocumentToolsProvider, type DocumentToolsProviderProps, type DocumentToolsUser, type DocumentUploadQuery, type DocumentUploadRequest, FIELD_TYPE_LABELS, type FrozenCopySource, LEGACY_LAYER_PREFIX, type LegacyPrompt, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, type MarkupDocument, MarkupDownloadError, type MarkupSnapshot, type MarkupStore, MarkupStoreError, type MarkupStoreOptions, type OlderMarkupNote, PRODUCTIONS_FOLDER, type ProductionSource, type ProductionUpload, type ResolvedDocumentToolsEnvironment, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, type SaveSignatureRequestVars, type SignDocumentResponse, type SignDocumentVars, type SignRequestSignResponse, type SignRequestVars, type SignatureAppearance, type SignatureField, type SignatureFieldType, type SignatureRecord, type SignatureRequest, type SignatureRequestSigner, type SignatureStatusResponse, type SignatureVerification, SignatureVerificationError, type SignerCandidate, type SignerDetails, SigningError, type SigningErrorReason, type SuggestedSignatureField, VERIFY_PATH, type VerifiedSignature, type VersionInfo, addToMarkup, buildProduction, canAnnotate, certificateLink, clientUpload, contentDispositionFileName, copyOpenThreads, createMarkupStore, currentHasMarkup, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, 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, uploadQueryString, useDeclineSignatureRequest, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useDocumentTools, useIsOnline, useOptionalDocumentTools, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
@@ -91,7 +91,11 @@ interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {
|
|
|
91
91
|
doc_ext_ids?: string[];
|
|
92
92
|
} | undefined>;
|
|
93
93
|
}
|
|
94
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at
|
|
96
|
+
* once: revoking straight after `click()` can cancel the download (Safari, and large files
|
|
97
|
+
* elsewhere) before the browser has read the blob.
|
|
98
|
+
*/
|
|
95
99
|
declare function downloadBlob(blob: Blob, fileName: string): void;
|
|
96
100
|
/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */
|
|
97
101
|
declare function clientUpload(client: DocumentToolsClient): ({ file, query }: DocumentUploadRequest) => Promise<{
|
|
@@ -137,13 +141,21 @@ declare class DocumentFetchError extends Error {
|
|
|
137
141
|
readonly status: number;
|
|
138
142
|
constructor(message: string, status: number);
|
|
139
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987
|
|
146
|
+
* `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.
|
|
147
|
+
*/
|
|
148
|
+
declare function contentDispositionFileName(header: string | null | undefined): string | undefined;
|
|
140
149
|
/**
|
|
141
150
|
* The PDF of a document version: `GET /v1/document/{id}/view?version=` with
|
|
142
151
|
* `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).
|
|
143
152
|
*/
|
|
144
153
|
declare function fetchDocumentPdf(client: DocumentToolsClient, documentRef: string, options?: DocumentFetchOptions): Promise<Blob>;
|
|
145
|
-
/**
|
|
146
|
-
|
|
154
|
+
/**
|
|
155
|
+
* The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the
|
|
156
|
+
* server names the file (`Content-Disposition`), the result is a `File` carrying that name.
|
|
157
|
+
*/
|
|
158
|
+
declare function fetchDocumentFile(client: DocumentToolsClient, documentRef: string, options?: DocumentFetchOptions): Promise<Blob | File>;
|
|
147
159
|
|
|
148
160
|
/**
|
|
149
161
|
* Production sets: number the selected documents with Bates labels (optionally a QR code back to
|
|
@@ -789,4 +801,4 @@ interface SignerCandidate {
|
|
|
789
801
|
*/
|
|
790
802
|
declare function useSignerCandidates(enabled?: boolean): _tanstack_react_query.UseQueryResult<NoInfer<SignerCandidate[]>, Error>;
|
|
791
803
|
|
|
792
|
-
export { type AdoptedSignature, type AnnotatableState, type BuildProductionOptions, type BuiltProduction, type CopyMatch, DEFAULT_FIELD_SIZE, type DocumentChange, DocumentFetchError, type DocumentFetchOptions, type DocumentToolsClient, type DocumentToolsEnvironment, type DocumentToolsNoticeKind, type DocumentToolsNoticeOptions, type DocumentToolsNotify, DocumentToolsProvider, type DocumentToolsProviderProps, type DocumentToolsUser, type DocumentUploadQuery, type DocumentUploadRequest, FIELD_TYPE_LABELS, type FrozenCopySource, LEGACY_LAYER_PREFIX, type LegacyPrompt, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, type MarkupDocument, MarkupDownloadError, type MarkupSnapshot, type MarkupStore, MarkupStoreError, type MarkupStoreOptions, type OlderMarkupNote, PRODUCTIONS_FOLDER, type ProductionSource, type ProductionUpload, type ResolvedDocumentToolsEnvironment, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, type SaveSignatureRequestVars, type SignDocumentResponse, type SignDocumentVars, type SignRequestSignResponse, type SignRequestVars, type SignatureAppearance, type SignatureField, type SignatureFieldType, type SignatureRecord, type SignatureRequest, type SignatureRequestSigner, type SignatureStatusResponse, type SignatureVerification, SignatureVerificationError, type SignerCandidate, type SignerDetails, SigningError, type SigningErrorReason, type SuggestedSignatureField, VERIFY_PATH, type VerifiedSignature, type VersionInfo, addToMarkup, buildProduction, canAnnotate, certificateLink, clientUpload, copyOpenThreads, createMarkupStore, currentHasMarkup, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, 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, uploadQueryString, useDeclineSignatureRequest, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useDocumentTools, useIsOnline, useOptionalDocumentTools, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
804
|
+
export { type AdoptedSignature, type AnnotatableState, type BuildProductionOptions, type BuiltProduction, type CopyMatch, DEFAULT_FIELD_SIZE, type DocumentChange, DocumentFetchError, type DocumentFetchOptions, type DocumentToolsClient, type DocumentToolsEnvironment, type DocumentToolsNoticeKind, type DocumentToolsNoticeOptions, type DocumentToolsNotify, DocumentToolsProvider, type DocumentToolsProviderProps, type DocumentToolsUser, type DocumentUploadQuery, type DocumentUploadRequest, FIELD_TYPE_LABELS, type FrozenCopySource, LEGACY_LAYER_PREFIX, type LegacyPrompt, MARK_FIELD_TYPES, MAX_MERGE_ATTEMPTS, type MarkupDocument, MarkupDownloadError, type MarkupSnapshot, type MarkupStore, MarkupStoreError, type MarkupStoreOptions, type OlderMarkupNote, PRODUCTIONS_FOLDER, type ProductionSource, type ProductionUpload, type ResolvedDocumentToolsEnvironment, SIGNATURE_FIELD_TYPES, SIGNED_LOCKED_REASON, SIGNED_UNCHANGED, type SaveSignatureRequestVars, type SignDocumentResponse, type SignDocumentVars, type SignRequestSignResponse, type SignRequestVars, type SignatureAppearance, type SignatureField, type SignatureFieldType, type SignatureRecord, type SignatureRequest, type SignatureRequestSigner, type SignatureStatusResponse, type SignatureVerification, SignatureVerificationError, type SignerCandidate, type SignerDetails, SigningError, type SigningErrorReason, type SuggestedSignatureField, VERIFY_PATH, type VerifiedSignature, type VersionInfo, addToMarkup, buildProduction, canAnnotate, certificateLink, clientUpload, contentDispositionFileName, copyOpenThreads, createMarkupStore, currentHasMarkup, defaultCertificateUrl, downloadBlob, fetchDocumentFile, fetchDocumentPdf, 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, uploadQueryString, useDeclineSignatureRequest, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useDocumentTools, useIsOnline, useOptionalDocumentTools, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
@@ -1,112 +1,19 @@
|
|
|
1
|
+
import { useDocumentTools } from '../chunk-6JSXDLIQ.js';
|
|
2
|
+
export { DocumentToolsProvider, certificateLink, clientUpload, defaultCertificateUrl, downloadBlob, uploadQueryString, useDocumentTools, useOptionalDocumentTools } from '../chunk-6JSXDLIQ.js';
|
|
3
|
+
import { mergeLayers, AnnotationStoreOfflineError } from '../chunk-IHTBAY57.js';
|
|
4
|
+
import { parseLayer, emptyLayer, LAYER_SCHEMA_VERSION } from '../chunk-COWZGCL5.js';
|
|
1
5
|
import { parseVersionRef } from '../chunk-74UTKIWQ.js';
|
|
2
6
|
import '../chunk-G6FHNURH.js';
|
|
3
7
|
import '../chunk-WUTL62MC.js';
|
|
4
|
-
import { mergeLayers, AnnotationStoreOfflineError } from '../chunk-IHTBAY57.js';
|
|
5
|
-
import { parseLayer, emptyLayer, LAYER_SCHEMA_VERSION } from '../chunk-COWZGCL5.js';
|
|
6
|
-
import '../chunk-QRCMKEE6.js';
|
|
7
8
|
import '../chunk-YNNAJJ5Z.js';
|
|
9
|
+
import '../chunk-QRCMKEE6.js';
|
|
8
10
|
import '../chunk-47CCGUWR.js';
|
|
9
11
|
import '../chunk-SN5YV6FF.js';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { jsx } from 'react/jsx-runtime';
|
|
12
|
+
import '../chunk-BUFDJCDS.js';
|
|
13
|
+
import { useMemo, useState, useCallback, useEffect, useSyncExternalStore } from 'react';
|
|
13
14
|
import { onlineManager, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
14
15
|
import { unlockIdentityWithPassword, signMessage } from '@arbidocs/client';
|
|
15
16
|
|
|
16
|
-
function uploadQueryString(query) {
|
|
17
|
-
const params = new URLSearchParams();
|
|
18
|
-
for (const [key, value] of Object.entries(query)) {
|
|
19
|
-
if (value === null || value === void 0) continue;
|
|
20
|
-
for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item));
|
|
21
|
-
}
|
|
22
|
-
return params.toString();
|
|
23
|
-
}
|
|
24
|
-
function downloadBlob(blob, fileName) {
|
|
25
|
-
const url = URL.createObjectURL(blob);
|
|
26
|
-
const a = document.createElement("a");
|
|
27
|
-
a.href = url;
|
|
28
|
-
a.download = fileName;
|
|
29
|
-
document.body.appendChild(a);
|
|
30
|
-
a.click();
|
|
31
|
-
a.remove();
|
|
32
|
-
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
33
|
-
}
|
|
34
|
-
function clientUpload(client) {
|
|
35
|
-
return async ({ file, query }) => {
|
|
36
|
-
const formData = new FormData();
|
|
37
|
-
formData.append("files", file);
|
|
38
|
-
const { data, response } = await client.POST("/v1/document/upload", {
|
|
39
|
-
params: { query },
|
|
40
|
-
// The schema types the multipart body as `{ files: string[] }`; the FormData is sent as is.
|
|
41
|
-
body: formData,
|
|
42
|
-
bodySerializer: () => formData
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) throw new Error(`Upload failed with status ${response.status}`);
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function defaultCertificateUrl(reference) {
|
|
49
|
-
const origin = typeof location === "undefined" ? "" : location.origin;
|
|
50
|
-
return `${origin}/verify/${encodeURIComponent(reference)}`;
|
|
51
|
-
}
|
|
52
|
-
function certificateLink(signature, certificateUrl) {
|
|
53
|
-
if (certificateUrl) return certificateUrl(signature.reference);
|
|
54
|
-
return signature.certificate_url || defaultCertificateUrl(signature.reference);
|
|
55
|
-
}
|
|
56
|
-
var DocumentToolsContext = createContext(null);
|
|
57
|
-
function DocumentToolsProvider({ children, ...env }) {
|
|
58
|
-
const arbiDeploymentDomain = useDeploymentDomain();
|
|
59
|
-
const {
|
|
60
|
-
client,
|
|
61
|
-
deploymentDomain,
|
|
62
|
-
user,
|
|
63
|
-
notify,
|
|
64
|
-
openDocument,
|
|
65
|
-
onDocumentsChanged,
|
|
66
|
-
uploadDocument,
|
|
67
|
-
saveFile,
|
|
68
|
-
emailDocument,
|
|
69
|
-
certificateUrl
|
|
70
|
-
} = env;
|
|
71
|
-
const value = useMemo(
|
|
72
|
-
() => ({
|
|
73
|
-
client,
|
|
74
|
-
deploymentDomain: deploymentDomain ?? arbiDeploymentDomain,
|
|
75
|
-
user,
|
|
76
|
-
openDocument,
|
|
77
|
-
onDocumentsChanged,
|
|
78
|
-
emailDocument,
|
|
79
|
-
notify: notify ?? (() => {
|
|
80
|
-
}),
|
|
81
|
-
saveFile: saveFile ?? downloadBlob,
|
|
82
|
-
uploadDocument: uploadDocument ?? clientUpload(client),
|
|
83
|
-
certificateUrl
|
|
84
|
-
}),
|
|
85
|
-
[
|
|
86
|
-
client,
|
|
87
|
-
deploymentDomain,
|
|
88
|
-
arbiDeploymentDomain,
|
|
89
|
-
user,
|
|
90
|
-
notify,
|
|
91
|
-
openDocument,
|
|
92
|
-
onDocumentsChanged,
|
|
93
|
-
uploadDocument,
|
|
94
|
-
saveFile,
|
|
95
|
-
emailDocument,
|
|
96
|
-
certificateUrl
|
|
97
|
-
]
|
|
98
|
-
);
|
|
99
|
-
return /* @__PURE__ */ jsx(DocumentToolsContext.Provider, { value, children });
|
|
100
|
-
}
|
|
101
|
-
function useOptionalDocumentTools() {
|
|
102
|
-
return useContext(DocumentToolsContext);
|
|
103
|
-
}
|
|
104
|
-
function useDocumentTools() {
|
|
105
|
-
const env = useContext(DocumentToolsContext);
|
|
106
|
-
if (!env) throw new Error("The document tools must be used within a <DocumentToolsProvider>");
|
|
107
|
-
return env;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
17
|
// src/document-tools/document-pdf.ts
|
|
111
18
|
var DocumentFetchError = class extends Error {
|
|
112
19
|
status;
|
|
@@ -131,10 +38,24 @@ async function fetchDocumentBytes(client, endpoint, documentRef, options, header
|
|
|
131
38
|
response.status
|
|
132
39
|
);
|
|
133
40
|
}
|
|
134
|
-
return data;
|
|
41
|
+
return { blob: data, response };
|
|
42
|
+
}
|
|
43
|
+
function contentDispositionFileName(header) {
|
|
44
|
+
if (!header) return void 0;
|
|
45
|
+
const extended = /filename\*\s*=\s*(?:[\w-]+)?'[^']*'([^;]+)/i.exec(header);
|
|
46
|
+
if (extended) {
|
|
47
|
+
try {
|
|
48
|
+
return decodeURIComponent(extended[1].trim().replace(/^"|"$/g, "")) || void 0;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const plain = /filename\s*=\s*("((?:[^"\\]|\\.)*)"|[^;]+)/i.exec(header);
|
|
53
|
+
if (!plain) return void 0;
|
|
54
|
+
const name = plain[2] !== void 0 ? plain[2].replace(/\\(.)/g, "$1") : plain[1].trim();
|
|
55
|
+
return name || void 0;
|
|
135
56
|
}
|
|
136
|
-
function fetchDocumentPdf(client, documentRef, options = {}) {
|
|
137
|
-
|
|
57
|
+
async function fetchDocumentPdf(client, documentRef, options = {}) {
|
|
58
|
+
const { blob } = await fetchDocumentBytes(
|
|
138
59
|
client,
|
|
139
60
|
"/v1/document/{document_ext_id}/view",
|
|
140
61
|
documentRef,
|
|
@@ -142,9 +63,10 @@ function fetchDocumentPdf(client, documentRef, options = {}) {
|
|
|
142
63
|
{ Accept: "application/pdf" },
|
|
143
64
|
"The PDF"
|
|
144
65
|
);
|
|
66
|
+
return blob;
|
|
145
67
|
}
|
|
146
|
-
function fetchDocumentFile(client, documentRef, options = {}) {
|
|
147
|
-
|
|
68
|
+
async function fetchDocumentFile(client, documentRef, options = {}) {
|
|
69
|
+
const { blob, response } = await fetchDocumentBytes(
|
|
148
70
|
client,
|
|
149
71
|
"/v1/document/{document_ext_id}/download",
|
|
150
72
|
documentRef,
|
|
@@ -152,6 +74,8 @@ function fetchDocumentFile(client, documentRef, options = {}) {
|
|
|
152
74
|
{},
|
|
153
75
|
"The file"
|
|
154
76
|
);
|
|
77
|
+
const name = contentDispositionFileName(response.headers.get("Content-Disposition"));
|
|
78
|
+
return name ? new File([blob], name, { type: blob.type }) : blob;
|
|
155
79
|
}
|
|
156
80
|
|
|
157
81
|
// src/document-tools/production.ts
|
|
@@ -1108,6 +1032,6 @@ function useSignerCandidates(enabled = true) {
|
|
|
1108
1032
|
});
|
|
1109
1033
|
}
|
|
1110
1034
|
|
|
1111
|
-
export { DEFAULT_FIELD_SIZE, DocumentFetchError,
|
|
1035
|
+
export { DEFAULT_FIELD_SIZE, DocumentFetchError, 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, contentDispositionFileName, copyOpenThreads, createMarkupStore, currentHasMarkup, fetchDocumentFile, fetchDocumentPdf, 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, useDocumentMarkup, useDocumentSignatureRequests, useDocumentSignatures, useIsOnline, useSaveSignatureRequest, useSignDocument, useSignSignatureRequest, useSignatureRequest, useSignatureRequestsAwaitingMe, useSignatureVerification, useSignerCandidates, useVoidSignatureRequest, versionsWithMarkup };
|
|
1112
1036
|
//# sourceMappingURL=index.js.map
|
|
1113
1037
|
//# sourceMappingURL=index.js.map
|