json-object-editor 0.10.210 → 0.10.222

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/js/joe.js CHANGED
@@ -9382,7 +9382,7 @@ logit(intent)
9382
9382
  logit(response);
9383
9383
  var bucket = response.bucket || (_joe.Data.setting.where({name:'AWS_BUCKETNAME'})[0] || {value:''}).value;
9384
9384
  var region = (_joe.Utils.Settings('AWS_S3CONFIG') ||{}).region;
9385
- var prefix = 'https://s3.'+((region && region +'.')||'')+'amazonaws.com/'+bucket+'/';
9385
+ var prefix = (_joe.Data.setting.where({name:'AWS_S3PREFIX'})[0] || {value:''}).value || 'https://s3.'+((region && region +'.')||'')+'amazonaws.com/'+bucket+'/';
9386
9386
  var url = prefix+response.Key;
9387
9387
  var filename = response.Key.replace(self.current.object._id+'/','');
9388
9388
  //TODO: change file status in list.
@@ -9421,7 +9421,9 @@ logit(intent)
9421
9421
  logit(data);
9422
9422
  var bucket = data.bucket || (_joe.Data.setting.where({name:'AWS_BUCKETNAME'})[0] || {value:''}).value;
9423
9423
 
9424
- var prefix = 'https://s3.amazonaws.com/'+bucket+'/';
9424
+ //var prefix = 'https://s3.amazonaws.com/'+bucket+'/';
9425
+ var prefix = (_joe.Data.setting.where({name:'AWS_S3PREFIX'})[0] || {value:''}).value || 'https://s3.'+((region && region +'.')||'')+'amazonaws.com/'+bucket+'/';
9426
+
9425
9427
  var url = prefix+data.Key;
9426
9428
  if(field.url_field){
9427
9429
  var nprop = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-object-editor",
3
- "version": "0.10.210",
3
+ "version": "0.10.222",
4
4
  "description": "JOE the Json Object Editor | Platform Edition",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -35,6 +35,7 @@
35
35
  "cookie-parser": "^1.4.1",
36
36
  "craydent": "^0.8.9",
37
37
  "express": "^4.16.4",
38
+ "got": "^12.6.0",
38
39
  "jwt-decode": "^2.2.0",
39
40
  "mailgun": "^0.5.0",
40
41
  "mongojs": "^2.3.0",
@@ -43,7 +44,7 @@
43
44
  "nodemailer-ses-transport": "^1.4.0",
44
45
  "opener": "^1.4.3",
45
46
  "pem": "^1.13.2",
46
- "plaid": "^3.1.1",
47
+ "plaid": "^13.1.0",
47
48
  "renderizer": "^1.1.0",
48
49
  "socket.io": "^2.2.0"
49
50
  },
package/pages/joe.html CHANGED
@@ -8,7 +8,7 @@
8
8
  <link rel="icon" href="/JsonObjectEditor/favicon.ico" type="image/x-icon">
9
9
  <link rel="icon" sizes="192x192" href="/JsonObjectEditor/img/ico/android-icon-192x192.png">
10
10
  <link rel="apple-touch-icon" sizes="144x144" href="/JsonObjectEditor/img/ico/android-icon-144x144.png" />
11
-
11
+ <meta name="joe-notes" content="joe.html template" >
12
12
  <meta name="apple-mobile-web-app-capable" content="yes">
13
13
  <meta name="mobile-web-app-capable" content="yes">
14
14
 
@@ -6,18 +6,19 @@
6
6
  <meta name='viewport' content='initial-scale=1.0, user-scalable=no' >
7
7
  <title> ${this.webconfig.name} > ${APPNAME} </title>
8
8
  <script src="/JsonObjectEditor/js/libs/adapter-latest.js"></script>
9
- <link rel="shortcut icon" href="/JsonObjectEditor/favicon.ico" type="image/x-icon">
9
+ <!-- <link rel="shortcut icon" href="/JsonObjectEditor/favicon.ico" type="image/x-icon">
10
10
  <link rel="icon" href="/JsonObjectEditor/favicon.ico" type="image/x-icon">
11
11
  <link rel="icon" sizes="192x192" href="/JsonObjectEditor/img/ico/android-icon-192x192.png">
12
- <link rel="apple-touch-icon" sizes="144x144" href="/JsonObjectEditor/img/ico/android-icon-144x144.png" />
12
+ <link rel="apple-touch-icon" sizes="144x144" href="/JsonObjectEditor/img/ico/android-icon-144x144.png" /> -->
13
13
 
