@verdocs/js-sdk 4.1.3 → 4.1.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
@@ -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,7 +1708,7 @@ 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 gettOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1711
+ const getOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1712
1712
  .get(`/v2/organization-invitations/${email}/${token}`)
1713
1713
  .then((r) => r.data);
1714
1714
  const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
@@ -2472,36 +2472,22 @@ const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2472
2472
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2473
2473
 
2474
2474
  /**
2475
- * Authenticate to Verdocs via user/password authentication
2475
+ * Authenticate to Verdocs.
2476
2476
  *
2477
2477
  * ```typescript
2478
- * import {Auth} from '@verdocs/js-sdk/Auth';
2479
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2478
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2480
2479
  *
2481
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2482
- * Transport.setAuthToken(accessToken);
2483
- * ```
2484
- */
2485
- const authenticateUser = (endpoint, params) => endpoint.api //
2486
- .post('/authentication/login', params)
2487
- .then((r) => r.data);
2488
- /**
2489
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2490
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2491
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2492
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2493
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
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);
2494
2483
  *
2495
- * ```typescript
2496
- * import {Auth} from '@verdocs/js-sdk/Auth';
2497
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2498
- *
2499
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2500
- * 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);
2501
2487
  * ```
2502
2488
  */
2503
- const authenticateApp = (endpoint, params) => endpoint.api //
2504
- .post('/authentication/login_client', {}, { headers: params })
2489
+ const authenticate = (endpoint, params) => endpoint.api //
2490
+ .post('/v2/oauth2/token', params)
2505
2491
  .then((r) => r.data);
2506
2492
  /**
2507
2493
  * If called before the session expires, this will refresh the caller's session and tokens.
@@ -2514,38 +2500,36 @@ const authenticateApp = (endpoint, params) => endpoint.api //
2514
2500
  * Transport.setAuthToken(accessToken);
2515
2501
  * ```
2516
2502
  */
2517
- const refreshTokens = (endpoint) => endpoint.api //
2518
- .get('/token')
2519
- .then((r) => r.data);
2503
+ const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_type: 'refresh_token', refresh_token: refreshToken });
2520
2504
  /**
2521
2505
  * Update the caller's password when the old password is known (typically for logged-in users).
2522
2506
  *
2523
2507
  * ```typescript
2524
- * import {Auth} from '@verdocs/js-sdk/Auth';
2508
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2525
2509
  *
2526
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2510
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2527
2511
  * if (status !== 'OK') {
2528
2512
  * window.alert(`Password reset error: ${message}`);
2529
2513
  * }
2530
2514
  * ```
2531
2515
  */
2532
2516
  const changePassword = (endpoint, params) => endpoint.api //
2533
- .put('/user/update_password', params)
2517
+ .post('/v2/users/change-password', params)
2534
2518
  .then((r) => r.data);
2535
2519
  /**
2536
2520
  * Request a password reset, when the old password is not known (typically in login forms).
2537
2521
  *
2538
2522
  * ```typescript
2539
- * import {Auth} from '@verdocs/js-sdk/Auth';
2523
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2540
2524
  *
2541
- * const {success} = await Auth.resetPassword({ email });
2525
+ * const {success} = await resetPassword({ email });
2542
2526
  * if (status !== 'OK') {
2543
2527
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2544
2528
  * }
2545
2529
  * ```
2546
2530
  */
2547
2531
  const resetPassword = (endpoint, params) => endpoint.api //
2548
- .post('/user/reset_password', params)
2532
+ .post('/v2/users/reset-password', params)
2549
2533
  .then((r) => r.data);
2550
2534
  /**
2551
2535
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
@@ -2561,7 +2545,7 @@ const resetPassword = (endpoint, params) => endpoint.api //
2561
2545
  * ```
2562
2546
  */
2563
2547
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2564
- .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2548
+ .post('/v2/users/resend-verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2565
2549
  .then((r) => r.data);
2566
2550
 
2567
2551
  const getNotifications = async (endpoint) => endpoint.api //
@@ -2674,5 +2658,5 @@ const recordSignupSurvey = (endpoint, params) => endpoint.api //
2674
2658
  .post('/user/signup', params)
2675
2659
  .then((r) => r.data);
2676
2660
 
2677
- 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, gettOrganizationInvitation, 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 };
2678
2662
  //# sourceMappingURL=index.mjs.map