@verdocs/js-sdk 4.1.2 → 4.1.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
@@ -866,7 +866,7 @@ class VerdocsEndpoint {
866
866
  static getDefault() {
867
867
  if (!globalThis$1[ENDPOINT_KEY]) {
868
868
  globalThis$1[ENDPOINT_KEY] = new VerdocsEndpoint();
869
- window.console.debug('[JS_SDK] Created default endpoint', globalThis$1[ENDPOINT_KEY].baseURL);
869
+ // window.console.debug('[JS_SDK] Created default endpoint', globalThis[ENDPOINT_KEY].baseURL);
870
870
  }
871
871
  return globalThis$1[ENDPOINT_KEY];
872
872
  }
@@ -1708,6 +1708,9 @@ const updateOrganizationInvitation = (endpoint, email, params) => endpoint.api /
1708
1708
  const resendOrganizationInvitation = (endpoint, email) => endpoint.api //
1709
1709
  .post('/v2/organization-invitations/resend', { email })
1710
1710
  .then((r) => r.data);
1711
+ const getOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1712
+ .get(`/v2/organization-invitations/${email}/${token}`)
1713
+ .then((r) => r.data);
1711
1714
  const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1712
1715
  .post('/v2/organization-invitations/accept', { email, token })
1713
1716
  .then((r) => r.data);
@@ -2469,36 +2472,22 @@ const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2469
2472
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2470
2473
 
2471
2474
  /**
2472
- * Authenticate to Verdocs via user/password authentication
2475
+ * Authenticate to Verdocs.
2473
2476
  *
2474
2477
  * ```typescript
2475
- * import {Auth} from '@verdocs/js-sdk/Auth';
2476
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2477
- *
2478
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2479
- * Transport.setAuthToken(accessToken);
2480
- * ```
2481
- */
2482
- const authenticateUser = (endpoint, params) => endpoint.api //
2483
- .post('/authentication/login', params)
2484
- .then((r) => r.data);
2485
- /**
2486
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2487
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2488
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2489
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2490
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2478
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2491
2479
  *
2492
- * ```typescript
2493
- * import {Auth} from '@verdocs/js-sdk/Auth';
2494
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2480
+ * // Client-side call, suitable for Web and mobile apps:
2481
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2482
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2495
2483
  *
2496
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2497
- * Transport.setAuthToken(accessToken);
2484
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2485
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2486
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2498
2487
  * ```
2499
2488
  */
2500
- const authenticateApp = (endpoint, params) => endpoint.api //
2501
- .post('/authentication/login_client', {}, { headers: params })
2489
+ const authenticate = (endpoint, params) => endpoint.api //
2490
+ .post('/v2/oauth2/token', params)
2502
2491
  .then((r) => r.data);
2503
2492
  /**
2504
2493
  * If called before the session expires, this will refresh the caller's session and tokens.
@@ -2511,38 +2500,36 @@ const authenticateApp = (endpoint, params) => endpoint.api //
2511
2500
  * Transport.setAuthToken(accessToken);
2512
2501
  * ```
2513
2502
  */
2514
- const refreshTokens = (endpoint) => endpoint.api //
2515
- .get('/token')
2516
- .then((r) => r.data);
2503
+ const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_type: 'refresh_token', refresh_token: refreshToken });
2517
2504
  /**
2518
2505
  * Update the caller's password when the old password is known (typically for logged-in users).
2519
2506
  *
2520
2507
  * ```typescript
2521
- * import {Auth} from '@verdocs/js-sdk/Auth';
2508
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2522
2509
  *
2523
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2510
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2524
2511
  * if (status !== 'OK') {
2525
2512
  * window.alert(`Password reset error: ${message}`);
2526
2513
  * }
2527
2514
  * ```
2528
2515
  */
2529
2516
  const changePassword = (endpoint, params) => endpoint.api //
2530
- .put('/user/update_password', params)
2517
+ .post('/v2/users/change-password', params)
2531
2518
  .then((r) => r.data);
2532
2519
  /**
2533
2520
  * Request a password reset, when the old password is not known (typically in login forms).
2534
2521
  *
2535
2522
  * ```typescript
2536
- * import {Auth} from '@verdocs/js-sdk/Auth';
2523
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2537
2524
  *
2538
- * const {success} = await Auth.resetPassword({ email });
2525
+ * const {success} = await resetPassword({ email });
2539
2526
  * if (status !== 'OK') {
2540
2527
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2541
2528
  * }
2542
2529
  * ```
2543
2530
  */
2544
2531
  const resetPassword = (endpoint, params) => endpoint.api //
2545
- .post('/user/reset_password', params)
2532
+ .post('/v2/users/reset-password', params)
2546
2533
  .then((r) => r.data);
2547
2534
  /**
2548
2535
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
@@ -2558,7 +2545,7 @@ const resetPassword = (endpoint, params) => endpoint.api //
2558
2545
  * ```
2559
2546
  */
2560
2547
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2561
- .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2548
+ .post('/v2/users/resend-verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2562
2549
  .then((r) => r.data);
2563
2550
 
2564
2551
  const getNotifications = async (endpoint) => endpoint.api //
@@ -2671,5 +2658,5 @@ const recordSignupSurvey = (endpoint, params) => endpoint.api //
2671
2658
  .post('/user/signup', params)
2672
2659
  .then((r) => r.data);
2673
2660
 
2674
- export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticateApp, authenticateUser, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createAccount, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganization, 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, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, 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, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationMember, updateProfile, 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 };
2661
+ export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createAccount, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganization, 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, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getOrganizations, 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, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationMember, updateProfile, 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 };
2675
2662
  //# sourceMappingURL=index.mjs.map