Allowing Connectors to save SessionInfo (which includes login secrets) to persistent storage when user is connecting via a Remote Preset
This commit is contained in:
@@ -620,11 +620,11 @@ class Builder {
|
|||||||
this.represeter = (n) => {
|
this.represeter = (n) => {
|
||||||
return command.represet(n);
|
return command.represet(n);
|
||||||
};
|
};
|
||||||
this.wizarder = (n, i, r, u, y, x, l) => {
|
this.wizarder = (n, i, r, u, y, x, l, p) => {
|
||||||
return command.wizard(n, i, r, u, y, x, l);
|
return command.wizard(n, i, r, u, y, x, l, p);
|
||||||
};
|
};
|
||||||
this.executer = (n, i, r, u, y, x, l) => {
|
this.executer = (n, i, r, u, y, x, l, p) => {
|
||||||
return command.execute(n, i, r, u, y, x, l);
|
return command.execute(n, i, r, u, y, x, l, p);
|
||||||
};
|
};
|
||||||
this.launchCmd = (n, i, r, u, y, x) => {
|
this.launchCmd = (n, i, r, u, y, x) => {
|
||||||
return command.launch(n, i, r, u, y, x);
|
return command.launch(n, i, r, u, y, x);
|
||||||
@@ -685,12 +685,13 @@ class Builder {
|
|||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
* @param {presets.Preset} preset
|
* @param {presets.Preset} preset
|
||||||
* @param {object} session
|
* @param {object} session
|
||||||
|
* @param {boolean} keepSession
|
||||||
* @param {function} done Callback which will be called when wizard is done
|
* @param {function} done Callback which will be called when wizard is done
|
||||||
*
|
*
|
||||||
* @returns {Wizard} Command wizard
|
* @returns {Wizard} Command wizard
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
wizard(streams, controls, history, preset, session, done) {
|
wizard(streams, controls, history, preset, session, keepSession, done) {
|
||||||
let subs = new subscribe.Subscribe();
|
let subs = new subscribe.Subscribe();
|
||||||
|
|
||||||
return new Wizard(
|
return new Wizard(
|
||||||
@@ -698,6 +699,7 @@ class Builder {
|
|||||||
new Info(this),
|
new Info(this),
|
||||||
preset,
|
preset,
|
||||||
session,
|
session,
|
||||||
|
keepSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
@@ -716,12 +718,13 @@ class Builder {
|
|||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
* @param {object} config
|
* @param {object} config
|
||||||
* @param {object} session
|
* @param {object} session
|
||||||
|
* @param {boolean} saveSession
|
||||||
* @param {function} done Callback which will be called when wizard is done
|
* @param {function} done Callback which will be called when wizard is done
|
||||||
*
|
*
|
||||||
* @returns {Wizard} Command wizard
|
* @returns {Wizard} Command wizard
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
execute(streams, controls, history, config, session, done) {
|
execute(streams, controls, history, config, session, saveSession, done) {
|
||||||
let subs = new subscribe.Subscribe();
|
let subs = new subscribe.Subscribe();
|
||||||
|
|
||||||
return new Wizard(
|
return new Wizard(
|
||||||
@@ -729,6 +732,7 @@ class Builder {
|
|||||||
new Info(this),
|
new Info(this),
|
||||||
config,
|
config,
|
||||||
session,
|
session,
|
||||||
|
saveSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
|
|||||||
@@ -71,9 +71,11 @@ export class History {
|
|||||||
* @param {Date} lastUsed Last used
|
* @param {Date} lastUsed Last used
|
||||||
* @param {object} data Data
|
* @param {object} data Data
|
||||||
* @param {object} sessionData Data which only available for current session
|
* @param {object} sessionData Data which only available for current session
|
||||||
|
* @param {boolean} keepSession Whether or not to keep session data when
|
||||||
|
* putting the item to the persistent storage
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
save(uname, title, lastUsed, info, data, sessionData) {
|
save(uname, title, lastUsed, info, data, sessionData, keepSession) {
|
||||||
const unameIdx = this.indexOf(uname);
|
const unameIdx = this.indexOf(uname);
|
||||||
|
|
||||||
if (unameIdx >= 0) {
|
if (unameIdx >= 0) {
|
||||||
@@ -87,7 +89,8 @@ export class History {
|
|||||||
color: info.color(),
|
color: info.color(),
|
||||||
last: lastUsed.getTime(),
|
last: lastUsed.getTime(),
|
||||||
data: data,
|
data: data,
|
||||||
session: sessionData
|
session: sessionData,
|
||||||
|
keepSession: keepSession,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.records.length > this.maxItems) {
|
if (this.records.length > this.maxItems) {
|
||||||
@@ -140,8 +143,11 @@ export class History {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.records[i].session = null;
|
this.records[i].session = null;
|
||||||
|
this.records[i].keepSession = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.store();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +168,8 @@ export class History {
|
|||||||
color: this.records[i].color,
|
color: this.records[i].color,
|
||||||
last: new Date(this.records[i].last),
|
last: new Date(this.records[i].last),
|
||||||
data: this.records[i].data,
|
data: this.records[i].data,
|
||||||
session: this.records[i].session
|
session: this.records[i].session,
|
||||||
|
keepSession: this.records[i].keepSession,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +192,9 @@ export class History {
|
|||||||
type: this.records[i].type,
|
type: this.records[i].type,
|
||||||
color: this.records[i].color,
|
color: this.records[i].color,
|
||||||
last: this.records[i].last,
|
last: this.records[i].last,
|
||||||
data: this.records[i].data
|
data: this.records[i].data,
|
||||||
|
session: this.records[i].keepSession ? this.records[i].session : null,
|
||||||
|
keepSession: this.records[i].keepSession,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +219,9 @@ export class History {
|
|||||||
type: records[i].type,
|
type: records[i].type,
|
||||||
color: records[i].color,
|
color: records[i].color,
|
||||||
last: records[i].last,
|
last: records[i].last,
|
||||||
data: records[i].data
|
data: records[i].data,
|
||||||
|
session: records[i].session,
|
||||||
|
keepSession: records[i].keepSession,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -509,9 +509,19 @@ class Wizard {
|
|||||||
* @param {subscribe.Subscribe} subs
|
* @param {subscribe.Subscribe} subs
|
||||||
* @param {controls.Controls} controls
|
* @param {controls.Controls} controls
|
||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
|
* @param {boolean} saveSession
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor(info, preset, session, streams, subs, controls, history) {
|
constructor(
|
||||||
|
info,
|
||||||
|
preset,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.preset = preset;
|
this.preset = preset;
|
||||||
this.hasStarted = false;
|
this.hasStarted = false;
|
||||||
@@ -521,6 +531,7 @@ class Wizard {
|
|||||||
: {
|
: {
|
||||||
credential: "",
|
credential: "",
|
||||||
};
|
};
|
||||||
|
this.saveSession = saveSession;
|
||||||
this.step = subs;
|
this.step = subs;
|
||||||
this.controls = controls.get("SSH");
|
this.controls = controls.get("SSH");
|
||||||
this.history = history;
|
this.history = history;
|
||||||
@@ -668,7 +679,8 @@ class Wizard {
|
|||||||
new Date(),
|
new Date(),
|
||||||
self.info,
|
self.info,
|
||||||
configInput,
|
configInput,
|
||||||
sessionData
|
sessionData,
|
||||||
|
self.saveSession
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async "connect.fingerprint"(rd, sd) {
|
async "connect.fingerprint"(rd, sd) {
|
||||||
@@ -899,17 +911,28 @@ class Executer extends Wizard {
|
|||||||
* @param {command.Info} info
|
* @param {command.Info} info
|
||||||
* @param {config} config
|
* @param {config} config
|
||||||
* @param {object} session
|
* @param {object} session
|
||||||
|
* @param {boolean} saveSession
|
||||||
* @param {streams.Streams} streams
|
* @param {streams.Streams} streams
|
||||||
* @param {subscribe.Subscribe} subs
|
* @param {subscribe.Subscribe} subs
|
||||||
* @param {controls.Controls} controls
|
* @param {controls.Controls} controls
|
||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor(info, config, session, streams, subs, controls, history) {
|
constructor(
|
||||||
|
info,
|
||||||
|
config,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
super(
|
super(
|
||||||
info,
|
info,
|
||||||
presets.emptyPreset(),
|
presets.emptyPreset(),
|
||||||
session,
|
session,
|
||||||
|
saveSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
@@ -961,15 +984,34 @@ export class Command {
|
|||||||
return "#3c8";
|
return "#3c8";
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard(info, preset, session, streams, subs, controls, history) {
|
wizard(info, preset, session, saveSession, streams, subs, controls, history) {
|
||||||
return new Wizard(info, preset, session, streams, subs, controls, history);
|
return new Wizard(
|
||||||
|
info,
|
||||||
|
preset,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(info, config, session, streams, subs, controls, history) {
|
execute(
|
||||||
|
info,
|
||||||
|
config,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
return new Executer(
|
return new Executer(
|
||||||
info,
|
info,
|
||||||
config,
|
config,
|
||||||
session,
|
session,
|
||||||
|
saveSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
|
|||||||
@@ -247,18 +247,29 @@ class Wizard {
|
|||||||
* @param {command.Info} info
|
* @param {command.Info} info
|
||||||
* @param {presets.Preset} preset
|
* @param {presets.Preset} preset
|
||||||
* @param {object} session
|
* @param {object} session
|
||||||
|
* @param {boolean} saveSession
|
||||||
* @param {streams.Streams} streams
|
* @param {streams.Streams} streams
|
||||||
* @param {subscribe.Subscribe} subs
|
* @param {subscribe.Subscribe} subs
|
||||||
* @param {controls.Controls} controls
|
* @param {controls.Controls} controls
|
||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor(info, preset, session, streams, subs, controls, history) {
|
constructor(
|
||||||
|
info,
|
||||||
|
preset,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.preset = preset;
|
this.preset = preset;
|
||||||
this.hasStarted = false;
|
this.hasStarted = false;
|
||||||
this.streams = streams;
|
this.streams = streams;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
this.saveSession = saveSession;
|
||||||
this.step = subs;
|
this.step = subs;
|
||||||
this.controls = controls.get("Telnet");
|
this.controls = controls.get("Telnet");
|
||||||
this.history = history;
|
this.history = history;
|
||||||
@@ -375,7 +386,8 @@ class Wizard {
|
|||||||
new Date(),
|
new Date(),
|
||||||
self.info,
|
self.info,
|
||||||
configInput,
|
configInput,
|
||||||
sessionData
|
sessionData,
|
||||||
|
self.saveSession
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async "connect.failed"(rd) {
|
async "connect.failed"(rd) {
|
||||||
@@ -457,17 +469,28 @@ class Executor extends Wizard {
|
|||||||
* @param {command.Info} info
|
* @param {command.Info} info
|
||||||
* @param {object} config
|
* @param {object} config
|
||||||
* @param {object} session
|
* @param {object} session
|
||||||
|
* @param {boolean} saveSession
|
||||||
* @param {streams.Streams} streams
|
* @param {streams.Streams} streams
|
||||||
* @param {subscribe.Subscribe} subs
|
* @param {subscribe.Subscribe} subs
|
||||||
* @param {controls.Controls} controls
|
* @param {controls.Controls} controls
|
||||||
* @param {history.History} history
|
* @param {history.History} history
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor(info, config, session, streams, subs, controls, history) {
|
constructor(
|
||||||
|
info,
|
||||||
|
config,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
super(
|
super(
|
||||||
info,
|
info,
|
||||||
presets.emptyPreset(),
|
presets.emptyPreset(),
|
||||||
session,
|
session,
|
||||||
|
saveSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
@@ -516,15 +539,34 @@ export class Command {
|
|||||||
return "#6ac";
|
return "#6ac";
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard(info, preset, session, streams, subs, controls, history) {
|
wizard(info, preset, session, saveSession, streams, subs, controls, history) {
|
||||||
return new Wizard(info, preset, session, streams, subs, controls, history);
|
return new Wizard(
|
||||||
|
info,
|
||||||
|
preset,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(info, config, session, streams, subs, controls, history) {
|
execute(
|
||||||
|
info,
|
||||||
|
config,
|
||||||
|
session,
|
||||||
|
saveSession,
|
||||||
|
streams,
|
||||||
|
subs,
|
||||||
|
controls,
|
||||||
|
history
|
||||||
|
) {
|
||||||
return new Executor(
|
return new Executor(
|
||||||
info,
|
info,
|
||||||
config,
|
config,
|
||||||
session,
|
session,
|
||||||
|
saveSession,
|
||||||
streams,
|
streams,
|
||||||
subs,
|
subs,
|
||||||
controls,
|
controls,
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ export default {
|
|||||||
self.connector.historyRec,
|
self.connector.historyRec,
|
||||||
presets.emptyPreset(),
|
presets.emptyPreset(),
|
||||||
null,
|
null,
|
||||||
|
false,
|
||||||
() => {}
|
() => {}
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -365,6 +366,7 @@ export default {
|
|||||||
self.connector.historyRec,
|
self.connector.historyRec,
|
||||||
preset.preset,
|
preset.preset,
|
||||||
null,
|
null,
|
||||||
|
true,
|
||||||
() => {}
|
() => {}
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -409,6 +411,7 @@ export default {
|
|||||||
self.connector.historyRec,
|
self.connector.historyRec,
|
||||||
known.data,
|
known.data,
|
||||||
known.session,
|
known.session,
|
||||||
|
known.keepSession,
|
||||||
() => {
|
() => {
|
||||||
self.connector.knowns = self.connector.historyRec.all();
|
self.connector.knowns = self.connector.historyRec.all();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user