Skip to content

Commit 0027fb6

Browse files
2 parents f821991 + 03c6b6e commit 0027fb6

4 files changed

Lines changed: 98 additions & 22 deletions

File tree

‎lib/eSignature/controllers/eg044FocusedView.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ eg044FocusedView.createController = async (req, res) => {
4545
const envelopeArgs = {
4646
signerEmail: validator.escape(body.signerEmail),
4747
signerName: validator.escape(body.signerName),
48+
phoneNumber: body.phoneNumber ? validator.escape(body.phoneNumber) : null,
49+
countryCode: body.countryCode ? validator.escape(body.countryCode) : null,
4850
signerClientId: signerClientId,
4951
dsReturnUrl: dsReturnUrl,
5052
dsPingUrl: dsPingUrl,

‎lib/eSignature/examples/focusedView.js‎

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,40 @@ const sendEnvelope = async (args) => {
2525
let envelopesApi = new docusign.EnvelopesApi(dsApiClient);
2626
let results = null;
2727

28+
// If phone authentication is needed, get the workflow ID
29+
if (args.envelopeArgs.phoneNumber) {
30+
let accountsApi = new docusign.AccountsApi(dsApiClient);
31+
let workflowId = null;
32+
33+
results = await accountsApi.getAccountIdentityVerification(
34+
args.accountId, (error, data, response) => {
35+
const headers = response?.headers;
36+
37+
const remaining = headers?.['x-ratelimit-remaining'];
38+
const reset = headers?.['x-ratelimit-reset'];
39+
40+
if (remaining && reset) {
41+
const resetInstant = new Date(Number(reset) * 1000);
42+
43+
console.log(`API calls remaining: ${remaining}`);
44+
console.log(`Next Reset: ${resetInstant.toISOString()}`);
45+
}
46+
});
47+
48+
// Find the workflow ID corresponding to the name "Phone Authentication"
49+
results.data.identityVerification.forEach(workflow => {
50+
if (workflow.defaultName === 'Phone Authentication') {
51+
workflowId = workflow.workflowId;
52+
}
53+
});
54+
55+
if (workflowId === null) {
56+
throw new Error('IDENTITY_WORKFLOW_INVALID_ID');
57+
}
58+
59+
args.envelopeArgs.workflowId = workflowId;
60+
}
61+
2862
// Make the envelope request body
2963
let envelope = makeEnvelope(args.envelopeArgs);
3064

@@ -88,7 +122,10 @@ function makeEnvelope(args) {
88122
// args.signerEmail
89123
// args.signerName
90124
// args.signerClientId
91-
// docFile
125+
// args.workflowId (optional, when phone auth is used)
126+
// args.phoneNumber (optional)
127+
// args.countryCode (optional0)
128+
// args.docFile
92129

93130
// document 1 (pdf) has tag /sn1/
94131
//
@@ -125,22 +162,22 @@ function makeEnvelope(args) {
125162
recipientId: 1,
126163
});
127164

128-
// Create signHere fields (also known as tabs) on the documents,
129-
// We're using anchor (autoPlace) positioning
130-
//
131-
// The DocuSign platform seaches throughout your envelope's
132-
// documents for matching anchor strings.
133-
let signHere1 = docusign.SignHere.constructFromObject({
134-
anchorString: '/sn1/',
135-
anchorYOffset: '10',
136-
anchorUnits: 'pixels',
137-
anchorXOffset: '20',
138-
});
139-
// Tabs are set per recipient / signer
140-
let signer1Tabs = docusign.Tabs.constructFromObject({
141-
signHereTabs: [signHere1],
142-
});
143-
signer1.tabs = signer1Tabs;
165+
// Add phone authentication if phone number is provided
166+
if (args.phoneNumber) {
167+
signer1.identityVerification = {
168+
workflowId: args.workflowId,
169+
steps: null,
170+
inputOptions: [{
171+
name: 'phone_number_list',
172+
valueType: 'PhoneNumberList',
173+
phoneNumberList: [{
174+
countryCode: args.countryCode,
175+
number: args.phoneNumber
176+
}]
177+
}],
178+
idCheckConfigurationName: ''
179+
};
180+
}
144181

145182
// Add the recipient to the envelope object
146183
let recipients = docusign.Recipients.constructFromObject({

‎views/pages/examples/eg044Embed.ejs‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
</body>
3333
</html>
3434

35-
<p><a href="/">Continue</a></p>
36-
3735
<script src='https://js.docusign.com/bundle.js'></script>
3836
<script>
3937
window.DocuSign.loadDocuSign('<%= integrationKey %>')
@@ -46,7 +44,7 @@
4644
branding: {
4745
primaryButton: {
4846
/** Background color of primary button */
49-
backgroundColor: '#333',
47+
backgroundColor: '#50C878',
5048
/** Text color of primary button */
5149
color: '#fff',
5250
}
@@ -55,8 +53,28 @@
5553
/** High-level components we allow specific overrides for */
5654
signingNavigationButton: {
5755
finishText: 'You have finished the document! Hooray!',
58-
position: 'bottom-center'
59-
}
56+
position: 'bottom-center',
57+
shape: 'pill',
58+
},
59+
60+
signingAgreeButton: {
61+
finishText: 'I Agree',
62+
},
63+
64+
signingDeclineButton: {
65+
show: true,
66+
finishText: 'Decline',
67+
backgroundColor: '#ff0000',
68+
color: '#ffffff',
69+
},
70+
71+
downloadModal: {
72+
show: true,
73+
},
74+
75+
declineModal: {
76+
show: true,
77+
},
6078
}
6179
});
6280
@@ -67,6 +85,7 @@
6785
signing.on('sessionEnd', (event) => {
6886
/** The event here denotes what caused the sessionEnd to trigger, such as signing_complete, ttl_expired etc../ **/
6987
console.log('sessionend', event);
88+
window.location.href = '/'
7089
});
7190
7291
signing.mount('#agreement');

‎views/pages/examples/eg044FocusedView.ejs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@
2020
value="<%= locals.dsConfig.signerName %>" required>
2121
</div>
2222

23+
<br/>
24+
<% if(example.Forms && example.Forms[1].FormName) { %>
25+
<%- example.Forms[1].FormName %>
26+
<% } %>
27+
28+
<div class="form-group">
29+
<label for="countryCode"><%= example.Forms[1].Inputs[0].InputName %></label>
30+
<input type="text" class="form-control" id="countryCode" name="countryCode"
31+
placeholder="<%= example.Forms[1].Inputs[0].InputPlaceholder %>">
32+
</div>
33+
34+
<div class="form-group">
35+
<label for="phoneNumber"><%= example.Forms[1].Inputs[1].InputName %></label>
36+
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber"
37+
aria-describedby="phoneHelp" placeholder="<%= example.Forms[1].Inputs[1].InputPlaceholder %>">
38+
<small id="phoneHelp" class="form-text text-muted">Provide a phone number to enable phone authentication for the signer</small>
39+
</div>
40+
2341
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
2442
<%- include("../../partials/submitButton") %>
2543
</form>

0 commit comments

Comments
 (0)