@verdocs/js-sdk 4.1.5 → 4.1.7

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
@@ -1385,6 +1385,35 @@ const createInitials = (endpoint, name, initials) => {
1385
1385
  .then((r) => r.data);
1386
1386
  };
1387
1387
 
1388
+ /**
1389
+ * Get the current KBA status. Note that this may only be called by the recipient and requires a
1390
+ * valid signing session to proceed. Although the Recipient object itself contains indications of
1391
+ * whether KBA is required, it will not contain the current status of the process. If
1392
+ * `recipient.kba_method` is set (not null), and `recipient.kba_completed` is false, this endpoint
1393
+ * should be called to determine the next KBA step required.
1394
+ */
1395
+ const getKbaStatus = (endpoint, envelopeId, roleName) => endpoint.api //
1396
+ .get(`/v2/kba/${envelopeId}/${encodeURIComponent(roleName)}`)
1397
+ .then((r) => r.data);
1398
+ /**
1399
+ * Submit a response to a KBA PIN challenge.
1400
+ */
1401
+ const submitKbaPin = (endpoint, envelopeId, roleName, pin) => endpoint.api //
1402
+ .post(`/v2/kba/pin`, { envelopeId, roleName, pin })
1403
+ .then((r) => r.data);
1404
+ /**
1405
+ * Submit an identity response to a KBA challenge.
1406
+ */
1407
+ const submitKbaIdentity = (endpoint, envelopeId, roleName, identity) => endpoint.api //
1408
+ .post(`/v2/kba/identity`, { envelopeId, roleName, identity })
1409
+ .then((r) => r.data);
1410
+ /**
1411
+ * Submit an identity response to a KBA challenge.
1412
+ */
1413
+ const submitKbaChallengeResponse = (endpoint, envelopeId, roleName, response) => endpoint.api //
1414
+ .post(`/v2/kba/response`, { envelopeId, roleName, response })
1415
+ .then((r) => r.data);
1416
+
1388
1417
  /**
1389
1418
  * Update a recipient's status block
1390
1419
  */
@@ -1770,6 +1799,52 @@ const deleteOrganization = (endpoint, organizationId) => endpoint.api //
1770
1799
  const updateOrganization = (endpoint, organizationId, params) => endpoint.api //
1771
1800
  .patch(`/v2/organizations/${organizationId}`, params)
1772
1801
  .then((r) => r.data);
1802
+ /**
1803
+ * Update the organization's logo. This can only be called by an admin or owner of the organization.
1804
+ *
1805
+ * ```typescript
1806
+ * import {uploadOrganizationLogo} from '@verdocs/js-sdk';
1807
+ *
1808
+ * await uploadOrganizationLogo((VerdocsEndpoint.getDefault(), file);
1809
+ * ```
1810
+ */
1811
+ const uploadOrganizationLogo = (endpoint, file, onUploadProgress) => {
1812
+ const formData = new FormData();
1813
+ formData.append('document', file, file.name);
1814
+ return endpoint.api //
1815
+ .post(`/v2/organizations/logo`, formData, {
1816
+ timeout: 120000,
1817
+ onUploadProgress: (event) => {
1818
+ const total = event.total || 1;
1819
+ const loaded = event.loaded || 0;
1820
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
1821
+ },
1822
+ })
1823
+ .then((r) => r.data);
1824
+ };
1825
+ /**
1826
+ * Update the organization's thumbnail. This can only be called by an admin or owner of the organization.
1827
+ *
1828
+ * ```typescript
1829
+ * import {uploadOrganizationThumbnail} from '@verdocs/js-sdk';
1830
+ *
1831
+ * await uploadOrganizationThumbnail((VerdocsEndpoint.getDefault(), file);
1832
+ * ```
1833
+ */
1834
+ const uploadOrganizationThumbnail = (endpoint, file, onUploadProgress) => {
1835
+ const formData = new FormData();
1836
+ formData.append('document', file, file.name);
1837
+ return endpoint.api //
1838
+ .post(`/v2/organizations/thumbnail`, formData, {
1839
+ timeout: 120000,
1840
+ onUploadProgress: (event) => {
1841
+ const total = event.total || 1;
1842
+ const loaded = event.loaded || 0;
1843
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
1844
+ },
1845
+ })
1846
+ .then((r) => r.data);
1847
+ };
1773
1848
 
