@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.js CHANGED
@@ -1575,61 +1575,61 @@ const deleteSignature = (endpoint, signatureId) => endpoint.api //
1575
1575
  * Get a list of keys for a given organization. The caller must have admin access to the organization.
1576
1576
  *
1577
1577
  * ```typescript
1578
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1578
+ * import {ApiKeys} from '@verdocs/js-sdk';
1579
1579
  *
1580
1580
  * const keys = await ApiKeys.getKeys(ORGID);
1581
1581
  * ```
1582
1582
  */
1583
- const getApiKeys = (endpoint, organizationId) => endpoint.api //
1584
- .get(`/organizations/${organizationId}/api_key`)
1583
+ const getApiKeys = (endpoint) => endpoint.api //
1584
+ .get(`/v2/api-keys`)
1585
1585
  .then((r) => r.data);
1586
1586
  /**
1587
1587
  * Create an API key.
1588
1588
  *
1589
1589
  * ```typescript
1590
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1590
+ * import {ApiKeys} from '@verdocs/js-sdk';
1591
1591
  *
1592
1592
  * await ApiKeys.createKey(ORGID, {name: NEWNAME});
1593
1593
  * ```
1594
1594
  */
1595
- const createApiKey = (endpoint, organizationId, params) => endpoint.api //
1596
- .post(`/organizations/${organizationId}/api_key`, params)
1595
+ const createApiKey = (endpoint, params) => endpoint.api //
1596
+ .post('/v2/api-keys', params)
1597
1597
  .then((r) => r.data);
1598
1598
  /**
1599
1599
  * Rotate the secret for an API key. The caller must have admin access to the organization.
1600
1600
  *
1601
1601
  * ```typescript
1602
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1602
+ * import {ApiKeys} from '@verdocs/js-sdk';
1603
1603
  *
1604
1604
  * const {client_secret: newSecret} = await ApiKeys.rotateKey(ORGID, CLIENTID);
1605
1605
  * ```
1606
1606
  */
1607
- const rotateApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1608
- .put(`/organizations/${organizationId}/api_key/${clientId}/rotate`)
1607
+ const rotateApiKey = (endpoint, clientId) => endpoint.api //
1608
+ .post(`/v2/api-keys/${clientId}/rotate`)
1609
1609
  .then((r) => r.data);
1610
1610
  /**
1611
1611
  * Update an API key to change its assigned Profile ID or Name.
1612
1612
  *
1613
1613
  * ```typescript
1614
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1614
+ * import {ApiKeys} from '@verdocs/js-sdk';
1615
1615
  *
1616
1616
  * await ApiKeys.updateKey(ORGID, CLIENTID, {name: NEWNAME});
1617
1617
  * ```
1618
1618
  */
1619
- const updateApiKey = (endpoint, organizationId, clientId, params) => endpoint.api //
1620
- .patch(`/organizations/${organizationId}/api_key/${clientId}`, params)
1619
+ const updateApiKey = (endpoint, clientId, params) => endpoint.api //
1620
+ .patch(`/v2/api-keys/${clientId}`, params)
1621
1621
  .then((r) => r.data);
1622
1622
  /**
1623
1623
  * Delete an API key.
1624
1624
  *
1625
1625
  * ```typescript
1626
- * import {ApiKeys} from '@verdocs/js-sdk/Organizations';
1626
+ * import {ApiKeys} from '@verdocs/js-sdk';
1627
1627
  *
1628
1628
  * await ApiKeys.deleteKey(ORGID, CLIENTID);
1629
1629
  * ```
1630
1630
  */
1631
- const deleteApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1632
- .delete(`/organizations/${organizationId}/api_key/${clientId}`)
1631
+ const deleteApiKey = (endpoint, clientId) => endpoint.api //
1632
+ .delete(`/v2/api-keys/${clientId}`)
1633
1633
  .then((r) => r.data);
1634
1634
 
1635
1635
  /**
@@ -1645,52 +1645,37 @@ const deleteApiKey = (endpoint, organizationId, clientId) => endpoint.api //
1645
1645
  * Get a list of groups for a given organization. The caller must have admin access to the organization.
1646
1646
  *
1647
1647
  * ```typescript
1648
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1648
+ * import {getGroups} from '@verdocs/js-sdk';
1649
1649
  *
1650
- * const groups = await Groups.getGroups(ORGID);
1650
+ * const groups = await getGroups(ORGID);
1651
1651
  * ```
1652
1652
  */
1653
- const getGroups = (endpoint, organizationId) => endpoint.api //
1654
- .get(`/organizations/${organizationId}/groups`)
1653
+ const getGroups = (endpoint) => endpoint.api //
1654
+ .get(`/v2/organization-groups`)
1655
1655
  .then((r) => r.data);
