-
Notifications
You must be signed in to change notification settings - Fork 2
/
token.js
43 lines (35 loc) · 1.01 KB
/
token.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs= require('fs');
const sess = require('./session');
exports.generateMultipleTokens = function(argv,result){
var arr='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var token_arr=[];
for(var i=0;i<argv.generator;i++ ){
var output='';
for(var j=0;j<argv.tokenLen;j++){
output+=arr.charAt( Math.floor(Math.random() * 62) );
}
token_arr[i]=output;
}
result(token_arr);
};
exports.storeMultipleTokens = function(token_arr,argv,stored){
for (const token of token_arr){
sess[`${token}`]={
"mode":`${argv.mode}`,
"redirect_url":`${argv.redirectUrl}`,
"local_url":`${argv.localUrl}`
};
}
fs.writeFile("session.json",JSON.stringify(sess,null,2), function (err) {
if (err) throw err; else stored(1);
});
};
exports.deleteAllTokens = function(delete_tokens_callback){
fs.writeFile('session.json','{}', function (err) {
if (err) throw err;
else delete_tokens_callback(1);
});
};
exports.showAllTokens = function(show_all_callback){
show_all_callback(sess);
};