Add remember my param to shareable link

pull/184/head
uzadude 2023-08-08 11:54:02 +03:00
rodzic 04d50a0ddc
commit 8039a80fd6
1 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -63,11 +63,17 @@ function init(staticryptConfig, templateConfig) {
* expose more information in the future we can do it without breaking the password_template
*/
async function handleDecryptionOfPage(password, isRememberChecked) {
const { isRememberEnabled, rememberDurationInDays, staticryptSaltUniqueVariableName } = staticryptConfig;
const { rememberExpirationKey, rememberPassphraseKey } = templateConfig;
const { staticryptSaltUniqueVariableName } = staticryptConfig;
// decrypt and replace the whole page
const hashedPassword = await cryptoEngine.hashPassword(password, staticryptSaltUniqueVariableName);
return handleDecryptionOfPageAndRemember(hashedPassword, isRememberChecked)
}
exports.handleDecryptionOfPage = handleDecryptionOfPage;
async function handleDecryptionOfPageAndRemember(hashedPassword, isRememberChecked) {
const { isRememberEnabled, rememberDurationInDays } = staticryptConfig;
const { rememberExpirationKey, rememberPassphraseKey } = templateConfig;
const isDecryptionSuccessful = await decryptAndReplaceHtml(hashedPassword);
@ -96,7 +102,6 @@ function init(staticryptConfig, templateConfig) {
hashedPassword,
};
}
exports.handleDecryptionOfPage = handleDecryptionOfPage;
/**
* Clear localstorage from staticrypt related values
@ -195,10 +200,12 @@ function init(staticryptConfig, templateConfig) {
function decryptOnLoadFromUrl() {
const passwordKey = "staticrypt_pwd";
const rememberMeKey = "remember_me";
// get the password from the query param
const queryParams = new URLSearchParams(window.location.search);
const hashedPasswordQuery = queryParams.get(passwordKey);
const rememberMeQuery = queryParams.get(rememberMeKey);
// get the password from the url fragment
const hashRegexMatch = window.location.hash.substring(1).match(new RegExp(passwordKey + "=(.*)"));
@ -207,7 +214,8 @@ function init(staticryptConfig, templateConfig) {
const hashedPassword = hashedPasswordFragment || hashedPasswordQuery;
if (hashedPassword) {
return decryptAndReplaceHtml(hashedPassword);
//return decryptAndReplaceHtml(hashedPassword);
return handleDecryptionOfPageAndRemember(hashedPassword, rememberMeQuery);
}
return false;