@verdocs/js-sdk 6.7.7 → 6.8.2

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
@@ -2153,6 +2153,12 @@ const userCanSendTemplate = (profile, template) => {
2153
2153
  case 'public':
2154
2154
  return true;
2155
2155
  }
2156
+ if (!template.roles || !template.roles.length) {
2157
+ return false;
2158
+ }
2159
+ if (!template.fields || !template.fields.length) {
2160
+ return false;
2161
+ }
2156
2162
  };
2157
2163
  /**
2158
2164
  * Confirm whether the user can create a new template.
@@ -2986,7 +2992,19 @@ const recipientCanAct = (recipient, recipientsWithActions) => recipient.sequence
2986
2992
  * Returns true if the user can act.
2987
2993
  */
2988
2994
  const userCanAct = (email, recipientsWithActions) => {
2989
- const recipient = recipientsWithActions.find((r) => r.email === email);
2995
+ const recipient = recipientsWithActions.find((r) => r.email?.toLowerCase() === email?.toLowerCase());
2996
+ return recipient && recipient.sequence === recipientsWithActions?.[0]?.sequence;
2997
+ };
2998
+ /**
2999
+ * Get a recipient from an envelope via an email match.
3000
+ */
3001
+ const getRecipient = (email, envelope) => (envelope.recipients || []).find((r) => r.email?.toLowerCase() === email?.toLowerCase());
3002
+ /**
3003
+ * Get a recipient that can act from an envelope via an email match.
3004
+ */
3005
+ const getRecipientWithActions = (email, envelope) => {
3006
+ const recipientsWithActions = getRecipientsWithActions(envelope);
3007
+ const recipient = recipientsWithActions.find((r) => r.email?.toLowerCase() === email?.toLowerCase());
2990
3008
  return recipient && recipient.sequence === recipientsWithActions?.[0]?.sequence;
2991
3009
  };
2992
3010
  /**
@@ -2997,7 +3015,7 @@ const userCanSignNow = (profile, envelope) => {
2997
3015
  return false;
2998
3016
  }
2999
3017
  const recipientsWithActions = getRecipientsWithActions(envelope);
3000
- const myRecipient = recipientsWithActions.find((r) => r.profile_id === profile?.id || r.email === profile?.email);
3018
+ const myRecipient = recipientsWithActions.find((r) => r.profile_id === profile?.id || r.email?.toLowerCase() === profile?.email?.toLowerCase());
3001
3019
  return (myRecipient &&
3002
3020
  envelopeIsActive(envelope) &&
3003
3021
  userIsEnvelopeRecipient(profile, envelope) &&
@@ -3486,6 +3504,47 @@ const deleteOrganizationMember = (endpoint, profileId) => endpoint.api //
3486
3504
  const updateOrganizationMember = (endpoint, profileId, params) => endpoint.api //
3487
3505
  .patch(`/v2/organization-members/${profileId}`, params)
3488
3506
  .then((r) => r.data);
3507
+ /**
3508
+ * Lock an organization member's account. The member will be unable to sign in until an admin
3509
+ * unlocks them or they complete the password-reset flow. Caller must be an admin or owner,
3510
+ * may not lock him/herself, and the target must have a linked user account.
3511
+ *
3512
+ * ```typescript
3513
+ * import {lockOrganizationMember} from '@verdocs/js-sdk';
3514
+ *
3515
+ * const result = await lockOrganizationMember(VerdocsEndpoint.getDefault(), 'PROFILEID', 'Departed employee');
3516
+ * ```
3517
+ *
3518
+ * @group Organization Members
3519
+ * @api PUT /v2/organization-members/:profile_id Perform an operation on an organization member.
3520
+ * @apiParam string(format:uuid) profile_id The Profile ID to operate on.
3521
+ * @apiBody string(enum:'lock') action Action to perform
3522
+ * @apiBody string reason Reason the account is being locked. Stored on the user record and shown to admins.
3523
+ * @apiSuccess IProfile . The updated profile for the member, with the joined user record.
3524
+ */
3525
+ const lockOrganizationMember = (endpoint, profileId, reason) => endpoint.api //
3526
+ .put(`/v2/organization-members/${profileId}`, { action: 'lock', reason })
3527
+ .then((r) => r.data);
3528
+ /**
3529
+ * Unlock a member whose account has been locked (typically after too many failed sign-in attempts
3530
+ * or via an earlier admin lock). Caller must be an admin or owner, may not unlock him/herself, and
3531
+ * the target must have a linked user account. Clears `locked`, `lock_reason`, and `login_failures`.
3532
+ *
3533
+ * ```typescript
3534
+ * import {unlockOrganizationMember} from '@verdocs/js-sdk';
3535
+ *
3536
+ * const result = await unlockOrganizationMember(VerdocsEndpoint.getDefault(), 'PROFILEID');
3537
+ * ```
3538
+ *
3539
+ * @group Organization Members
3540
+ * @api PUT /v2/organization-members/:profile_id Perform an operation on an organization member.
3541
+ * @apiParam string(format:uuid) profile_id The Profile ID to operate on.
3542
+ * @apiBody string(enum:'unlock') action Action to perform
3543
+ * @apiSuccess IProfile . The updated profile for the member, with the joined user record.
3544
+ */
3545
+ const unlockOrganizationMember = (endpoint, profileId) => endpoint.api //
3546
+ .put(`/v2/organization-members/${profileId}`, { action: 'unlock' })
3547
+ .then((r) => r.data);
3489
3548
 
