@verdocs/js-sdk 4.0.10 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1573,61 +1573,61 @@ const deleteSignature = (endpoint, signatureId) => endpoint.api //
1573
1573
  * Get a list of keys for a given organization. The caller must have admin access to the organization.
1574
1574
  *
1575
1575
  * ```typescript
1576
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1576
+ * import {ApiKeys} from '@verdocs/js-sdk';
1577
1577
  *
1578
1578
  * const keys = await ApiKeys.getKeys(ORGID);
1579
1579
  * ```
1580
1580
  */
1581
- const getApiKeys = (endpoint, organizationId) => endpoint.api //
1582
- .get(`/organizations/${organizationId}/api_key`)
1581
+ const getApiKeys = (endpoint) => endpoint.api //
1582
+ .get(`/v2/api-keys`)
1583
1583
  .then((r) => r.data);
1584
1584
  /**
1585
1585
  * Create an API key.
1586
1586
  *
1587
1587
  * ```typescript
1588
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1588
+ * import {ApiKeys} from '@verdocs/js-sdk';
1589
1589
  *
1590
1590
  * await ApiKeys.createKey(ORGID, {name: NEWNAME});
1591
1591
  * ```
1592
1592
  */
1593
- const createApiKey = (endpoint, organizationId, params) => endpoint.api //
1594
- .post(`/organizations/${organizationId}/api_key`, params)
1593
+ const createApiKey = (endpoint, params) => endpoint.api //
1594
+ .post('/v2/api-keys', params)
1595
1595
  .then((r) => r.data);
1596
1596
  /**
1597
1597
  * Rotate the secret for an API key. The caller must have admin access to the organization.
1598
1598
  *
1599
1599
  * ```typescript
1600
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1600
+ * import {ApiKeys} from '@verdocs/js-sdk';
1601
1601
  *
1602
1602
  * const {client_secret: newSecret} = await ApiKeys.rotateKey(ORGID, CLIENTID);
1603
1603
  * ```
1604
1604
  */
1605
- const rotateApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1606
- .put(`/organizations/${organizationId}/api_key/${clientId}/rotate`)
1605
+ const rotateApiKey = (endpoint, clientId) => endpoint.api //
1606
+ .post(`/v2/api-keys/${clientId}/rotate`)
1607
1607
  .then((r) => r.data);
1608
1608
  /**
1609
1609
  * Update an API key to change its assigned Profile ID or Name.
1610
1610
  *
1611
1611
  * ```typescript
1612
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1612
+ * import {ApiKeys} from '@verdocs/js-sdk';
1613
1613
  *
1614
1614
  * await ApiKeys.updateKey(ORGID, CLIENTID, {name: NEWNAME});
1615
1615
  * ```
1616
1616
  */
1617
- const updateApiKey = (endpoint, organizationId, clientId, params) => endpoint.api //
1618
- .patch(`/organizations/${organizationId}/api_key/${clientId}`, params)
1617
+ const updateApiKey = (endpoint, clientId, params) => endpoint.api //
1618
+ .patch(`/v2/api-keys/${clientId}`, params)
1619
1619
  .then((r) => r.data);
1620
1620
  /**
1621
1621
  * Delete an API key.
1622
1622
  *
1623
1623
  * ```typescript
1624
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1624
+ * import {ApiKeys} from '@verdocs/js-sdk';
1625
1625
  *
1626
1626
  * await ApiKeys.deleteKey(ORGID, CLIENTID);
1627
1627
  * ```
1628
1628
  */
1629
- const deleteApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1630
- .delete(`/organizations/${organizationId}/api_key/${clientId}`)
1629
+ const deleteApiKey = (endpoint, clientId) => endpoint.api //
1630
+ .delete(`/v2/api-keys/${clientId}`)
1631
1631
  .then((r) => r.data);
1632
1632
 
