@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.d.mts CHANGED
@@ -1619,6 +1619,7 @@ declare const createOrganizationInvitation: (endpoint: VerdocsEndpoint, params:
1619
1619
  declare const deleteOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1620
1620
  declare const updateOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, params: Partial<ICreateInvitationRequest>) => Promise<IOrganizationInvitation>;
1621
1621
  declare const resendOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1622
+ declare const getOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1622
1623
  declare const acceptOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IProfile>;
1623
1624
  declare const declineOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<{
1624
1625
  status: "OK";
@@ -2321,9 +2322,11 @@ interface ICreateProfileRequest {
2321
2322
  }
2322
2323
  interface ISwitchProfileResponse {
2323
2324
  profile: IProfile;
2324
- idToken: string;
2325
2325
  accessToken: string;
2326
+ idToken: string;
2326
2327
  refreshToken: string;
2328
+ accessTokenExp: number;
2329
+ refreshTokenExp: number;
2327
2330
  }
2328
2331
  interface IUpdateProfileRequest {
2329
2332
  first_name?: string;
@@ -2333,25 +2336,20 @@ interface IUpdateProfileRequest {
2333
2336
  permissions?: TPermission[];
2334
2337
  roles?: TRole[];
2335
2338
  }
2336
- interface IAuthenticateUserRequest {
2337
- username: string;
2338
- password: string;
2339
- }
2340
- interface IAuthenticateAppRequest {
2341
- client_id: string;
2342
- client_secret: string;
2343
- }
2344
2339
  interface IAuthenticateResponse {
2345
- idToken: string;
2346
- accessToken: string;
2347
- refreshToken: string;
2340
+ access_token: string;
2341
+ id_token: string;
2342
+ refresh_token: string;
2343
+ expires_in: number;
2344
+ access_token_exp: number;
2345
+ refresh_token_exp: number;
2348
2346
  }
2349
2347
  interface IUpdatePasswordRequest {
2350
2348
  email: string;
2351
2349
  oldPassword: string;
2352
2350
  newPassword: string;
2353
2351
  }
2354
- interface UpdatePasswordResponse {
2352
+ interface IUpdatePasswordResponse {
2355
2353
  status: TRequestStatus;
2356
2354
  /** Success or failure message */
2357
2355
  message: string;
@@ -2363,34 +2361,42 @@ interface ICreateAccountRequest {
2363
2361
  lastName: string;
2364
2362
  orgName: string;
2365
2363
  }
2364
+ interface IROPCRequest {
2365
+ grant_type: "password";
2366
+ username: string;
2367
+ password: string;
2368
+ client_id?: string;
2369
+ scope?: string;
2370
+ }
2371
+ interface IClientCredentialsRequest {
2372
+ grant_type: "client_credentials";
2373
+ client_id: string;
2374
+ client_secret: string;
2375
+ scope?: string;
2376
+ }
2377
+ interface IRefreshTokenRequest {
2378
+ grant_type: "refresh_token";
2379
+ refresh_token: string;
2380
+ client_id?: string;
2381
+ scope?: string;
2382
+ }
2383
+ type TAuthenticationRequest = IROPCRequest | IClientCredentialsRequest | IRefreshTokenRequest;
2366
2384
  /**
2367
- * Authenticate to Verdocs via user/password authentication
2385
+ * Authenticate to Verdocs.
2368
2386
  *
2369
2387
  * ```typescript
2370
- * import {Auth} from '@verdocs/js-sdk/Auth';
2371
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2388
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2372
2389
  *
2373
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2374
- * Transport.setAuthToken(accessToken);
2375
- * ```
2376
- */
2377
- declare const authenticateUser: (endpoint: VerdocsEndpoint, params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
2378
- /**
2379
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2380
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2381
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2382
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2383
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2390
+ * // Client-side call, suitable for Web and mobile apps:
2391
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2392
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2384
2393
  *
2385
- * ```typescript
2386
- * import {Auth} from '@verdocs/js-sdk/Auth';
2387
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2388
- *
2389
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2390
- * Transport.setAuthToken(accessToken);
2394
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2395
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2396
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2391
2397
  * ```
2392
2398
  */
2393
- declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
2399
+ declare const authenticate: (endpoint: VerdocsEndpoint, params: TAuthenticationRequest) => Promise<IAuthenticateResponse>;
2394
2400
  /**
2395
2401
  * If called before the session expires, this will refresh the caller's session and tokens.
2396
2402
  *
@@ -2402,27 +2408,27 @@ declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticate
2402
2408
  * Transport.setAuthToken(accessToken);
2403
2409
  * ```
2404
2410
  */
2405
- declare const refreshTokens: (endpoint: VerdocsEndpoint) => Promise<IAuthenticateResponse>;
2411
+ declare const refreshToken: (endpoint: VerdocsEndpoint, refreshToken: string) => Promise<IAuthenticateResponse>;
2406
2412
  /**
2407
2413
  * Update the caller's password when the old password is known (typically for logged-in users).
2408
2414
  *
2409
2415
  * ```typescript
2410
- * import {Auth} from '@verdocs/js-sdk/Auth';
2416
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2411
2417
  *
2412
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2418
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2413
2419
  * if (status !== 'OK') {
2414
2420
  * window.alert(`Password reset error: ${message}`);
2415
2421
  * }
2416
2422
  * ```
2417
2423
  */
2418
- declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
2424
+ declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<IUpdatePasswordResponse>;
2419
2425
  /**
2420
2426
  * Request a password reset, when the old password is not known (typically in login forms).
2421
2427
  *
2422
2428
  * ```typescript
2423
- * import {Auth} from '@verdocs/js-sdk/Auth';
2429
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2424
2430
  *
2425
- * const {success} = await Auth.resetPassword({ email });
2431
+ * const {success} = await resetPassword({ email });
2426
2432
  * if (status !== 'OK') {
2427
2433
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2428
2434
  * }
@@ -2551,4 +2557,4 @@ interface ISignupSurvey {
2551
2557
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2552
2558
  status: "OK";
2553
2559
  }>;
2554
- export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganizations, getOrganization, createOrganization, deleteOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, refreshTokens, changePassword, resetPassword, resendVerification, getNotifications, getProfiles, getCurrentProfile, createProfile, getProfile, switchProfile, updateProfile, deleteProfile, createAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, IUpdatePasswordRequest, UpdatePasswordResponse, ICreateAccountRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
2560
+ export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganizations, getOrganization, createOrganization, deleteOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, getNotifications, getProfiles, getCurrentProfile, createProfile, getProfile, switchProfile, updateProfile, deleteProfile, createAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateResponse, IUpdatePasswordRequest, IUpdatePasswordResponse, ICreateAccountRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
package/dist/index.d.ts CHANGED
@@ -1619,6 +1619,7 @@ declare const createOrganizationInvitation: (endpoint: VerdocsEndpoint, params:
1619
1619
  declare const deleteOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1620
1620
  declare const updateOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, params: Partial<ICreateInvitationRequest>) => Promise<IOrganizationInvitation>;
1621
1621
  declare const resendOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1622
+ declare const getOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1622
1623
  declare const acceptOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IProfile>;
1623
1624
  declare const declineOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<{
1624
1625
  status: "OK";
@@ -2321,9 +2322,11 @@ interface ICreateProfileRequest {
2321
2322
  }
2322
2323
  interface ISwitchProfileResponse {
2323
2324
  profile: IProfile;
2324
- idToken: string;
2325
2325
  accessToken: string;
2326
+ idToken: string;
2326
2327
  refreshToken: string;
2328
+ accessTokenExp: number;
2329
+ refreshTokenExp: number;
2327
2330
  }
2328
2331
  interface IUpdateProfileRequest {
2329
2332
  first_name?: string;
@@ -2333,25 +2336,20 @@ interface IUpdateProfileRequest {
2333
2336
  permissions?: TPermission[];
2334
2337
  roles?: TRole[];
2335
2338
  }
2336
- interface IAuthenticateUserRequest {
2337
- username: string;
2338
- password: string;
2339
- }
2340
- interface IAuthenticateAppRequest {
2341
- client_id: string;
2342
- client_secret: string;
2343
- }
2344
2339
  interface IAuthenticateResponse {
2345
- idToken: string;
2346
- accessToken: string;
2347
- refreshToken: string;
2340
+ access_token: string;
2341
+ id_token: string;
2342
+ refresh_token: string;
2343
+ expires_in: number;
2344
+ access_token_exp: number;
2345
+ refresh_token_exp: number;
2348
2346
  }
2349
2347
  interface IUpdatePasswordRequest {
2350
2348
  email: string;
2351
2349
  oldPassword: string;
2352
2350
  newPassword: string;
2353
2351
  }
2354
- interface UpdatePasswordResponse {
2352
+ interface IUpdatePasswordResponse {
2355
2353
  status: TRequestStatus;
2356
2354
  /** Success or failure message */
2357
2355
  message: string;
@@ -2363,34 +2361,42 @@ interface ICreateAccountRequest {
2363
2361
  lastName: string;
2364
2362
  orgName: string;
2365
2363
  }
2364
+ interface IROPCRequest {
2365
+ grant_type: "password";
2366
+ username: string;
2367
+ password: string;
2368
+ client_id?: string;
2369
+ scope?: string;
2370
+ }
2371
+ interface IClientCredentialsRequest {
2372
+ grant_type: "client_credentials";
2373
+ client_id: string;
2374
+ client_secret: string;
2375
+ scope?: string;
2376
+ }
2377
+ interface IRefreshTokenRequest {
2378
+ grant_type: "refresh_token";
2379
+ refresh_token: string;
2380
+ client_id?: string;
2381
+ scope?: string;
2382
+ }
2383
+ type TAuthenticationRequest = IROPCRequest | IClientCredentialsRequest | IRefreshTokenRequest;
2366
2384
  /**
2367
- * Authenticate to Verdocs via user/password authentication
2385
+ * Authenticate to Verdocs.
2368
2386
  *
2369
2387
  * ```typescript
2370
- * import {Auth} from '@verdocs/js-sdk/Auth';
2371
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2388
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2372
2389
  *
2373
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2374
- * Transport.setAuthToken(accessToken);
2375
- * ```
2376
- */
2377
- declare const authenticateUser: (endpoint: VerdocsEndpoint, params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
2378
- /**
2379
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2380
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2381
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2382
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2383
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2390
+ * // Client-side call, suitable for Web and mobile apps:
2391
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2392
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2384
2393
  *
2385
- * ```typescript
2386
- * import {Auth} from '@verdocs/js-sdk/Auth';
2387
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2388
- *
2389
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2390
- * Transport.setAuthToken(accessToken);
2394
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2395
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2396
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2391
2397
  * ```
2392
2398
  */
2393
- declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
2399
+ declare const authenticate: (endpoint: VerdocsEndpoint, params: TAuthenticationRequest) => Promise<IAuthenticateResponse>;
2394
2400
  /**
2395
2401
  * If called before the session expires, this will refresh the caller's session and tokens.
2396
2402
  *
@@ -2402,27 +2408,27 @@ declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticate
2402
2408
  * Transport.setAuthToken(accessToken);
2403
2409
  * ```
2404
2410
  */
2405
- declare const refreshTokens: (endpoint: VerdocsEndpoint) => Promise<IAuthenticateResponse>;
2411
+ declare const refreshToken: (endpoint: VerdocsEndpoint, refreshToken: string) => Promise<IAuthenticateResponse>;
2406
2412
  /**
2407
2413
  * Update the caller's password when the old password is known (typically for logged-in users).
2408
2414
  *
2409
2415
  * ```typescript
2410
- * import {Auth} from '@verdocs/js-sdk/Auth';
2416
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2411
2417
  *
2412
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2418
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2413
2419
  * if (status !== 'OK') {
2414
2420
  * window.alert(`Password reset error: ${message}`);
2415
2421
  * }
2416
2422
  * ```
2417
2423
  */
2418
- declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
2424
+ declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<IUpdatePasswordResponse>;
2419
2425
  /**
2420
2426
  * Request a password reset, when the old password is not known (typically in login forms).
2421
2427
  *
2422
2428
  * ```typescript
2423
- * import {Auth} from '@verdocs/js-sdk/Auth';
2429
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2424
2430
  *
2425
- * const {success} = await Auth.resetPassword({ email });
2431
+ * const {success} = await resetPassword({ email });
2426
2432
  * if (status !== 'OK') {
2427
2433
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2428
2434
  * }
@@ -2551,4 +2557,4 @@ interface ISignupSurvey {
2551
2557
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2552
2558
  status: "OK";
2553
2559
  }>;
2554
- export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganizations, getOrganization, createOrganization, deleteOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, refreshTokens, changePassword, resetPassword, resendVerification, getNotifications, getProfiles, getCurrentProfile, createProfile, getProfile, switchProfile, updateProfile, deleteProfile, createAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, IUpdatePasswordRequest, UpdatePasswordResponse, ICreateAccountRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
2560
+ export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganizations, getOrganization, createOrganization, deleteOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, getNotifications, getProfiles, getCurrentProfile, createProfile, getProfile, switchProfile, updateProfile, deleteProfile, createAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateResponse, IUpdatePasswordRequest, IUpdatePasswordResponse, ICreateAccountRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
package/dist/index.js CHANGED
@@ -868,7 +868,7 @@ class VerdocsEndpoint {
868
868
  static getDefault() {
869
869
  if (!globalThis$1[ENDPOINT_KEY]) {
870
870
  globalThis$1[ENDPOINT_KEY] = new VerdocsEndpoint();
871
- window.console.debug('[JS_SDK] Created default endpoint', globalThis$1[ENDPOINT_KEY].baseURL);
871
+ // window.console.debug('[JS_SDK] Created default endpoint', globalThis[ENDPOINT_KEY].baseURL);
872
872
  }
873
873
  return globalThis$1[ENDPOINT_KEY];
874
874
  }
@@ -1710,6 +1710,9 @@ const updateOrganizationInvitation = (endpoint, email, params) => endpoint.api /
1710
1710
  const resendOrganizationInvitation = (endpoint, email) => endpoint.api //
1711
1711
  .post('/v2/organization-invitations/resend', { email })
1712
1712
  .then((r) => r.data);
1713
+ const getOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1714
+ .get(`/v2/organization-invitations/${email}/${token}`)
1715
+ .then((r) => r.data);
1713
1716
  const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1714
1717
  .post('/v2/organization-invitations/accept', { email, token })
1715
1718
  .then((r) => r.data);
@@ -2471,36 +2474,22 @@ const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2471
2474
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2472
2475
 
2473
2476
  /**
2474
- * Authenticate to Verdocs via user/password authentication
2477
+ * Authenticate to Verdocs.
2475
2478
  *
2476
2479
  * ```typescript
2477
- * import {Auth} from '@verdocs/js-sdk/Auth';
2478
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2479
- *
2480
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2481
- * Transport.setAuthToken(accessToken);
2482
- * ```
2483
- */
2484
- const authenticateUser = (endpoint, params) => endpoint.api //
2485
- .post('/authentication/login', params)
2486
- .then((r) => r.data);
2487
- /**
2488
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2489
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2490
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2491
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2492
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2480
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2493
2481
  *
2494
- * ```typescript
2495
- * import {Auth} from '@verdocs/js-sdk/Auth';
2496
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2482
+ * // Client-side call, suitable for Web and mobile apps:
2483
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2484
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2497
2485
  *
2498
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2499
- * Transport.setAuthToken(accessToken);
2486
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2487
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2488
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2500
2489
  * ```
2501
2490
  */
2502
- const authenticateApp = (endpoint, params) => endpoint.api //
2503
- .post('/authentication/login_client', {}, { headers: params })
2491
+ const authenticate = (endpoint, params) => endpoint.api //
2492
+ .post('/v2/oauth2/token', params)
2504
2493
  .then((r) => r.data);
2505
2494
  /**
2506
2495
  * If called before the session expires, this will refresh the caller's session and tokens.
@@ -2513,38 +2502,36 @@ const authenticateApp = (endpoint, params) => endpoint.api //
2513
2502
  * Transport.setAuthToken(accessToken);
2514
2503
  * ```
2515
2504
  */
2516
- const refreshTokens = (endpoint) => endpoint.api //
2517
- .get('/token')
2518
- .then((r) => r.data);
2505
+ const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_type: 'refresh_token', refresh_token: refreshToken });
2519
2506
  /**
2520
2507
  * Update the caller's password when the old password is known (typically for logged-in users).
2521
2508
  *
2522
2509
  * ```typescript
2523
- * import {Auth} from '@verdocs/js-sdk/Auth';
2510
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2524
2511
  *
2525
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2512
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2526
2513
  * if (status !== 'OK') {
2527
2514
  * window.alert(`Password reset error: ${message}`);
2528
2515
  * }
2529
2516
  * ```
2530
2517
  */
2531
2518
  const changePassword = (endpoint, params) => endpoint.api //
2532
- .put('/user/update_password', params)
2519
+ .post('/v2/users/change-password', params)
2533
2520
  .then((r) => r.data);
2534
2521
  /**
2535
2522
  * Request a password reset, when the old password is not known (typically in login forms).
2536
2523
  *
2537
2524
  * ```typescript
2538
- * import {Auth} from '@verdocs/js-sdk/Auth';
2525
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2539
2526
  *
2540
- * const {success} = await Auth.resetPassword({ email });
2527
+ * const {success} = await resetPassword({ email });
2541
2528
  * if (status !== 'OK') {
2542
2529
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2543
2530
  * }
2544
2531
  * ```
2545
2532
  */
2546
2533
  const resetPassword = (endpoint, params) => endpoint.api //
2547
- .post('/user/reset_password', params)
2534
+ .post('/v2/users/reset-password', params)
2548
2535
  .then((r) => r.data);
2549
2536
  /**
2550
2537
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
@@ -2560,7 +2547,7 @@ const resetPassword = (endpoint, params) => endpoint.api //
2560
2547
  * ```
2561
2548
  */
2562
2549
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2563
- .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2550
+ .post('/v2/users/resend-verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2564
2551
  .then((r) => r.data);
2565
2552
 
2566
2553
  const getNotifications = async (endpoint) => endpoint.api //
@@ -2679,8 +2666,7 @@ exports.VerdocsEndpoint = VerdocsEndpoint;
2679
2666
  exports.acceptOrganizationInvitation = acceptOrganizationInvitation;
2680
2667
  exports.addGroupMember = addGroupMember;
2681
2668
  exports.addTemplateTag = addTemplateTag;
2682
- exports.authenticateApp = authenticateApp;
2683
- exports.authenticateUser = authenticateUser;
2669
+ exports.authenticate = authenticate;
2684
2670
  exports.blobToBase64 = blobToBase64;
2685
2671
  exports.canPerformTemplateAction = canPerformTemplateAction;
2686
2672
  exports.cancelEnvelope = cancelEnvelope;
@@ -2760,6 +2746,7 @@ exports.getMatchingCountry = getMatchingCountry;
2760
2746
  exports.getNextRecipient = getNextRecipient;
2761
2747
  exports.getNotifications = getNotifications;
2762
2748
  exports.getOrganization = getOrganization;
2749
+ exports.getOrganizationInvitation = getOrganizationInvitation;
2763
2750
  exports.getOrganizationInvitations = getOrganizationInvitations;
2764
2751
  exports.getOrganizationMembers = getOrganizationMembers;
2765
2752
  exports.getOrganizations = getOrganizations;
@@ -2816,7 +2803,7 @@ exports.nameToRGBA = nameToRGBA;
2816
2803
  exports.recipientCanAct = recipientCanAct;
2817
2804
  exports.recipientHasAction = recipientHasAction;
2818
2805
  exports.recordSignupSurvey = recordSignupSurvey;
2819
- exports.refreshTokens = refreshTokens;
2806
+ exports.refreshToken = refreshToken;
2820
2807
  exports.rescale = rescale;
2821
2808
  exports.resendInvitation = resendInvitation;
2822
2809
  exports.resendOrganizationInvitation = resendOrganizationInvitation;