1656
1656
  /**
1657
- * Get a single group by name. Returns a detail record.
1657
+ * Get the details for a group, including its member profiles and list of permissions.
1658
1658
  *
1659
1659
  * ```typescript
1660
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1660
+ * import {getGroup} from '@verdocs/js-sdk/v2/organization-groups';
1661
1661
  *
1662
- * const groups = await Groups.getGroups(ORGID);
1662
+ * const groups = await getGroup(GROUPID);
1663
1663
  * ```
1664
1664
  */
1665
- const getGroupByName = (endpoint, organizationId, name) => endpoint.api //
1666
- .get(`/organizations/${organizationId}/groups`, { params: { name } })
1665
+ const getGroup = (endpoint, groupId) => endpoint.api //
1666
+ .get(`/v2/organization-groups/${groupId}`)
1667
1667
  .then((r) => r.data);
1668
- /**
1669
- * Get the details for a group.
1670
- *
1671
- * ```typescript
1672
- * import {Groups} from '@verdocs/js-sdk/Organizations';
1673
- *
1674
- * const groups = await Groups.getGroups(ORGID);
1675
- * ```
1676
- */
1677
- const getGroup = (endpoint, organizationId, groupId) => endpoint.api //
1678
- .get(`/organizations/${organizationId}/groups/${groupId}`)
1679
- .then((r) => r.data);
1680
- const getGroupMembers = (endpoint, organizationId, groupId) => endpoint.api //
1681
- .get(`/organizations/${organizationId}/groups/${groupId}/members`)
1668
+ const createGroup = (endpoint, name) => endpoint.api //
1669
+ .post('/v2/organization-groups', { name })
1682
1670
  .then((r) => r.data);
1683
- const addGroupMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1684
- .post(`/organizations/${organizationId}/groups/${groupId}/members`, params)
1671
+ const addGroupMember = (endpoint, groupId, profile_id) => endpoint.api //
1672
+ .post(`/v2/organization-groups/${groupId}/members`, { profile_id })
1685
1673
  .then((r) => r.data);
1686
- const deleteGroupMembers = (endpoint, organizationId, groupId, params) => endpoint.api //
1687
- .put(`/organizations/${organizationId}/groups/${groupId}/delete_members`, params)
1674
+ const deleteGroupMember = (endpoint, groupId, profile_id) => endpoint.api //
1675
+ .delete(`/v2/organization-groups/${groupId}/members/${profile_id}`)
1688
1676
  .then((r) => r.data);
1689
- const addGroupPermission = (endpoint, organizationId, groupId, permission) => endpoint.api //
1690
- .post(`/organizations/${organizationId}/groups/${groupId}/permissions/${permission}`, {})
1691
- .then((r) => r.data);
1692
- const deleteGroupPermission = (endpoint, organizationId, groupId, permission) => endpoint.api //
1693
- .delete(`/organizations/${organizationId}/groups/${groupId}/permissions/${permission}`)
1677
+ const updateGroup = (endpoint, groupId, params) => endpoint.api //
1678
+ .patch(`/v2/organization-groups/${groupId}`, params)
1694
1679
  .then((r) => r.data);
1695
1680
 
1696
1681
  /**
@@ -1698,32 +1683,26 @@ const deleteGroupPermission = (endpoint, organizationId, groupId, permission) =>
1698
1683
  *
1699
1684
  * @module
1700
1685
  */
1701
- const getOrganizationInvitations = (endpoint, organizationId) => endpoint.api //
1702
- .get(`/organizations/${organizationId}/invitation`)
1703
- .then((r) => r.data);
1704
- const createOrganizationInvitation = (endpoint, organizationId, params) => endpoint.api //
1705
- .post(`/organizations/${organizationId}/invitation`, params)
1686
+ const getOrganizationInvitations = (endpoint) => endpoint.api //
1687
+ .get(`/v2/organization-invitations`)
1706
1688
  .then((r) => r.data);
1707
- const deleteOrganizationInvitation = (endpoint, organizationId, email) => endpoint.api //
1708
- .delete(`/organizations/${organizationId}/invitation/${email}`)
1689
+ const createOrganizationInvitation = (endpoint, params) => endpoint.api //
1690
+ .post(`/v2/organization-invitations`, params)
1709
1691
  .then((r) => r.data);
1710
- const updateOrganizationInvitation = (endpoint, organizationId, email, params) => endpoint.api //
1711
- .patch(`/organizations/${organizationId}/invitation/${email}`, params)
1692
+ const deleteOrganizationInvitation = (endpoint, email) => endpoint.api //
1693
+ .delete(`/v2/organization-invitations/${email}`)
1712
1694
  .then((r) => r.data);
1713
- const resendOrganizationInvitation = (endpoint, organizationId, email) => endpoint.api //
1714
- .post(`/organizations/${organizationId}/invitation/${email}/resend`)
1695
+ const updateOrganizationInvitation = (endpoint, email, params) => endpoint.api //
1696
+ .patch(`/v2/organization-invitations/${email}`, params)
1715
1697
  .then((r) => r.data);