1633
1633
  /**
@@ -1643,52 +1643,37 @@ const deleteApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1643
1643
  * Get a list of groups for a given organization. The caller must have admin access to the organization.
1644
1644
  *
1645
1645
  * ```typescript
1646
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1646
+ * import {getGroups} from '@verdocs/js-sdk';
1647
1647
  *
1648
- * const groups = await Groups.getGroups(ORGID);
1648
+ * const groups = await getGroups(ORGID);
1649
1649
  * ```
1650
1650
  */
1651
- const getGroups = (endpoint, organizationId) => endpoint.api //
1652
- .get(`/organizations/${organizationId}/groups`)
1651
+ const getGroups = (endpoint) => endpoint.api //
1652
+ .get(`/v2/organization-groups`)
1653
1653
  .then((r) => r.data);
1654
1654
  /**
1655
- * Get a single group by name. Returns a detail record.
1655
+ * Get the details for a group, including its member profiles and list of permissions.
1656
1656
  *
1657
1657
  * ```typescript
1658
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1658
+ * import {getGroup} from '@verdocs/js-sdk/v2/organization-groups';
1659
1659
  *
1660
- * const groups = await Groups.getGroups(ORGID);
1660
+ * const groups = await getGroup(GROUPID);
1661
1661
  * ```
1662
1662
  */
1663
- const getGroupByName = (endpoint, organizationId, name) => endpoint.api //
1664
- .get(`/organizations/${organizationId}/groups`, { params: { name } })
1663
+ const getGroup = (endpoint, groupId) => endpoint.api //
1664
+ .get(`/v2/organization-groups/${groupId}`)
1665
1665
  .then((r) => r.data);
1666
- /**
1667
- * Get the details for a group.
1668
- *
1669
- * ```typescript
1670
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1671
- *
1672
- * const groups = await Groups.getGroups(ORGID);
1673
- * ```
1674
- */
1675
- const getGroup = (endpoint, organizationId, groupId) => endpoint.api //
1676
- .get(`/organizations/${organizationId}/groups/${groupId}`)
1677
- .then((r) => r.data);
1678
- const getGroupMembers = (endpoint, organizationId, groupId) => endpoint.api //
1679
- .get(`/organizations/${organizationId}/groups/${groupId}/members`)
1666
+ const createGroup = (endpoint, name) => endpoint.api //
1667
+ .post('/v2/organization-groups', { name })
1680
1668
  .then((r) => r.data);
1681
- const addGroupMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1682
- .post(`/organizations/${organizationId}/groups/${groupId}/members`, params)
1669
+ const addGroupMember = (endpoint, groupId, profile_id) => endpoint.api //
1670
+ .post(`/v2/organization-groups/${groupId}/members`, { profile_id })
1683
1671
  .then((r) => r.data);
1684
- const deleteGroupMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1685
- .put(`/organizations/${organizationId}/groups/${groupId}/delete_members`, params)
1672
+ const deleteGroupMember = (endpoint, groupId, profile_id) => endpoint.api //
1673
+ .delete(`/v2/organization-groups/${groupId}/members/${profile_id}`)
1686
1674
  .then((r) => r.data);
1687
- const addGroupPermission = (endpoint, organizationId, groupId, permission) => endpoint.api //
1688
- .post(`/organizations/${organizationId}/groups/${groupId}/permissions/${permission}`, {})
1689
- .then((r) => r.data);
1690
- const deleteGroupPermission = (endpoint, organizationId, groupId, permission) => endpoint.api //
1691
- .delete(`/organizations/${organizationId}/groups/${groupId}/permissions/${permission}`)
1675
+ const updateGroup = (endpoint, groupId, params) => endpoint.api //
1676
+ .patch(`/v2/organization-groups/${groupId}`, params)
1692
1677
  .then((r) => r.data);
1693
1678
 
1694
1679
  /**
@@ -1696,32 +1681,26 @@ const deleteGroupPermission = (endpoint, organizationId, groupId, permission) =>
1696
1681
  *
1697
1682
  * @module
1698
1683
  */
