Skip to content

Commit 0dd23a7

Browse files
authored
Merge pull request #46 from docusign/DEVDOCS-6116-6124
DEVDOCS 6116 and 6124: Fixing Phone Auth and IDV Workflow
2 parents bcd571c + 2fed6c7 commit 0dd23a7

File tree

6 files changed

+177
-84
lines changed

6 files changed

+177
-84
lines changed

lib/eSignature/controllers/eg020PhoneAuthentication.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const eg020PhoneAuthentication = exports;
1313
const eg = 'eg020'; // This example reference.
1414
const mustAuthenticate = '/ds/mustAuthenticate';
1515
const minimumBufferMin = 3;
16+
const demoDocsPath = path.resolve(__dirname, '../../../demo_documents');
17+
const pdf1File = 'World_Wide_Corp_lorem.pdf';
1618

1719
/**
1820
* Create the envelope
@@ -37,7 +39,8 @@ eg020PhoneAuthentication.createController = async (req, res) => {
3739
signerEmail: validator.escape(body.signerEmail), // represents your {SIGNER_EMAIL}
3840
signerName: validator.escape(body.signerName), // represents your {SIGNER_NAME}
3941
phoneNumber: validator.escape(body.phoneNumber), // represents your phone number
40-
countryCode: validator.escape(body.countryCode) // represents your country code
42+
countryCode: validator.escape(body.countryCode), // represents your country code
43+
docFile: path.resolve(demoDocsPath, pdf1File)
4144
};
4245
const args = {
4346
accessToken: req.user.accessToken, // represents your {ACCESS_TOKEN}
@@ -53,13 +56,21 @@ eg020PhoneAuthentication.createController = async (req, res) => {
5356
console.log("WorkflowId: " + results.workflowId);
5457
}
5558
catch (error) {
56-
const errorBody = error && error.response && error.response.body;
57-
// we can pull the DocuSign error code and message from the response body
58-
const errorCode = errorBody && errorBody.errorCode;
59-
const errorMessage = errorBody && errorBody.message;
60-
// In production, may want to provide customized error messages and
61-
// remediation advice to the user.
62-
res.render('pages/error', {err: error, errorCode, errorMessage});
59+
if (error.message.includes("IDENTITY_WORKFLOW_INVALID_ID")) {
60+
const errorCode = error.message;
61+
const errorMessage = "The identity workflow ID specified is not valid.";
62+
const errorInfo = "Please contact <a target='_blank' href='https://support.docusign.com'>Support</a> to enable Phone Authentication in your account."
63+
res.render("pages/error", {err: error, errorCode, errorMessage, errorInfo});
64+
} else {
65+
const errorBody = error && error.response && error.response.body;
66+
// We can pull the DocuSign error code and message from the response body
67+
const errorCode = errorBody && errorBody.errorCode;
68+
const errorMessage = errorBody && errorBody.message;
69+
70+
// In production, may want to provide customized error messages and
71+
// remediation advice to the user.
72+
res.render('pages/error', {err: error, errorCode, errorMessage});
73+
}
6374
}
6475

6576
if (results) {

lib/eSignature/controllers/eg023IdvAuthentication.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const eg023IdvAuthentication = exports;
1313
const eg = 'eg023'; // This example reference.
1414
const mustAuthenticate = '/ds/mustAuthenticate';
1515
const minimumBufferMin = 3;
16+
const demoDocsPath = path.resolve(__dirname, '../../../demo_documents');
17+
const pdf1File = 'World_Wide_Corp_lorem.pdf';
1618

1719
/**
1820
* Create the envelope
@@ -35,7 +37,8 @@ eg023IdvAuthentication.createController = async (req, res) => {
3537
// Additional data validation might also be appropriate
3638
const envelopeArgs = {
3739
signerEmail: validator.escape(body.signerEmail), // represents your {SIGNER_EMAIL}
38-
signerName: validator.escape(body.signerName) // represents your {SIGNER_NAME}
40+
signerName: validator.escape(body.signerName), // represents your {SIGNER_NAME}
41+
docFile: path.resolve(demoDocsPath, pdf1File)
3942
};
4043
const args = {
4144
accessToken: req.user.accessToken, // represents your {ACCESS_TOKEN}
@@ -51,13 +54,21 @@ eg023IdvAuthentication.createController = async (req, res) => {
5154
console.log("WorkflowId: " + results.workflowId);
5255
}
5356
catch (error) {
54-
const errorBody = error && error.response && error.response.body;
55-
// we can pull the DocuSign error code and message from the response body
56-
const errorCode = errorBody && errorBody.errorCode;
57-
const errorMessage = errorBody && errorBody.message;
58-
// In production, may want to provide customized error messages and
59-
// remediation advice to the user.
60-
res.render('pages/error', {err: error, errorCode, errorMessage});
57+
if (error.message.includes("IDENTITY_WORKFLOW_INVALID_ID")) {
58+
const errorCode = error.message;
59+
const errorMessage = "The identity workflow ID specified is not valid.";
60+
const errorInfo = "Please contact <a target='_blank' href='https://support.docusign.com'>Support</a> to enable Identity Verification in your account."
61+
res.render("pages/error", {err: error, errorCode, errorMessage, errorInfo});
62+
} else {
63+
const errorBody = error && error.response && error.response.body;
64+
// We can pull the DocuSign error code and message from the response body
65+
const errorCode = errorBody && errorBody.errorCode;
66+
const errorMessage = errorBody && errorBody.message;
67+
68+
// In production, may want to provide customized error messages and
69+
// remediation advice to the user.
70+
res.render('pages/error', {err: error, errorCode, errorMessage});
71+
}
6172
}
6273

6374
if (results) {

lib/eSignature/examples/idvAuthentication.js

Lines changed: 62 additions & 29 deletions
Large diffs are not rendered by default.

lib/eSignature/examples/phoneAuthentication.js

Lines changed: 56 additions & 27 deletions
Large diffs are not rendered by default.

views/pages/error.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
<% if (errorCode) { %>
88
<p><%= errorCode %>: <%= errorMessage %></p>
9+
<% if (typeof errorInfo !== 'undefined') { %>
10+
<p><%- errorInfo %></p>
11+
<% } %>
912
<% } else { %>
1013
<p><pre><%= err %></pre></p>
1114

views/pages/index_esignature_examples.ejs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<% } %>
55

66
<% if (locals.dsConfig.multiSourceChooser) { %>
7-
<h3 class="mt-4">Code Examples for C#, PHP, Java, Node.js, Python, and Curl</h3>
7+
<h3 class="mt-4">Run and explore eSignature REST API code examples with Authorization Code Grant or JWT Grant authentication</h3>
88
<% } else { %>
9-
<h3 class="mt-4">Basic examples</h3>
9+
<h2 class="mt-4">Basic examples</h2>
1010
<% } %>
1111

1212
<h4 id="example001">1. <a href="eg001">Use embedded signing</a></h4>
@@ -129,6 +129,7 @@
129129
</p>
130130

131131
<h2>Payments</h2>
132+
132133
<h4 id="example014">14. <a href="eg014">Send an envelope with an order form and payment field</a></h4>
133134
<p>Anchor text
134135
(<a target='_blank'
@@ -140,6 +141,7 @@
140141
</p>
141142

142143
<h2>Tabs</h2>
144+
143145
<h4 id="example015">15. <a href="eg015">Get the tab data from an envelope</a></h4>
144146
<p>This example retrieves the tab (field) values from an envelope.</p>
145147
<p>API method used:
@@ -168,36 +170,36 @@
168170
</p>
169171

170172
<h2>Recipient authentication</h2>
171-
<h4 id="example019">19. <a href="eg019">Access Code Authentication</a></h4>
172-
<p>This is an example of an envelope utilizing Access Code authentication for multi-factor verification of a
173-
recipient.</p>
173+
174+
<h4 id="example019">19. <a href="eg019">Require access code authentication for a recipient</a></h4>
175+
<p>Sends an envelope that requires entering an access code for the purpose of multifactor authentication.</p>
174176
<p>API method used:
175177
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
176178
</p>
177179

178-
<h4 id="example020">20. <a href="eg020">Require Phone Authentication for a Recipient</a></h4>
180+
<h4 id="example020">20. <a href="eg020">Require phone authentication for a recipient</a></h4>
179181
<p>Sends an envelope that requires entering a six-digit code from a text message or phone call for the purpose of multifactor authentication.</p>
180182
<p>API method used:
181183
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
182184
</p>
183185

184-
<h4 id="example022">22. <a href="eg022">KBA Authentication</a></h4>
185-
<p>This is an example of an envelope utilizing Knowledge based authentication for multi-factor verification of a
186-
recipient.</p>
186+
<h4 id="example022">22. <a href="eg022">Require knowledge-based authentication (KBA) for a recipient</a></h4>
187+
<p>Sends an envelope that requires passing a public records check to validate identity for the purpose of multifactor authentication.</p>
187188
<p>API method used:
188189
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
189190
</p>
190191

191-
<h4 id="example023">23. <a href="eg023">IDV Authentication</a></h4>
192-
<p>This is an example of an envelope utilizing Id verification authentication for a recipient.</p>
192+
<h4 id="example023">23. <a href="eg023">Require ID Verification (IDV) for a recipient</a></h4>
193+
<p>Sends an envelope that requires the recipient to upload a government-issued ID for the purpose of multifactor authentication.</p>
193194
<p>API methods used:
194195
<a target='_blank'
195196
href="https://developers.docusign.com/esign-rest-api/reference/Accounts/IdentityVerifications/list">Accounts::getAccountIdentityVerificationsList</a>.
196197
<a target='_blank' href="https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/">Envelopes::create</a>.
197198
</p>
198199

199200
<h2>Permissions</h2>
200-
<h4 id="example024">24. <a href="eg024">Creating a permission</a></h4>
201+
202+
<h4 id="example024">24. <a href="eg024">Creating a permission profile</a></h4>
201203
<p>This code example demonstrates how to create a permission profile with the eSignature REST API. </p>
202204
<p>API methods used:
203205
<a target='_blank'
@@ -225,6 +227,7 @@
225227
</p>
226228

227229
<h2>Brands</h2>
230+
228231
<h4 id="example028">28. <a href="eg028">Creating a brand</a></h4>
229232
<p>This code example demonstrates how to create a brand with the eSignature REST API. </p>
230233
<p>API methods used:
@@ -245,6 +248,7 @@
245248
</p>
246249

247250
<h2>Bulk operations</h2>
251+
248252
<h4 id="example031">31. <a href="eg031">Bulk sending envelopes to multiple recipients.</a></h4>
249253
<p>
250254
Method BulkSend::createBulkSendList creates a bulk send list that you can use to send an envelope to up to 1,000
@@ -266,6 +270,7 @@
266270
</p>
267271

268272
<h2>Advanced recipient routing</h2>
273+
269274
<h4 id="example032">32. <a href="eg032">Pausing a signature workflow</a></h4>
270275
<p>
271276
This example creates and envelope and then pauses the signature workflow
@@ -294,6 +299,7 @@
294299
</p>
295300

296301
<h2>Premium features</h2>
302+
297303
<h4 id="example035">35. <a href="eg035">Sending via SMS delivery</a></h4>
298304
<p>
299305
This example demonstrates how to send a signature request for a signer (and CC) to read and sign via an SMS message.

0 commit comments

Comments
 (0)