3490
3549
  /**
3491
3550
  * Notification Templates allow organizations to customize the email and SMS notifications
@@ -3897,5 +3956,5 @@ const rotateWebhookSecret = (endpoint) => endpoint.api //
3897
3956
  .put(`/v2/webhooks/rotate-secret`)
3898
3957
  .then((r) => r.data);
3899
3958
 
3900
- export { ALL_PERMISSIONS, AtoB, Countries, DEFAULT_DISCLOSURES, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, WEBHOOK_EVENTS, acceptOrganizationInvitation, addGroupMember, askQuestion, authenticate, blobToBase64, canAccessEnvelope, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, collapseEntitlements, convertToE164, createApiKey, createEnvelope, createField, createGroup, createInitials, createNotificationTemplate, createOrganization, createOrganizationContact, createOrganizationInvitation, createProfile, createSignature, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, delegateRecipient, deleteApiKey, deleteEnvelopeFieldAttachment, deleteField, deleteGroup, deleteGroupMember, deleteNotificationTemplate, deleteOrganization, deleteOrganizationContact, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteTemplate, deleteTemplateDocument, deleteTemplateRole, downloadBlob, downloadEnvelopeDocument, downloadTemplateDocument, duplicateTemplate, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getActiveEntitlements, getApiKeys, getCountryByCode, getCurrentProfile, getEntitlements, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPageDisplayUri, getEnvelopeDocumentPreviewLink, getEnvelopeFile, getEnvelopes, getEnvelopesZip, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotificationTemplate, getNotificationTemplates, getNotifications, getOrganization, getOrganizationChildren, getOrganizationContacts, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getOrganizationUsage, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getTemplate, getTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentPreviewLink, getTemplateDocumentThumbnail, getTemplates, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isEnvelopeOwner, isEnvelopeRecipient, isFieldFilled, isFieldValid, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidInput, isValidPhone, isValidRoleName, isValidTag, nameToRGBA, randomString, recipientCanAct, recipientHasAction, refreshToken, remindRecipient, rescale, resendOrganizationInvitation, resendVerification, resetPassword, resetRecipient, rotateApiKey, rotateWebhookSecret, setWebhooks, sortDocuments, sortFields, sortRecipients, startSigningSession, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, toggleTemplateStar, updateApiKey, updateEnvelope, updateEnvelopeField, updateField, updateGroup, updateNotificationTemplate, updateOrganization, updateOrganizationContact, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, updateRecipient, 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 };
3959
+ export { ALL_PERMISSIONS, AtoB, Countries, DEFAULT_DISCLOSURES, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, WEBHOOK_EVENTS, acceptOrganizationInvitation, addGroupMember, askQuestion, authenticate, blobToBase64, canAccessEnvelope, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, collapseEntitlements, convertToE164, createApiKey, createEnvelope, createField, createGroup, createInitials, createNotificationTemplate, createOrganization, createOrganizationContact, createOrganizationInvitation, createProfile, createSignature, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, delegateRecipient, deleteApiKey, deleteEnvelopeFieldAttachment, deleteField, deleteGroup, deleteGroupMember, deleteNotificationTemplate, deleteOrganization, deleteOrganizationContact, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteTemplate, deleteTemplateDocument, deleteTemplateRole, downloadBlob, downloadEnvelopeDocument, downloadTemplateDocument, duplicateTemplate, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getActiveEntitlements, getApiKeys, getCountryByCode, getCurrentProfile, getEntitlements, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPageDisplayUri, getEnvelopeDocumentPreviewLink, getEnvelopeFile, getEnvelopes, getEnvelopesZip, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotificationTemplate, getNotificationTemplates, getNotifications, getOrganization, getOrganizationChildren, getOrganizationContacts, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getOrganizationUsage, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipient, getRecipientWithActions, getRecipientsWithActions, getRoleColor, getTemplate, getTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentPreviewLink, getTemplateDocumentThumbnail, getTemplates, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isEnvelopeOwner, isEnvelopeRecipient, isFieldFilled, isFieldValid, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidInput, isValidPhone, isValidRoleName, isValidTag, lockOrganizationMember, nameToRGBA, randomString, recipientCanAct, recipientHasAction, refreshToken, remindRecipient, rescale, resendOrganizationInvitation, resendVerification, resetPassword, resetRecipient, rotateApiKey, rotateWebhookSecret, setWebhooks, sortDocuments, sortFields, sortRecipients, startSigningSession, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, toggleTemplateStar, unlockOrganizationMember, updateApiKey, updateEnvelope, updateEnvelopeField, updateField, updateGroup, updateNotificationTemplate, updateOrganization, updateOrganizationContact, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, updateRecipient, 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 };
3901
3960
  //# sourceMappingURL=index.mjs.map