@verdocs/js-sdk 4.2.2 → 4.2.4

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.mjs CHANGED
@@ -1595,7 +1595,7 @@ const createInitials = (endpoint, name, initials) => {
1595
1595
  * `recipient.kba_method` is set (not null), and `recipient.kba_completed` is false, this endpoint
1596
1596
  * should be called to determine the next KBA step required.
1597
1597
  */
1598
- const getKbaStatus = (endpoint, envelopeId, roleName) => endpoint.api //
1598
+ const getKbaStep = (endpoint, envelopeId, roleName) => endpoint.api //
1599
1599
  .get(`/v2/kba/${envelopeId}/${encodeURIComponent(roleName)}`)
1600
1600
  .then((r) => r.data);
1601
1601
  /**
@@ -1611,7 +1611,8 @@ const submitKbaIdentity = (endpoint, envelopeId, roleName, identity) => endpoint
1611
1611
  .post(`/v2/kba/identity`, { envelopeId, roleName, identity })
1612
1612
  .then((r) => r.data);
1613
1613
  /**
1614
- * 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`.
1615
1616
  */
1616
1617
  const submitKbaChallengeResponse = (endpoint, envelopeId, roleName, response) => endpoint.api //
1617
1618
  .post(`/v2/kba/response`, { envelopeId, roleName, response })
@@ -2563,7 +2564,7 @@ const getAllTags = (endpoint) => endpoint.api //
2563
2564
  * ```
2564
2565
  */
2565
2566
  const getTemplates = (endpoint, params) => endpoint.api //
2566
- .post('/templates', { params })
2567
+ .post('/v2/templates', { params })
2567
2568
  .then((r) => r.data);
2568
2569
  // export interface IListTemplatesParams {
2569
2570
  // name?: string;
@@ -2597,7 +2598,7 @@ const getTemplates = (endpoint, params) => endpoint.api //
2597
2598
  * ```
2598
2599
  */
2599
2600
  const getTemplate = (endpoint, templateId) => endpoint.api //
2600
- .get(`/templates/${templateId}`)
2601
+ .get(`/v2/templates/${templateId}`)
2601
2602
  .then((r) => {
2602
2603
  const template = r.data;
2603
2604
  window?.console?.log('[JS_SDK] Post-processing template', template);
@@ -2620,18 +2621,6 @@ const getTemplate = (endpoint, templateId) => endpoint.api //
2620
2621
  });
2621
2622
  return template;
2622
2623
  });
2623
- /**
2624
- * Get owner information for a template.
2625
- *
2626
- * ```typescript
2627
- * import {Templates} from '@verdocs/js-sdk/Templates';
2628
- *
2629
- * const template = await Templates.getTemplateOwnerInfo((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2630
- * ```
2631
- */
2632
- const getTemplateOwnerInfo = (endpoint, templateId) => endpoint.api //
2633
- .get(`/templates/${templateId}`)
2634
- .then((r) => r.data);
2635
2624
  const ALLOWED_CREATE_FIELDS = [
2636
2625
  'name',
2637
2626
  'is_personal',
@@ -2641,43 +2630,6 @@ const ALLOWED_CREATE_FIELDS = [
2641
2630
  'roles',
2642
2631
  'fields',
2643
2632
  ];
2644
- /**
2645
- * Create a template.
2646
- *
2647
- * ```typescript
2648
- * import {Templates} from '@verdocs/js-sdk/Templates';
2649
- *
2650
- * const newTemplate = await Templates.createTemplate((VerdocsEndpoint.getDefault(), {...});
2651
- * ```
2652
- */
2653
- const createTemplate = (endpoint, params, onUploadProgress) => {
2654
- const options = {
2655
- timeout: 120000,
2656
- onUploadProgress: (event) => {
2657
- const total = event.total || 1;
2658
- const loaded = event.loaded || 0;
2659
- onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
2660
- },
2661
- };
2662
- if (params.documents && params.documents[0] instanceof File) {
2663
- if (params.documents.length > 10) {
2664
- throw new Error('createTemplate() has a maximum of 10 documents that can be attached.');
2665
- }
2666
- const formData = new FormData();
2667
- ALLOWED_CREATE_FIELDS.forEach((allowedKey) => {
2668
- if (params[allowedKey] !== undefined) {
2669
- formData.append(allowedKey, params[allowedKey]);
2670
- }
2671
- });
2672
- params.documents.forEach((file) => {
2673
- formData.append('documents', file, file.name);
2674
- });
2675
- return endpoint.api.post('/templates', formData, options).then((r) => r.data);
2676
- }
2677
- else {
2678
- return endpoint.api.post('/templates', params, options).then((r) => r.data);
2679
- }
2680
- };
2681
2633
  /**
2682
2634
  * Create a template.
2683
2635
  *
@@ -2687,7 +2639,7 @@ const createTemplate = (endpoint, params, onUploadProgress) => {
2687
2639
  * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
2688
2640
  * ```
2689
2641
  */
2690
- const createTemplatev2 = (endpoint, params, onUploadProgress) => {
2642
+ const createTemplate = (endpoint, params, onUploadProgress) => {
2691
2643
  const options = {
2692
2644
  timeout: 120000,
2693
2645
  onUploadProgress: (event) => {
@@ -2763,33 +2715,6 @@ const deleteTemplate = (endpoint, templateId) => endpoint.api //
2763
2715
  const searchTemplates = async (endpoint, params) => endpoint.api //
2764
2716
  .post('/templates/search', params)
2765
2717
  .then((r) => r.data);
2766
- /**
2767
- * Get a summary of template data, typically used to populate admin panel dashboard pages.
2768
- *
2769
- * ```typescript
2770
- * import {Templates} from '@verdocs/js-sdk/Templates';
2771
- *
2772
- * const summary = await Templates.getSummary((VerdocsEndpoint.getDefault(), 0);
2773
- * ```
2774
- */
2775
- const getTemplatesSummary = async (endpoint, params = {}) => endpoint.api //
2776
- .post('/templates/summary', params)
2777
- .then((r) => r.data);
2778
- const cachedTemplates = {};
2779
- /**
2780
- * Wrapper for `getTemplate()` that limits queries to one every 2 seconds per template ID.
2781
- * This is intended for use in component hierarchies that all rely on the same template
2782
- * to avoid unnecessary repeat server calls.
2783
- */
2784
- const throttledGetTemplate = (endpoint, templateId) => {
2785
- if (cachedTemplates[templateId] && cachedTemplates[templateId].loaded + 2000 < new Date().getTime()) {
2786
- return cachedTemplates[templateId].template;
2787
- }
2788
- return getTemplate(endpoint, templateId).then((template) => {
2789
- cachedTemplates[templateId] = { loaded: new Date().getTime(), template };
2790
- return template;
2791
- });
2792
- };
2793
2718
  /**
2794
2719
  * List templates.
2795
2720
  *
@@ -2914,5 +2839,5 @@ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name ==
2914
2839
  const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2915
2840
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2916
2841
 
2917
- 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, createTemplatev2, 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, getKbaStatus, 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, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, 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, throttledGetTemplate, 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 };
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 };
2918
2843
  //# sourceMappingURL=index.mjs.map