donbot-cli 1.0.9 → 1.0.11
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/cli/access.js +78 -1
- package/donbot.js +9 -1
- package/package.json +1 -1
package/cli/access.js
CHANGED
|
@@ -156,4 +156,81 @@ const createKey = async (user, app, description, expiration, options) => {
|
|
|
156
156
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
const createKeyProd = async (user, app, TOKEN_KEY, description, expiration, options) => {
|
|
160
|
+
|
|
161
|
+
console.log(`
|
|
162
|
+
_____ _______ __ _ ______ _______ _______
|
|
163
|
+
| | | || | | || _ | | || |
|
|
164
|
+
| _ | | _ || || || | | | | _ ||_ _|
|
|
165
|
+
| | | || | | || || | | | | | | |
|
|
166
|
+
| |_| | | |_| || _ || _ | | |_| | | |
|
|
167
|
+
| | | || | | || |_| | | | | |
|
|
168
|
+
|____| |_______||_| |___||_____| |_______| |___|
|
|
169
|
+
|
|
170
|
+
DonBot CLI - Herramienta para operaciones automatizadas.
|
|
171
|
+
`);
|
|
172
|
+
|
|
173
|
+
console.log("Crear llave...");
|
|
174
|
+
|
|
175
|
+
if (!user || !app || !TOKEN_KEY || !description || !expiration) {
|
|
176
|
+
console.error('❌ Verifique que los siguientes valores estén definidos: mail, first_name, last_name, password.');
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
let today = new Date().toISOString();
|
|
182
|
+
|
|
183
|
+
const payload = {
|
|
184
|
+
user: user,
|
|
185
|
+
app: app,
|
|
186
|
+
creationDate: today,
|
|
187
|
+
expiresIn: expiration
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
let expiresobj;
|
|
191
|
+
let expiresday;
|
|
192
|
+
if(expiration == "noexpire"){
|
|
193
|
+
expiresobj = "";
|
|
194
|
+
expiresday = expiration;
|
|
195
|
+
}else{
|
|
196
|
+
expiresobj = {
|
|
197
|
+
expiresIn: expiration
|
|
198
|
+
};
|
|
199
|
+
expiresday = expiration;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const access_token = jwt.sign(payload, TOKEN_KEY, expiresobj);
|
|
203
|
+
|
|
204
|
+
let keydata = {
|
|
205
|
+
user: user,
|
|
206
|
+
app: app,
|
|
207
|
+
description: description,
|
|
208
|
+
key: access_token,
|
|
209
|
+
creationDate: today,
|
|
210
|
+
expirationDate: expiresday,
|
|
211
|
+
active: true
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
console.log("Inserta este registro en la coleccion accesstokens");
|
|
216
|
+
console.log(keydata);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
console.error("❌ Error en la creación de usuario:", error.message);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let keyreso = {
|
|
223
|
+
user: keydata.user,
|
|
224
|
+
app: app,
|
|
225
|
+
description: keydata.description,
|
|
226
|
+
key: keydata.key
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
console.log("✅ Usuario creado exitosamente el usuario " + user + ".");
|
|
230
|
+
console.table(keyreso);
|
|
231
|
+
|
|
232
|
+
process.exit(0);
|
|
233
|
+
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
module.exports = { createKey, createKeyProd, registry };
|
package/donbot.js
CHANGED
|
@@ -11,7 +11,7 @@ const flows = require('./cli/flows');
|
|
|
11
11
|
|
|
12
12
|
//Version
|
|
13
13
|
program
|
|
14
|
-
.version("DonBot 1.0.
|
|
14
|
+
.version("DonBot 1.0.11")
|
|
15
15
|
.description( `
|
|
16
16
|
_____ _______ __ _ ______ _______ _______
|
|
17
17
|
| | | || | | || _ | | || |
|
|
@@ -43,6 +43,14 @@ program.
|
|
|
43
43
|
access.createKey(user, app, description, expiration, options);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
program.
|
|
47
|
+
command("prodaccess <user> <app> <TOKEN_KEY> <description> <expiration>").
|
|
48
|
+
alias("pac").
|
|
49
|
+
description("Crea un App Key que se debera usar en prod , para una key sin expiracion enviar el valor noexpire en lugar del numero de dias u horas (2 days, 10h, 7d)").
|
|
50
|
+
action((user, app, TOKEN_KEY, description, expiration, options) => {
|
|
51
|
+
access.createKeyProd(user, app, TOKEN_KEY, description, expiration, options);
|
|
52
|
+
});
|
|
53
|
+
|
|
46
54
|
|
|
47
55
|
//Lectura de archivo
|
|
48
56
|
/*program.
|