mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-30 10:39:17 -05:00
committed by
GitHub
parent
d027adc734
commit
bddc372650
@@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.(t|j)sx?$': '@swc/jest',
|
||||
},
|
||||
};
|
||||
@@ -12,7 +12,7 @@
|
||||
"build:node": "tsc --p tsconfig.dist.json",
|
||||
"proto:generate": "./bin/generate-proto",
|
||||
"build": "rm -rf dist && yarn run build:node && cp src/proto/sync_pb.d.ts dist/src/proto/",
|
||||
"test": "jest -c jest.config.js"
|
||||
"test": "vitest --globals"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-protobuf": "^3.12.4",
|
||||
@@ -20,12 +20,9 @@
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/core": "^1.5.3",
|
||||
"@swc/jest": "^0.2.36",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"jest": "^29.7.0",
|
||||
"ts-protoc-gen": "^0.15.0",
|
||||
"typescript": "^5.8.2"
|
||||
"typescript": "^5.8.2",
|
||||
"vitest": "^3.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`merkle trie adding an item works 1`] = `
|
||||
exports[`merkle trie > adding an item works 1`] = `
|
||||
{
|
||||
"1": {
|
||||
"2": {
|
||||
@@ -78,7 +78,7 @@ exports[`merkle trie adding an item works 1`] = `
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`merkle trie pruning works and keeps correct hashes 1`] = `
|
||||
exports[`merkle trie > pruning works and keeps correct hashes 1`] = `
|
||||
{
|
||||
"1": {
|
||||
"2": {
|
||||
@@ -246,7 +246,7 @@ exports[`merkle trie pruning works and keeps correct hashes 1`] = `
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`merkle trie pruning works and keeps correct hashes 2`] = `
|
||||
exports[`merkle trie > pruning works and keeps correct hashes 2`] = `
|
||||
{
|
||||
"1": {
|
||||
"2": {
|
||||
|
||||
@@ -3,10 +3,6 @@ import crypto from 'crypto';
|
||||
|
||||
const ENCRYPTION_ALGORITHM = 'aes-256-gcm' as const;
|
||||
|
||||
export async function sha256String(str) {
|
||||
return crypto.createHash('sha256').update(str).digest('base64');
|
||||
}
|
||||
|
||||
export function randomBytes(n) {
|
||||
return crypto.randomBytes(n);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,6 @@ function browserAlgorithmName(name) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function sha256String(str) {
|
||||
// @ts-expect-error TextEncoder might not accept an argument
|
||||
const inputBuffer = new TextEncoder('utf-8').encode(str).buffer;
|
||||
const buffer = await crypto.subtle.digest('sha-256', inputBuffer);
|
||||
const outputStr = Array.from(new Uint8Array(buffer))
|
||||
.map(n => String.fromCharCode(n))
|
||||
.join('');
|
||||
return btoa(outputStr);
|
||||
}
|
||||
|
||||
export function randomBytes(n) {
|
||||
return Buffer.from(crypto.getRandomValues(new Uint8Array(n)));
|
||||
}
|
||||
@@ -27,7 +17,7 @@ export function randomBytes(n) {
|
||||
export async function encrypt(masterKey, value) {
|
||||
const iv = crypto.getRandomValues(new Uint8Array(12));
|
||||
|
||||
let encrypted = await crypto.subtle.encrypt(
|
||||
const encryptedArrayBuffer = await crypto.subtle.encrypt(
|
||||
{
|
||||
name: browserAlgorithmName(ENCRYPTION_ALGORITHM),
|
||||
iv,
|
||||
@@ -37,19 +27,18 @@ export async function encrypt(masterKey, value) {
|
||||
value,
|
||||
);
|
||||
|
||||
encrypted = Buffer.from(encrypted);
|
||||
const encrypted = Buffer.from(encryptedArrayBuffer);
|
||||
|
||||
// Strip the auth tag off the end
|
||||
const authTag = encrypted.slice(-16);
|
||||
encrypted = encrypted.slice(0, -16);
|
||||
const strippedEncrypted = encrypted.slice(0, -16);
|
||||
|
||||
return {
|
||||
value: encrypted,
|
||||
value: strippedEncrypted,
|
||||
meta: {
|
||||
keyId: masterKey.getId(),
|
||||
algorithm: ENCRYPTION_ALGORITHM,
|
||||
iv: Buffer.from(iv).toString('base64'),
|
||||
// @ts-expect-error base64 argument is valid only on NodeJS
|
||||
authTag: authTag.toString('base64'),
|
||||
},
|
||||
};
|
||||
|
||||
6
upcoming-release-notes/4851.md
Normal file
6
upcoming-release-notes/4851.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [jfdoming]
|
||||
---
|
||||
|
||||
Move crdt to vitest
|
||||
@@ -70,16 +70,13 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@actual-app/crdt@workspace:packages/crdt"
|
||||
dependencies:
|
||||
"@swc/core": "npm:^1.5.3"
|
||||
"@swc/jest": "npm:^0.2.36"
|
||||
"@types/jest": "npm:^29.5.14"
|
||||
"@types/uuid": "npm:^9.0.8"
|
||||
google-protobuf: "npm:^3.12.4"
|
||||
jest: "npm:^29.7.0"
|
||||
murmurhash: "npm:^2.0.1"
|
||||
ts-protoc-gen: "npm:^0.15.0"
|
||||
typescript: "npm:^5.8.2"
|
||||
uuid: "npm:^9.0.1"
|
||||
vitest: "npm:^3.0.2"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user