@deinossrl/dgp-agent 1.4.23 → 1.4.24
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/index.mjs +8 -16
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -206,9 +206,7 @@ let platformConfig = null;
|
|
|
206
206
|
* Obtiene la ruta del archivo de SSH key del agente
|
|
207
207
|
*/
|
|
208
208
|
function getDgpSshKeyPath() {
|
|
209
|
-
|
|
210
|
-
const path = require('path');
|
|
211
|
-
return path.join(os.homedir(), '.ssh', 'dgp_key');
|
|
209
|
+
return join(homedir(), '.ssh', 'dgp_key');
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
/**
|
|
@@ -216,19 +214,15 @@ function getDgpSshKeyPath() {
|
|
|
216
214
|
*/
|
|
217
215
|
function saveSshKeyLocally(sshPrivateKey) {
|
|
218
216
|
try {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const sshDir = path.join(os.homedir(), '.ssh');
|
|
224
|
-
if (!fs.existsSync(sshDir)) {
|
|
225
|
-
fs.mkdirSync(sshDir, { recursive: true, mode: 0o700 });
|
|
217
|
+
const sshDir = join(homedir(), '.ssh');
|
|
218
|
+
if (!existsSync(sshDir)) {
|
|
219
|
+
mkdirSync(sshDir, { recursive: true, mode: 0o700 });
|
|
226
220
|
}
|
|
227
221
|
|
|
228
222
|
const keyPath = getDgpSshKeyPath();
|
|
229
223
|
// Normalizar saltos de línea
|
|
230
224
|
const normalizedKey = sshPrivateKey.replace(/\\n/g, '\n').replace(/\r\n/g, '\n');
|
|
231
|
-
|
|
225
|
+
writeFileSync(keyPath, normalizedKey, { mode: 0o600 });
|
|
232
226
|
|
|
233
227
|
return keyPath;
|
|
234
228
|
} catch (e) {
|
|
@@ -242,10 +236,9 @@ function saveSshKeyLocally(sshPrivateKey) {
|
|
|
242
236
|
*/
|
|
243
237
|
function loadLocalSshKey() {
|
|
244
238
|
try {
|
|
245
|
-
const fs = require('fs');
|
|
246
239
|
const keyPath = getDgpSshKeyPath();
|
|
247
|
-
if (
|
|
248
|
-
return
|
|
240
|
+
if (existsSync(keyPath)) {
|
|
241
|
+
return readFileSync(keyPath, 'utf8');
|
|
249
242
|
}
|
|
250
243
|
return null;
|
|
251
244
|
} catch (e) {
|
|
@@ -257,8 +250,7 @@ function loadLocalSshKey() {
|
|
|
257
250
|
* Verifica si hay una SSH key guardada localmente
|
|
258
251
|
*/
|
|
259
252
|
function hasLocalSshKey() {
|
|
260
|
-
|
|
261
|
-
return fs.existsSync(getDgpSshKeyPath());
|
|
253
|
+
return existsSync(getDgpSshKeyPath());
|
|
262
254
|
}
|
|
263
255
|
|
|
264
256
|
// Versión del agente
|