1716
- const getOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1717
- .get(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1698
+ const resendOrganizationInvitation = (endpoint, email) => endpoint.api //
1699
+ .post('/v2/organization-invitations/resend', { email })
1718
1700
  .then((r) => r.data);
1719
- const acceptOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1720
- .post(`/organizations/${organizationId}/invitation/${email}/accept/${token}`)
1701
+ const acceptOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1702
+ .post('/v2/organization-invitations/accept', { email, token })
1721
1703
  .then((r) => r.data);
1722
- const declineOrganizationInvitation = (endpoint, organizationId, email, token) => endpoint.api //
1723
- .post(`/organizations/${organizationId}/invitation/${email}/decline/${token}`)
1724
- .then((r) => r.data);
1725
- const claimNewUser = (endpoint, organizationId, email, token) => endpoint.api //
1726
- .put(`/organizations/${organizationId}/invitation/${email}/token/${token}/new_user`)
1704
+ const declineOrganizationInvitation = (endpoint, email, token) => endpoint.api //
1705
+ .post('/v2/organization-invitations/decline', { email, token })
1727
1706
  .then((r) => r.data);
1728
1707
 
1729
1708
  /**
@@ -1731,20 +1710,14 @@ const claimNewUser = (endpoint, organizationId, email, token) => endpoint.api //
1731
1710
  *
1732
1711
  * @module
1733
1712
  */
1734
- const getOrganizationMembers = (endpoint, organizationId) => endpoint.api //
1735
- .get(`/organizations/${organizationId}/profiles`)
1736
- .then((r) => r.data);
1737
- const deleteOrganizationMember = (endpoint, organizationId, profileId) => endpoint.api //
1738
- .delete(`/organizations/${organizationId}/profiles/${profileId}`)
1713
+ const getOrganizationMembers = (endpoint) => endpoint.api //
1714
+ .get(`/v2/organization-members`)
1739
1715
  .then((r) => r.data);
1740
- const addOrganizationMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1741
- .post(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1716
+ const deleteOrganizationMember = (endpoint, profileId) => endpoint.api //
1717
+ .delete(`/v2/organization-members/${profileId}`)
1742
1718
  .then((r) => r.data);
1743
- const deleteOrganizationMemberRole = (endpoint, organizationId, profileId, roleId) => endpoint.api //
1744
- .delete(`/organizations/${organizationId}/profiles/${profileId}/role/${roleId}`)
1745
- .then((r) => r.data);
1746
- const getOrganizationMemberPlans = (endpoint, organizationId, profileId) => endpoint.api //
1747
- .get(`/organizations/${organizationId}/profiles/${profileId}/plans`)
1719
+ const updateOrganizationMember = (endpoint, profileId, params) => endpoint.api //
1720
+ .patch(`/v2/organization-members/${profileId}`, params)
1748
1721
  .then((r) => r.data);
1749
1722
 
1750
1723
  /**
@@ -1753,41 +1726,53 @@ const getOrganizationMemberPlans = (endpoint, organizationId, profileId) => endp
1753
1726
  * @module
1754
1727
  */
1755
1728
  /**
1756
- * Get a list of organizations the user has access to.
1729
+ * Get a list of organizations the caller is a member of.
1757
1730
  */
1758
1731
  const getOrganizations = (endpoint) => endpoint.api //
1759
- .get('/organizations')
1732
+ .get('/v2/organizations')
1733
+ .then((r) => r.data);
1734
+ /**
1735
+ * Get an organization by ID.
1736
+ */
1737
+ const getOrganization = (endpoint, organizationId) => endpoint.api //
1738
+ .get(`/v2/organizations/${organizationId}`)
1760
1739
  .then((r) => r.data);
1761
1740
  /**
1762
1741
  * Create an organization.
1763
1742
  */
1764
1743
  const createOrganization = (endpoint) => endpoint.api //
1765
- .post('/organizations')
1744
+ .post('/v2/organizations')
1766
1745
  .then((r) => r.data);
1767
1746
  /**
1768
1747
  * Delete an organization.
1769
1748
  */
1770
1749
  const deleteOrganization = (endpoint, organizationId) => endpoint.api //
1771
- .delete(`/organizations/${organizationId}`)
1772
- .then((r) => r.data);
1773
- /**
1774
- * Get an organization by ID.
1775
- */
1776
- const getOrganization = (endpoint, organizationId) => endpoint.api //
1777
- .get(`/organizations/${organizationId}`)
1750
+ .delete(`/v2/organizations/${organizationId}`)
1778
1751
  .then((r) => r.data);
1779
1752
  /**
1780
1753
  * Update an organization.
1781
1754
  */
1782
1755
  const updateOrganization = (endpoint, organizationId, params) => endpoint.api //
1783
- .patch(`/organizations/${organizationId}`, params)
1756
+ .patch(`/v2/organizations/${organizationId}`, params)
1784
1757
  .then((r) => r.data);
1785
1758
 
1759
+ /**
1760
+ * Webhooks are callback triggers from Verdocs to your servers that notify your applications
1761
+ * of various events, such as signing operations.
1762
+ *
1763
+ * @module
1764
+ */
1765
+ /**
1766
+ * Get the registered Webhooks for the caller's organization.
1767
+ */
1786
1768
  const getWebhooks = (endpoint) => endpoint.api //
1787
1769
  .get(`/v2/webhooks/organization`)
1788
1770
  .then((r) => r.data);
1771
+ /**
1772
+ * Update the registered Webhooks for the caller's organization.
1773
+ */
1789
1774
  const setWebhooks = (endpoint, params) => endpoint.api //
1790
- .post(`/v2/webhooks/organization`, params)
1775
+ .patch(`/v2/webhooks/organization`, params)
1791
1776
  .then((r) => r.data);
1792
1777
 
1793
1778
  /**
@@ -1896,6 +1881,104 @@ const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
1896
1881
  .delete(`/templates/${templateId}/fields/${fieldName}`)
1897
1882
  .then((r) => r.data);
1898
1883
 
1884
+ /**
1885
+ * Various helpers to identify available operations for a template by a user.
1886
+ *
1887
+ * @module
1888
+ */
1889
+ /**
1890
+ * Check to see if the user created the template.
1891
+ */
1892
+ const userIsTemplateCreator = (session, template) => session && template && session.profile_id === template.profile_id;
1893
+ /**
1894
+ * Check to see if a template is "shared" with the user.
1895
+ */
1896
+ const userHasSharedTemplate = (session, template) => session && template && !template.is_personal && session.organization_id === template.organization_id;
1897
+ /**
1898
+ * Check to see if the user can create a personal/private template.
1899
+ */
1900
+ const userCanCreatePersonalTemplate = (session) => userHasPermissions(session, ['template:creator:create:personal']);
1901
+ /**
1902
+ * Check to see if the user can create an org-shared template.
1903
+ */
1904
+ const userCanCreateOrgTemplate = (session) => userHasPermissions(session, ['template:creator:create:org']);
1905
+ /**
1906
+ * Check to see if the user can create a public template.
1907
+ */
1908
+ const userCanCreatePublicTemplate = (session) => userHasPermissions(session, ['template:creator:create:public']);
1909
+ /**
1910
+ * Check to see if the user can read/view a template.
1911
+ */
1912
+ const userCanReadTemplate = (session, template) => template.is_public ||
1913
+ userIsTemplateCreator(session, template) ||
1914
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read']));
1915
+ /**
1916
+ * Check to see if the user can update a tempate.
1917
+ */
1918
+ const userCanUpdateTemplate = (session, template) => userIsTemplateCreator(session, template) ||
1919
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read', 'template:member:write']));
1920
+ /**
1921
+ * Check to see if the user can change whether a template is personal vs org-shared.
1922
+ */
1923
+ const userCanMakeTemplatePrivate = (session, template) => userIsTemplateCreator(session, template)
1924
+ ? userHasPermissions(session, ['template:creator:create:personal'])
1925
+ : userHasPermissions(session, ['template:member:visibility']);
1926
+ /**
1927
+ * Check to see if the user can change whether a template is personal vs org-shared.
1928
+ */
1929
+ const userCanMakeTemplateShared = (session, template) => userIsTemplateCreator(session, template)
1930
+ ? userHasPermissions(session, ['template:creator:create:org'])
1931
+ : userHasPermissions(session, ['template:member:visibility']);
1932
+ /**
1933
+ * Check to see if the user can change whether a template is personal vs org-shared.
1934
+ */
1935
+ const userCanMakeTemplatePublic = (session, template) => userIsTemplateCreator(session, template)
1936
+ ? userHasPermissions(session, ['template:creator:create:public'])
1937
+ : userHasPermissions(session, ['template:member:visibility']);
1938
+ /**
1939
+ * Check to see if the user can change whether a template is personal vs org-shared.
1940
+ */
1941
+ const userCanChangeOrgVisibility = (session, template) => userIsTemplateCreator(session, template) && userHasPermissions(session, ['template:creator:create:personal']);
1942
+ /**
1943
+ * Check to see if the user can change whether a template is personal vs org-shared.
1944
+ */
1945
+ const userCanDeleteTemplate = (session, template) => userIsTemplateCreator(session, template)
1946
+ ? userHasPermissions(session, ['template:creator:delete'])
1947
+ : userHasPermissions(session, ['template:member:delete']);
1948
+ /**
1949
+ * Confirm whether the user can create an envelope using the specified template.
1950
+ */
1951
+ const userCanSendTemplate = (session, template) => {
1952
+ switch (template.sender) {
1953
+ case 'creator':
1954
+ return userIsTemplateCreator(session, template);
1955
+ case 'organization_member':
1956
+ case 'organization_member_as_creator':
1957
+ return userIsTemplateCreator(session, template) || template.organization_id === session?.organization_id;
1958
+ default:
1959
+ return true;
1960
+ }
1961
+ };
1962
+ /**
1963
+ * Confirm whether the user can create a new template.
1964
+ */
1965
+ const userCanCreateTemplate = (session) => userCanCreatePersonalTemplate(session) || userCanCreateOrgTemplate(session) || userCanCreatePublicTemplate(session);
1966
+ /**
1967
+ * Check to see if the user can "build" the template (use the field builder). The user must have write access to the
1968
+ * template, and the template must have at least one signer role.
1969
+ */
1970
+ const userCanBuildTemplate = (session, template) => userCanUpdateTemplate(session, template) && (template.roles || []).filter((role) => role.type === 'signer').length > 0;
1971
+ const getFieldsForRole = (template, role_name) => (template.fields || []).filter((field) => field.role_name === role_name);
1972
+ /**
1973
+ * Check to see if the user can preview the template. The user must have read access to the template, the template must
1974
+ * have at least one signer, and every signer must have at least one field.
1975
+ */
1976
+ const userCanPreviewTemplate = (session, template) => {
1977
+ const hasPermission = userCanReadTemplate(session, template);
1978
+ const signers = (template.roles || []).filter((role) => role.type === 'signer');
1979
+ return hasPermission && signers.length > 0 && signers.every((signer) => getFieldsForRole(template, signer.name).length > 0);
1980
+ };
1981
+
1899
1982
  /**
1900
1983
  * Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
1901
1984
  * should be sent. interval_time is the number of days between reminders.
@@ -2373,7 +2456,7 @@ const authenticateUser = (endpoint, params) => endpoint.api //
2373
2456
  * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
2374
2457
  * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
2375
2458
  * hours. This expiration may change based on future security needs. Application developers are encouraged
2376
- * to check the `exp` expiration field in the response accessToken and renew tokens after they expire.
2459
+ * to check the `exp` expiration field in the response, and renew tokens after they expire.
2377
2460
  *
2378
2461
  * ```typescript
2379
2462
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2386,23 +2469,6 @@ const authenticateUser = (endpoint, params) => endpoint.api //
2386
2469
  const authenticateApp = (endpoint, params) => endpoint.api //
2387
2470
  .post('/authentication/login_client', {}, { headers: params })
2388
2471
  .then((r) => r.data);
2389
- /**
2390
- * Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
2391
- * because tokens will be validated when API calls are made anyway. However, high-security applications
2392
- * may use this endpoint to check if a token has been revoked.
2393
- *
2394
- * ```typescript
2395
- * import {Auth} from '@verdocs/js-sdk/Auth';
2396
- *
2397
- * const {valid} = await Auth.validateToken({ token });
2398
- * if (!valid) {
2399
- * window.alert('Session invalid or expired. Please re-authenticate.');
2400
- * }
2401
- * ```
2402
- */
2403
- const validateToken = (endpoint, params) => endpoint.api //
2404
- .post('/token/isValid', params)
2405
- .then((r) => r.data);
2406
2472
  /**
2407
2473
  * If called before the session expires, this will refresh the caller's session and tokens.
2408
2474
  *
@@ -2418,7 +2484,7 @@ const refreshTokens = (endpoint) => endpoint.api //
2418
2484
  .get('/token')
2419
2485
  .then((r) => r.data);
2420
2486
  /**
2421
- * Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
2487
+ * Update the caller's password when the old password is known (typically for logged-in users).
2422
2488
  *
2423
2489
  * ```typescript
2424
2490
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2429,11 +2495,11 @@ const refreshTokens = (endpoint) => endpoint.api //
2429
2495
  * }
2430
2496
  * ```
2431
2497
  */
2432
- const updatePassword = (endpoint, params) => endpoint.api //
2498
+ const changePassword = (endpoint, params) => endpoint.api //
2433
2499
  .put('/user/update_password', params)
2434
2500
  .then((r) => r.data);
2435
2501
  /**
2436
- * Reset the caller's password.
2502
+ * Request a password reset, when the old password is not known (typically in login forms).
2437
2503
  *
2438
2504
  * ```typescript
2439
2505
  * import {Auth} from '@verdocs/js-sdk/Auth';
@@ -2447,18 +2513,6 @@ const updatePassword = (endpoint, params) => endpoint.api //
2447
2513
  const resetPassword = (endpoint, params) => endpoint.api //
2448
2514
  .post('/user/reset_password', params)
2449
2515
  .then((r) => r.data);
2450
- /**
2451
- * Update the caller's email address.
2452
- *
2453
- * ```typescript
2454
- * import {Auth} from '@verdocs/js-sdk/Auth';
2455
- *
2456
- * const {profiles} = await Auth.updateEmail({ email: newEmail });
2457
- * ```
2458
- */
2459
- const updateEmail = (endpoint, params) => endpoint.api //
2460
- .put('/user/update_email', params)
2461
- .then((r) => r.data);
2462
2516
  /**
2463
2517
  * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
2464
2518
  * a parameter here. Instead, the caller must be authenticated as the (unverified) user. To simplify this process,
@@ -2475,15 +2529,9 @@ const updateEmail = (endpoint, params) => endpoint.api //
2475
2529
  const resendVerification = (endpoint, accessToken) => endpoint.api //
2476
2530
  .post('/user/email_verification', {}, accessToken ? { headers: { Authorization: `Bearer ${accessToken}` } } : {})
2477
2531
  .then((r) => r.data);
2478
- const createUser = (endpoint, params) => endpoint.api //
2479
- .post('/user', params)
2480
- .then((r) => r.data);
2481
-
2482
- // TODO
2483
- const billingPlaceholder = {};
2484
2532
 
2485
2533
  const getNotifications = async (endpoint) => endpoint.api //
2486
- .get('/notifications')
2534
+ .get('/v2/notifications')
2487
2535
  .then((r) => r.data);
2488
2536
 
2489
2537
  /**
@@ -2496,7 +2544,7 @@ const getNotifications = async (endpoint) => endpoint.api //
2496
2544
  * ```
2497
2545
  */
2498
2546
  const getProfiles = (endpoint) => endpoint.api //
2499
- .get('/profiles')
2547
+ .get('/v2/profiles')
2500
2548
  .then((r) => r.data);
2501
2549
  /**
2502
2550
  * Get the user's available profiles. The current profile will be marked with `current: true`.
@@ -2508,20 +2556,8 @@ const getProfiles = (endpoint) => endpoint.api //
2508
2556
  * ```
2509
2557
  */
2510
2558
  const getCurrentProfile = (endpoint) => endpoint.api //
2511
- .get('/profiles')
2559
+ .get('/v2/profiles')
2512
2560
  .then((r) => (r.data || []).find((profile) => profile.current));
2513
- /**
2514
- * Get a list of system roles.
2515
- *
2516
- * ```typescript
2517
- * import {Profiles} from '@verdocs/js-sdk/Users';
2518
- *
2519
- * const roles = await Profiles.getRoles();
2520
- * ```
2521
- */
2522
- const getRoles = (endpoint) => endpoint.api //
2523
- .get('/roles')
2524
- .then((r) => r.data);
2525
2561
  /**
2526
2562
  * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
2527
2563
  *
@@ -2532,7 +2568,7 @@ const getRoles = (endpoint) => endpoint.api //
2532
2568
  * ```
2533
2569
  */
2534
2570
  const createProfile = (endpoint, params) => endpoint.api //
2535
- .post('/profiles', params)
2571
+ .post('/v2/profiles', params)
2536
2572
  .then((r) => r.data);
2537
2573
  /**
2538
2574
  * Get a profile. The caller must have admin access to the given profile.
@@ -2545,19 +2581,7 @@ const createProfile = (endpoint, params) => endpoint.api //
2545
2581
  * ```
2546
2582
  */
2547
2583
  const getProfile = (endpoint, profileId) => endpoint.api //
2548
- .get(`/profiles/${profileId}`)
2549
- .then((r) => r.data);
2550
- /**
2551
- * Get a profile's groups.
2552
- *
2553
- * ```typescript
2554
- * import {Profiles} from '@verdocs/js-sdk/Users';
2555
- *
2556
- * const groups = await Profiles.getProfileGroups('PROFILEID');
2557
- * ```
2558
- */
2559
- const getProfileGroups = (endpoint, profileId) => endpoint.api //
2560
- .get(`/profiles/${profileId}/groups`)
2584
+ .get(`/v2/profiles/${profileId}`)
2561
2585
  .then((r) => r.data);
2562
2586
  /**
2563
2587
  * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
@@ -2570,7 +2594,7 @@ const getProfileGroups = (endpoint, profileId) => endpoint.api //
2570
2594
  * ```
2571
2595
  */
2572
2596
  const switchProfile = (endpoint, profileId) => endpoint.api //
2573
- .post(`/profiles/${profileId}/switch`)
2597
+ .post(`/v2/profiles/${profileId}/switch`)
2574
2598
  .then((r) => r.data);
2575
2599
  /**
2576
2600
  * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
@@ -2583,11 +2607,8 @@ const switchProfile = (endpoint, profileId) => endpoint.api //
2583
2607
  * ```
2584
2608
  */
2585
2609
  const updateProfile = (endpoint, profileId, params) => endpoint.api //
2586
- .put(`/profiles/${profileId}`, params, { baseURL: endpoint.getBaseURLv2() })
2610
+ .patch(`/v2/profiles/${profileId}`, params)
2587
2611
  .then((r) => r.data);
2588
- // endpoint.api //
2589
- // .post<IEnvelopeSummaries>('/envelopes/list', params, {baseURL: endpoint.getBaseURLv2()})
2590
- // .then((r) => r.data);
2591
2612
  /**
2592
2613
  * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
2593
2614
  *
@@ -2598,7 +2619,7 @@ const updateProfile = (endpoint, profileId, params) => endpoint.api //
2598
2619
  * ```
2599
2620
  */
2600
2621
  const deleteProfile = (endpoint, profileId) => endpoint.api //
2601
- .delete(`/profiles/${profileId}`)
2622
+ .delete(`/v2/profiles/${profileId}`)
2602
2623
  .then((r) => r.data);
2603
2624
  /**
2604
2625
  * Create a user account and parent organization. This endpoint is for creating a new organization. Users joining an
@@ -2612,7 +2633,7 @@ const deleteProfile = (endpoint, profileId) => endpoint.api //
2612
2633
  * });
2613
2634
  * ```
2614
2635
  */
2615
- const createBusinessAccount = (endpoint, params) => endpoint.api //
2636
+ const createAccount = (endpoint, params) => endpoint.api //
2616
2637
  .post('/user/business', params)
2617
2638
  .then((r) => r.data);
2618
2639
  const recordSignupSurvey = (endpoint, params) => endpoint.api //
@@ -2623,24 +2644,22 @@ exports.AtoB = AtoB;
2623
2644
  exports.Countries = Countries;
2624
2645
  exports.VerdocsEndpoint = VerdocsEndpoint;
2625
2646
  exports.acceptOrganizationInvitation = acceptOrganizationInvitation;
2626
- exports.addGroupMembers = addGroupMembers;
2627
- exports.addGroupPermission = addGroupPermission;
2628
- exports.addOrganizationMemberRole = addOrganizationMemberRole;
2647
+ exports.addGroupMember = addGroupMember;
2629
2648
  exports.addTemplateTag = addTemplateTag;
2630
2649
  exports.authenticateApp = authenticateApp;
2631
2650
  exports.authenticateUser = authenticateUser;
2632
- exports.billingPlaceholder = billingPlaceholder;
2633
2651
  exports.blobToBase64 = blobToBase64;
2634
2652
  exports.canPerformTemplateAction = canPerformTemplateAction;
2635
2653
  exports.cancelEnvelope = cancelEnvelope;
2636
2654
  exports.capitalize = capitalize;
2637
- exports.claimNewUser = claimNewUser;
2655
+ exports.changePassword = changePassword;
2638
2656
  exports.convertToE164 = convertToE164;
2657
+ exports.createAccount = createAccount;
2639
2658
  exports.createApiKey = createApiKey;
2640
- exports.createBusinessAccount = createBusinessAccount;
2641
2659
  exports.createEnvelope = createEnvelope;
2642
2660
  exports.createEnvelopeReminder = createEnvelopeReminder;
2643
2661
  exports.createField = createField;
2662
+ exports.createGroup = createGroup;
2644
2663
  exports.createInitials = createInitials;
2645
2664
  exports.createOrganization = createOrganization;
2646
2665
  exports.createOrganizationInvitation = createOrganizationInvitation;
@@ -2653,7 +2672,6 @@ exports.createTemplateFromSharepoint = createTemplateFromSharepoint;
2653
2672
  exports.createTemplateReminder = createTemplateReminder;
2654
2673
  exports.createTemplateRole = createTemplateRole;
2655
2674
  exports.createTemplatev2 = createTemplatev2;
2656
- exports.createUser = createUser;
2657
2675
  exports.declineOrganizationInvitation = declineOrganizationInvitation;
2658
2676
  exports.decodeAccessTokenBody = decodeAccessTokenBody;
2659
2677
  exports.decodeJWTBody = decodeJWTBody;
@@ -2661,12 +2679,10 @@ exports.deleteApiKey = deleteApiKey;
2661
2679
  exports.deleteEnvelopeFieldAttachment = deleteEnvelopeFieldAttachment;
2662
2680
  exports.deleteEnvelopeReminder = deleteEnvelopeReminder;
2663
2681
  exports.deleteField = deleteField;
2664
- exports.deleteGroupMembers = deleteGroupMembers;
2665
- exports.deleteGroupPermission = deleteGroupPermission;
2682
+ exports.deleteGroupMember = deleteGroupMember;
2666
2683
  exports.deleteOrganization = deleteOrganization;
2667
2684
  exports.deleteOrganizationInvitation = deleteOrganizationInvitation;
2668
2685
  exports.deleteOrganizationMember = deleteOrganizationMember;
2669
- exports.deleteOrganizationMemberRole = deleteOrganizationMemberRole;
2670
2686
  exports.deleteProfile = deleteProfile;
2671
2687
  exports.deleteSignature = deleteSignature;
2672
2688
  exports.deleteTemplate = deleteTemplate;
@@ -2703,23 +2719,19 @@ exports.getEnvelopeReminder = getEnvelopeReminder;
2703
2719
  exports.getEnvelopesByTemplateId = getEnvelopesByTemplateId;
2704
2720
  exports.getEnvelopesSummary = getEnvelopesSummary;
2705
2721
  exports.getFieldAttachment = getFieldAttachment;
2722
+ exports.getFieldsForRole = getFieldsForRole;
2706
2723
  exports.getGroup = getGroup;
2707
- exports.getGroupByName = getGroupByName;
2708
- exports.getGroupMembers = getGroupMembers;
2709
2724
  exports.getGroups = getGroups;
2710
2725
  exports.getInPersonLink = getInPersonLink;
2711
2726
  exports.getMatchingCountry = getMatchingCountry;
2712
2727
  exports.getNextRecipient = getNextRecipient;
2713
2728
  exports.getNotifications = getNotifications;
2714
2729
  exports.getOrganization = getOrganization;
2715
- exports.getOrganizationInvitation = getOrganizationInvitation;
2716
2730
  exports.getOrganizationInvitations = getOrganizationInvitations;
2717
- exports.getOrganizationMemberPlans = getOrganizationMemberPlans;
2718
2731
  exports.getOrganizationMembers = getOrganizationMembers;
2719
2732
  exports.getOrganizations = getOrganizations;
2720
2733
  exports.getPlusOneCountry = getPlusOneCountry;
2721
2734
  exports.getProfile = getProfile;
2722
- exports.getProfileGroups = getProfileGroups;
2723
2735
  exports.getProfiles = getProfiles;
2724
2736
  exports.getRGB = getRGB;
2725
2737
  exports.getRGBA = getRGBA;
@@ -2728,7 +2740,6 @@ exports.getRTop = getRTop;
2728
2740
  exports.getRValue = getRValue;
2729
2741
  exports.getRecipientsWithActions = getRecipientsWithActions;
2730
2742
  exports.getRoleColor = getRoleColor;
2731
- exports.getRoles = getRoles;
2732
2743
  exports.getSignature = getSignature;
2733
2744
  exports.getSignatures = getSignatures;
2734
2745
  exports.getSignerToken = getSignerToken;
@@ -2789,15 +2800,15 @@ exports.throttledGetTemplate = throttledGetTemplate;
2789
2800
  exports.timePeriod = timePeriod;
2790
2801
  exports.toggleStar = toggleStar;
2791
2802
  exports.updateApiKey = updateApiKey;
2792
- exports.updateEmail = updateEmail;
2793
2803
  exports.updateEnvelopeField = updateEnvelopeField;
2794
2804
  exports.updateEnvelopeFieldInitials = updateEnvelopeFieldInitials;
2795
2805
  exports.updateEnvelopeFieldSignature = updateEnvelopeFieldSignature;
2796
2806
  exports.updateEnvelopeReminder = updateEnvelopeReminder;
2797
2807
  exports.updateField = updateField;
2808
+ exports.updateGroup = updateGroup;
2798
2809
  exports.updateOrganization = updateOrganization;
2799
2810
  exports.updateOrganizationInvitation = updateOrganizationInvitation;
2800
- exports.updatePassword = updatePassword;
2811
+ exports.updateOrganizationMember = updateOrganizationMember;
2801
2812
  exports.updateProfile = updateProfile;
2802
2813
  exports.updateRecipient = updateRecipient;
2803
2814
  exports.updateTemplate = updateTemplate;
@@ -2805,11 +2816,26 @@ exports.updateTemplateReminder = updateTemplateReminder;
2805
2816
  exports.updateTemplateRole = updateTemplateRole;
2806
2817
  exports.uploadEnvelopeFieldAttachment = uploadEnvelopeFieldAttachment;
2807
2818
  exports.userCanAct = userCanAct;
2819
+ exports.userCanBuildTemplate = userCanBuildTemplate;
2808
2820
  exports.userCanCancelEnvelope = userCanCancelEnvelope;
2821
+ exports.userCanChangeOrgVisibility = userCanChangeOrgVisibility;
2822
+ exports.userCanCreateOrgTemplate = userCanCreateOrgTemplate;
2823
+ exports.userCanCreatePersonalTemplate = userCanCreatePersonalTemplate;
2824
+ exports.userCanCreatePublicTemplate = userCanCreatePublicTemplate;
2825
+ exports.userCanCreateTemplate = userCanCreateTemplate;
2826
+ exports.userCanDeleteTemplate = userCanDeleteTemplate;
2809
2827
  exports.userCanFinishEnvelope = userCanFinishEnvelope;
2828
+ exports.userCanMakeTemplatePrivate = userCanMakeTemplatePrivate;
2829
+ exports.userCanMakeTemplatePublic = userCanMakeTemplatePublic;
2830
+ exports.userCanMakeTemplateShared = userCanMakeTemplateShared;
2831
+ exports.userCanPreviewTemplate = userCanPreviewTemplate;
2832
+ exports.userCanReadTemplate = userCanReadTemplate;
2833
+ exports.userCanSendTemplate = userCanSendTemplate;
2810
2834
  exports.userCanSignNow = userCanSignNow;
2835
+ exports.userCanUpdateTemplate = userCanUpdateTemplate;
2811
2836
  exports.userHasPermissions = userHasPermissions;
2837
+ exports.userHasSharedTemplate = userHasSharedTemplate;
2812
2838
  exports.userIsEnvelopeOwner = userIsEnvelopeOwner;
2813
2839
  exports.userIsEnvelopeRecipient = userIsEnvelopeRecipient;
2814
- exports.validateToken = validateToken;
2840
+ exports.userIsTemplateCreator = userIsTemplateCreator;
2815
2841
  //# sourceMappingURL=index.js.map