Save credential (Password and private key etc) in webpage memory.
This commit is contained in:
@@ -572,8 +572,8 @@ class Builder {
|
||||
*/
|
||||
constructor(command) {
|
||||
this.cid = command.id();
|
||||
this.builder = (n, i, r, u, y, x) => {
|
||||
return command.builder(n, i, r, u, y, x);
|
||||
this.builder = (n, i, r, u, y, x, l) => {
|
||||
return command.builder(n, i, r, u, y, x, l);
|
||||
};
|
||||
this.launchCmd = (n, i, r, u, y, x) => {
|
||||
return command.launch(n, i, r, u, y, x);
|
||||
@@ -633,16 +633,25 @@ class Builder {
|
||||
* @param {controls.Controls} controls
|
||||
* @param {history.History} history
|
||||
* @param {object} config
|
||||
* @param {object} session
|
||||
* @param {function} done Callback which will be called when wizard is done
|
||||
*
|
||||
* @returns {Wizard} Command wizard
|
||||
*
|
||||
*/
|
||||
build(streams, controls, history, config, done) {
|
||||
build(streams, controls, history, config, session, done) {
|
||||
let subs = new subscribe.Subscribe();
|
||||
|
||||
return new Wizard(
|
||||
this.builder(new Info(this), config, streams, subs, controls, history),
|
||||
this.builder(
|
||||
new Info(this),
|
||||
config,
|
||||
session,
|
||||
streams,
|
||||
subs,
|
||||
controls,
|
||||
history
|
||||
),
|
||||
subs,
|
||||
done
|
||||
);
|
||||
|
||||
@@ -40,9 +40,10 @@ export class History {
|
||||
* @param {command.Info} info Command info
|
||||
* @param {Date} lastUsed Last used
|
||||
* @param {object} data Data
|
||||
* @param {object} sessionData Data which only available for current session
|
||||
*
|
||||
*/
|
||||
save(uname, title, lastUsed, info, data) {
|
||||
save(uname, title, lastUsed, info, data, sessionData) {
|
||||
for (let i in this.records) {
|
||||
if (this.records[i].uname !== uname) {
|
||||
continue;
|
||||
@@ -58,7 +59,8 @@ export class History {
|
||||
type: info.name(),
|
||||
color: info.color(),
|
||||
last: lastUsed.getTime(),
|
||||
data: data
|
||||
data: data,
|
||||
session: sessionData
|
||||
});
|
||||
|
||||
if (this.records.length > this.maxItems) {
|
||||
@@ -68,7 +70,28 @@ export class History {
|
||||
);
|
||||
}
|
||||
|
||||
this.saver(this, this.records);
|
||||
this.store();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save current records to storage
|
||||
*
|
||||
*/
|
||||
store() {
|
||||
let r = [];
|
||||
|
||||
for (let i in this.records) {
|
||||
r.push({
|
||||
uname: this.records[i].uname,
|
||||
title: this.records[i].title,
|
||||
type: this.records[i].type,
|
||||
color: this.records[i].color,
|
||||
last: this.records[i].last,
|
||||
data: this.records[i].data
|
||||
});
|
||||
}
|
||||
|
||||
this.saver(this, r);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +129,8 @@ export class History {
|
||||
type: this.records[i].type,
|
||||
color: this.records[i].color,
|
||||
last: new Date(this.records[i].last),
|
||||
data: this.records[i].data
|
||||
data: this.records[i].data,
|
||||
session: this.records[i].session
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -435,17 +435,23 @@ class Wizard {
|
||||
*
|
||||
* @param {command.Info} info
|
||||
* @param {object} config
|
||||
* @param {object} session
|
||||
* @param {streams.Streams} streams
|
||||
* @param {subscribe.Subscribe} subs
|
||||
* @param {controls.Controls} controls
|
||||
* @param {history.History} history
|
||||
*
|
||||
*/
|
||||
constructor(info, config, streams, subs, controls, history) {
|
||||
constructor(info, config, session, streams, subs, controls, history) {
|
||||
this.info = info;
|
||||
this.hasStarted = false;
|
||||
this.streams = streams;
|
||||
this.config = config;
|
||||
this.session = session
|
||||
? session
|
||||
: {
|
||||
credential: ""
|
||||
};
|
||||
this.step = subs;
|
||||
this.controls = controls;
|
||||
this.history = history;
|
||||
@@ -504,14 +510,16 @@ class Wizard {
|
||||
*
|
||||
* @param {stream.Sender} sender
|
||||
* @param {object} configInput
|
||||
* @param {object} sessionData
|
||||
*
|
||||
*/
|
||||
buildCommand(sender, configInput) {
|
||||
buildCommand(sender, configInput, sessionData) {
|
||||
let self = this;
|
||||
|
||||
let config = {
|
||||
user: common.strToUint8Array(configInput.user),
|
||||
auth: getAuthMethodFromStr(configInput.authentication),
|
||||
credential: sessionData.credential,
|
||||
host: address.parseHostPort(configInput.host, DEFAULT_PORT),
|
||||
fingerprint: configInput.fingerprint
|
||||
};
|
||||
@@ -581,7 +589,8 @@ class Wizard {
|
||||
configInput.user + "@" + configInput.host,
|
||||
new Date(),
|
||||
self.info,
|
||||
configInput
|
||||
configInput,
|
||||
sessionData
|
||||
);
|
||||
},
|
||||
async "connect.fingerprint"(rd, sd) {
|
||||
@@ -607,7 +616,11 @@ class Wizard {
|
||||
);
|
||||
},
|
||||
async "connect.credential"(rd, sd) {
|
||||
self.step.resolve(self.stepCredentialPrompt(rd, sd, config));
|
||||
self.step.resolve(
|
||||
self.stepCredentialPrompt(rd, sd, config, newCredential => {
|
||||
sessionData.credential = newCredential;
|
||||
})
|
||||
);
|
||||
},
|
||||
"@stdout"(rd) {},
|
||||
"@stderr"(rd) {},
|
||||
@@ -630,7 +643,7 @@ class Wizard {
|
||||
self.hasStarted = true;
|
||||
|
||||
self.streams.request(COMMAND_ID, sd => {
|
||||
return self.buildCommand(sd, this.config);
|
||||
return self.buildCommand(sd, this.config, this.session);
|
||||
});
|
||||
|
||||
return self.stepWaitForAcceptWait();
|
||||
@@ -644,12 +657,16 @@ class Wizard {
|
||||
self.hasStarted = true;
|
||||
|
||||
self.streams.request(COMMAND_ID, sd => {
|
||||
return self.buildCommand(sd, {
|
||||
user: r.user,
|
||||
authentication: r.authentication,
|
||||
host: r.host,
|
||||
fingerprint: ""
|
||||
});
|
||||
return self.buildCommand(
|
||||
sd,
|
||||
{
|
||||
user: r.user,
|
||||
authentication: r.authentication,
|
||||
host: r.host,
|
||||
fingerprint: ""
|
||||
},
|
||||
this.session
|
||||
);
|
||||
});
|
||||
|
||||
self.step.resolve(self.stepWaitForAcceptWait());
|
||||
@@ -712,10 +729,19 @@ class Wizard {
|
||||
);
|
||||
}
|
||||
|
||||
async stepCredentialPrompt(rd, sd, config) {
|
||||
async stepCredentialPrompt(rd, sd, config, newCredential) {
|
||||
let self = this,
|
||||
fields = [];
|
||||
|
||||
if (config.credential.length > 0) {
|
||||
sd.send(
|
||||
CLIENT_CONNECT_RESPOND_CREDENTIAL,
|
||||
new TextEncoder("utf-8").encode(config.credential)
|
||||
);
|
||||
|
||||
return this.stepContinueWaitForEstablishWait();
|
||||
}
|
||||
|
||||
switch (config.auth) {
|
||||
case AUTHMETHOD_PASSPHRASE:
|
||||
fields = [{ name: "Passphrase" }];
|
||||
@@ -743,6 +769,8 @@ class Wizard {
|
||||
new TextEncoder("utf-8").encode(vv)
|
||||
);
|
||||
|
||||
newCredential(vv);
|
||||
|
||||
self.step.resolve(self.stepContinueWaitForEstablishWait());
|
||||
},
|
||||
() => {
|
||||
@@ -779,8 +807,8 @@ export class Command {
|
||||
return "#3c8";
|
||||
}
|
||||
|
||||
builder(info, config, streams, subs, controls, history) {
|
||||
return new Wizard(info, config, streams, subs, controls, history);
|
||||
builder(info, config, session, streams, subs, controls, history) {
|
||||
return new Wizard(info, config, session, streams, subs, controls, history);
|
||||
}
|
||||
|
||||
launch(info, launcher, streams, subs, controls, history) {
|
||||
@@ -811,6 +839,7 @@ export class Command {
|
||||
host: host,
|
||||
authentication: auth
|
||||
},
|
||||
null,
|
||||
streams,
|
||||
subs,
|
||||
controls,
|
||||
|
||||
@@ -217,17 +217,19 @@ class Wizard {
|
||||
*
|
||||
* @param {command.Info} info
|
||||
* @param {object} config
|
||||
* @param {object} session
|
||||
* @param {streams.Streams} streams
|
||||
* @param {subscribe.Subscribe} subs
|
||||
* @param {controls.Controls} controls
|
||||
* @param {history.History} history
|
||||
*
|
||||
*/
|
||||
constructor(info, config, streams, subs, controls, history) {
|
||||
constructor(info, config, session, streams, subs, controls, history) {
|
||||
this.info = info;
|
||||
this.hasStarted = false;
|
||||
this.streams = streams;
|
||||
this.config = config;
|
||||
this.session = session;
|
||||
this.step = subs;
|
||||
this.controls = controls;
|
||||
this.history = history;
|
||||
@@ -279,9 +281,10 @@ class Wizard {
|
||||
*
|
||||
* @param {stream.Sender} sender
|
||||
* @param {object} configInput
|
||||
* @param {object} sessionData
|
||||
*
|
||||
*/
|
||||
buildCommand(sender, configInput) {
|
||||
buildCommand(sender, configInput, sessionData) {
|
||||
let self = this;
|
||||
|
||||
let parsedConfig = {
|
||||
@@ -333,7 +336,8 @@ class Wizard {
|
||||
configInput.host,
|
||||
new Date(),
|
||||
self.info,
|
||||
configInput
|
||||
configInput,
|
||||
sessionData
|
||||
);
|
||||
},
|
||||
async "connect.failed"(rd) {
|
||||
@@ -355,7 +359,7 @@ class Wizard {
|
||||
self.hasStarted = true;
|
||||
|
||||
self.streams.request(COMMAND_ID, sd => {
|
||||
return self.buildCommand(sd, this.config);
|
||||
return self.buildCommand(sd, this.config, this.session);
|
||||
});
|
||||
|
||||
return self.stepWaitForAcceptWait();
|
||||
@@ -369,7 +373,7 @@ class Wizard {
|
||||
self.hasStarted = true;
|
||||
|
||||
self.streams.request(COMMAND_ID, sd => {
|
||||
return self.buildCommand(sd, r);
|
||||
return self.buildCommand(sd, r, this.session);
|
||||
});
|
||||
|
||||
self.step.resolve(self.stepWaitForAcceptWait());
|
||||
@@ -399,8 +403,8 @@ export class Command {
|
||||
return "#6ac";
|
||||
}
|
||||
|
||||
builder(info, config, streams, subs, controls, history) {
|
||||
return new Wizard(info, config, streams, subs, controls, history);
|
||||
builder(info, config, session, streams, subs, controls, history) {
|
||||
return new Wizard(info, config, session, streams, subs, controls, history);
|
||||
}
|
||||
|
||||
launch(info, launcher, streams, subs, controls, history) {
|
||||
@@ -417,6 +421,7 @@ export class Command {
|
||||
{
|
||||
host: launcher
|
||||
},
|
||||
null,
|
||||
streams,
|
||||
subs,
|
||||
controls,
|
||||
|
||||
@@ -320,6 +320,7 @@ export default {
|
||||
this.controls,
|
||||
this.connector.historyRec,
|
||||
null,
|
||||
null,
|
||||
() => {}
|
||||
)
|
||||
};
|
||||
@@ -361,6 +362,7 @@ export default {
|
||||
this.controls,
|
||||
this.connector.historyRec,
|
||||
known.data,
|
||||
known.session,
|
||||
() => {}
|
||||
)
|
||||
};
|
||||
|
||||
@@ -109,3 +109,7 @@
|
||||
margin-right: 5px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#connect-known-list li h2.highlight::before {
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="lst-wrap" @click="select(known.data)">
|
||||
<h2 :title="known.data.title">{{ known.data.title }}</h2>
|
||||
<h2
|
||||
:title="known.data.title"
|
||||
:class="{ highlight: known.data.session }"
|
||||
>
|
||||
{{ known.data.title }}
|
||||
</h2>
|
||||
Last: {{ known.data.last.toLocaleString() }}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user