2020-11-05 11:13:06 +00:00
|
|
|
const domain = window.location.origin;
|
|
|
|
const provider = "AppServer";
|
2020-11-05 14:54:55 +00:00
|
|
|
const isDesktop = window["AscDesktopEditor"] || false;
|
|
|
|
const isEncryptionSupport =
|
|
|
|
(window["AscDesktopEditor"] &&
|
|
|
|
typeof window.AscDesktopEditor.cloudCryptoCommand === "function") ||
|
|
|
|
false;
|
2020-11-05 11:13:06 +00:00
|
|
|
|
2020-11-05 14:54:55 +00:00
|
|
|
if (isDesktop && isEncryptionSupport) {
|
2020-11-05 11:13:06 +00:00
|
|
|
window.cloudCryptoCommand = (type, params, callback) => {
|
|
|
|
switch (type) {
|
|
|
|
case "encryptionKeys":
|
|
|
|
return Desktop.setEncryptionKeys(params);
|
|
|
|
case "relogin":
|
|
|
|
return Desktop.relogin();
|
|
|
|
case "getsharingkeys":
|
|
|
|
return {};
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-11-03 06:52:05 +00:00
|
|
|
export class Desktop {
|
2020-11-05 11:13:06 +00:00
|
|
|
static regDesktop(displayName, email, userId) {
|
2020-11-03 06:52:05 +00:00
|
|
|
const data = {
|
2020-11-05 11:13:06 +00:00
|
|
|
displayName,
|
|
|
|
email,
|
|
|
|
domain,
|
|
|
|
provider,
|
|
|
|
userId,
|
2020-11-03 06:52:05 +00:00
|
|
|
};
|
2020-11-05 14:54:55 +00:00
|
|
|
if (isEncryptionSupport) {
|
|
|
|
data.cryptoEngineId = "{FFF0E1EB-13DB-4678-B67D-FF0A41DBBCEF}";
|
|
|
|
}
|
|
|
|
|
2020-11-05 11:13:06 +00:00
|
|
|
const execCommand = window.AscDesktopEditor.execCommand(
|
2020-11-03 06:52:05 +00:00
|
|
|
"portal:login",
|
|
|
|
JSON.stringify(data)
|
|
|
|
);
|
2020-11-05 11:13:06 +00:00
|
|
|
return execCommand;
|
2020-11-03 06:52:05 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 11:13:06 +00:00
|
|
|
static checkPwd() {
|
2020-11-03 06:52:05 +00:00
|
|
|
const data = {
|
2020-11-05 11:13:06 +00:00
|
|
|
domain,
|
|
|
|
emailInput: "login",
|
|
|
|
pwdInput: "password",
|
2020-11-03 06:52:05 +00:00
|
|
|
};
|
2020-11-05 11:13:06 +00:00
|
|
|
const execCommand = window.AscDesktopEditor.execCommand(
|
|
|
|
"portal:checkpwd",
|
2020-11-03 06:52:05 +00:00
|
|
|
JSON.stringify(data)
|
|
|
|
);
|
2020-11-05 11:13:06 +00:00
|
|
|
|
|
|
|
return execCommand;
|
2020-11-03 06:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static relogin() {
|
2020-11-05 11:13:06 +00:00
|
|
|
const data = {
|
|
|
|
domain,
|
|
|
|
onsuccess: "reload",
|
|
|
|
};
|
|
|
|
const execCommand = setTimeout(() => {
|
2020-11-03 06:52:05 +00:00
|
|
|
window.AscDesktopEditor.execCommand(
|
|
|
|
"portal:logout",
|
|
|
|
JSON.stringify(data)
|
|
|
|
);
|
|
|
|
}, 1000);
|
2020-11-05 11:13:06 +00:00
|
|
|
return execCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
static logout() {
|
|
|
|
const data = {
|
|
|
|
domain,
|
|
|
|
};
|
|
|
|
const execCommand = window.AscDesktopEditor.execCommand(
|
|
|
|
"portal:logout",
|
|
|
|
JSON.stringify(data)
|
|
|
|
);
|
|
|
|
return execCommand;
|
2020-11-03 06:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static setEncryptionKeys() {
|
2020-11-05 11:13:06 +00:00
|
|
|
return {
|
|
|
|
// publicKey: encryptionKeys.publicKey,
|
|
|
|
// privateKeyEnc: encryptionKeys.privateKeyEnc
|
|
|
|
};
|
2020-11-03 06:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static setAccess() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
static encryptionUploadDialog() {
|
|
|
|
return {};
|
|
|
|
}
|
2020-11-03 08:07:00 +00:00
|
|
|
|
|
|
|
static cloudCryptoCommand() {
|
|
|
|
const cryptoCommand = (window.cloudCryptoCommand = (
|
|
|
|
type,
|
|
|
|
params,
|
|
|
|
callback
|
|
|
|
) => {
|
|
|
|
switch (type) {
|
|
|
|
case "encryptionKeys":
|
2020-11-05 11:13:06 +00:00
|
|
|
return this.setEncryptionKeys(params);
|
2020-11-03 08:07:00 +00:00
|
|
|
case "relogin":
|
2020-11-05 11:13:06 +00:00
|
|
|
return this.relogin();
|
2020-11-03 08:07:00 +00:00
|
|
|
case "getsharingkeys":
|
|
|
|
return {};
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return cryptoCommand;
|
|
|
|
}
|
2020-11-03 06:52:05 +00:00
|
|
|
}
|