Skip to content

Commit b540517

Browse files
added code analyzer, fixed code style issues
1 parent 56fb30a commit b540517

File tree

149 files changed

+5563
-2218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+5563
-2218
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
config/*
2+
public/*
3+
node_modules/*
4+
test/*

.eslintrc.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es2021": true
6+
},
7+
"overrides": [
8+
],
9+
"parserOptions": {
10+
"ecmaVersion": "latest"
11+
},
12+
"rules": {
13+
"arrow-spacing": [1, { "before": true, "after": true }],
14+
"block-spacing": [1, "always"],
15+
"brace-style": [1, "1tbs", { "allowSingleLine": true }],
16+
"comma-spacing": [1, { "before": false, "after": true }],
17+
"comma-style": [1, "last"],
18+
"dot-location": [1, "property"],
19+
"eol-last": 1,
20+
"eqeqeq": [1, "always", {"null": "ignore"}],
21+
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
22+
"no-cond-assign": 1,
23+
"no-const-assign": 1,
24+
"no-debugger": 1,
25+
"no-delete-var": 1,
26+
"no-dupe-args": 1,
27+
"no-dupe-class-members": 1,
28+
"no-dupe-keys": 1,
29+
"no-duplicate-case": 1,
30+
"no-empty-character-class": 1,
31+
"no-labels": 1,
32+
"no-ex-assign": 1,
33+
"no-extra-boolean-cast": 1,
34+
"no-extra-parens": [1, "functions"],
35+
"no-fallthrough": 1,
36+
"no-floating-decimal": 1,
37+
"no-func-assign": 1,
38+
"no-implied-eval": 1,
39+
"no-inner-declarations": [1, "functions"],
40+
"no-invalid-regexp": 1,
41+
"no-irregular-whitespace": 1,
42+
"no-label-var": 1,
43+
"no-lone-blocks": 1,
44+
"no-mixed-spaces-and-tabs": 1,
45+
"no-multi-spaces": 1,
46+
"no-multi-str": 1,
47+
"no-multiple-empty-lines": [1, { "max": 2 }],
48+
"no-native-reassign": 1,
49+
"no-negated-in-lhs": 1,
50+
"no-new": 1,
51+
"no-new-func": 1,
52+
"no-new-require": 1,
53+
"no-new-wrappers": 1,
54+
"no-obj-calls": 1,
55+
"no-octal": 1,
56+
"no-octal-escape": 1,
57+
"no-return-assign": 1,
58+
"no-self-compare": 1,
59+
"no-sequences": 1,
60+
"no-shadow-restricted-names": 1,
61+
"no-spaced-func": 1,
62+
"no-sparse-arrays": 1,
63+
"no-throw-literal": 1,
64+
"no-trailing-spaces": 1,
65+
"no-undef-init": 1,
66+
"no-unexpected-multiline": 1,
67+
"no-unneeded-ternary": [1, { "defaultAssignment": false }],
68+
"no-unreachable": 1,
69+
"no-useless-call": 1,
70+
"no-with": 1,
71+
"one-var": [1, { "initialized": "never" }],
72+
"quotes": [1, "single", "avoid-escape"],
73+
"quote-props": [1, "as-needed"],
74+
"semi": [1, "always"],
75+
"semi-spacing": [1, { "before": false, "after": false }],
76+
"keyword-spacing": [1, { "before": true, "after": true }],
77+
"space-before-function-paren": [1, {
78+
"anonymous": "never",
79+
"named": "never",
80+
"asyncArrow": "always"
81+
}],
82+
"space-in-parens": [1, "never"],
83+
"space-infix-ops": 1,
84+
"space-unary-ops": [1, { "words": true, "nonwords": false }],
85+
"spaced-comment": [1, "always", {
86+
"markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ",", "#region", "TODO:", "/"]
87+
}],
88+
"yoda": [1, "never"]
89+
}
90+
}

embeddedSigning.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @author DocuSign
55
*/
66

7-
const fs = require("fs-extra");
8-
const docusign = require("docusign-esign");
7+
const fs = require('fs-extra');
8+
const docusign = require('docusign-esign');
99