1699
- const getOrganizationInvitations = (endpoint, organizationId) => endpoint.api //
1700
- .get(`/organizations/${organizationId}/invitation`)
1701
- .then((r) => r.data);
1702
- const createOrganizationInvitation = (endpoint, organizationId, params) => endpoint.api //
1703
- .post(`/organizations/${organizationId}/invitation`, params)
1684
+ const getOrganizationInvitations = (endpoint) => endpoint.api //
1685
+ .get(`/v2/organization-invitations`)
1704
1686
  .then((r) => r.data);
1705
- const deleteOrganizationInvitation = (endpoint, organizationId, email) => endpoint.api //
1706
- .delete(`/organizations/${organizationId}/invitation/${email}`)
1687
+ const createOrganizationInvitation = (endpoint, params) => endpoint.api //
1688
+ .post(`/v2/organization-invitations`, params)
1707
1689
  .then((r) => r.data);
1708
- const updateOrganizationInvitation = (endpoint, organizationId, email, params) => endpoint.api //
1709
- .patch(`/organizations/${organizationId}/invitation/${email}`, params)
1690
+ const deleteOrganizationInvitation = (endpoint, email) => endpoint.api //
1691
+ .delete(`/v2/organization-invitations/${email}`)
1710
1692
  .then((r) => r.data);
1711
- const resendOrganizationInvitation = (endpoint, organizationId, email) => endpoint.api //
1712
- .post(`/organizations/${organizationId}/invitation/${email}/resend`)
1693
+ const updateOrganizationInvitation = (endpoint, email, params) => endpoint.api //
1694
+ .patch(`/v2/organization-invitations/${email}`, params)
1713
1695
  .then((r) => r.data);