14
+ <meta name="joe-notes" content="template.html template" >
14
15
  <meta name="apple-mobile-web-app-capable" content="yes">
15
16
  <meta name="mobile-web-app-capable" content="yes">
16
17
 
17
18
  <link rel="stylesheet" href="${JOEPATH}js/plugins/c3/c3.min.css"/>
18
19
  <link rel="stylesheet" href="${JOEPATH}capp/capp.css"/>
19
20
  <link href="/JsonObjectEditor/css/joe.css" rel="stylesheet" type="text/css"/>
20
-
21
+ ${this.settings.joe_icons}
21
22
  <!--<script src="${JOEPATH}_joeinclude.js"></script>-->
22
23
 
23
24
  <script type="text/javascript" src="/JsonObjectEditor/js/libs/jquery-1.11.3.min.js"></script>
package/plaidTest.js ADDED
@@ -0,0 +1,87 @@
1
+ const plaid = require('plaid');
2
+
3
+ var self = this;
4
+ var plaidClient;
5
+
6
+ var PUBLIC_TOKEN = null;
7
+
8
+ var ACCESS_TOKENS
9
+
10
+ function getAT(data){
11
+ var AT = ACCESS_TOKENS[data.bank];
12
+ if(!AT){return false;}
13
+ return AT.access_token;
14
+ }
15
+
16
+ function initPlaidClient() {
17
+ var client_id = "57ec34dbf5c9c9795f46a523";
18
+ var secret = "dc2dd377d986f833101da67dfbac34";
19
+ var public_key = "5b7b648e71bc056b974036d32026db";
20
+ ACCESS_TOKENS = {
21
+ "chase":{
22
+ "access_token":"access-development-655b2910-0e0d-4fde-80da-8c77aa92be87"
23
+ },
24
+ "wf":{
25
+ "access_token":"access-development-5a3be1ca-0150-4e96-8a5d-38964d0f0ebf"
26
+ },
27
+ "corey_discover":{
28
+ "access_token":"access-development-95426771-6f02-4c25-ab5c-7d2488f49c86"
29
+ },
30
+ "liz_discover":{
31
+ "access_token":"access-development-bdd33633-ebc6-4944-a487-3552c4648fa5"
32
+ }
33
+ }
34
+ //console.log('plaidinit',plaidClient);
35
+ if(!client_id || !secret || !ACCESS_TOKENS){
36
+ return 'plaidClient not initialized';
37
+ }
38
+ if(plaidClient){ return;}
39
+ console.log('initializing plaid client')
40
+ try {
41
+
42
+ const configuration = new plaid.Configuration({
43
+ basePath: plaid.PlaidEnvironments.development,
44
+ baseOptions: {
45
+ headers: {
46
+ 'PLAID-CLIENT-ID': client_id,
47
+ 'PLAID-SECRET': secret,
48
+ 'Plaid-Version': '2020-09-14',
49
+ },
50
+ },
51
+ });
52
+
53
+ plaidClient = new plaid.PlaidApi(configuration);
54
+ return true;
55
+ } catch (e) {
56
+ console.log("plaid client init error",e);
57
+ return e;
58
+ }
59
+ }
60
+ async function createLink(data, request, response){
61
+ initPlaidClient();
62
+ const options = {
63
+ user: {
64
+ client_user_id: 'user-123',
65
+ },
66
+ client_name: 'Plaid Test',
67
+ products: ['auth'],
68
+ country_codes: ['US'],
69
+ language: 'en',
70
+ };
71
+
72
+ try {
73
+ const linkTokenResponse = await plaidClient.linkTokenCreate(options);
74
+ const linkToken = linkTokenResponse.data.link_token;
75
+ console.log(linkToken);
76
+ const response = await plaidClient.itemPublicTokenExchange({ linkToken });
77
+
78
+ const access_token = response.data.access_token;
79
+ const accounts_response = await plaidClient.accountsGet({ access_token });
80
+ const accounts = accounts_response.data.accounts;
81
+ } catch (error) {
82
+ console.error(error);
83
+ }
84
+ }
85
+
86
+ initPlaidClient();
87
+ createLink();
@@ -2,6 +2,22 @@ var fs = require('fs');
2
2
  function Apps(){
3
3
  var moduleName = JOE.Utils.color('[apps] ','module');
4
4
  var self = this;
5
+
6
+ function formatBytes(bytes,pretty) {
7
+ let mbs = bytes / (1024 * 1024);
8
+ let gbs = null;
9
+ let pref="mbs";
10
+
11
+ if(mbs > 1000){
12
+ gbs = (mbs/1000);
13
+ pretty && (gbs = gbs.toFixed(2));
14
+ pref="gbs"
15
+ }
16
+ pretty && (mbs = mbs.toFixed(2));
17
+
18
+ return {mbs,gbs,pref};
19
+ }
20
+
5
21
  this.Cards = {
6
22
  _generate : function(cardtype,specs,cardtype_specs){
7
23
  //console.log('generating card '+cardtype);
@@ -443,7 +443,7 @@ server.get(['/API/schema/:names','/API/schemas/:names'],auth,function(req,res,ne
443
443
 
444
444
 
445
445
  //PLUGINS
446
- function pluginHandling(req,res,next){
446
+ async function pluginHandling(req,res,next){
447
447
  var pBM = new Benchmarker();
448
448
  var plugin = req.params.plugin;
449
449
 
@@ -483,7 +483,11 @@ function pluginHandling(req,res,next){
483
483
  if(typeof pluginClass[method] == "string"){
484
484
  var response = pluginClass[method];
485
485
  }else{
486
- var response = pluginClass[method](data,req,res);
486
+ if(pluginClass.async && pluginClass.async[method]){
487
+ var response = await pluginClass[method](data,req,res);
488
+ }else{
489
+ var response = pluginClass[method](data,req,res);
490
+ }
487
491
  }
488
492
  if(response && response.use_callback){
489
493
  return;
@@ -0,0 +1,103 @@
1
+ var jwtDecode = require('jwt-decode');
2
+ var request = require("request");
3
+ function Auth(){
4
+ var self = this;
5
+ this.default = function(data,req,res){
6
+ try{
7
+ var payload = {
8
+ params:req.params,
9
+ data:data
10
+ }
11
+
12
+ }catch(e){
13
+ return {errors:'plugin error: '+e,failedat:'plugin'};
14
+ }
15
+
16
+
17
+
18
+ return payload;
19
+ };
20
+
21
+ this.login = function(data,req,res){
22
+
23
+ //make post request
24
+ var originalUrl = data.state||'';
25
+ console.log(originalUrl);
26
+
27
+ var options = { method: 'POST',
28
+ url: 'https://www.googleapis.com/oauth2/v4/token',
29
+ qs:
30
+ {
31
+ grant_type: 'authorization_code',
32
+ code: data.code,
33
+ redirect_uri: `${JOE.webconfig.authorization.host}/API/plugin/auth/login`,
34
+ 'Content-Type': 'application/x-www-form-urlencoded',
35
+ 'client_id':JOE.webconfig.authorization.client_id,
36
+ 'client_secret':JOE.webconfig.authorization.client_secret
37
+ },
38
+ headers:
39
+ {
40
+ 'cache-control': 'no-cache',
41
+ Authorization: JOE.webconfig.authorization.header,
42
+ Accept: 'application/json',
43
+
44
+ },
45
+ rejectUnauthorized:false,
46
+ json: true
47
+ };
48
+
49
+ request(options, function (error, response, body) {
50
+ if (error){
51
+ res.send(error);
52
+ return;
53
+ }
54
+ if (body.error){
55
+ res.send(body.error);
56
+ return;
57
+ }
58
+ //res.send(body);
59
+
60
+ //get creds
61
+ var id_token = body.id_token;
62
+ var access_token = body.access_token;
63
+ var user = {};
64
+ var idTokenInfo = jwtDecode(id_token);
65
+ //var accessTokenInfo = jwtDecode(access_token);
66
+
67
+ //user.username = accessTokenInfo.username.toLowerCase();
68
+ user.email = idTokenInfo.email.toLowerCase();
69
+ var users = (JOE.Data && JOE.Data.user) || [];
70
+ var User = users.where({email:user.email})[0]||false;
71
+ if(User){
72
+ //req.cookies._j_user && req.cookies._j_token
73
+ res.cookie('_j_user',User.name);
74
+ res.cookie('_j_token',User.token);
75
+
76
+ }else{
77
+ var finalUrl = originalUrl+(originalUrl.indexOf('?') == -1?'?':'&')+'noSSO=true'
78
+ res.redirect(finalUrl);
79
+ return;
80
+ }
81
+ //redirect to home or gotoUrl
82
+ res.redirect(originalUrl || `/JOE/${User.apps[0]}`);
83
+ //res.send(body);
84
+
85
+
86
+
87
+ });
88
+
89
+
90
+ //return(data);
91
+ return({use_callback:true})
92
+ }
93
+ this.html = function(data,req,res){
94
+
95
+
96
+
97
+
98
+ return JSON.stringify(self.default(data,req),'','\t\r\n <br/>');
99
+ }
100
+ this.protected = [];
101
+ return self;
102
+ }
103
+ module.exports = new Auth();
@@ -1,6 +1,9 @@
1
1
  var jwtDecode = require('jwt-decode');
2
- var request = require("request");
2
+ // var request = require("request");
3
+
4
+ //var got = require('got');
3
5
  function Auth(){
6
+
4
7
  var self = this;
5
8
  this.default = function(data,req,res){
6
9
  try{
@@ -18,39 +21,49 @@ function Auth(){
18
21
  return payload;
19
22
  };
20
23
 
21
- this.login = function(data,req,res){
22
-
24
+ this.login = async function(data,req,res){
25
+ const got = await import('got');
23
26
  //make post request
24
27
  var originalUrl = data.state||'';
25
28
  console.log(originalUrl);
26
29
 
27
- var options = { method: 'POST',
28
- url: 'https://www.googleapis.com/oauth2/v4/token',
29
- qs:
30
- {
31
- grant_type: 'authorization_code',
32
- code: data.code,
33
- redirect_uri: `${JOE.webconfig.authorization.host}/API/plugin/auth/login`,
34
- 'Content-Type': 'application/x-www-form-urlencoded',
35
- 'client_id':JOE.webconfig.authorization.client_id,
36
- 'client_secret':JOE.webconfig.authorization.client_secret
37
- },
38
- headers:
39
- {
40
- 'cache-control': 'no-cache',
41
- Authorization: JOE.webconfig.authorization.header,
42
- Accept: 'application/json',
30
+ var options = {
31
+ method: 'POST',
32
+ url: 'https://www.googleapis.com/oauth2/v4/token',
33
+ searchParams: {
34
+ grant_type: 'authorization_code',
35
+ code: data.code,
36
+ redirect_uri: `${JOE.webconfig.authorization.host}/API/plugin/auth/login`,
37
+ 'Content-Type': 'application/x-www-form-urlencoded',
38
+ 'client_id':JOE.webconfig.authorization.client_id,
39
+ 'client_secret':JOE.webconfig.authorization.client_secret
40
+ },
41
+ headers:
42
+ {
43
+ 'cache-control': 'no-cache',
44
+ Authorization: JOE.webconfig.authorization.header,
45
+ Accept: 'application/json',
43
46
 
44
- },
45
- rejectUnauthorized:false,
46
- json: true
47
+ },
48
+ responseType: 'json',
49
+ https: {
50
+ rejectUnauthorized: false
51
+ }
52
+ // rejectUnauthorized:false,
53
+ // json: true
47
54
  };
48
55
 
49
- request(options, function (error, response, body) {
50
- if (error){
51
- res.send(error);
52
- return;
53
- }
56
+ // request(options, function (error, response, body) {
57
+ got.default(options)
58
+ .catch(error => {
59
+ res.send(error);
60
+ })
61
+ .then(response => {
62
+ const body = response.body;
63
+ // if (error){
64
+ // res.send(error);
65
+ // return;
66
+ // }
54
67
  if (body.error){
55
68
  res.send(body.error);
56
69
  return;
@@ -98,6 +111,7 @@ function Auth(){
98
111
  return JSON.stringify(self.default(data,req),'','\t\r\n <br/>');
99
112
  }
100
113
  this.protected = [];
114
+ this.async = {login:true}
101
115
  return self;
102
116
  }
103
117
  module.exports = new Auth();
@@ -0,0 +1,268 @@
1
+ function Money() {
2
+ var self = this;
3
+ const plaid = require("plaid");
4
+ var environment = plaid.environments.development;
5
+ var plaidClient;
6
+ var ACCESS_TOKEN = "";
7
+ var PUBLIC_TOKEN = null;
8
+
9
+ var ACCESS_TOKENS
10
+ //initPlaidClient();
11
+
12
+ function initPlaidClient() {
13
+ //console.log('plaidinit',plaidClient);
14
+ if(plaidClient){ return;}
15
+ logit('initializing plaid client')
16
+ try {
17
+ var client_id = JOE.Cache.settings.PLAID_CLIENTID;
18
+ var secret = JOE.Cache.settings.PLAID_SECRET_development;
19
+ var public_key = JOE.Cache.settings.PLAID_PUBLIC_KEY;
20
+ ACCESS_TOKENS = JOE.Cache.settings.PLAID_ACCESS_TOKENS && JSON.parse(JOE.Cache.settings.PLAID_ACCESS_TOKENS);
21
+ //console.log(ACCESS_TOKENS);
22
+ plaidClient = new plaid.Client(
23
+ client_id,
24
+ secret,
25
+ public_key,
26
+ environment,
27
+ { version: "2018-05-22" }
28
+ );
29
+ return true;
30
+ } catch (e) {
31
+ logit("plaid client init error",e);
32
+ return e;
33
+ }
34
+ }
35
+ function checkPlaidClient(res){
36
+ var p = initPlaidClient();
37
+ if(!plaidClient){
38
+ res.jsonp(p);
39
+ return false;
40
+ }
41
+ return true;
42
+ }
43
+
44
+ function getAT(data){
45
+ var AT = ACCESS_TOKENS[data.bank];
46
+ if(!AT){return false;}
47
+ return AT.access_token;
48
+ }
49
+
50
+ this.getPublicToken = function(data, request, response){
51
+ var p = initPlaidClient();
52
+ if(!plaidClient){
53
+ return p;
54
+ }
55
+ var AT = ACCESS_TOKENS[data.bank];
56
+ if(!AT)return {error:'bank not found'}
57
+ logit(AT);
58
+ plaidClient.createPublicToken(AT.access_token, (err,data)=>{
59
+ response.jsonp({err,data})
60
+ });
61
+ return { use_callback: true };
62
+ }
63
+ this.getItem = function(data, request, response){
64
+ var p = initPlaidClient();
65
+ if(!plaidClient){
66
+ return p;
67
+ }
68
+ var AT = getAT(data);
69
+
70
+ if(!AT){return {error:'access token not found',ACCESS_TOKENS};}
71
+ //plaidClient.getItem(ACCESS_TOKEN, cb);
72
+ plaidClient.getItem(AT, (err,pdata)=>{
73
+ response.jsonp({err,pdata,data})
74
+ });
75
+ return { use_callback: true };
76
+ }
77
+
78
+ this.get_access_token = function(data, request, response) {
79
+ var p = initPlaidClient();
80
+ if(!plaidClient){
81
+ return p;
82
+ }
83
+ console.log(data);
84
+ PUBLIC_TOKEN = (request.query && request.query.public_token)
85
+ ||(request.body && request.body.public_token);
86
+ plaidClient.exchangePublicToken(PUBLIC_TOKEN, function(
87
+ error,
88
+ tokenResponse
89
+ ) {
90
+ if (error != null) {
91
+ console.log("Could not exchange public_token!" + "\n" + error);
92
+ return response.jsonp({ error });
93
+ }
94
+ ACCESS_TOKEN = tokenResponse.access_token;
95
+ ITEM_ID = tokenResponse.item_id;
96
+ console.log("Access Token: " + ACCESS_TOKEN);
97
+ console.log("Item ID: " + ITEM_ID);
98
+ response.jsonp({ error: false });
99
+ });
100
+ return { use_callback: true };
101
+ };
102
+ this.accounts = function(data, request, response){
103
+ var p = initPlaidClient();
104
+ if(!plaidClient){
105
+ return p;
106
+ }
107
+ var AT = getAT(data);
108
+ if(!AT)return {error:'bank not found'}
109
+ plaidClient.getAccounts(AT, (err, result) => {
110
+ // Handle err
111
+ if(err){
112
+ response.json({error:err});
113
+ }else{
114
+ const accounts = result.accounts;
115
+ response.jsonp(result);
116
+ }
117
+ });
118
+ return { use_callback: true };
119
+ }
120
+ this.accountNumbers = function(data, request, response){
121
+ var p = initPlaidClient();
122
+ if(!plaidClient){
123
+ return p;
124
+ }
125
+ var AT = getAT(data);
126
+ if(!AT)return {error:'bank not found'}
127
+ plaidClient.getAuth(AT,{}, (err, result) => {
128
+ // Handle err
129
+ if(err){
130
+ response.json({error:err});
131
+ }else{
132
+ var accounts = result.accounts;
133
+ response.jsonp(result);
134
+ }
135
+ });
136
+ return { use_callback: true };
137
+ }
138
+ this.transactions = function(data, request, response,specs={}){
139
+ var p = initPlaidClient();
140
+ if(!plaidClient){
141
+ return p;
142
+ }
143
+ var request = request || (data && data.request);
144
+ console.log('params',data);
145
+ var AT = request.query.at || (data.account && data.account.access_token)|| getAT(data);
146
+ var account_ids = request.query.account_ids && (request.query.account_ids.split(',')) || null;
147
+ console.log('accounts',account_ids);
148
+ console.log('AT',AT)
149
+ var curDate = new Date();
150
+ var start_date = data.start_date || curDate.getFullYear()+'-01-01';
151
+ var end_date = data.end_date || new Date().format('Y-m-d');
152
+ var count = data.count || 500;
153
+ if(!AT){return {error:'access token not found',ACCESS_TOKENS};}
154
+ plaidClient.getTransactions(AT, start_date, end_date, {count,account_ids}, (error,pdata)=>{
155
+
156
+ if(!specs.callback){
157
+ if(error){
158
+ return response.jsonp({error})
159
+ }
160
+ if(!request.query.full){
161
+ return response.jsonp({error,transactions:pdata.transactions})
162
+ }
163
+ response.jsonp({error,pdata,data})
164
+ }else{
165
+ logit('[money] using callback')
166
+ specs.callback(error,pdata,data)
167
+ return;
168
+ }
169
+ });
170
+
171
+ if(!specs.async){
172
+ return { use_callback: true };
173
+ }
174
+ }
175
+ this.institutions = function(data, req, res) {
176
+ var p = initPlaidClient();
177
+ if(!plaidClient){
178
+ return p;
179
+ }
180
+ var callback = function(err, mfaResponse, response) {
181
+ res.jsonp({
182
+ err: err,
183
+ mfaResponse: mfaResponse,
184
+ response: response,
185
+ environments: plaid.environments
186
+ });
187
+ };
188
+ if (data["id"]) {
189
+ plaid.getInstitution(data["id"], environment, callback);
190
+ } else {
191
+ plaid.getInstitutions(environment, callback);
192
+ }
193
+ return { use_callback: true };
194
+ };
195
+
196
+ this.authTest = function(data, req, res) {
197
+ if (!plaidClient) {
198
+ initPlaidClient();
199
+ }
200
+ try {
201
+ var user = data["username"] || "plaid_test";
202
+ var pass = data["password"] || "plaid_good";
203
+
204
+ var credentials = { username: user, password: pass };
205
+ var institution_type = "wells"; //wf
206
+ plaidClient.addAuthUser(institution_type, credentials, function(
207
+ err,
208
+ mfaResponse,
209
+ response
210
+ ) {
211
+ res.jsonp({ err: err, mfaResponse: mfaResponse, response: response });
212
+ });
213
+
214
+ return { use_callback: true };
215
+ } catch (e) {
216
+ return { error: e };
217
+ }
218
+ };
219
+
220
+ this.connect = function(data, req, res) {
221
+ if (!plaidClient) {
222
+ initPlaidClient();
223
+ }
224
+ try {
225
+ var user = data["username"] || "plaid_test";
226
+ var pass = data["password"] || "plaid_good";
227
+
228
+ var credentials = { username: user, password: pass };
229
+ var institution_type = "wells"; //wf
230
+ plaidClient.addConnectUser(institution_type, credentials, function(
231
+ err,
232
+ mfaResponse,
233
+ response
234
+ ) {
235
+ res.jsonp({ err: err, mfaResponse: mfaResponse, response: response });
236
+ });
237
+
238
+ return { use_callback: true };
239
+ } catch (e) {
240
+ return { error: e };
241
+ }
242
+ };
243
+
244
+ this.token = function(data, req, res) {
245
+ var public_token = data["token"];
246
+ var callback = function(err, mfaResponse, response) {
247
+ res.jsonp({ err: err, mfaResponse: mfaResponse, response: response });
248
+ };
249
+ try {
250
+ plaidClient.exchangeToken(public_token, callback);
251
+ } catch (e) {
252
+ return { error: e };
253
+ }
254
+ };
255
+
256
+ this.default = function(data, req, res) {
257
+ res.jsonp({ data: data });
258
+ return { use_callback: true };
259
+ };
260
+
261
+ this.html = function(data, req) {
262
+ logit('html route')
263
+ return JSON.stringify(self.default(data, req), "", "\t\r\n <br/>");
264
+ };
265
+ this.protected = [];
266
+ return self;
267
+ }
268
+ module.exports = new Money();