@verdocs/js-sdk 4.2.1 → 4.2.3
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/index.d.mts +173 -401
- package/dist/index.d.ts +173 -401
- package/dist/index.js +12 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -114
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1412,26 +1412,14 @@ const createEnvelope = async (endpoint, request) => endpoint.api //
|
|
|
1412
1412
|
* Get a summary of currently active envelopes.
|
|
1413
1413
|
*
|
|
1414
1414
|
* ```typescript
|
|
1415
|
-
* import {
|
|
1415
|
+
* import {getEnvelopesSummary} from '@verdocs/js-sdk/Envelopes';
|
|
1416
1416
|
*
|
|
1417
|
-
* const {action_required, completed, waiting_on_others} = await
|
|
1417
|
+
* const {action_required, completed, waiting_on_others} = await getEnvelopesSummary(VerdocsEndpoint.getDefault());
|
|
1418
1418
|
* ```
|
|
1419
1419
|
*/
|
|
1420
1420
|
const getEnvelopesSummary = async (endpoint, page) => endpoint.api //
|
|
1421
1421
|
.post('/envelopes/summary', { page })
|
|
1422
1422
|
.then((r) => r.data);
|
|
1423
|
-
/**
|
|
1424
|
-
* Search for envelopes matching various criteria.
|
|
1425
|
-
*
|
|
1426
|
-
* ```typescript
|
|
1427
|
-
* import {Envelopes} from '@verdocs/js-sdk/Envelopes';
|
|
1428
|
-
*
|
|
1429
|
-
* const {result, page, total} = await Envelopes.search(VerdocsEndpoint.getDefault(), { ... });
|
|
1430
|
-
* ```
|
|
1431
|
-
*/
|
|
1432
|
-
const searchEnvelopes = async (endpoint, params) => endpoint.api //
|
|
1433
|
-
.post('/envelopes/search', params)
|
|
1434
|
-
.then((r) => r.data);
|
|
1435
1423
|
/**
|
|
1436
1424
|
* Get a signing session for an Envelope.
|
|
1437
1425
|
*/
|
|
@@ -1573,32 +1561,17 @@ const getFieldAttachment = async (endpoint, envelopeId, fieldName) => endpoint.a
|
|
|
1573
1561
|
const getEnvelopeDocumentPageDisplayUri = async (endpoint, envelopeId, documentId, page, type = 'original') => endpoint.api
|
|
1574
1562
|
.get(`/envelopes/${envelopeId}/envelope_documents/${documentId}/pages/${page}/image?type=${type}`, { timeout: 20000 })
|
|
1575
1563
|
.then((r) => r.data);
|
|
1576
|
-
const cachedEnvelopes = {};
|
|
1577
1564
|
/**
|
|
1578
|
-
* Wrapper for `getEnvelope()` that limits queries to one every 2 seconds per template ID.
|
|
1579
|
-
* This is intended for use in component hierarchies that all rely on the same template
|
|
1580
|
-
* to avoid unnecessary repeat server calls.
|
|
1581
|
-
*/
|
|
1582
|
-
const throttledGetEnvelope = (endpoint, envelopeId) => {
|
|
1583
|
-
if (cachedEnvelopes[envelopeId] && cachedEnvelopes[envelopeId].loaded + 2000 < new Date().getTime()) {
|
|
1584
|
-
return cachedEnvelopes[envelopeId].envelope;
|
|
1585
|
-
}
|
|
1586
|
-
return getEnvelope(endpoint, envelopeId).then((envelope) => {
|
|
1587
|
-
cachedEnvelopes[envelopeId] = { loaded: new Date().getTime(), envelope };
|
|
1588
|
-
return envelope;
|
|
1589
|
-
});
|
|
1590
|
-
};
|
|
1591
|
-
/**a
|
|
1592
1565
|
* Lists all envelopes accessible by the caller, with optional filters.
|
|
1593
1566
|
*
|
|
1594
1567
|
* ```typescript
|
|
1595
|
-
* import {
|
|
1568
|
+
* import {getEnvelopes} from '@verdocs/js-sdk/Envelopes';
|
|
1596
1569
|
*
|
|
1597
|
-
* const {
|
|
1570
|
+
* const {count, envelopes} = await getEnvelopes((VerdocsEndpoint.getDefault(), { q: 'test' });
|
|
1598
1571
|
* ```
|
|
1599
1572
|
*/
|
|
1600
1573
|
const getEnvelopes = (endpoint, params) => endpoint.api //
|
|
1601
|
-
.
|
|
1574
|
+
.get('/envelopes', { params })
|
|
1602
1575
|
.then((r) => r.data);
|
|
1603
1576
|
|
|
1604
1577
|
/**
|
|
@@ -1622,7 +1595,7 @@ const createInitials = (endpoint, name, initials) => {
|
|
|
1622
1595
|
* `recipient.kba_method` is set (not null), and `recipient.kba_completed` is false, this endpoint
|
|
1623
1596
|
* should be called to determine the next KBA step required.
|
|
1624
1597
|
*/
|
|
1625
|
-
const
|
|
1598
|
+
const getKbaStep = (endpoint, envelopeId, roleName) => endpoint.api //
|
|
1626
1599
|
.get(`/v2/kba/${envelopeId}/${encodeURIComponent(roleName)}`)
|
|
1627
1600
|
.then((r) => r.data);
|
|
1628
1601
|
/**
|
|
@@ -1638,7 +1611,8 @@ const submitKbaIdentity = (endpoint, envelopeId, roleName, identity) => endpoint
|
|
|
1638
1611
|
.post(`/v2/kba/identity`, { envelopeId, roleName, identity })
|
|
1639
1612
|
.then((r) => r.data);
|
|
1640
1613
|
/**
|
|
1641
|
-
* Submit an identity response to a KBA challenge.
|
|
1614
|
+
* Submit an identity response to a KBA challenge. Answers should be submitted in the same order as
|
|
1615
|
+
* the challenges were listed in `IRecipientKbaStepChallenge.questions`.
|
|
1642
1616
|
*/
|
|
1643
1617
|
const submitKbaChallengeResponse = (endpoint, envelopeId, roleName, response) => endpoint.api //
|
|
1644
1618
|
.post(`/v2/kba/response`, { envelopeId, roleName, response })
|
|
@@ -2590,7 +2564,7 @@ const getAllTags = (endpoint) => endpoint.api //
|
|
|
2590
2564
|
* ```
|
|
2591
2565
|
*/
|
|
2592
2566
|
const getTemplates = (endpoint, params) => endpoint.api //
|
|
2593
|
-
.post('/templates', { params })
|
|
2567
|
+
.post('/v2/templates', { params })
|
|
2594
2568
|
.then((r) => r.data);
|
|
2595
2569
|
// export interface IListTemplatesParams {
|
|
2596
2570
|
// name?: string;
|
|
@@ -2624,7 +2598,7 @@ const getTemplates = (endpoint, params) => endpoint.api //
|
|
|
2624
2598
|
* ```
|
|
2625
2599
|
*/
|
|
2626
2600
|
const getTemplate = (endpoint, templateId) => endpoint.api //
|
|
2627
|
-
.get(`/templates/${templateId}`)
|
|
2601
|
+
.get(`/v2/templates/${templateId}`)
|
|
2628
2602
|
.then((r) => {
|
|
2629
2603
|
const template = r.data;
|
|
2630
2604
|
window?.console?.log('[JS_SDK] Post-processing template', template);
|
|
@@ -2647,18 +2621,6 @@ const getTemplate = (endpoint, templateId) => endpoint.api //
|
|
|
2647
2621
|
});
|
|
2648
2622
|
return template;
|
|
2649
2623
|
});
|
|
2650
|
-
/**
|
|
2651
|
-
* Get owner information for a template.
|
|
2652
|
-
*
|
|
2653
|
-
* ```typescript
|
|
2654
|
-
* import {Templates} from '@verdocs/js-sdk/Templates';
|
|
2655
|
-
*
|
|
2656
|
-
* const template = await Templates.getTemplateOwnerInfo((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
|
|
2657
|
-
* ```
|
|
2658
|
-
*/
|
|
2659
|
-
const getTemplateOwnerInfo = (endpoint, templateId) => endpoint.api //
|
|
2660
|
-
.get(`/templates/${templateId}`)
|
|
2661
|
-
.then((r) => r.data);
|
|
2662
2624
|
const ALLOWED_CREATE_FIELDS = [
|
|
2663
2625
|
'name',
|
|
2664
2626
|
'is_personal',
|
|
@@ -2668,43 +2630,6 @@ const ALLOWED_CREATE_FIELDS = [
|
|
|
2668
2630
|
'roles',
|
|
2669
2631
|
'fields',
|
|
2670
2632
|
];
|
|
2671
|
-
/**
|
|
2672
|
-
* Create a template.
|
|
2673
|
-
*
|
|
2674
|
-
* ```typescript
|
|
2675
|
-
* import {Templates} from '@verdocs/js-sdk/Templates';
|
|
2676
|
-
*
|
|
2677
|
-
* const newTemplate = await Templates.createTemplate((VerdocsEndpoint.getDefault(), {...});
|
|
2678
|
-
* ```
|
|
2679
|
-
*/
|
|
2680
|
-
const createTemplate = (endpoint, params, onUploadProgress) => {
|
|
2681
|
-
const options = {
|
|
2682
|
-
timeout: 120000,
|
|
2683
|
-
onUploadProgress: (event) => {
|
|
2684
|
-
const total = event.total || 1;
|
|
2685
|
-
const loaded = event.loaded || 0;
|
|
2686
|
-
onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
|
|
2687
|
-
},
|
|
2688
|
-
};
|
|
2689
|
-
if (params.documents && params.documents[0] instanceof File) {
|
|
2690
|
-
if (params.documents.length > 10) {
|
|
2691
|
-
throw new Error('createTemplate() has a maximum of 10 documents that can be attached.');
|
|
2692
|
-
}
|
|
2693
|
-
const formData = new FormData();
|
|
2694
|
-
ALLOWED_CREATE_FIELDS.forEach((allowedKey) => {
|
|
2695
|
-
if (params[allowedKey] !== undefined) {
|
|
2696
|
-
formData.append(allowedKey, params[allowedKey]);
|
|
2697
|
-
}
|
|
2698
|
-
});
|
|
2699
|
-
params.documents.forEach((file) => {
|
|
2700
|
-
formData.append('documents', file, file.name);
|
|
2701
|
-
});
|
|
2702
|
-
return endpoint.api.post('/templates', formData, options).then((r) => r.data);
|
|
2703
|
-
}
|
|
2704
|
-
else {
|
|
2705
|
-
return endpoint.api.post('/templates', params, options).then((r) => r.data);
|
|
2706
|
-
}
|
|
2707
|
-
};
|
|
2708
2633
|
/**
|
|
2709
2634
|
* Create a template.
|
|
2710
2635
|
*
|
|
@@ -2714,7 +2639,7 @@ const createTemplate = (endpoint, params, onUploadProgress) => {
|
|
|
2714
2639
|
* const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
|
|
2715
2640
|
* ```
|
|
2716
2641
|
*/
|
|
2717
|
-
const
|
|
2642
|
+
const createTemplate = (endpoint, params, onUploadProgress) => {
|
|
2718
2643
|
const options = {
|
|
2719
2644
|
timeout: 120000,
|
|
2720
2645
|
onUploadProgress: (event) => {
|
|
@@ -2790,33 +2715,6 @@ const deleteTemplate = (endpoint, templateId) => endpoint.api //
|
|
|
2790
2715
|
const searchTemplates = async (endpoint, params) => endpoint.api //
|
|
2791
2716
|
.post('/templates/search', params)
|
|
2792
2717
|
.then((r) => r.data);
|
|
2793
|
-
/**
|
|
2794
|
-
* Get a summary of template data, typically used to populate admin panel dashboard pages.
|
|
2795
|
-
*
|
|
2796
|
-
* ```typescript
|
|
2797
|
-
* import {Templates} from '@verdocs/js-sdk/Templates';
|
|
2798
|
-
*
|
|
2799
|
-
* const summary = await Templates.getSummary((VerdocsEndpoint.getDefault(), 0);
|
|
2800
|
-
* ```
|
|
2801
|
-
*/
|
|
2802
|
-
const getTemplatesSummary = async (endpoint, params = {}) => endpoint.api //
|
|
2803
|
-
.post('/templates/summary', params)
|
|
2804
|
-
.then((r) => r.data);
|
|
2805
|
-
const cachedTemplates = {};
|
|
2806
|
-
/**
|
|
2807
|
-
* Wrapper for `getTemplate()` that limits queries to one every 2 seconds per template ID.
|
|
2808
|
-
* This is intended for use in component hierarchies that all rely on the same template
|
|
2809
|
-
* to avoid unnecessary repeat server calls.
|
|
2810
|
-
*/
|
|
2811
|
-
const throttledGetTemplate = (endpoint, templateId) => {
|
|
2812
|
-
if (cachedTemplates[templateId] && cachedTemplates[templateId].loaded + 2000 < new Date().getTime()) {
|
|
2813
|
-
return cachedTemplates[templateId].template;
|
|
2814
|
-
}
|
|
2815
|
-
return getTemplate(endpoint, templateId).then((template) => {
|
|
2816
|
-
cachedTemplates[templateId] = { loaded: new Date().getTime(), template };
|
|
2817
|
-
return template;
|
|
2818
|
-
});
|
|
2819
|
-
};
|
|
2820
2718
|
/**
|
|
2821
2719
|
* List templates.
|
|
2822
2720
|
*
|
|
@@ -2941,5 +2839,5 @@ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name ==
|
|
|
2941
2839
|
const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
|
|
2942
2840
|
const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
|
|
2943
2841
|
|
|
2944
|
-
export { AtoB, Countries, RolePermissions, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole,
|
|
2842
|
+
export { AtoB, Countries, RolePermissions, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopes, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getPlusOneCountry, getProfile, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchTemplates, sendDelegate, setWebhooks, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanBuildTemplate, userCanCancelEnvelope, userCanChangeOrgVisibility, userCanCreateOrgTemplate, userCanCreatePersonalTemplate, userCanCreatePublicTemplate, userCanCreateTemplate, userCanDeleteTemplate, userCanFinishEnvelope, userCanMakeTemplatePrivate, userCanMakeTemplatePublic, userCanMakeTemplateShared, userCanPreviewTemplate, userCanReadTemplate, userCanSendTemplate, userCanSignNow, userCanUpdateTemplate, userHasPermissions, userHasSharedTemplate, userIsEnvelopeOwner, userIsEnvelopeRecipient, userIsTemplateCreator, verifyEmail };
|
|
2945
2843
|
//# sourceMappingURL=index.mjs.map
|