1010
/**
1111
* This function does the work of creating the envelope and the
@@ -20,9 +20,9 @@ const sendEnvelopeForEmbeddedSigning = async (args) => {
2020

2121
let dsApiClient = new docusign.ApiClient();
2222
dsApiClient.setBasePath(args.basePath);
23-
dsApiClient.addDefaultHeader("Authorization", "Bearer " + args.accessToken);
24-
let envelopesApi = new docusign.EnvelopesApi(dsApiClient),
25-
results = null;
23+
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
24+
let envelopesApi = new docusign.EnvelopesApi(dsApiClient);
25+
let results = null;
2626

2727
// Step 1. Make the envelope request body
2828
let envelope = makeEnvelope(args.envelopeArgs);
@@ -59,7 +59,7 @@ function makeEnvelope(args) {
5959
// args.signerEmail
6060
// args.signerName
6161
// args.signerClientId
62-
// docFile
62+
// docFile
6363

6464
// document 1 (pdf) has tag /sn1/
6565
//
@@ -73,15 +73,15 @@ function makeEnvelope(args) {
7373

7474
// create the envelope definition
7575
let env = new docusign.EnvelopeDefinition();
76-
env.emailSubject = "Please sign this document";
76+
env.emailSubject = 'Please sign this document';
7777

7878
// add the documents
79-
let doc1 = new docusign.Document(),
80-
doc1b64 = Buffer.from(docPdfBytes).toString("base64");
79+
let doc1 = new docusign.Document();
80+
let doc1b64 = Buffer.from(docPdfBytes).toString('base64');
8181
doc1.documentBase64 = doc1b64;
82-
doc1.name = "Lorem Ipsum"; // can be different from actual file name
83-
doc1.fileExtension = "pdf";
84-
doc1.documentId = "3";
82+
doc1.name = 'Lorem Ipsum'; // can be different from actual file name
83+
doc1.fileExtension = 'pdf';
84+
doc1.documentId = '3';
8585

8686
// The order in the docs array determines the order in the envelope
8787
env.documents = [doc1];
@@ -102,10 +102,10 @@ function makeEnvelope(args) {
102102
// The DocuSign platform seaches throughout your envelope's
103103
// documents for matching anchor strings.
104104
let signHere1 = docusign.SignHere.constructFromObject({
105-
anchorString: "/sn1/",
106-
anchorYOffset: "10",
107-
anchorUnits: "pixels",
108-
anchorXOffset: "20",
105+
anchorString: '/sn1/',
106+
anchorYOffset: '10',
107+
anchorUnits: 'pixels',
108+
anchorXOffset: '20',
109109
});
110110
// Tabs are set per recipient / signer
111111
let signer1Tabs = docusign.Tabs.constructFromObject({
@@ -121,7 +121,7 @@ function makeEnvelope(args) {
121121

122122
// Request that the envelope be sent by setting |status| to "sent".
123123
// To request that the envelope be created as a draft, set to "created"
124-
env.status = "sent";
124+
env.status = 'sent';
125125

126126
return env;
127127
}
@@ -143,12 +143,12 @@ function makeRecipientViewRequest(args) {
143143
// the DocuSign signing. It's usually better to use
144144
// the session mechanism of your web framework. Query parameters
145145
// can be changed/spoofed very easily.
146-
viewRequest.returnUrl = args.dsReturnUrl + "?state=123";
146+
viewRequest.returnUrl = args.dsReturnUrl + '?state=123';
147147

148148
// How has your app authenticated the user? In addition to your app's
149149
// authentication, you can include authenticate steps from DocuSign.
150150
// Eg, SMS authentication
151-
viewRequest.authenticationMethod = "none";
151+
viewRequest.authenticationMethod = 'none';
152152

153153
// Recipient information must match embedded recipient info
154154
// we used to create the envelope.

index.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
const express = require('express');
4-
const session = require('express-session'); // https://github.com/expressjs/session
4+
const session = require('express-session'); // https://github.com/expressjs/session
55
const bodyParser = require('body-parser');
66
const cookieParser = require('cookie-parser');
77
const MemoryStore = require('memorystore')(session); // https://github.com/roccomuso/memorystore
@@ -19,7 +19,7 @@ const helmet = require('helmet'); // https://expressjs.com/en/advanced/best-prac
1919
const moment = require('moment');
2020
const csrf = require('csurf'); // https://www.npmjs.com/package/csurf
2121
const examplesApi = require('./config/examplesAPI.json');
22-
const { getManifest } = require('./lib/manifestService')
22+
const { getManifest } = require('./lib/manifestService');
2323

2424
const eg001 = require('./lib/eSignature/controllers/eg001EmbeddedSigning');
2525

@@ -30,36 +30,36 @@ const {
3030
eg024, eg025, eg026, eg027, eg028, eg029, eg030,
3131
eg031, eg032, eg033, eg034, eg035, eg036, eg037,
3232
eg038, eg039, eg040
33-
} = require("./lib/eSignature/controllers");
33+
} = require('./lib/eSignature/controllers');
3434

3535
const {
3636
eg001click, eg002click, eg003click,
3737
eg004click, eg005click,
38-
} = require("./lib/click/controllers");
38+
} = require('./lib/click/controllers');
3939

4040
const {
4141
eg001rooms, eg002rooms, eg003rooms,
4242
eg004rooms, eg005rooms, eg006rooms,
4343
eg007rooms, eg008rooms, eg009rooms,
44-
} = require("./lib/rooms/controllers");
44+
} = require('./lib/rooms/controllers');
4545

4646
const {
4747
eg001monitor, eg002monitor
48-
} = require("./lib/monitor/controllers/index");
48+
} = require('./lib/monitor/controllers/index');
4949

5050
const {
5151
eg001admin, eg002admin, eg003admin,
5252
eg004admin, eg005admin, eg006admin,
5353
eg007admin, eg008admin, eg009admin
54-
} = require("./lib/admin/controllers");
54+
} = require('./lib/admin/controllers');
5555

5656
const PORT = process.env.PORT || 3000;
5757
const HOST = process.env.HOST || 'localhost';
5858
const max_session_min = 180;
5959
const csrfProtection = csrf({ cookie: true });
6060

61-
let hostUrl = 'http://' + HOST + ':' + PORT
62-
if (dsConfig.appUrl != '' && dsConfig.appUrl != '{APP_URL}') { hostUrl = dsConfig.appUrl }
61+
let hostUrl = 'http://' + HOST + ':' + PORT;
62+
if (dsConfig.appUrl !== '' && dsConfig.appUrl !== '{APP_URL}') { hostUrl = dsConfig.appUrl; }
6363

6464
let app = express()
6565
.use(helmet())
@@ -78,14 +78,14 @@ let app = express()
7878
.use(passport.initialize())
7979
.use(passport.session())
8080
.use(bodyParser.urlencoded({ extended: true }))
81-
.use(((req, res, next) => {
81+
.use((req, res, next) => {
8282
res.locals.user = req.user;
8383
res.locals.session = req.session;
8484
res.locals.dsConfig = { ...dsConfig, docOptions: docOptions, docNames: docNames };
85-
res.locals.examplesApi = examplesApi
85+
res.locals.examplesApi = examplesApi;
8686
res.locals.hostUrl = hostUrl; // Used by DSAuthCodeGrant#logout
87-
next()
88-
})) // Send user info to views
87+
next();
88+
}) // Send user info to views
8989
.use(flash())
9090
.set('views', path.join(__dirname, 'views'))
9191
.set('view engine', 'ejs')
@@ -97,12 +97,12 @@ let app = express()
9797
if (req.session.authMethod === 'jwt-auth') {
9898
req.dsAuth = req.dsAuthJwt;
9999
}
100-
next()
100+
next();
101101
})
102102
.use(async (req, res, next) => {
103103
let manifestUrl;
104104

105-
switch(true) {
105+
switch (true) {
106106
case examplesApi.examplesApi.isRoomsApi:
107107
manifestUrl = dsConfig.roomsManifestUrl;
108108
break;
@@ -158,7 +158,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
158158
.get('/eg008', eg008rooms.getController)
159159
.post('/eg008', eg008rooms.createController)
160160
.get('/eg009', eg009rooms.getController)
161-
.post('/eg009', eg009rooms.createController)
161+
.post('/eg009', eg009rooms.createController);
162162
} else if (examplesApi.examplesApi.isClickApi) {
163163
app.get('/eg001', eg001click.getController)
164164
.post('/eg001', eg001click.createController)
@@ -169,12 +169,12 @@ if (examplesApi.examplesApi.isRoomsApi) {
169169
.get('/eg004', eg004click.getController)
170170
.post('/eg004', eg004click.createController)
171171
.get('/eg005', eg005click.getController)
172-
.post('/eg005', eg005click.createController)
172+
.post('/eg005', eg005click.createController);
173173
} else if (examplesApi.examplesApi.isMonitorApi) {
174174
app.get('/eg001', eg001monitor.getController)
175175
.post('/eg001', eg001monitor.createController)
176176
.get('/eg002', eg002monitor.getController)
177-
.post('/eg002', eg002monitor.createController)
177+
.post('/eg002', eg002monitor.createController);
178178
} else if (examplesApi.examplesApi.isAdminApi) {
179179
app.get('/eg001', eg001admin.getController)
180180
.post('/eg001', eg001admin.createController)
@@ -194,7 +194,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
194194
.get('/eg008', eg008admin.getController)
195195
.post('/eg008', eg008admin.createController)
196196
.get('/eg009', eg009admin.getController)
197-
.post('/eg009', eg009admin.createController)
197+
.post('/eg009', eg009admin.createController);
198198
} else {
199199
app.get('/eg001', eg001.getController)
200200
.post('/eg001', eg001.createController)
@@ -273,16 +273,16 @@ if (examplesApi.examplesApi.isRoomsApi) {
273273
.get('/eg039', eg039.getController)
274274
.post('/eg039', eg039.createController)
275275
.get('/eg040', eg040.getController)
276-
.post('/eg040', eg040.createController)
276+
.post('/eg040', eg040.createController);
277277
}
278278

279-
function dsLoginCB1(req, res, next) { req.dsAuthCodeGrant.oauth_callback1(req, res, next) }
280-
function dsLoginCB2(req, res, next) { req.dsAuthCodeGrant.oauth_callback2(req, res, next) }
279+
function dsLoginCB1(req, res, next) { req.dsAuthCodeGrant.oauth_callback1(req, res, next); }
280+
function dsLoginCB2(req, res, next) { req.dsAuthCodeGrant.oauth_callback2(req, res, next); }
281281

282282
/* Start the web server */
283283
if (dsConfig.dsClientId && dsConfig.dsClientId !== '{CLIENT_ID}' &&
284284
dsConfig.dsClientSecret && dsConfig.dsClientSecret !== '{CLIENT_SECRET}') {
285-
app.listen(PORT)
285+
app.listen(PORT);
286286
console.log(`Listening on ${PORT}`);
287287
console.log(`Ready! Open ${hostUrl}`);
288288
} else {
@@ -298,25 +298,25 @@ You can set them in the configuration file config/appsettings.json or set enviro
298298
// the user by ID when deserializing. However, since this example does not
299299
// have a database of user records, the complete DocuSign profile is serialized
300300
// and deserialized.
301-
passport.serializeUser(function (user, done) { done(null, user) });
302-
passport.deserializeUser(function (obj, done) { done(null, obj) });
301+
passport.serializeUser(function(user, done) { done(null, user); });
302+
passport.deserializeUser(function(obj, done) { done(null, obj); });
303303

304-
const SCOPES = ["signature"];
304+
const SCOPES = ['signature'];
305305
const ROOM_SCOPES = [
306-
"signature", "dtr.rooms.read", "dtr.rooms.write",
307-
"dtr.documents.read", "dtr.documents.write", "dtr.profile.read", "dtr.profile.write",
308-
"dtr.company.read", "dtr.company.write", "room_forms"
306+
'signature', 'dtr.rooms.read', 'dtr.rooms.write',
307+
'dtr.documents.read', 'dtr.documents.write', 'dtr.profile.read', 'dtr.profile.write',
308+
'dtr.company.read', 'dtr.company.write', 'room_forms'
309309
];
310310
const CLICK_SCOPES = [
311-
"signature", "click.manage", "click.send"
311+
'signature', 'click.manage', 'click.send'
312312
];
313313
const MONITOR_SCOPES = [
314-
"signature", "impersonation"
314+
'signature', 'impersonation'
315315
];
316316
const ADMIN_SCOPES = [
317-
"organization_read", "group_read", "permission_read ",
318-
"user_read", "user_write", "account_read",
319-
"domain_read", "identity_provider_read", "signature"
317+
'organization_read', 'group_read', 'permission_read ',
318+
'user_read', 'user_write', 'account_read',
319+
'domain_read', 'identity_provider_read', 'signature'
320320
];
321321
let scope;
322322
if (examplesApi.examplesApi.isRoomsApi) {
@@ -334,7 +334,7 @@ if (examplesApi.examplesApi.isRoomsApi) {
334334
let docusignStrategy = new DocusignStrategy({
335335
production: dsConfig.production,
336336
clientID: dsConfig.dsClientId,
337-
scope: scope.join(" "),
337+
scope: scope.join(' '),
338338
clientSecret: dsConfig.dsClientSecret,
339339
callbackURL: hostUrl + '/ds/callback',
340340
state: true // automatic CSRF protection.
@@ -361,8 +361,8 @@ let docusignStrategy = new DocusignStrategy({
361361
*/
362362
if (!dsConfig.allowSilentAuthentication) {
363363
// See https://stackoverflow.com/a/32877712/64904
364-
docusignStrategy.authorizationParams = function (options) {
364+
docusignStrategy.authorizationParams = function(options) {
365365
return { prompt: 'login' };
366-
}
366+
};
367367
}
368368
passport.use(docusignStrategy);

0 commit comments

Comments
 (0)