@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.d.mts CHANGED
@@ -142,6 +142,7 @@ interface IProfile {
142
142
  last_name: string;
143
143
  email: string;
144
144
  phone: string | null;
145
+ picture: string | null;
145
146
  /** If true, this is the caller's "currently selected" profile. All operations will performed "as" this profile. */
146
147
  current: boolean;
147
148
  permissions: TPermission[];
@@ -1619,7 +1620,7 @@ declare const createOrganizationInvitation: (endpoint: VerdocsEndpoint, params:
1619
1620
  declare const deleteOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1620
1621
  declare const updateOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, params: Partial<ICreateInvitationRequest>) => Promise<IOrganizationInvitation>;
1621
1622
  declare const resendOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1622
- declare const gettOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1623
+ declare const getOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1623
1624
  declare const acceptOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IProfile>;
1624
1625
  declare const declineOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<{
1625
1626
  status: "OK";
@@ -2322,9 +2323,11 @@ interface ICreateProfileRequest {
2322
2323
  }
2323
2324
  interface ISwitchProfileResponse {
2324
2325
  profile: IProfile;
2325
- idToken: string;
2326
2326
  accessToken: string;
2327
+ idToken: string;
2327
2328
  refreshToken: string;
2329
+ accessTokenExp: number;
2330
+ refreshTokenExp: number;
2328
2331
  }
2329
2332
  interface IUpdateProfileRequest {
2330
2333
  first_name?: string;
@@ -2334,25 +2337,20 @@ interface IUpdateProfileRequest {
2334
2337
  permissions?: TPermission[];
2335
2338
  roles?: TRole[];
2336
2339
  }
2337
- interface IAuthenticateUserRequest {
2338
- username: string;
2339
- password: string;
2340
- }
2341
- interface IAuthenticateAppRequest {
2342
- client_id: string;
2343
- client_secret: string;
2344
- }
2345
2340
  interface IAuthenticateResponse {
2346
- idToken: string;
2347
- accessToken: string;
2348
- refreshToken: string;
2341
+ access_token: string;
2342
+ id_token: string;
2343
+ refresh_token: string;
2344
+ expires_in: number;
2345
+ access_token_exp: number;
2346
+ refresh_token_exp: number;
2349
2347
  }
2350
2348
  interface IUpdatePasswordRequest {
2351
2349
  email: string;
2352
2350
  oldPassword: string;
2353
2351
  newPassword: string;
2354
2352
  }
2355
- interface UpdatePasswordResponse {
2353
+ interface IUpdatePasswordResponse {
2356
2354
  status: TRequestStatus;
2357
2355
  /** Success or failure message */
2358
2356
  message: string;
@@ -2364,34 +2362,42 @@ interface ICreateAccountRequest {
2364
2362
  lastName: string;
2365
2363
  orgName: string;
2366
2364
  }
2365
+ interface IROPCRequest {
2366
+ grant_type: "password";
2367
+ username: string;
2368
+ password: string;
2369
+ client_id?: string;
2370
+ scope?: string;
2371
+ }
2372
+ interface IClientCredentialsRequest {
2373
+ grant_type: "client_credentials";
2374
+ client_id: string;
2375
+ client_secret: string;
2376
+ scope?: string;
2377
+ }
2378
+ interface IRefreshTokenRequest {
2379
+ grant_type: "refresh_token";
2380
+ refresh_token: string;
2381
+ client_id?: string;
2382
+ scope?: string;
2383
+ }
2384
+ type TAuthenticationRequest = IROPCRequest | IClientCredentialsRequest | IRefreshTokenRequest;
2367
2385
  /**
2368
- * Authenticate to Verdocs via user/password authentication
2386
+ * Authenticate to Verdocs.
2369
2387
  *
2370
2388
  * ```typescript
2371
- * import {Auth} from '@verdocs/js-sdk/Auth';
2372
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2389
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2373
2390
  *
2374
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2375
- * Transport.setAuthToken(accessToken);
2376
- * ```
2377
- */
2378
- declare const authenticateUser: (endpoint: VerdocsEndpoint, params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
2379
- /**
2380
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2381
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2382
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2383
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2384
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2391
+ * // Client-side call, suitable for Web and mobile apps:
2392
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2393
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2385
2394
  *
2386
- * ```typescript
2387
- * import {Auth} from '@verdocs/js-sdk/Auth';
2388
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2389
- *
2390
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2391
- * Transport.setAuthToken(accessToken);
2395
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2396
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2397
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2392
2398
  * ```
2393
2399
  */
2394
- declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
2400
+ declare const authenticate: (endpoint: VerdocsEndpoint, params: TAuthenticationRequest) => Promise<IAuthenticateResponse>;
2395
2401
  /**
2396
2402
  * If called before the session expires, this will refresh the caller's session and tokens.
2397
2403
  *
@@ -2403,27 +2409,27 @@ declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticate
2403
2409
  * Transport.setAuthToken(accessToken);
2404
2410
  * ```
2405
2411
  */
2406
- declare const refreshTokens: (endpoint: VerdocsEndpoint) => Promise<IAuthenticateResponse>;
2412
+ declare const refreshToken: (endpoint: VerdocsEndpoint, refreshToken: string) => Promise<IAuthenticateResponse>;
2407
2413
  /**
2408
2414
  * Update the caller's password when the old password is known (typically for logged-in users).
2409
2415
  *
2410
2416
  * ```typescript
2411
- * import {Auth} from '@verdocs/js-sdk/Auth';
2417
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2412
2418
  *
2413
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2419
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2414
2420
  * if (status !== 'OK') {
2415
2421
  * window.alert(`Password reset error: ${message}`);
2416
2422
  * }
2417
2423
  * ```
2418
2424
  */
2419
- declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
2425
+ declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<IUpdatePasswordResponse>;
2420
2426
  /**
2421
2427
  * Request a password reset, when the old password is not known (typically in login forms).
2422
2428
  *
2423
2429
  * ```typescript
2424
- * import {Auth} from '@verdocs/js-sdk/Auth';
2430
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2425
2431
  *
2426
- * const {success} = await Auth.resetPassword({ email });
2432
+ * const {success} = await resetPassword({ email });
2427
2433
  * if (status !== 'OK') {
2428
2434
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2429
2435
  * }
@@ -2552,4 +2558,4 @@ interface ISignupSurvey {
2552
2558
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2553
2559
  status: "OK";
2554
2560
  }>;
2555
- 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, gettOrganizationInvitation, 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 };
2561
+ 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
@@ -142,6 +142,7 @@ interface IProfile {
142
142
  last_name: string;
143
143
  email: string;
144
144
  phone: string | null;
145
+ picture: string | null;
145
146
  /** If true, this is the caller's "currently selected" profile. All operations will performed "as" this profile. */
146
147
  current: boolean;
147
148
  permissions: TPermission[];
@@ -1619,7 +1620,7 @@ declare const createOrganizationInvitation: (endpoint: VerdocsEndpoint, params:
1619
1620
  declare const deleteOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1620
1621
  declare const updateOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, params: Partial<ICreateInvitationRequest>) => Promise<IOrganizationInvitation>;
1621
1622
  declare const resendOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string) => Promise<any>;
1622
- declare const gettOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1623
+ declare const getOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IOrganizationInvitation>;
1623
1624
  declare const acceptOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<IProfile>;
1624
1625
  declare const declineOrganizationInvitation: (endpoint: VerdocsEndpoint, email: string, token: string) => Promise<{
1625
1626
  status: "OK";
@@ -2322,9 +2323,11 @@ interface ICreateProfileRequest {
2322
2323
  }
2323
2324
  interface ISwitchProfileResponse {
2324
2325
  profile: IProfile;
2325
- idToken: string;
2326
2326
  accessToken: string;
2327
+ idToken: string;
2327
2328
  refreshToken: string;
2329
+ accessTokenExp: number;
2330
+ refreshTokenExp: number;
2328
2331
  }
2329
2332
  interface IUpdateProfileRequest {
2330
2333
  first_name?: string;
@@ -2334,25 +2337,20 @@ interface IUpdateProfileRequest {
2334
2337
  permissions?: TPermission[];
2335
2338
  roles?: TRole[];
2336
2339
  }
2337
- interface IAuthenticateUserRequest {
2338
- username: string;
2339
- password: string;
2340
- }
2341
- interface IAuthenticateAppRequest {
2342
- client_id: string;
2343
- client_secret: string;
2344
- }
2345
2340
  interface IAuthenticateResponse {
2346
- idToken: string;
2347
- accessToken: string;
2348
- refreshToken: string;
2341
+ access_token: string;
2342
+ id_token: string;
2343
+ refresh_token: string;
2344
+ expires_in: number;
2345
+ access_token_exp: number;
2346
+ refresh_token_exp: number;
2349
2347
  }
2350
2348
  interface IUpdatePasswordRequest {
2351
2349
  email: string;
2352
2350
  oldPassword: string;
2353
2351
  newPassword: string;
2354
2352
  }
2355
- interface UpdatePasswordResponse {
2353
+ interface IUpdatePasswordResponse {
2356
2354
  status: TRequestStatus;
2357
2355
  /** Success or failure message */
2358
2356
  message: string;
@@ -2364,34 +2362,42 @@ interface ICreateAccountRequest {
2364
2362
  lastName: string;
2365
2363
  orgName: string;
2366
2364
  }
2365
+ interface IROPCRequest {
2366
+ grant_type: "password";
2367
+ username: string;
2368
+ password: string;
2369
+ client_id?: string;
2370
+ scope?: string;
2371
+ }
2372
+ interface IClientCredentialsRequest {
2373
+ grant_type: "client_credentials";
2374
+ client_id: string;
2375
+ client_secret: string;
2376
+ scope?: string;
2377
+ }
2378
+ interface IRefreshTokenRequest {
2379
+ grant_type: "refresh_token";
2380
+ refresh_token: string;
2381
+ client_id?: string;
2382
+ scope?: string;
2383
+ }
2384
+ type TAuthenticationRequest = IROPCRequest | IClientCredentialsRequest | IRefreshTokenRequest;
2367
2385
  /**
2368
- * Authenticate to Verdocs via user/password authentication
2386
+ * Authenticate to Verdocs.
2369
2387
  *
2370
2388
  * ```typescript
2371
- * import {Auth} from '@verdocs/js-sdk/Auth';
2372
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2389
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2373
2390
  *
2374
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2375
- * Transport.setAuthToken(accessToken);
2376
- * ```
2377
- */
2378
- declare const authenticateUser: (endpoint: VerdocsEndpoint, params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
2379
- /**
2380
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2381
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2382
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2383
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2384
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
2391
+ * // Client-side call, suitable for Web and mobile apps:
2392
+ * const {access_token} = await Auth.authenticate({ username: 'test@test.com', password: 'PASSWORD', grant_type:'password' });
2393
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2385
2394
  *
2386
- * ```typescript
2387
- * import {Auth} from '@verdocs/js-sdk/Auth';
2388
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2389
- *
2390
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2391
- * Transport.setAuthToken(accessToken);
2395
+ * // Server-side call, suitable for server apps. NEVER EXPOSE client_secret IN FRONT-END CODE:
2396
+ * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
2397
+ * VerdocsEndpoint.getDefault().setAuthToken(access_token);
2392
2398
  * ```
2393
2399
  */
2394
- declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
2400
+ declare const authenticate: (endpoint: VerdocsEndpoint, params: TAuthenticationRequest) => Promise<IAuthenticateResponse>;
2395
2401
  /**
2396
2402
  * If called before the session expires, this will refresh the caller's session and tokens.
2397
2403
  *
@@ -2403,27 +2409,27 @@ declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticate
2403
2409
  * Transport.setAuthToken(accessToken);
2404
2410
  * ```
2405
2411
  */
2406
- declare const refreshTokens: (endpoint: VerdocsEndpoint) => Promise<IAuthenticateResponse>;
2412
+ declare const refreshToken: (endpoint: VerdocsEndpoint, refreshToken: string) => Promise<IAuthenticateResponse>;
2407
2413
  /**
2408
2414
  * Update the caller's password when the old password is known (typically for logged-in users).
2409
2415
  *
2410
2416
  * ```typescript
2411
- * import {Auth} from '@verdocs/js-sdk/Auth';
2417
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2412
2418
  *
2413
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2419
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2414
2420
  * if (status !== 'OK') {
2415
2421
  * window.alert(`Password reset error: ${message}`);
2416
2422
  * }
2417
2423
  * ```
2418
2424
  */
2419
- declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
2425
+ declare const changePassword: (endpoint: VerdocsEndpoint, params: IUpdatePasswordRequest) => Promise<IUpdatePasswordResponse>;
2420
2426
  /**
2421
2427
  * Request a password reset, when the old password is not known (typically in login forms).
2422
2428
  *
2423
2429
  * ```typescript
2424
- * import {Auth} from '@verdocs/js-sdk/Auth';
2430
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2425
2431
  *
2426
- * const {success} = await Auth.resetPassword({ email });
2432
+ * const {success} = await resetPassword({ email });
2427
2433
  * if (status !== 'OK') {
2428
2434
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2429
2435
  * }
@@ -2552,4 +2558,4 @@ interface ISignupSurvey {
2552
2558
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2553
2559
  status: "OK";
2554
2560
  }>;
2555
- 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, gettOrganizationInvitation, 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 };
2561
+ 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,7 +1710,7 @@ 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 gettOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1713
+ const getOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1714
1714
  .get(`/v2/organization-invitations/${email}/${token}`)
1715
1715
  .then((r) => r.data);
1716
1716
  const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
@@ -2474,36 +2474,22 @@ const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2474
2474
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2475
2475
 
2476
2476
  /**
2477
- * Authenticate to Verdocs via user/password authentication
2477
+ * Authenticate to Verdocs.
2478
2478
  *
2479
2479
  * ```typescript
2480
- * import {Auth} from '@verdocs/js-sdk/Auth';
2481
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2480
+ * import {authenticate, VerdocsEndpoint} from '@verdocs/js-sdk';
2482
2481
  *
2483
- * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
2484
- * Transport.setAuthToken(accessToken);
2485
- * ```
2486
- */
2487
- const authenticateUser = (endpoint, params) => endpoint.api //
2488
- .post('/authentication/login', params)
2489
- .then((r) => r.data);
2490
- /**
2491
- * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
2492
- * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2493
- * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2494
- * hours. This expiration may change based on future security needs. Application developers are encouraged
2495
- * to check the `exp` expiration field in the response, and renew tokens after they expire.
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);
2496
2485
  *
2497
- * ```typescript
2498
- * import {Auth} from '@verdocs/js-sdk/Auth';
2499
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2500
- *
2501
- * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
2502
- * 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);
2503
2489
  * ```
2504
2490
  */
2505
- const authenticateApp = (endpoint, params) => endpoint.api //
2506
- .post('/authentication/login_client', {}, { headers: params })
2491
+ const authenticate = (endpoint, params) => endpoint.api //
2492
+ .post('/v2/oauth2/token', params)
2507
2493
  .then((r) => r.data);
2508
2494
  /**
2509
2495
  * If called before the session expires, this will refresh the caller's session and tokens.
@@ -2516,38 +2502,36 @@ const authenticateApp = (endpoint, params) => endpoint.api //
2516
2502
  * Transport.setAuthToken(accessToken);
2517
2503
  * ```
2518
2504
  */
2519
- const refreshTokens = (endpoint) => endpoint.api //
2520
- .get('/token')
2521
- .then((r) => r.data);
2505
+ const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_type: 'refresh_token', refresh_token: refreshToken });
2522
2506
  /**
2523
2507
  * Update the caller's password when the old password is known (typically for logged-in users).
2524
2508
  *
2525
2509
  * ```typescript
2526
- * import {Auth} from '@verdocs/js-sdk/Auth';
2510
+ * import {changePassword} from '@verdocs/js-sdk/Auth';
2527
2511
  *
2528
- * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
2512
+ * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2529
2513
  * if (status !== 'OK') {
2530
2514
  * window.alert(`Password reset error: ${message}`);
2531
2515
  * }
2532
2516
  * ```
2533
2517
  */
2534
2518
  const changePassword = (endpoint, params) => endpoint.api //
2535
- .put('/user/update_password', params)
2519
+ .post('/v2/users/change-password', params)
2536
2520
  .then((r) => r.data);
2537
2521
  /**
2538
2522
  * Request a password reset, when the old password is not known (typically in login forms).
2539
2523
  *
2540
2524
  * ```typescript
2541
- * import {Auth} from '@verdocs/js-sdk/Auth';
2525
+ * import {resetPassword} from '@verdocs/js-sdk/Auth';
2542
2526
  *
2543
- * const {success} = await Auth.resetPassword({ email });
2527
+ * const {success} = await resetPassword({ email });
2544
2528
  * if (status !== 'OK') {
2545
2529
  * window.alert(`Please check your email for instructions on how to reset your password.`);
2546
2530
  * }
2547
2531
  * ```
2548
2532
  */
2549
2533
  const resetPassword = (endpoint, params) => endpoint.api //
2550
- .post('/user/reset_password', params)
2534
+ .post('/v2/users/reset-password', params)
2551
2535
  .then((r) => r.data);
2552
2536
  /**
2553
2537
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
@@ -2563,7 +2547,7 @@ const resetPassword = (endpoint, params) => endpoint.api //
2563
2547
  * ```
2564
2548
  */
2565
2549
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2566
- .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2550
+ .post('/v2/users/resend-verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2567
2551
  .then((r) => r.data);
2568
2552
 
2569
2553
  const getNotifications = async (endpoint) => endpoint.api //
@@ -2682,8 +2666,7 @@ exports.VerdocsEndpoint = VerdocsEndpoint;
2682
2666
  exports.acceptOrganizationInvitation = acceptOrganizationInvitation;
2683
2667
  exports.addGroupMember = addGroupMember;
2684
2668
  exports.addTemplateTag = addTemplateTag;
2685
- exports.authenticateApp = authenticateApp;
2686
- exports.authenticateUser = authenticateUser;
2669
+ exports.authenticate = authenticate;
2687
2670
  exports.blobToBase64 = blobToBase64;
2688
2671
  exports.canPerformTemplateAction = canPerformTemplateAction;
2689
2672
  exports.cancelEnvelope = cancelEnvelope;
@@ -2763,6 +2746,7 @@ exports.getMatchingCountry = getMatchingCountry;
2763
2746
  exports.getNextRecipient = getNextRecipient;
2764
2747
  exports.getNotifications = getNotifications;
2765
2748
  exports.getOrganization = getOrganization;
2749
+ exports.getOrganizationInvitation = getOrganizationInvitation;
2766
2750
  exports.getOrganizationInvitations = getOrganizationInvitations;
2767
2751
  exports.getOrganizationMembers = getOrganizationMembers;
2768
2752
  exports.getOrganizations = getOrganizations;
@@ -2799,7 +2783,6 @@ exports.getTemplatesSummary = getTemplatesSummary;
2799
2783
  exports.getValidator = getValidator;
2800
2784
  exports.getValidators = getValidators;
2801
2785
  exports.getWebhooks = getWebhooks;
2802
- exports.gettOrganizationInvitation = gettOrganizationInvitation;
2803
2786
  exports.hasRequiredPermissions = hasRequiredPermissions;
2804
2787
  exports.integerSequence = integerSequence;
2805
2788
  exports.isAmericanSamoa = isAmericanSamoa;
@@ -2820,7 +2803,7 @@ exports.nameToRGBA = nameToRGBA;
2820
2803
  exports.recipientCanAct = recipientCanAct;
2821
2804
  exports.recipientHasAction = recipientHasAction;
2822
2805
  exports.recordSignupSurvey = recordSignupSurvey;
2823
- exports.refreshTokens = refreshTokens;
2806
+ exports.refreshToken = refreshToken;
2824
2807
  exports.rescale = rescale;
2825
2808
  exports.resendInvitation = resendInvitation;
2826
2809
  exports.resendOrganizationInvitation = resendOrganizationInvitation;