1774
1849
  /**
1775
1850
  * Webhooks are callback triggers from Verdocs to your servers that notify your applications
@@ -2495,11 +2570,10 @@ const authenticate = (endpoint, params) => endpoint.api //
2495
2570
  * If called before the session expires, this will refresh the caller's session and tokens.
2496
2571
  *
2497
2572
  * ```typescript
2498
- * import {Auth} from '@verdocs/js-sdk/Auth';
2499
- * import {Transport} from '@verdocs/js-sdk/HTTP';
2573
+ * import {Auth, VerdocsEndpoint} from '@verdocs/js-sdk';
2500
2574
  *
2501
2575
  * const {accessToken} = await Auth.refreshTokens();
2502
- * Transport.setAuthToken(accessToken);
2576
+ * VerdocsEndpoint.setAuthToken(accessToken);
2503
2577
  * ```
2504
2578
  */
2505
2579
  const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_type: 'refresh_token', refresh_token: refreshToken });
@@ -2507,7 +2581,7 @@ const refreshToken = (endpoint, refreshToken) => authenticate(endpoint, { grant_
2507
2581
  * Update the caller's password when the old password is known (typically for logged-in users).
2508
2582
  *
2509
2583
  * ```typescript
2510
- * import {changePassword} from '@verdocs/js-sdk/Auth';
2584
+ * import {changePassword} from '@verdocs/js-sdk';
2511
2585
  *
2512
2586
  * const {status, message} = await changePassword({ email, oldPassword, newPassword });
2513
2587
  * if (status !== 'OK') {
@@ -2522,7 +2596,7 @@ const changePassword = (endpoint, params) => endpoint.api //
2522
2596
  * Request a password reset, when the old password is not known (typically in login forms).
2523
2597
  *
2524
2598
  * ```typescript
2525
- * import {resetPassword} from '@verdocs/js-sdk/Auth';
2599
+ * import {resetPassword} from '@verdocs/js-sdk';
2526
2600
  *
2527
2601
  * const {success} = await resetPassword({ email });
2528
2602
  * if (status !== 'OK') {
@@ -2541,9 +2615,25 @@ const resetPassword = (endpoint, params) => endpoint.api //
2541
2615
  * "anonymous" mode while verification is being performed.
2542
2616
  *
2543
2617
  * ```typescript
2544
- * import {Auth} from '@verdocs/js-sdk/Auth';
2618
+ * import {resendVerification} from '@verdocs/js-sdk';
2545
2619
  *
2546
- * const result = await Auth.resendVerification();
2620
+ * const result = await resendVerification();
2621
+ * ```
2622
+ */
2623
+ const verifyEmail = (endpoint, email, code) => endpoint.api //
2624
+ .post('/v2/users/verify-email', { email, code })
2625
+ .then((r) => r.data);
2626
+ /**
2627
+ * Resend the email verification request. Note that to prevent certain forms of abuse, the email address is not
2628
+ * a parameter here. Instead, the caller must be authenticated as the (unverified) user. To simplify this process,
2629
+ * the access token to be used may be passed directly as a parameter here. This avoids the need to set it as the
2630
+ * active token on an endpoint, which may be inconvenient in workflows where it is preferable to keep the user in
2631
+ * "anonymous" mode while verification is being performed.
2632
+ *
2633
+ * ```typescript
2634
+ * import {resendVerification} from '@verdocs/js-sdk';
2635
+ *
2636
+ * const result = await resendVerification();
2547
2637
  * ```
2548
2638
  */
2549
2639
  const resendVerification = (endpoint, accessToken) => endpoint.api //
@@ -2558,9 +2648,9 @@ const getNotifications = async (endpoint) => endpoint.api //
2558
2648
  * Get the user's available profiles. The current profile will be marked with `current: true`.
2559
2649
  *
2560
2650
  * ```typescript
2561
- * import {Profiles} from '@verdocs/js-sdk/Users';
2651
+ * import {getProfiles} from '@verdocs/js-sdk';
2562
2652
  *
2563
- * const profiles = await Profiles.getProfiles()
2653
+ * const profiles = await getProfiles();
2564
2654
  * ```
2565
2655
  */
2566
2656
  const getProfiles = (endpoint) => endpoint.api //
@@ -2570,95 +2660,116 @@ const getProfiles = (endpoint) => endpoint.api //
2570
2660
  * Get the user's available profiles. The current profile will be marked with `current: true`.
2571
2661
  *
2572
2662
  * ```typescript
2573
- * import {Profiles} from '@verdocs/js-sdk/Users';
2663
+ * import {getCurrentProfile} from '@verdocs/js-sdk';
2574
2664
  *
2575
- * const profiles = await Profiles.getCurrentProfile()
2665
+ * const profiles = await getCurrentProfile();
2576
2666
  * ```
2577
2667
  */
2578
2668
  const getCurrentProfile = (endpoint) => endpoint.api //
2579
2669
  .get('/v2/profiles')
2580
2670
  .then((r) => (r.data || []).find((profile) => profile.current));
2581
- /**
2582
- * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
2583
- *
2584
- * ```typescript
2585
- * import {Profiles} from '@verdocs/js-sdk/Users';
2586
- *
2587
- * const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
2588
- * ```
2589
- */
2590
- const createProfile = (endpoint, params) => endpoint.api //
2591
- .post('/v2/profiles', params)
2592
- .then((r) => r.data);
2593
2671
  /**
2594
2672
  * Get a profile. The caller must have admin access to the given profile.
2595
2673
  * TODO: Add a "public" profile endpoint for public pages
2596
2674
  *
2597
2675
  * ```typescript
2598
- * import {Profiles} from '@verdocs/js-sdk/Users';
2676
+ * import {getProfile} from '@verdocs/js-sdk';
2599
2677
  *
2600
- * const profile = await Profiles.getProfile('PROFILEID');
2678
+ * const profile = await getProfile('PROFILEID');
2601
2679
  * ```
2602
2680
  */
2603
2681
  const getProfile = (endpoint, profileId) => endpoint.api //
2604
2682
  .get(`/v2/profiles/${profileId}`)
2605
2683
  .then((r) => r.data);
2606
2684
  /**
2607
- * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
2608
- * for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
2685
+ * Switch the caller's "current" profile. The current profile is used for permissions checking
2686
+ * and profile_id field settings for most operations in Verdocs. It is important to select the
2687
+ * appropropriate profile before calling other API functions.
2609
2688
  *
2610
2689
  * ```typescript
2611
- * import {Profiles} from '@verdocs/js-sdk/Users';
2690
+ * import {switchProfile} from '@verdocs/js-sdk';
2612
2691
  *
2613
- * const newProfile = await Profiles.switchProfile('PROFILEID');
2692
+ * const newProfile = await switchProfile('PROFILEID');
2614
2693
  * ```
2615
2694
  */
2616
2695
  const switchProfile = (endpoint, profileId) => endpoint.api //
2617
2696
  .post(`/v2/profiles/${profileId}/switch`)
2618
2697
  .then((r) => r.data);
2619
2698
  /**
2620
- * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
2621
- * "current" profile for the caller.
2699
+ * Update a profile. For future expansion, the profile ID to update is required, but currently
2700
+ * this must also be the "current" profile for the caller.
2622
2701
  *
2623
2702
  * ```typescript
2624
- * import {Profiles} from '@verdocs/js-sdk/Users';
2703
+ * import {updateProfile} from '@verdocs/js-sdk/Users';
2625
2704
  *
2626
- * const newProfile = await Profiles.updateProfile('PROFILEID');
2705
+ * const newProfile = await updateProfile('PROFILEID');
2627
2706
  * ```
2628
2707
  */
2629
2708
  const updateProfile = (endpoint, profileId, params) => endpoint.api //
2630
2709
  .patch(`/v2/profiles/${profileId}`, params)
2631
2710
  .then((r) => r.data);
2632
2711
  /**
2633
- * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
2712
+ * Delete a profile. If the requested profile is the caller's curent profile, the next
2713
+ * available profile will be selected.
2634
2714
  *
2635
2715
  * ```typescript
2636
- * import {Profiles} from '@verdocs/js-sdk/Users';
2716
+ * import {deleteProfile} from '@verdocs/js-sdk';
2637
2717
  *
2638
- * await Profiles.deleteProfile('PROFILEID');
2718
+ * await deleteProfile('PROFILEID');
2639
2719
  * ```
2640
2720
  */
2641
2721
  const deleteProfile = (endpoint, profileId) => endpoint.api //
2642
2722
  .delete(`/v2/profiles/${profileId}`)
2643
2723
  .then((r) => r.data);
2644
2724
  /**
2645
- * Create a user account and parent organization. This endpoint is for creating a new organization. Users joining an
2646
- * existing organization should be invited, and follow their invitation links/instructions to create their accounts.
2725
+ * Create a new user account. Note that there are two registration paths for creation:
2726
+ * - Get invited to an organization, by an admin or owner of that org.
2727
+ * - Created a new organization. The caller will become the first owner of the new org.
2728
+ *
2729
+ * This endpoint is for the second path, so an organization name is required. It is NOT
2730
+ * required to be unique because it is very common for businesses to have the same names,
2731
+ * without conflicting (e.g. "Delta" could be Delta Faucet or Delta Airlines).
2732
+ *
2733
+ * The new profile will automatically be set as the user's "current" profile, and new
2734
+ * session tokens will be returned to the caller. However, the caller's email may not yet
2735
+ * be verified. In that case, the caller will not yet be able to call other endpoints in
2736
+ * the Verdocs API. The caller will need to check their email for a verification code,
2737
+ * which should be submitted via the `verifyEmail` endpoint.
2647
2738
  *
2648
2739
  * ```typescript
2649
- * import {Profiles} from '@verdocs/js-sdk/Users';
2740
+ * import {createProfile} from '@verdocs/js-sdk';
2650
2741
  *
2651
- * const newAccount = await Profiles.createBusinessAccount({
2652
- * orgName: 'ORG', email: 'a@b.com', password: '12345678', firstName: 'FIRST', lastName: 'LAST'
2742
+ * const newSession = await createProfile({
2743
+ * orgName: 'NEW ORG', email: 'a@b.com', password: '12345678', firstName: 'FIRST', lastName: 'LAST'
2653
2744
  * });
2654
2745
  * ```
2655
2746
  */
2656
- const createAccount = (endpoint, params) => endpoint.api //
2657
- .post('/user/business', params)
2658
- .then((r) => r.data);
2659
- const recordSignupSurvey = (endpoint, params) => endpoint.api //
2660
- .post('/user/signup', params)
2747
+ const createProfile = (endpoint, params) => endpoint.api //
2748
+ .post('/v2/profiles', params)
2661
2749
  .then((r) => r.data);
2750
+ /**
2751
+ * Update the caller's profile photo. This can only be called for the user's "current" profile.
2752
+ *
2753
+ * ```typescript
2754
+ * import {uploadProfilePhoto} from '@verdocs/js-sdk';
2755
+ *
2756
+ * await uploadProfilePhoto((VerdocsEndpoint.getDefault(), file);
2757
+ * ```
2758
+ */
2759
+ const uploadProfilePhoto = (endpoint, file, onUploadProgress) => {
2760
+ const formData = new FormData();
2761
+ formData.append('document', file, file.name);
2762
+ return endpoint.api //
2763
+ .post(`/v2/profiles/picture`, formData, {
2764
+ timeout: 120000,
2765
+ onUploadProgress: (event) => {
2766
+ const total = event.total || 1;
2767
+ const loaded = event.loaded || 0;
2768
+ onUploadProgress?.(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
2769
+ },
2770
+ })
2771
+ .then((r) => r.data);
2772
+ };
2662
2773
 
2663
2774
  exports.AtoB = AtoB;
2664
2775
  exports.Countries = Countries;
@@ -2673,7 +2784,6 @@ exports.cancelEnvelope = cancelEnvelope;
2673
2784
  exports.capitalize = capitalize;
2674
2785
  exports.changePassword = changePassword;
2675
2786
  exports.convertToE164 = convertToE164;
2676
- exports.createAccount = createAccount;
2677
2787
  exports.createApiKey = createApiKey;
2678
2788
  exports.createEnvelope = createEnvelope;
2679
2789
  exports.createEnvelopeReminder = createEnvelopeReminder;
@@ -2742,6 +2852,7 @@ exports.getFieldsForRole = getFieldsForRole;
2742
2852
  exports.getGroup = getGroup;
2743
2853
  exports.getGroups = getGroups;
2744
2854
  exports.getInPersonLink = getInPersonLink;
2855
+ exports.getKbaStatus = getKbaStatus;
2745
2856
  exports.getMatchingCountry = getMatchingCountry;
2746
2857
  exports.getNextRecipient = getNextRecipient;
2747
2858
  exports.getNotifications = getNotifications;
@@ -2802,7 +2913,6 @@ exports.listTemplates = listTemplates;
2802
2913
  exports.nameToRGBA = nameToRGBA;
2803
2914
  exports.recipientCanAct = recipientCanAct;
2804
2915
  exports.recipientHasAction = recipientHasAction;
2805
- exports.recordSignupSurvey = recordSignupSurvey;
2806
2916
  exports.refreshToken = refreshToken;
2807
2917
  exports.rescale = rescale;
2808
2918
  exports.resendInvitation = resendInvitation;
@@ -2814,6 +2924,9 @@ exports.searchEnvelopes = searchEnvelopes;
2814
2924
  exports.searchTemplates = searchTemplates;
2815
2925
  exports.sendDelegate = sendDelegate;
2816
2926
  exports.setWebhooks = setWebhooks;
2927
+ exports.submitKbaChallengeResponse = submitKbaChallengeResponse;
2928
+ exports.submitKbaIdentity = submitKbaIdentity;
2929
+ exports.submitKbaPin = submitKbaPin;
2817
2930
  exports.switchProfile = switchProfile;
2818
2931
  exports.throttledGetEnvelope = throttledGetEnvelope;
2819
2932
  exports.throttledGetTemplate = throttledGetTemplate;
@@ -2835,6 +2948,9 @@ exports.updateTemplate = updateTemplate;
2835
2948
  exports.updateTemplateReminder = updateTemplateReminder;
2836
2949
  exports.updateTemplateRole = updateTemplateRole;
2837
2950
  exports.uploadEnvelopeFieldAttachment = uploadEnvelopeFieldAttachment;
2951
+ exports.uploadOrganizationLogo = uploadOrganizationLogo;
2952
+ exports.uploadOrganizationThumbnail = uploadOrganizationThumbnail;
2953
+ exports.uploadProfilePhoto = uploadProfilePhoto;
2838
2954
  exports.userCanAct = userCanAct;
2839
2955
  exports.userCanBuildTemplate = userCanBuildTemplate;
2840
2956
  exports.userCanCancelEnvelope = userCanCancelEnvelope;
@@ -2858,4 +2974,5 @@ exports.userHasSharedTemplate = userHasSharedTemplate;
2858
2974
  exports.userIsEnvelopeOwner = userIsEnvelopeOwner;
2859
2975
  exports.userIsEnvelopeRecipient = userIsEnvelopeRecipient;
2860
2976
  exports.userIsTemplateCreator = userIsTemplateCreator;
2977
+ exports.verifyEmail = verifyEmail;
2861
2978
  //# sourceMappingURL=index.js.map