@verdocs/js-sdk 6.0.3 → 6.0.5

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
@@ -1615,7 +1615,7 @@ const getEnvelopeDocument = async (endpoint, _envelopeId, documentId) => endpoin
1615
1615
  * Download a document directly.
1616
1616
  */
1617
1617
  const downloadDocument = async (endpoint, _envelopeId, documentId) => endpoint.api //
1618
- .get(`/v2/envelope-documents/${documentId}?type=file`)
1618
+ .get(`/v2/envelope-documents/${documentId}?type=file`, { responseType: 'blob' })
1619
1619
  .then((r) => r.data);
1620
1620
  /**
1621
1621
  * Get an envelope document's metadata, or the document itself. If no "type" parameter is specified,
@@ -1656,9 +1656,11 @@ const cancelEnvelope = async (endpoint, envelopeId) => endpoint.api //
1656
1656
  * Get (binary download) a file attached to an Envelope. It is important to use this method
1657
1657
  * rather than a direct A HREF or similar link to set the authorization headers for the
1658
1658
  * request.
1659
+ *
1660
+ * @deprecated Use getDocumentPreviewLink/getDocumentDownloadLink/downloadDocument instead.
1659
1661
  */
1660
1662
  const getEnvelopeFile = async (endpoint, envelopeId, documentId) => endpoint.api //
