From b79631a35d4176469b1e232d36a61d40ef111b34 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 4 Jun 2023 20:51:08 +0200 Subject: [PATCH] setContent refactoring --- package-lock.json | 164 ++++++++++---------- package.json | 12 +- src/becca/entities/abstract_becca_entity.js | 25 +-- 3 files changed, 103 insertions(+), 98 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8874c76dc..d47b77125 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "compression": "1.7.4", "cookie-parser": "1.4.6", "csurf": "1.11.0", - "dayjs": "1.11.7", + "dayjs": "1.11.8", "dayjs-plugin-utc": "0.1.2", "debounce": "1.2.1", "ejs": "3.1.9", @@ -50,7 +50,7 @@ "jsdom": "22.1.0", "mime-types": "2.1.35", "multer": "1.4.5-lts.1", - "node-abi": "3.40.0", + "node-abi": "3.43.0", "normalize-strings": "1.1.1", "open": "8.4.1", "rand-token": "1.0.1", @@ -79,11 +79,11 @@ }, "devDependencies": { "cross-env": "7.0.3", - "electron": "25.0.0-beta.8", + "electron": "25.0.1", "electron-builder": "23.6.0", "electron-packager": "17.1.1", "electron-rebuild": "3.2.9", - "eslint": "8.41.0", + "eslint": "8.42.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.8.0", "eslint-plugin-import": "2.27.5", @@ -99,8 +99,8 @@ "nodemon": "2.0.22", "prettier": "2.8.8", "rcedit": "3.0.1", - "webpack": "5.84.1", - "webpack-cli": "5.1.1" + "webpack": "5.85.0", + "webpack-cli": "5.1.3" }, "optionalDependencies": { "electron-installer-debian": "3.1.0" @@ -450,9 +450,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -474,9 +474,9 @@ "dev": true }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -1655,9 +1655,9 @@ } }, "node_modules/@webpack-cli/configtest": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.0.tgz", - "integrity": "sha512-K/vuv72vpfSEZoo5KIU0a2FsEoYdW0DUMtMpB5X3LlUwshetMZRZRxB7sCsVji/lFaSxtQQ3aM9O4eMolXkU9w==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.1.tgz", + "integrity": "sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw==", "dev": true, "engines": { "node": ">=14.15.0" @@ -1668,9 +1668,9 @@ } }, "node_modules/@webpack-cli/info": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz", - "integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.2.tgz", + "integrity": "sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A==", "dev": true, "engines": { "node": ">=14.15.0" @@ -1681,9 +1681,9 @@ } }, "node_modules/@webpack-cli/serve": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.4.tgz", - "integrity": "sha512-0xRgjgDLdz6G7+vvDLlaRpFatJaJ69uTalZLRSMX5B3VUrDmXcrVA3+6fXXQgmYz7bY9AAgs348XQdmtLsK41A==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.5.tgz", + "integrity": "sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==", "dev": true, "engines": { "node": ">=14.15.0" @@ -3769,9 +3769,9 @@ } }, "node_modules/dayjs": { - "version": "1.11.7", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", - "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" + "version": "1.11.8", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.8.tgz", + "integrity": "sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==" }, "node_modules/dayjs-plugin-utc": { "version": "0.1.2", @@ -4198,9 +4198,9 @@ } }, "node_modules/electron": { - "version": "25.0.0-beta.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.8.tgz", - "integrity": "sha512-o3X0pkg1PyR/yawlSJzTXrh5GG8sH7jjtOzr74f0Zb4PnInzI3MIr8NopyhcGCW0JmOwFu+DLZX4bDlaLmtyGQ==", + "version": "25.0.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.0.1.tgz", + "integrity": "sha512-YD3xCrH01LiPeLlG90DWgMXJK69UxY4NiXKqXT12HOiXLqEaKrLWap+CiiS7J7SWUXz+4XOItQI8g1dtG7zkkA==", "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", @@ -5030,16 +5030,16 @@ } }, "node_modules/eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -9169,9 +9169,9 @@ "dev": true }, "node_modules/node-abi": { - "version": "3.40.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.40.0.tgz", - "integrity": "sha512-zNy02qivjjRosswoYmPi8hIKJRr8MpQyeKT6qlcq/OnOgA3Rhoae+IYOqsM9V5+JnHWmxKnWOT2GxvtqdtOCXA==", + "version": "3.43.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.43.0.tgz", + "integrity": "sha512-QB0MMv+tn9Ur2DtJrc8y09n0n6sw88CyDniWSX2cHW10goQXYPK9ZpFJOktDS4ron501edPX6h9i7Pg+RnH5nQ==", "dependencies": { "semver": "^7.3.5" }, @@ -12564,9 +12564,9 @@ } }, "node_modules/webpack": { - "version": "5.84.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.84.1.tgz", - "integrity": "sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==", + "version": "5.85.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.85.0.tgz", + "integrity": "sha512-7gazTiYqwo5OSqwH1tigLDL2r3qDeP2dOKYgd+LlXpsUMqDTklg6tOghexqky0/+6QY38kb/R/uRPUleuL43zg==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.3", @@ -12611,15 +12611,15 @@ } }, "node_modules/webpack-cli": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.1.tgz", - "integrity": "sha512-OLJwVMoXnXYH2ncNGU8gxVpUtm3ybvdioiTvHgUyBuyMLKiVvWy+QObzBsMtp5pH7qQoEuWgeEUQ/sU3ZJFzAw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.3.tgz", + "integrity": "sha512-MTuk7NUMvEHQUSXCpvUrF1q2p0FJS40dPFfqQvG3jTWcgv/8plBNz2Kv2HXZiLGPnfmSAA5uCtCILO1JBmmkfw==", "dev": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", - "@webpack-cli/configtest": "^2.1.0", - "@webpack-cli/info": "^2.0.1", - "@webpack-cli/serve": "^2.0.4", + "@webpack-cli/configtest": "^2.1.1", + "@webpack-cli/info": "^2.0.2", + "@webpack-cli/serve": "^2.0.5", "colorette": "^2.0.14", "commander": "^10.0.1", "cross-spawn": "^7.0.3", @@ -13324,9 +13324,9 @@ } }, "@eslint/js": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", - "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", + "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", "dev": true }, "@excalidraw/excalidraw": { @@ -13342,9 +13342,9 @@ "dev": true }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", @@ -14297,23 +14297,23 @@ } }, "@webpack-cli/configtest": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.0.tgz", - "integrity": "sha512-K/vuv72vpfSEZoo5KIU0a2FsEoYdW0DUMtMpB5X3LlUwshetMZRZRxB7sCsVji/lFaSxtQQ3aM9O4eMolXkU9w==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.1.tgz", + "integrity": "sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw==", "dev": true, "requires": {} }, "@webpack-cli/info": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz", - "integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.2.tgz", + "integrity": "sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A==", "dev": true, "requires": {} }, "@webpack-cli/serve": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.4.tgz", - "integrity": "sha512-0xRgjgDLdz6G7+vvDLlaRpFatJaJ69uTalZLRSMX5B3VUrDmXcrVA3+6fXXQgmYz7bY9AAgs348XQdmtLsK41A==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.5.tgz", + "integrity": "sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==", "dev": true, "requires": {} }, @@ -15929,9 +15929,9 @@ } }, "dayjs": { - "version": "1.11.7", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz", - "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==" + "version": "1.11.8", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.8.tgz", + "integrity": "sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==" }, "dayjs-plugin-utc": { "version": "0.1.2", @@ -16251,9 +16251,9 @@ } }, "electron": { - "version": "25.0.0-beta.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.0.0-beta.8.tgz", - "integrity": "sha512-o3X0pkg1PyR/yawlSJzTXrh5GG8sH7jjtOzr74f0Zb4PnInzI3MIr8NopyhcGCW0JmOwFu+DLZX4bDlaLmtyGQ==", + "version": "25.0.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.0.1.tgz", + "integrity": "sha512-YD3xCrH01LiPeLlG90DWgMXJK69UxY4NiXKqXT12HOiXLqEaKrLWap+CiiS7J7SWUXz+4XOItQI8g1dtG7zkkA==", "requires": { "@electron/get": "^2.0.0", "@types/node": "^18.11.18", @@ -16901,16 +16901,16 @@ "dev": true }, "eslint": { - "version": "8.41.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", - "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", + "version": "8.42.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", + "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.41.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint/js": "8.42.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", @@ -19970,9 +19970,9 @@ "dev": true }, "node-abi": { - "version": "3.40.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.40.0.tgz", - "integrity": "sha512-zNy02qivjjRosswoYmPi8hIKJRr8MpQyeKT6qlcq/OnOgA3Rhoae+IYOqsM9V5+JnHWmxKnWOT2GxvtqdtOCXA==", + "version": "3.43.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.43.0.tgz", + "integrity": "sha512-QB0MMv+tn9Ur2DtJrc8y09n0n6sw88CyDniWSX2cHW10goQXYPK9ZpFJOktDS4ron501edPX6h9i7Pg+RnH5nQ==", "requires": { "semver": "^7.3.5" } @@ -22556,9 +22556,9 @@ "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==" }, "webpack": { - "version": "5.84.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.84.1.tgz", - "integrity": "sha512-ZP4qaZ7vVn/K8WN/p990SGATmrL1qg4heP/MrVneczYtpDGJWlrgZv55vxaV2ul885Kz+25MP2kSXkPe3LZfmg==", + "version": "5.85.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.85.0.tgz", + "integrity": "sha512-7gazTiYqwo5OSqwH1tigLDL2r3qDeP2dOKYgd+LlXpsUMqDTklg6tOghexqky0/+6QY38kb/R/uRPUleuL43zg==", "dev": true, "requires": { "@types/eslint-scope": "^3.7.3", @@ -22588,15 +22588,15 @@ } }, "webpack-cli": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.1.tgz", - "integrity": "sha512-OLJwVMoXnXYH2ncNGU8gxVpUtm3ybvdioiTvHgUyBuyMLKiVvWy+QObzBsMtp5pH7qQoEuWgeEUQ/sU3ZJFzAw==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.3.tgz", + "integrity": "sha512-MTuk7NUMvEHQUSXCpvUrF1q2p0FJS40dPFfqQvG3jTWcgv/8plBNz2Kv2HXZiLGPnfmSAA5uCtCILO1JBmmkfw==", "dev": true, "requires": { "@discoveryjs/json-ext": "^0.5.0", - "@webpack-cli/configtest": "^2.1.0", - "@webpack-cli/info": "^2.0.1", - "@webpack-cli/serve": "^2.0.4", + "@webpack-cli/configtest": "^2.1.1", + "@webpack-cli/info": "^2.0.2", + "@webpack-cli/serve": "^2.0.5", "colorette": "^2.0.14", "commander": "^10.0.1", "cross-spawn": "^7.0.3", diff --git a/package.json b/package.json index b552b76d6..484705430 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "compression": "1.7.4", "cookie-parser": "1.4.6", "csurf": "1.11.0", - "dayjs": "1.11.7", + "dayjs": "1.11.8", "dayjs-plugin-utc": "0.1.2", "debounce": "1.2.1", "ejs": "3.1.9", @@ -71,7 +71,7 @@ "jsdom": "22.1.0", "mime-types": "2.1.35", "multer": "1.4.5-lts.1", - "node-abi": "3.40.0", + "node-abi": "3.43.0", "normalize-strings": "1.1.1", "open": "8.4.1", "rand-token": "1.0.1", @@ -97,11 +97,11 @@ }, "devDependencies": { "cross-env": "7.0.3", - "electron": "25.0.0-beta.8", + "electron": "25.0.1", "electron-builder": "23.6.0", "electron-packager": "17.1.1", "electron-rebuild": "3.2.9", - "eslint": "8.41.0", + "eslint": "8.42.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.8.0", "eslint-plugin-import": "2.27.5", @@ -117,8 +117,8 @@ "prettier": "2.8.8", "nodemon": "2.0.22", "rcedit": "3.0.1", - "webpack": "5.84.1", - "webpack-cli": "5.1.1" + "webpack": "5.85.0", + "webpack-cli": "5.1.3" }, "optionalDependencies": { "electron-installer-debian": "3.1.0" diff --git a/src/becca/entities/abstract_becca_entity.js b/src/becca/entities/abstract_becca_entity.js index 16e0f87c5..a7cce2375 100644 --- a/src/becca/entities/abstract_becca_entity.js +++ b/src/becca/entities/abstract_becca_entity.js @@ -149,20 +149,13 @@ class AbstractBeccaEntity { content = Buffer.isBuffer(content) ? content : Buffer.from(content); } - let unencryptedContentForHashCalculation = content; + const unencryptedContentForHashCalculation = this.getUnencryptedContentForHashCalculation(content); if (this.isProtected) { if (protectedSessionService.isProtectedSessionAvailable()) { content = protectedSessionService.encrypt(content); - - // this is to make sure that the calculated hash/blobId is different for an encrypted note and decrypted - const encryptedPrefixSuffix = "ThisIsEncryptedContent&^$#$1%&8*)(^%$5#@"; - unencryptedContentForHashCalculation = Buffer.isBuffer(unencryptedContentForHashCalculation) - ? Buffer.concat([Buffer.from(encryptedPrefixSuffix), unencryptedContentForHashCalculation, Buffer.from(encryptedPrefixSuffix)]) - : `${encryptedPrefixSuffix}${unencryptedContentForHashCalculation}${encryptedPrefixSuffix}`; - } - else { - throw new Error(`Cannot update content of blob since we're out of protected session.`); + } else { + throw new Error(`Cannot update content of blob since protected session is not available.`); } } @@ -176,6 +169,18 @@ class AbstractBeccaEntity { }); } + getUnencryptedContentForHashCalculation(unencryptedContent) { + if (this.isProtected) { + // a "random" prefix make sure that the calculated hash/blobId is different for an encrypted note and decrypted + const encryptedPrefixSuffix = "t$[nvQg7q)&_ENCRYPTED_?M:Bf&j3jr_"; + return Buffer.isBuffer(unencryptedContent) + ? Buffer.concat([Buffer.from(encryptedPrefixSuffix), unencryptedContent]) + : `${encryptedPrefixSuffix}${unencryptedContent}`; + } else { + return unencryptedContent; + } + } + /** @protected */ _saveBlob(content, unencryptedContentForHashCalculation, opts = {}) { let newBlobId;