diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 9d5a27d90..c4755b586 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -1,18 +1,19 @@
module.exports = {
+ ignorePatterns: ['**/*.css'],
env: {
browser: true,
es2021: true,
},
extends: [
- "eslint:recommended",
- "plugin:react/recommended",
- "plugin:react-hooks/recommended",
- "plugin:@typescript-eslint/eslint-recommended",
- "plugin:@typescript-eslint/recommended",
+ 'eslint:recommended',
+ 'plugin:react/recommended',
+ 'plugin:react-hooks/recommended',
+ 'plugin:@typescript-eslint/eslint-recommended',
+ 'plugin:@typescript-eslint/recommended',
'airbnb',
'prettier',
],
- parser: "@typescript-eslint/parser",
+ parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
@@ -20,46 +21,40 @@ module.exports = {
ecmaVersion: 'latest',
sourceType: 'module',
},
- "globals": {
- JSX: "readonly"
+ globals: {
+ JSX: 'readonly',
},
- plugins: [
- 'react',
- '@typescript-eslint'
- ],
+ plugins: ['react', '@typescript-eslint'],
rules: {
'linebreak-style': 0,
'no-underscore-dangle': 0,
- "no-shadow": "off",
+ 'no-shadow': 'off',
- "import/prefer-default-export": "off",
- "import/extensions": "off",
- "import/no-unresolved": "off",
- "import/no-extraneous-dependencies": [
- "error",
+ 'import/prefer-default-export': 'off',
+ 'import/extensions': 'off',
+ 'import/no-unresolved': 'off',
+ 'import/no-extraneous-dependencies': [
+ 'error',
{
devDependencies: true,
},
],
- 'react/no-unstable-nested-components': [
+ 'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
+ 'react/jsx-filename-extension': [
'error',
- { allowAsProps: true },
- ],
- "react/jsx-filename-extension": [
- "error",
{
- extensions: [".tsx", ".jsx"],
+ extensions: ['.tsx', '.jsx'],
},
],
- "react/require-default-props": "off",
- "react/jsx-props-no-spreading": "off",
- "react-hooks/rules-of-hooks": "error",
- "react-hooks/exhaustive-deps": "error",
+ 'react/require-default-props': 'off',
+ 'react/jsx-props-no-spreading': 'off',
+ 'react-hooks/rules-of-hooks': 'error',
+ 'react-hooks/exhaustive-deps': 'error',
- "@typescript-eslint/no-unused-vars": "error",
- "@typescript-eslint/no-shadow": "error"
+ '@typescript-eslint/no-unused-vars': 'error',
+ '@typescript-eslint/no-shadow': 'error',
},
overrides: [
{
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 76fc578ab..f7887c4e9 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -40,12 +40,12 @@ body:
id: info
attributes:
label: Platform and versions
- description: "Provide OS, browser and Cinny version with your Homeserver."
+ description: 'Provide OS, browser and Cinny version with your Homeserver.'
placeholder: |
- 1. OS: [e.g. Windows 10, MacOS]
- 2. Browser: [e.g. chrome 99.5, firefox 97.2]
- 3. Cinny version: [e.g. 1.8.1 (app.cinny.in)]
- 4. Matrix homeserver: [e.g. matrix.org]
+ 1. OS: [e.g. Windows 10, MacOS]
+ 2. Browser: [e.g. chrome 99.5, firefox 97.2]
+ 3. Cinny version: [e.g. 1.8.1 (app.cinny.in)]
+ 4. Matrix homeserver: [e.g. matrix.org]
render: shell
validations:
required: true
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index 412d5181d..04c181229 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -16,7 +16,7 @@ body:
attributes:
label: "Describe the solution you'd like"
description: A clear description of what change you would like
- placeholder: "I would like to..."
+ placeholder: 'I would like to...'
validations:
required: true
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 1292f1d24..d481c26ba 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,8 +1,8 @@
### Description
-
+
Fixes #
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
index 2dd642df5..2a84c3241 100644
--- a/.github/SECURITY.md
+++ b/.github/SECURITY.md
@@ -1,3 +1,3 @@
# Reporting a Vulnerability
-**If you've found a security vulnerability, please report it to cinnyapp@gmail.com**
\ No newline at end of file
+**If you've found a security vulnerability, please report it to cinnyapp@gmail.com**
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index c5a31bb7b..d59f55cc4 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -2,29 +2,29 @@
version: 2
updates:
-# - package-ecosystem: npm
-# directory: /
-# schedule:
-# interval: weekly
-# day: "tuesday"
-# time: "01:00"
-# timezone: "Asia/Kolkata"
-# open-pull-requests-limit: 15
+ # - package-ecosystem: npm
+ # directory: /
+ # schedule:
+ # interval: weekly
+ # day: "tuesday"
+ # time: "01:00"
+ # timezone: "Asia/Kolkata"
+ # open-pull-requests-limit: 15
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- day: "tuesday"
- time: "01:00"
- timezone: "Asia/Kolkata"
+ day: 'tuesday'
+ time: '01:00'
+ timezone: 'Asia/Kolkata'
open-pull-requests-limit: 5
- package-ecosystem: docker
directory: /
schedule:
interval: weekly
- day: "tuesday"
- time: "01:00"
- timezone: "Asia/Kolkata"
+ day: 'tuesday'
+ time: '01:00'
+ timezone: 'Asia/Kolkata'
open-pull-requests-limit: 5
diff --git a/.github/workflows/deploy-pull-request.yml b/.github/workflows/deploy-pull-request.yml
index b330c3c1c..2b5d13808 100644
--- a/.github/workflows/deploy-pull-request.yml
+++ b/.github/workflows/deploy-pull-request.yml
@@ -2,8 +2,8 @@ name: Deploy PR to Netlify
on:
workflow_run:
- workflows: ["Build pull request"]
- types: [completed]
+ workflows: ['Build pull request']
+ types: [completed]
jobs:
deploy-pull-request:
@@ -35,7 +35,7 @@ jobs:
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654
with:
publish-dir: dist
- deploy-message: "Deploy PR ${{ steps.pr.outputs.id }}"
+ deploy-message: 'Deploy PR ${{ steps.pr.outputs.id }}'
alias: ${{ steps.pr.outputs.id }}
# These don't work because we're in workflow_run
enable-pull-request-comment: false
@@ -52,5 +52,5 @@ jobs:
pr_number: ${{ steps.pr.outputs.id }}
comment_tag: ${{ steps.pr.outputs.id }}
message: |
- Preview: ${{ steps.netlify.outputs.deploy-url }}
- ⚠️ Exercise caution. Use test accounts. ⚠️
\ No newline at end of file
+ Preview: ${{ steps.netlify.outputs.deploy-url }}
+ ⚠️ Exercise caution. Use test accounts. ⚠️
diff --git a/.github/workflows/lockfile.yml b/.github/workflows/lockfile.yml
index be52eb50a..afc1d62a9 100644
--- a/.github/workflows/lockfile.yml
+++ b/.github/workflows/lockfile.yml
@@ -23,4 +23,4 @@ jobs:
collapsibleThreshold: 25
failOnDowngrade: false
path: package-lock.json
- updateComment: true
\ No newline at end of file
+ updateComment: true
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8272ea1e4..8ee79efe4 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,5 +1,8 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
- "typescript.tsdk": "node_modules/typescript/lib"
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "[jsonc]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ }
}
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index f1ef5d468..37a7e9c8b 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:
-* Demonstrating empathy and kindness toward other people
-* Being respectful of differing opinions, viewpoints, and experiences
-* Giving and gracefully accepting constructive feedback
-* Accepting responsibility and apologizing to those affected by our mistakes,
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
-* Focusing on what is best not just for us as individuals, but for the
+- Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
-* The use of sexualized language or imagery, and sexual attention or
+- The use of sexualized language or imagery, and sexual attention or
advances of any kind
-* Trolling, insulting or derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or email
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email
address, without their explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
+- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
-standards, including sustained inappropriate behavior, harassment of an
+standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fea421b23..42fccadca 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,6 +5,7 @@ First off, thanks for taking the time to contribute! ❤️
All types of contributions are encouraged and valued. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
+>
> - Star the project
> - Tweet about it (tag @cinnyapp)
> - Refer this project in your project's readme
@@ -18,6 +19,7 @@ Bug reports and feature suggestions must use descriptive and concise titles and
## Pull requests
> ### Legal Notice
+>
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
**NOTE: If you want to add new features, please discuss with maintainers before coding or opening a pull request.** This is to ensure that we are on same track and following our roadmap.
@@ -26,9 +28,9 @@ Bug reports and feature suggestions must use descriptive and concise titles and
Example:
-|Not ideal|Better|
-|---|----|
-|Fixed markAllAsRead in RoomTimeline|Fix read marker when paginating room timeline|
+| Not ideal | Better |
+| ----------------------------------- | --------------------------------------------- |
+| Fixed markAllAsRead in RoomTimeline | Fix read marker when paginating room timeline |
It is not always possible to phrase every change in such a manner, but it is desired.
@@ -39,6 +41,7 @@ Also, we use [ESLint](https://eslint.org/) for clean and stylistically consisten
**For any query or design discussion, join our [Matrix room](https://matrix.to/#/#cinny:matrix.org).**
## Helpful links
+
- [BEM methodology](http://getbem.com/introduction/)
- [Atomic design](https://bradfrost.com/blog/post/atomic-web-design/)
- [Matrix JavaScript SDK documentation](https://matrix-org.github.io/matrix-js-sdk/index.html)
diff --git a/config.json b/config.json
index 644f0eb61..aed232e62 100644
--- a/config.json
+++ b/config.json
@@ -1,12 +1,6 @@
{
"defaultHomeserver": 1,
- "homeserverList": [
- "converser.eu",
- "matrix.org",
- "mozilla.org",
- "unredacted.org",
- "xmr.se"
- ],
+ "homeserverList": ["converser.eu", "matrix.org", "mozilla.org", "unredacted.org", "xmr.se"],
"allowCustomHomeservers": true,
"featuredCommunities": {
@@ -27,7 +21,7 @@
"#PrivSec.dev:arcticfoxes.net",
"#disroot:aria-net.org"
],
- "servers": [ "matrix.org", "mozilla.org", "unredacted.org" ]
+ "servers": ["matrix.org", "mozilla.org", "unredacted.org"]
},
"hashRouter": {
diff --git a/package.json b/package.json
index d996d6ee9..aff3d446a 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"scripts": {
"start": "vite",
"build": "vite build",
- "lint": "yarn check:eslint && yarn check:prettier",
+ "lint": "npm run check:eslint && npm run check:prettier",
"check:eslint": "eslint src/*",
"check:prettier": "prettier --check .",
"fix:prettier": "prettier --write .",
diff --git a/src/app/components/editor/output.ts b/src/app/components/editor/output.ts
index c5ab4d8c5..78e6b88e5 100644
--- a/src/app/components/editor/output.ts
+++ b/src/app/components/editor/output.ts
@@ -215,7 +215,7 @@ export const getMentions = (mx: MatrixClient, roomId: string, editor: Editor): M
if (node.name === '@room') {
mentionData.room = true;
}
-
+
if (isUserId(node.id) && node.id !== mx.getUserId()) {
mentionData.users.add(node.id);
}
diff --git a/src/app/components/message/Reaction.tsx b/src/app/components/message/Reaction.tsx
index ad572725f..b3d0b759e 100644
--- a/src/app/components/message/Reaction.tsx
+++ b/src/app/components/message/Reaction.tsx
@@ -29,8 +29,7 @@ export const Reaction = as<
{reaction.startsWith('mxc://') ? (
) : (
diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx
index fb7615410..98122e42b 100644
--- a/src/app/components/url-preview/UrlPreviewCard.tsx
+++ b/src/app/components/url-preview/UrlPreviewCard.tsx
@@ -30,7 +30,15 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
if (previewStatus.status === AsyncStatus.Error) return null;
const renderContent = (prev: IPreviewUrlResponse) => {
- const imgUrl = mxcUrlToHttp(mx, prev['og:image'] || '', useAuthentication, 256, 256, 'scale', false);
+ const imgUrl = mxcUrlToHttp(
+ mx,
+ prev['og:image'] || '',
+ useAuthentication,
+ 256,
+ 256,
+ 'scale',
+ false
+ );
return (
<>
diff --git a/src/app/features/lobby/LobbyHero.tsx b/src/app/features/lobby/LobbyHero.tsx
index 1cd0b8e26..22774476e 100644
--- a/src/app/features/lobby/LobbyHero.tsx
+++ b/src/app/features/lobby/LobbyHero.tsx
@@ -22,7 +22,9 @@ export function LobbyHero() {
const name = useRoomName(space);
const topic = useRoomTopic(space);
const avatarMxc = useRoomAvatar(space);
- const avatarUrl = avatarMxc ? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined : undefined;
+ const avatarUrl = avatarMxc
+ ? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined
+ : undefined;
return (
=
item: T | T[];
}
| {
- type: 'REPLACE';
- item: T;
- replacement: T;
+ type: 'REPLACE';
+ item: T;
+ replacement: T;
}
| {
type: 'DELETE';
@@ -34,9 +34,12 @@ export const createListAtom = () => {
return;
}
if (action.type === 'REPLACE') {
- set(baseListAtom, items.map((item) => item === action.item ? action.replacement : item));
+ set(
+ baseListAtom,
+ items.map((item) => (item === action.item ? action.replacement : item))
+ );
}
}
);
};
-export type TListAtom = ReturnType>;
\ No newline at end of file
+export type TListAtom = ReturnType>;
diff --git a/src/app/state/room/roomInputDrafts.ts b/src/app/state/room/roomInputDrafts.ts
index 85ae40bd4..afad4874a 100644
--- a/src/app/state/room/roomInputDrafts.ts
+++ b/src/app/state/room/roomInputDrafts.ts
@@ -20,9 +20,7 @@ export type TUploadItem = {
export type TUploadListAtom = ReturnType>;
-export const roomIdToUploadItemsAtomFamily = atomFamily(
- createListAtom
-);
+export const roomIdToUploadItemsAtomFamily = atomFamily(createListAtom);
export const roomUploadAtomFamily = createUploadAtomFamily();
diff --git a/src/client/initMatrix.ts b/src/client/initMatrix.ts
index 7c5a61ee4..28eced1a6 100644
--- a/src/client/initMatrix.ts
+++ b/src/client/initMatrix.ts
@@ -1,4 +1,9 @@
-import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from '$types/matrix-sdk';
+import {
+ createClient,
+ MatrixClient,
+ IndexedDBStore,
+ IndexedDBCryptoStore,
+} from '$types/matrix-sdk';
import { cryptoCallbacks } from './secretStorageKeys';
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
diff --git a/src/index.tsx b/src/index.tsx
index 0019a224f..fa2628efb 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -37,8 +37,7 @@ const mountApp = () => {
const rootContainer = document.getElementById('root');
if (rootContainer === null) {
- console.error('Root container element not found!');
- return;
+ throw new Error('Root container element not found!');
}
const root = createRoot(rootContainer);
diff --git a/src/util/colorMXID.js b/src/util/colorMXID.js
index 95600d29e..152e8925e 100644
--- a/src/util/colorMXID.js
+++ b/src/util/colorMXID.js
@@ -10,7 +10,7 @@ function hashCode(str) {
for (i = 0; i < str.length; i += 1) {
chr = str.charCodeAt(i);
// eslint-disable-next-line no-bitwise
- hash = ((hash << 5) - hash) + chr;
+ hash = (hash << 5) - hash + chr;
// eslint-disable-next-line no-bitwise
hash |= 0;
}
diff --git a/src/util/cryptE2ERoomKeys.js b/src/util/cryptE2ERoomKeys.js
index 50254a3cd..d80ef316a 100644
--- a/src/util/cryptE2ERoomKeys.js
+++ b/src/util/cryptE2ERoomKeys.js
@@ -37,7 +37,7 @@ async function deriveKeys(salt, iterations, password) {
new TextEncoder().encode(password),
{ name: 'PBKDF2' },
false,
- ['deriveBits'],
+ ['deriveBits']
);
} catch (e) {
throw friendlyError(`subtleCrypto.importKey failed: ${e}`, cryptoFailMsg());
@@ -53,40 +53,38 @@ async function deriveKeys(salt, iterations, password) {
hash: 'SHA-512',
},
key,
- 512,
+ 512
);
} catch (e) {
throw friendlyError(`subtleCrypto.deriveBits failed: ${e}`, cryptoFailMsg());
}
const now = new Date();
- console.log(`E2e import/export: deriveKeys took ${(now - start)}ms`);
+ console.log(`E2e import/export: deriveKeys took ${now - start}ms`);
const aesKey = keybits.slice(0, 32);
const hmacKey = keybits.slice(32);
- const aesProm = subtleCrypto.importKey(
- 'raw',
- aesKey,
- { name: 'AES-CTR' },
- false,
- ['encrypt', 'decrypt'],
- ).catch((e) => {
- throw friendlyError(`subtleCrypto.importKey failed for AES key: ${e}`, cryptoFailMsg());
- });
+ const aesProm = subtleCrypto
+ .importKey('raw', aesKey, { name: 'AES-CTR' }, false, ['encrypt', 'decrypt'])
+ .catch((e) => {
+ throw friendlyError(`subtleCrypto.importKey failed for AES key: ${e}`, cryptoFailMsg());
+ });
- const hmacProm = subtleCrypto.importKey(
- 'raw',
- hmacKey,
- {
- name: 'HMAC',
- hash: { name: 'SHA-256' },
- },
- false,
- ['sign', 'verify'],
- ).catch((e) => {
- throw friendlyError(`subtleCrypto.importKey failed for HMAC key: ${e}`, cryptoFailMsg());
- });
+ const hmacProm = subtleCrypto
+ .importKey(
+ 'raw',
+ hmacKey,
+ {
+ name: 'HMAC',
+ hash: { name: 'SHA-256' },
+ },
+ false,
+ ['sign', 'verify']
+ )
+ .catch((e) => {
+ throw friendlyError(`subtleCrypto.importKey failed for HMAC key: ${e}`, cryptoFailMsg());
+ });
// eslint-disable-next-line no-return-await
return await Promise.all([aesProm, hmacProm]);
@@ -177,7 +175,6 @@ function unpackMegolmKeyFile(data) {
return decodeBase64(fileStr.slice(dataStart, dataEnd));
}
-
/**
* ascii-armour a megolm key file
*
@@ -189,20 +186,20 @@ function unpackMegolmKeyFile(data) {
function packMegolmKeyFile(data) {
// we split into lines before base64ing, because encodeBase64 doesn't deal
// terribly well with large arrays.
- const LINE_LENGTH = ((72 * 4) / 3);
+ const LINE_LENGTH = (72 * 4) / 3;
const nLines = Math.ceil(data.length / LINE_LENGTH);
const lines = new Array(nLines + 3);
lines[0] = HEADER_LINE;
let o = 0;
let i;
for (i = 1; i <= nLines; i += 1) {
- lines[i] = encodeBase64(data.subarray(o, o+LINE_LENGTH));
+ lines[i] = encodeBase64(data.subarray(o, o + LINE_LENGTH));
o += LINE_LENGTH;
}
lines[i] = TRAILER_LINE;
i += 1;
lines[i] = '';
- return (new TextEncoder().encode(lines.join('\n'))).buffer;
+ return new TextEncoder().encode(lines.join('\n')).buffer;
}
export async function decryptMegolmKeyFile(data, password) {
@@ -225,7 +222,7 @@ export async function decryptMegolmKeyFile(data, password) {
const salt = body.subarray(1, 1 + 16);
const iv = body.subarray(17, 17 + 16);
- const iterations = body[33] << 24 | body[34] << 16 | body[35] << 8 | body[36];
+ const iterations = (body[33] << 24) | (body[34] << 16) | (body[35] << 8) | body[36];
const ciphertext = body.subarray(37, 37 + ciphertextLength);
const hmac = body.subarray(-32);
@@ -234,12 +231,7 @@ export async function decryptMegolmKeyFile(data, password) {
let isValid;
try {
- isValid = await subtleCrypto.verify(
- { name: 'HMAC' },
- hmacKey,
- hmac,
- toVerify,
- );
+ isValid = await subtleCrypto.verify({ name: 'HMAC' }, hmacKey, hmac, toVerify);
} catch (e) {
throw friendlyError(`subtleCrypto.verify failed: ${e}`, cryptoFailMsg());
}
@@ -256,7 +248,7 @@ export async function decryptMegolmKeyFile(data, password) {
length: 64,
},
aesKey,
- ciphertext,
+ ciphertext
);
} catch (e) {
throw friendlyError(`subtleCrypto.decrypt failed: ${e}`, cryptoFailMsg());
@@ -302,34 +294,33 @@ export async function encryptMegolmKeyFile(data, password, options) {
length: 64,
},
aesKey,
- encodedData,
+ encodedData
);
} catch (e) {
throw friendlyError('subtleCrypto.encrypt failed: ' + e, cryptoFailMsg());
}
const cipherArray = new Uint8Array(ciphertext);
- const bodyLength = (1+salt.length+iv.length+4+cipherArray.length+32);
+ const bodyLength = 1 + salt.length + iv.length + 4 + cipherArray.length + 32;
const resultBuffer = new Uint8Array(bodyLength);
let idx = 0;
resultBuffer[idx++] = 1; // version
- resultBuffer.set(salt, idx); idx += salt.length;
- resultBuffer.set(iv, idx); idx += iv.length;
+ resultBuffer.set(salt, idx);
+ idx += salt.length;
+ resultBuffer.set(iv, idx);
+ idx += iv.length;
resultBuffer[idx++] = kdfRounds >> 24;
resultBuffer[idx++] = (kdfRounds >> 16) & 0xff;
resultBuffer[idx++] = (kdfRounds >> 8) & 0xff;
resultBuffer[idx++] = kdfRounds & 0xff;
- resultBuffer.set(cipherArray, idx); idx += cipherArray.length;
+ resultBuffer.set(cipherArray, idx);
+ idx += cipherArray.length;
const toSign = resultBuffer.subarray(0, idx);
let hmac;
try {
- hmac = await subtleCrypto.sign(
- { name: 'HMAC' },
- hmacKey,
- toSign,
- );
+ hmac = await subtleCrypto.sign({ name: 'HMAC' }, hmacKey, toSign);
} catch (e) {
throw friendlyError('subtleCrypto.sign failed: ' + e, cryptoFailMsg());
}