1661
- .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}?file=true`, { responseType: 'blob' })
1663
+ .get(`/v2/envelope-documents/${documentId}?type=file`, { responseType: 'blob' })
1662
1664
  .then((r) => r.data);
1663
1665
  /**
1664
1666
  * Update an envelope. Currently, only reminder settings may be changed.
@@ -1971,22 +1973,8 @@ const getInPersonLink = (endpoint, envelope_id, role_name) => endpoint.api //
1971
1973
  const verifySigner = (endpoint, params) => endpoint.api //
1972
1974
  .post(`/v2/sign/verify`, params)
1973
1975
  .then((r) => r.data);
1974
- // TODO: Use "oneOf" to describe the unions of these two calls.
1975
- /**
1976
- * Resend a recipient's invitation. NOTE: User interfaces should rate-limit this operation to
1977
- * avoid spamming recipients. Excessive use of this endpoint may result in Verdocs rate-limiting
1978
- * the calling application to prevent abuse. This endpoint will return a 200 OK even if the
1979
- * no_contact flag is set on the envelope (in which case the call will be ignored).
1980
- *
1981
- * @group Recipients
1982
- * @api PUT /v2/envelopes/:envelope_id/recipients/:role_name Resend Invitation
1983
- * @apiParam string(format:uuid) envelope_id The envelope to operate on.
1984
- * @apiParam string role_name The role to operate on.
1985
- * @apiBody string(enum:'resend') action The operation to perform (resend).
1986
- * @apiSuccess string . Success message.
1987
- */
1988
- const resendInvitation = (endpoint, envelopeId, roleName) => endpoint.api //
1989
- .put(`/v2/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}`, { action: 'resend' })
1976
+ const resendInvitation = (endpoint, envelopeId, roleName, message) => endpoint.api //
1977
+ .patch(`/v2/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}`, { message })
1990
1978
  .then((r) => r.data);
1991
1979
  /**
1992
1980
  * Delegate a recipient's signing responsibility. The envelope sender must enable this before the
@@ -2013,10 +2001,13 @@ const delegateRecipient = (endpoint, envelopeId, roleName, params) => endpoint.a
2013
2001
  .put(`/v2/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}`, { action: 'delegate', ...params })
2014
2002
  .then((r) => r.data);
2015
2003
  /**
2016
- * Update a recipient. NOTE: User interfaces should rate-limit this operation to
2017
- * avoid spamming recipients. Excessive use of this endpoint may result in Verdocs rate-limiting
2018
- * the calling application to prevent abuse. This endpoint will return a 200 OK even if the
2019
- * no_contact flag is set on the envelope (in which case the call will be ignored).
2004
+ * Update a recipient. NOTE: User interfaces should rate-limit this operation to avoid spamming recipients.
2005
+ * Excessive use of this endpoint may result in Verdocs rate-limiting the calling application to prevent
2006
+ * abuse. This endpoint will return a 200 OK even if the no_contact flag is set on the envelope (in which
2007
+ * case the call will be silently ignored).
2008
+ *
2009
+ * If the recipient's first_name, last_name, email, or message are updated, a new invitation will be sent
2010
+ * to the recipient. This may also be used to trigger a reminder.
2020
2011
  *
2021
2012
  * @group Recipients
2022
2013
  * @api PATCH /envelopes/:envelope_id/recipients/:role_name Update Recipient
@@ -2045,14 +2036,30 @@ const updateRecipient = (endpoint, envelopeId, roleName, params) => endpoint.api
2045
2036
  *
2046
2037
  * @module
2047
2038
  */
2039
+ /**
2040
+ * Check to see if the profile ID owns the envelope.
2041
+ */
2042
+ const isEnvelopeOwner = (profile_id, envelope) => envelope.profile_id === profile_id;
2043
+ /**
2044
+ * Check to see if the profile ID is a recipient within the envelope.
2045
+ */
2046
+ const isEnvelopeRecipient = (profile_id, envelope) => (envelope.recipients || []).some((recipient) => recipient.profile_id === profile_id);
2047
+ /**
2048
+ * Check to see if the profile ID is the envelope's sender or one of the recipients.
2049
+ */
2050
+ const canAccessEnvelope = (profile_id, envelope) => isEnvelopeOwner(profile_id, envelope) || isEnvelopeRecipient(profile_id, envelope);
2048
2051
  /**
2049
2052
  * Check to see if the user owns the envelope.
2050
2053
  */
2051
2054
  const userIsEnvelopeOwner = (profile, envelope) => envelope.profile_id === profile?.id;
2052
2055
  /**
2053
- * Check to see if the user owns the envelope.
2056
+ * Check to see if the user is a recipient within the envelope.
2057
+ */
2058
+ const userIsEnvelopeRecipient = (profile, envelope) => (envelope.recipients || []).some((recipient) => recipient.profile_id === profile?.id);
2059
+ /**
2060
+ * Check to see if the profile ID is the envelope's sender or one of the recipients.
2054
2061
  */
2055
- const userIsEnvelopeRecipient = (profile, envelope) => envelope.profile_id === profile?.id;
2062
+ const useCanAccessEnvelope = (profile, envelope) => userIsEnvelopeOwner(profile, envelope) || userIsEnvelopeRecipient(profile, envelope);
2056
2063
  /**
2057
2064
  * Check to see if the envelope has pending actions.
2058
2065
  */
@@ -3691,5 +3698,5 @@ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name ==
3691
3698
  const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
3692
3699
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
3693
3700
 
3694
- export { ALL_PERMISSIONS, AtoB, Countries, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, WEBHOOK_EVENTS, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, collapseEntitlements, convertToE164, createApiKey, createEnvelope, createField, createGroup, createInitials, createOrganization, createOrganizationContact, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, delegateRecipient, deleteApiKey, deleteEnvelopeFieldAttachment, deleteField, deleteGroup, deleteGroupMember, deleteOrganization, deleteOrganizationContact, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateRole, deleteTemplateTag, downloadBlob, downloadDocument, duplicateTemplate, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getActiveEntitlements, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEntitlements, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopes, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotifications, getOrganization, getOrganizationChildren, getOrganizationContacts, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getOrganizationUsage, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateTags, getTemplates, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, nameToRGBA, randomString, recipientCanAct, recipientHasAction, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, setWebhooks, sortFields, startSigningSession, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, toggleStar, updateApiKey, updateEnvelope, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateField, updateGroup, updateOrganization, updateOrganizationContact, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, updateRecipient, updateRecipientStatus, updateTemplate, 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, verifySigner };
3701
+ export { ALL_PERMISSIONS, AtoB, Countries, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, WEBHOOK_EVENTS, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canAccessEnvelope, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, collapseEntitlements, convertToE164, createApiKey, createEnvelope, createField, createGroup, createInitials, createOrganization, createOrganizationContact, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, delegateRecipient, deleteApiKey, deleteEnvelopeFieldAttachment, deleteField, deleteGroup, deleteGroupMember, deleteOrganization, deleteOrganizationContact, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateRole, deleteTemplateTag, downloadBlob, downloadDocument, duplicateTemplate, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getActiveEntitlements, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEntitlements, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopes, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotifications, getOrganization, getOrganizationChildren, getOrganizationContacts, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getOrganizationUsage, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateTags, getTemplates, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isEnvelopeOwner, isEnvelopeRecipient, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, nameToRGBA, randomString, recipientCanAct, recipientHasAction, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, setWebhooks, sortFields, startSigningSession, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, toggleStar, updateApiKey, updateEnvelope, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateField, updateGroup, updateOrganization, updateOrganizationContact, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, updateRecipient, updateRecipientStatus, updateTemplate, updateTemplateRole, uploadEnvelopeFieldAttachment, useCanAccessEnvelope, userCanAct, userCanBuildTemplate, userCanCancelEnvelope, userCanChangeOrgVisibility, userCanCreateOrgTemplate, userCanCreatePersonalTemplate, userCanCreatePublicTemplate, userCanCreateTemplate, userCanDeleteTemplate, userCanFinishEnvelope, userCanMakeTemplatePrivate, userCanMakeTemplatePublic, userCanMakeTemplateShared, userCanPreviewTemplate, userCanReadTemplate, userCanSendTemplate, userCanSignNow, userCanUpdateTemplate, userHasPermissions, userHasSharedTemplate, userIsEnvelopeOwner, userIsEnvelopeRecipient, userIsTemplateCreator, verifyEmail, verifySigner };
3695
3702
  //# sourceMappingURL=index.mjs.map