1714
- const getOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1715
- .get(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1696
+ const resendOrganizationInvitation = (endpoint, email) => endpoint.api //
1697
+ .post('/v2/organization-invitations/resend', { email })
1716
1698
  .then((r) => r.data);
1717
- const acceptOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1718
- .post(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1699
+ const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1700
+ .post('/v2/organization-invitations/accept', { email, token })
1719
1701
  .then((r) => r.data);
1720
- const declineOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1721
- .post(`/organizations/${organizationId}/invitation/${email}/decline/${token}`)
1722
- .then((r) => r.data);
1723
- const claimNewUser = (endpoint, organizationId, email, token) => endpoint.api //
1724
- .put(`/organizations/${organizationId}/invitation/${email}/token/${token}/new_user`)
1702
+ const declineOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1703
+ .post('/v2/organization-invitations/decline', { email, token })
1725
1704
  .then((r) => r.data);
1726
1705
 
1727
1706
  /**
@@ -1729,20 +1708,14 @@ const claimNewUser = (endpoint, organizationId, email, token) => endpoint.api //
1729
1708
  *
1730
1709
  * @module
1731
1710
  */
1732
- const getOrganizationMembers = (endpoint, organizationId) => endpoint.api //
1733
- .get(`/organizations/${organizationId}/profiles`)
1734
- .then((r) => r.data);
1735
- const deleteOrganizationMember = (endpoint, organizationId, profileId) => endpoint.api //
1736
- .delete(`/organizations/${organizationId}/profiles/${profileId}`)
1711
+ const getOrganizationMembers = (endpoint) => endpoint.api //
1712
+ .get(`/v2/organization-members`)
1737
1713
  .then((r) => r.data);
1738
- const addOrganizationMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1739
- .post(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1714
+ const deleteOrganizationMember = (endpoint, profileId) => endpoint.api //
1715
+ .delete(`/v2/organization-members/${profileId}`)
1740
1716
  .then((r) => r.data);
1741
- const deleteOrganizationMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1742
- .delete(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1743
- .then((r) => r.data);
1744
- const getOrganizationMemberPlans = (endpoint, organizationId, profileId) => endpoint.api //
1745
- .get(`/organizations/${organizationId}/profiles/${profileId}/plans`)
1717
+ const updateOrganizationMember = (endpoint, profileId, params) => endpoint.api //
1718
+ .patch(`/v2/organization-members/${profileId}`, params)
1746
1719
  .then((r) => r.data);
1747
1720
 
1748
1721
  /**
@@ -1751,41 +1724,53 @@ const getOrganizationMemberPlans = (endpoint, organizationId, profileId) => endp
1751
1724
  * @module
1752
1725
  */
1753
1726
  /**
1754
- * Get a list of organizations the user has access to.
1727
+ * Get a list of organizations the caller is a member of.
1755
1728
  */
1756
1729
  const getOrganizations = (endpoint) => endpoint.api //
1757
- .get('/organizations')
1730
+ .get('/v2/organizations')
1731
+ .then((r) => r.data);
1732
+ /**
1733
+ * Get an organization by ID.
1734
+ */
1735
+ const getOrganization = (endpoint, organizationId) => endpoint.api //
1736
+ .get(`/v2/organizations/${organizationId}`)
1758
1737
  .then((r) => r.data);
1759
1738
  /**
1760
1739
  * Create an organization.
1761
1740
  */
1762
1741
  const createOrganization = (endpoint) => endpoint.api //
1763
- .post('/organizations')
1742
+ .post('/v2/organizations')
1764
1743
  .then((r) => r.data);
1765
1744
  /**
1766
1745
  * Delete an organization.
1767
1746
  */
1768
1747
  const deleteOrganization = (endpoint, organizationId) => endpoint.api //
1769
- .delete(`/organizations/${organizationId}`)
1770
- .then((r) => r.data);
1771
- /**
1772
- * Get an organization by ID.
1773
- */
1774
- const getOrganization = (endpoint, organizationId) => endpoint.api //
1775
- .get(`/organizations/${organizationId}`)
1748
+ .delete(`/v2/organizations/${organizationId}`)
1776
1749
  .then((r) => r.data);
1777
1750
  /**
1778
1751
  * Update an organization.
1779
1752
  */
1780
1753
  const updateOrganization = (endpoint, organizationId, params) => endpoint.api //
1781
- .patch(`/organizations/${organizationId}`, params)
1754
+ .patch(`/v2/organizations/${organizationId}`, params)
1782
1755
  .then((r) => r.data);
1783
1756
 
1757
+ /**
1758
+ * Webhooks are callback triggers from Verdocs to your servers that notify your applications
1759
+ * of various events, such as signing operations.
1760
+ *
1761
+ * @module
1762
+ */
1763
+ /**
1764
+ * Get the registered Webhooks for the caller's organization.
1765
+ */
1784
1766
  const getWebhooks = (endpoint) => endpoint.api //
1785
1767
  .get(`/v2/webhooks/organization`)
1786
1768
  .then((r) => r.data);
1769
+ /**
1770
+ * Update the registered Webhooks for the caller's organization.
1771
+ */
1787
1772
  const setWebhooks = (endpoint, params) => endpoint.api //
1788
- .post(`/v2/webhooks/organization`, params)
1773
+ .patch(`/v2/webhooks/organization`, params)
1789
1774
  .then((r) => r.data);
1790
1775
 
1791
1776
  /**
@@ -1894,6 +1879,104 @@ const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
1894
1879
  .delete(`/templates/${templateId}/fields/${fieldName}`)
1895
1880
  .then((r) => r.data);
1896
1881
 
1882
+ /**
1883
+ * Various helpers to identify available operations for a template by a user.
1884
+ *
1885
+ * @module
1886
+ */
1887
+ /**
1888
+ * Check to see if the user created the template.
1889
+ */
1890
+ const userIsTemplateCreator = (session, template) => session && template && session.profile_id === template.profile_id;
1891
+ /**
1892
+ * Check to see if a template is "shared" with the user.
1893
+ */
1894
+ const userHasSharedTemplate = (session, template) => session && template && !template.is_personal && session.organization_id === template.organization_id;
1895
+ /**
1896
+ * Check to see if the user can create a personal/private template.
1897
+ */
1898
+ const userCanCreatePersonalTemplate = (session) => userHasPermissions(session, ['template:creator:create:personal']);
1899
+ /**
1900
+ * Check to see if the user can create an org-shared template.
1901
+ */
1902
+ const userCanCreateOrgTemplate = (session) => userHasPermissions(session, ['template:creator:create:org']);
1903
+ /**
1904
+ * Check to see if the user can create a public template.
1905
+ */
1906
+ const userCanCreatePublicTemplate = (session) => userHasPermissions(session, ['template:creator:create:public']);
1907
+ /**
1908
+ * Check to see if the user can read/view a template.
1909
+ */
1910
+ const userCanReadTemplate = (session, template) => template.is_public ||
1911
+ userIsTemplateCreator(session, template) ||
1912
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read']));
1913
+ /**
1914
+ * Check to see if the user can update a tempate.
1915
+ */
1916
+ const userCanUpdateTemplate = (session, template) => userIsTemplateCreator(session, template) ||
1917
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read', 'template:member:write']));
1918
+ /**
1919
+ * Check to see if the user can change whether a template is personal vs org-shared.
1920
+ */
1921
+ const userCanMakeTemplatePrivate = (session, template) => userIsTemplateCreator(session, template)
1922
+ ? userHasPermissions(session, ['template:creator:create:personal'])
1923
+ : userHasPermissions(session, ['template:member:visibility']);
1924
+ /**
1925
+ * Check to see if the user can change whether a template is personal vs org-shared.
1926
+ */
1927
+ const userCanMakeTemplateShared = (session, template) => userIsTemplateCreator(session, template)
1928
+ ? userHasPermissions(session, ['template:creator:create:org'])
1929
+ : userHasPermissions(session, ['template:member:visibility']);
1930
+ /**
1931
+ * Check to see if the user can change whether a template is personal vs org-shared.
1932
+ */
1933
+ const userCanMakeTemplatePublic = (session, template) => userIsTemplateCreator(session, template)
1934
+ ? userHasPermissions(session, ['template:creator:create:public'])
1935
+ : userHasPermissions(session, ['template:member:visibility']);
1936
+ /**
1937
+ * Check to see if the user can change whether a template is personal vs org-shared.
1938
+ */
1939
+ const userCanChangeOrgVisibility = (session, template) => userIsTemplateCreator(session, template) && userHasPermissions(session, ['template:creator:create:personal']);
1940
+ /**
1941
+ * Check to see if the user can change whether a template is personal vs org-shared.
1942
+ */
1943
+ const userCanDeleteTemplate = (session, template) => userIsTemplateCreator(session, template)
1944
+ ? userHasPermissions(session, ['template:creator:delete'])
1945
+ : userHasPermissions(session, ['template:member:delete']);
1946
+ /**
1947
+ * Confirm whether the user can create an envelope using the specified template.
1948
+ */
1949
+ const userCanSendTemplate = (session, template) => {
1950
+ switch (template.sender) {
1951
+ case 'creator':
1952
+ return userIsTemplateCreator(session, template);
1953
+ case 'organization_member':
1954
+ case 'organization_member_as_creator':
1955
+ return userIsTemplateCreator(session, template) || template.organization_id === session?.organization_id;
1956
+ default:
1957
+ return true;
1958
+ }
1959
+ };
1960
+ /**
1961
+ * Confirm whether the user can create a new template.
1962
+ */
1963
+ const userCanCreateTemplate = (session) => userCanCreatePersonalTemplate(session) || userCanCreateOrgTemplate(session) || userCanCreatePublicTemplate(session);
1964
+ /**
1965
+ * Check to see if the user can "build" the template (use the field builder). The user must have write access to the
1966
+ * template, and the template must have at least one signer role.
1967
+ */
1968
+ const userCanBuildTemplate = (session, template) => userCanUpdateTemplate(session, template) && (template.roles || []).filter((role) => role.type === 'signer').length > 0;
1969
+ const getFieldsForRole = (template, role_name) => (template.fields || []).filter((field) => field.role_name === role_name);
1970
+ /**
1971
+ * Check to see if the user can preview the template. The user must have read access to the template, the template must
1972
+ * have at least one signer, and every signer must have at least one field.
1973
+ */
1974
+ const userCanPreviewTemplate = (session, template) => {
1975
+ const hasPermission = userCanReadTemplate(session, template);
1976
+ const signers = (template.roles || []).filter((role) => role.type === 'signer');
1977
+ return hasPermission && signers.length > 0 && signers.every((signer) => getFieldsForRole(template, signer.name).length > 0);
1978
+ };
1979
+
1897
1980
  /**
1898
1981
  * Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
1899
1982
  * should be sent. interval_time is the number of days between reminders.
@@ -2371,7 +2454,7 @@ const authenticateUser = (endpoint, params) => endpoint.api //
2371
2454
  * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2372
2455
  * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2373
2456
  * hours. This expiration may change based on future security needs. Application developers are encouraged
2374
- * to check the `exp` expiration field in the response accessToken and renew tokens after they expire.
2457
+ * to check the `exp` expiration field in the response, and renew tokens after they expire.
2375
2458
  *
2376
2459
  * ```typescript
2377
2460
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2384,23 +2467,6 @@ const authenticateUser = (endpoint, params) => endpoint.api //
2384
2467
  const authenticateApp = (endpoint, params) => endpoint.api //
2385
2468
  .post('/authentication/login_client', {}, { headers: params })
2386
2469
  .then((r) => r.data);
2387
- /**
2388
- * Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
2389
- * because tokens will be validated when API calls are made anyway. However, high-security applications
2390
- * may use this endpoint to check if a token has been revoked.
2391
- *
2392
- * ```typescript
2393
- * import {Auth} from '@verdocs/js-sdk/Auth';
2394
- *
2395
- * const {valid} = await Auth.validateToken({ token });
2396
- * if (!valid) {
2397
- * window.alert('Session invalid or expired. Please re-authenticate.');
2398
- * }
2399
- * ```
2400
- */
2401
- const validateToken = (endpoint, params) => endpoint.api //
2402
- .post('/token/isValid', params)
2403
- .then((r) => r.data);
2404
2470
  /**
2405
2471
  * If called before the session expires, this will refresh the caller's session and tokens.
2406
2472
  *
@@ -2416,7 +2482,7 @@ const refreshTokens = (endpoint) => endpoint.api //
2416
2482
  .get('/token')
2417
2483
  .then((r) => r.data);
2418
2484
  /**
2419
- * Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
2485
+ * Update the caller's password when the old password is known (typically for logged-in users).
2420
2486
  *
2421
2487
  * ```typescript
2422
2488
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2427,11 +2493,11 @@ const refreshTokens = (endpoint) => endpoint.api //
2427
2493
  * }
2428
2494
  * ```
2429
2495
  */
2430
- const updatePassword = (endpoint, params) => endpoint.api //
2496
+ const changePassword = (endpoint, params) => endpoint.api //
2431
2497
  .put('/user/update_password', params)
2432
2498
  .then((r) => r.data);
2433
2499
  /**
2434
- * Reset the caller's password.
2500
+ * Request a password reset, when the old password is not known (typically in login forms).
2435
2501
  *
2436
2502
  * ```typescript
2437
2503
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2445,18 +2511,6 @@ const updatePassword = (endpoint, params) => endpoint.api //
2445
2511
  const resetPassword = (endpoint, params) => endpoint.api //
2446
2512
  .post('/user/reset_password', params)
2447
2513
  .then((r) => r.data);
2448
- /**
2449
- * Update the caller's email address.
2450
- *
2451
- * ```typescript
2452
- * import {Auth} from '@verdocs/js-sdk/Auth';
2453
- *
2454
- * const {profiles} = await Auth.updateEmail({ email: newEmail });
2455
- * ```
2456
- */
2457
- const updateEmail = (endpoint, params) => endpoint.api //
2458
- .put('/user/update_email', params)
2459
- .then((r) => r.data);
2460
2514
  /**
2461
2515
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
2462
2516
  * a parameter here. Instead, the caller must be authenticated as the (unverified) user. To simplify this process,
@@ -2473,15 +2527,9 @@ const updateEmail = (endpoint, params) => endpoint.api //
2473
2527
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2474
2528
  .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2475
2529
  .then((r) => r.data);
2476
- const createUser = (endpoint, params) => endpoint.api //
2477
- .post('/user', params)
2478
- .then((r) => r.data);
2479
-
2480
- // TODO
2481
- const billingPlaceholder = {};
2482
2530
 
2483
2531
  const getNotifications = async (endpoint) => endpoint.api //
2484
- .get('/notifications')
2532
+ .get('/v2/notifications')
2485
2533
  .then((r) => r.data);
2486
2534
 
2487
2535
  /**
@@ -2494,7 +2542,7 @@ const getNotifications = async (endpoint) => endpoint.api //
2494
2542
  * ```
2495
2543
  */
2496
2544
  const getProfiles = (endpoint) => endpoint.api //
2497
- .get('/profiles')
2545
+ .get('/v2/profiles')
2498
2546
  .then((r) => r.data);
2499
2547
  /**
2500
2548
  * Get the user's available profiles. The current profile will be marked with `current: true`.
@@ -2506,20 +2554,8 @@ const getProfiles = (endpoint) => endpoint.api //
2506
2554
  * ```
2507
2555
  */
2508
2556
  const getCurrentProfile = (endpoint) => endpoint.api //
2509
- .get('/profiles')
2557
+ .get('/v2/profiles')
2510
2558
  .then((r) => (r.data || []).find((profile) => profile.current));
2511
- /**
2512
- * Get a list of system roles.
2513
- *
2514
- * ```typescript
2515
- * import {Profiles} from '@verdocs/js-sdk/Users';
2516
- *
2517
- * const roles = await Profiles.getRoles();
2518
- * ```
2519
- */
2520
- const getRoles = (endpoint) => endpoint.api //
2521
- .get('/roles')
2522
- .then((r) => r.data);
2523
2559
  /**
2524
2560
  * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
2525
2561
  *
@@ -2530,7 +2566,7 @@ const getRoles = (endpoint) => endpoint.api //
2530
2566
  * ```
2531
2567
  */
2532
2568
  const createProfile = (endpoint, params) => endpoint.api //
2533
- .post('/profiles', params)
2569
+ .post('/v2/profiles', params)
2534
2570
  .then((r) => r.data);
2535
2571
  /**
2536
2572
  * Get a profile. The caller must have admin access to the given profile.
@@ -2543,19 +2579,7 @@ const createProfile = (endpoint, params) => endpoint.api //
2543
2579
  * ```
2544
2580
  */
2545
2581
  const getProfile = (endpoint, profileId) => endpoint.api //
2546
- .get(`/profiles/${profileId}`)
2547
- .then((r) => r.data);
2548
- /**
2549
- * Get a profile's groups.
2550
- *
2551
- * ```typescript
2552
- * import {Profiles} from '@verdocs/js-sdk/Users';
2553
- *
2554
- * const groups = await Profiles.getProfileGroups('PROFILEID');
2555
- * ```
2556
- */
2557
- const getProfileGroups = (endpoint, profileId) => endpoint.api //
2558
- .get(`/profiles/${profileId}/groups`)
2582
+ .get(`/v2/profiles/${profileId}`)
2559
2583
  .then((r) => r.data);
2560
2584
  /**
2561
2585
  * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
@@ -2568,7 +2592,7 @@ const getProfileGroups = (endpoint, profileId) => endpoint.api //
2568
2592
  * ```
2569
2593
  */
2570
2594
  const switchProfile = (endpoint, profileId) => endpoint.api //
2571
- .post(`/profiles/${profileId}/switch`)
2595
+ .post(`/v2/profiles/${profileId}/switch`)
2572
2596
  .then((r) => r.data);
2573
2597
  /**
2574
2598
  * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
@@ -2581,11 +2605,8 @@ const switchProfile = (endpoint, profileId) => endpoint.api //
2581
2605
  * ```
2582
2606
  */
2583
2607
  const updateProfile = (endpoint, profileId, params) => endpoint.api //
2584
- .put(`/profiles/${profileId}`, params, { baseURL: endpoint.getBaseURLv2() })
2608
+ .patch(`/v2/profiles/${profileId}`, params)
2585
2609
  .then((r) => r.data);
2586
- // endpoint.api //
2587
- // .post<IEnvelopeSummaries>('/envelopes/list', params, {baseURL: endpoint.getBaseURLv2()})
2588
- // .then((r) => r.data);
2589
2610
  /**
2590
2611
  * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
2591
2612
  *
@@ -2596,7 +2617,7 @@ const updateProfile = (endpoint, profileId, params) => endpoint.api //
2596
2617
  * ```
2597
2618
  */
2598
2619
  const deleteProfile = (endpoint, profileId) => endpoint.api //
2599
- .delete(`/profiles/${profileId}`)
2620
+ .delete(`/v2/profiles/${profileId}`)
2600
2621
  .then((r) => r.data);
2601
2622
  /**
2602
2623
  * Create a user account and parent organization. This endpoint is for creating a new organization. Users joining an
@@ -2610,12 +2631,12 @@ const deleteProfile = (endpoint, profileId) => endpoint.api //
2610
2631
  * });
2611
2632
  * ```
2612
2633
  */
2613
- const createBusinessAccount = (endpoint, params) => endpoint.api //
2634
+ const createAccount = (endpoint, params) => endpoint.api //
2614
2635
  .post('/user/business', params)
2615
2636
  .then((r) => r.data);
2616
2637
  const recordSignupSurvey = (endpoint, params) => endpoint.api //
2617
2638
  .post('/user/signup', params)
2618
2639
  .then((r) => r.data);
2619
2640
 
2620
- export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMembers, addGroupPermission, addOrganizationMemberRole, addTemplateTag, authenticateApp, authenticateUser, billingPlaceholder, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, claimNewUser, convertToE164, createApiKey, createBusinessAccount, createEnvelope, createEnvelopeReminder, createField, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, createUser, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMembers, deleteGroupPermission, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteOrganizationMemberRole, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getGroup, getGroupByName, getGroupMembers, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMemberPlans, getOrganizationMembers, getOrganizations, getPlusOneCountry, getProfile, getProfileGroups, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getRoles, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEmail, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateOrganization, updateOrganizationInvitation, updatePassword, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanCancelEnvelope, userCanFinishEnvelope, userCanSignNow, userHasPermissions, userIsEnvelopeOwner, userIsEnvelopeRecipient, validateToken };
2641
+ export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticateApp, authenticateUser, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createAccount, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, getPlusOneCountry, getProfile, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationMember, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanBuildTemplate, userCanCancelEnvelope, userCanChangeOrgVisibility, userCanCreateOrgTemplate, userCanCreatePersonalTemplate, userCanCreatePublicTemplate, userCanCreateTemplate, userCanDeleteTemplate, userCanFinishEnvelope, userCanMakeTemplatePrivate, userCanMakeTemplatePublic, userCanMakeTemplateShared, userCanPreviewTemplate, userCanReadTemplate, userCanSendTemplate, userCanSignNow, userCanUpdateTemplate, userHasPermissions, userHasSharedTemplate, userIsEnvelopeOwner, userIsEnvelopeRecipient, userIsTemplateCreator };
2621
2642
  //# sourceMappingURL=index.mjs.map