25 Commits

Author SHA1 Message Date
static
66c3f2df71 데모를 위해 파일 용량 제한 추가, 비밀번호 변경 기능 삭제, 악용될 수 있는 API에 로깅 추가 2026-01-18 18:07:53 +09:00
static
385404ece2 Merge pull request #21 from kmc7468/dev
v0.9.1
2026-01-18 16:35:41 +09:00
static
9635d2a51b IndexedDB에 가끔 파일 및 디렉터리 정보를 저장하지 못하던 버그 수정 2026-01-18 16:32:06 +09:00
static
3b0cfd5a92 즐겨찾기 검색 필터를 재귀적으로 동작하도록 변경 2026-01-18 16:16:38 +09:00
static
2f6d35c335 모바일 환경에서 SearchBar의 레이아웃이 깨지는 문제 수정 2026-01-18 14:16:40 +09:00
static
ac6aaa18ca Merge pull request #20 from kmc7468/dev
v0.9.0
2026-01-18 13:30:15 +09:00
static
72babc532f 검색 필터에 즐겨찾기 여부 추가 2026-01-18 13:29:06 +09:00
static
63163d6279 파일 및 디렉터리 메타데이터 복호화 로직 리팩토링 2026-01-18 13:01:44 +09:00
static
4797ccfd23 FileRepo의 함수 중 디렉터리 관련된 함수들을 DirectoryRepo로 분리 2026-01-18 12:34:04 +09:00
static
14693160b8 사소한 리팩토링 2026-01-18 12:03:24 +09:00
static
bcb57bb12d IndexedDB에 즐겨찾기 여부를 항상 저장하도록 변경 2026-01-18 11:33:30 +09:00
static
ff6ea3a0b9 파일 페이지에서 즐겨찾기 설정이 가능하도록 변경 및 즐겨찾기에 추가된 경우 목록에서 즐겨찾기 여부를 아이콘으로 표시하도록 개선 2026-01-17 20:11:01 +09:00
static
420e30f677 즐겨찾기 기능 구현 2026-01-17 19:41:52 +09:00
static
befa535526 비효율적인 비디오 스트리밍 로직 개선 2026-01-17 18:25:54 +09:00
static
d8e18fb1d3 OR 조건 대신 IN 연산자를 사용하도록 일부 SQL 쿼리 수정 2026-01-16 10:24:32 +09:00
static
cb5105a355 패키지 버전 업데이트 2026-01-16 07:51:17 +09:00
static
7b621d6e98 Merge pull request #19 from kmc7468/dev
v0.8.0
2026-01-13 00:29:14 +09:00
static
3906ec4371 Merge pull request #17 from kmc7468/dev
v0.7.0
2026-01-06 07:50:16 +09:00
static
90ac5ba4c3 Merge pull request #15 from kmc7468/dev
v0.6.0
2025-12-27 14:22:26 +09:00
static
dfffa004ac Merge pull request #13 from kmc7468/dev
v0.5.1
2025-07-12 19:56:12 +09:00
static
0cd55a413d Merge pull request #12 from kmc7468/dev
v0.5.0
2025-07-12 06:01:08 +09:00
static
361d966a59 Merge pull request #10 from kmc7468/dev
v0.4.0
2025-01-30 21:06:50 +09:00
static
aef43b8bfa Merge pull request #6 from kmc7468/dev
v0.3.0
2025-01-18 13:29:09 +09:00
static
7f128cccf6 Merge pull request #5 from kmc7468/dev
v0.2.0
2025-01-13 03:53:14 +09:00
static
a198e5f6dc Merge pull request #2 from kmc7468/dev
v0.1.0
2025-01-09 06:24:31 +09:00
79 changed files with 1498 additions and 845 deletions

View File

@@ -13,6 +13,7 @@ node_modules
/library
/thumbnails
/uploads
/log
# OS
.DS_Store

1
.gitignore vendored
View File

@@ -11,6 +11,7 @@ node_modules
/library
/thumbnails
/uploads
/log
# OS
.DS_Store

View File

@@ -10,6 +10,7 @@ services:
- ./data/library:/app/data/library
- ./data/thumbnails:/app/data/thumbnails
- ./data/uploads:/app/data/uploads
- ./data/log:/app/data/log
environment:
# ArkVault
- DATABASE_HOST=database
@@ -22,6 +23,7 @@ services:
- LIBRARY_PATH=/app/data/library
- THUMBNAILS_PATH=/app/data/thumbnails
- UPLOADS_PATH=/app/data/uploads
- LOG_DIR=/app/data/log
# SvelteKit
- ADDRESS_HEADER=${TRUST_PROXY:+X-Forwarded-For}
- XFF_DEPTH=${TRUST_PROXY:-}

View File

@@ -1,7 +1,7 @@
{
"name": "arkvault",
"private": true,
"version": "0.8.0",
"version": "0.9.0",
"type": "module",
"scripts": {
"dev": "vite dev",
@@ -20,8 +20,8 @@
"@eslint/js": "^9.39.2",
"@iconify-json/material-symbols": "^1.2.51",
"@noble/hashes": "^2.0.1",
"@sveltejs/adapter-node": "^5.4.0",
"@sveltejs/kit": "^2.49.4",
"@sveltejs/adapter-node": "^5.5.1",
"@sveltejs/kit": "^2.49.5",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tanstack/svelte-virtual": "^3.13.18",
"@trpc/client": "^11.8.1",
@@ -37,23 +37,23 @@
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.14.0",
"eslint-plugin-tailwindcss": "^3.18.2",
"exifreader": "^4.35.0",
"exifreader": "^4.36.0",
"file-saver": "^2.0.5",
"globals": "^17.0.0",
"heic2any": "^0.0.4",
"kysely-ctl": "^0.19.0",
"kysely-ctl": "^0.20.0",
"lru-cache": "^11.2.4",
"mime": "^4.1.0",
"p-limit": "^7.2.0",
"prettier": "^3.7.4",
"prettier": "^3.8.0",
"prettier-plugin-svelte": "^3.4.1",
"prettier-plugin-tailwindcss": "^0.7.2",
"svelte": "^5.46.1",
"svelte": "^5.46.4",
"svelte-check": "^4.3.5",
"tailwindcss": "^3.4.19",
"typescript": "^5.9.3",
"typescript-eslint": "^8.52.0",
"unplugin-icons": "^22.5.0",
"typescript-eslint": "^8.53.0",
"unplugin-icons": "^23.0.1",
"vite": "^7.3.1"
},
"dependencies": {
@@ -62,7 +62,7 @@
"kysely": "^0.28.9",
"ms": "^2.1.3",
"node-schedule": "^2.1.1",
"pg": "^8.16.3",
"pg": "^8.17.1",
"superjson": "^2.2.6",
"uuid": "^13.0.0",
"zod": "^4.3.5"

366
pnpm-lock.yaml generated
View File

@@ -24,8 +24,8 @@ importers:
specifier: ^2.1.1
version: 2.1.1
pg:
specifier: ^8.16.3
version: 8.16.3
specifier: ^8.17.1
version: 8.17.1
superjson:
specifier: ^2.2.6
version: 2.2.6
@@ -49,17 +49,17 @@ importers:
specifier: ^2.0.1
version: 2.0.1
'@sveltejs/adapter-node':
specifier: ^5.4.0
version: 5.4.0(@sveltejs/kit@2.49.4(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))
specifier: ^5.5.1
version: 5.5.1(@sveltejs/kit@2.49.5(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))
'@sveltejs/kit':
specifier: ^2.49.4
version: 2.49.4(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
specifier: ^2.49.5
version: 2.49.5(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
'@sveltejs/vite-plugin-svelte':
specifier: ^6.2.4
version: 6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
version: 6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
'@tanstack/svelte-virtual':
specifier: ^3.13.18
version: 3.13.18(svelte@5.46.1)
version: 3.13.18(svelte@5.46.4)
'@trpc/client':
specifier: ^11.8.1
version: 11.8.1(@trpc/server@11.8.1(typescript@5.9.3))(typescript@5.9.3)
@@ -95,13 +95,13 @@ importers:
version: 10.1.8(eslint@9.39.2(jiti@1.21.7))
eslint-plugin-svelte:
specifier: ^3.14.0
version: 3.14.0(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.1)
version: 3.14.0(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.4)
eslint-plugin-tailwindcss:
specifier: ^3.18.2
version: 3.18.2(tailwindcss@3.4.19(yaml@2.8.0))
exifreader:
specifier: ^4.35.0
version: 4.35.0
specifier: ^4.36.0
version: 4.36.0
file-saver:
specifier: ^2.0.5
version: 2.0.5
@@ -112,8 +112,8 @@ importers:
specifier: ^0.0.4
version: 0.0.4
kysely-ctl:
specifier: ^0.19.0
version: 0.19.0(kysely@0.28.9)(typescript@5.9.3)
specifier: ^0.20.0
version: 0.20.0(kysely@0.28.9)(typescript@5.9.3)
lru-cache:
specifier: ^11.2.4
version: 11.2.4
@@ -124,20 +124,20 @@ importers:
specifier: ^7.2.0
version: 7.2.0
prettier:
specifier: ^3.7.4
version: 3.7.4
specifier: ^3.8.0
version: 3.8.0
prettier-plugin-svelte:
specifier: ^3.4.1
version: 3.4.1(prettier@3.7.4)(svelte@5.46.1)
version: 3.4.1(prettier@3.8.0)(svelte@5.46.4)
prettier-plugin-tailwindcss:
specifier: ^0.7.2
version: 0.7.2(prettier-plugin-svelte@3.4.1(prettier@3.7.4)(svelte@5.46.1))(prettier@3.7.4)
version: 0.7.2(prettier-plugin-svelte@3.4.1(prettier@3.8.0)(svelte@5.46.4))(prettier@3.8.0)
svelte:
specifier: ^5.46.1
version: 5.46.1
specifier: ^5.46.4
version: 5.46.4
svelte-check:
specifier: ^4.3.5
version: 4.3.5(picomatch@4.0.3)(svelte@5.46.1)(typescript@5.9.3)
version: 4.3.5(picomatch@4.0.3)(svelte@5.46.4)(typescript@5.9.3)
tailwindcss:
specifier: ^3.4.19
version: 3.4.19(yaml@2.8.0)
@@ -145,14 +145,14 @@ importers:
specifier: ^5.9.3
version: 5.9.3
typescript-eslint:
specifier: ^8.52.0
version: 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
specifier: ^8.53.0
version: 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
unplugin-icons:
specifier: ^22.5.0
version: 22.5.0(svelte@5.46.1)
specifier: ^23.0.1
version: 23.0.1(svelte@5.46.4)
vite:
specifier: ^7.3.1
version: 7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)
version: 7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)
packages:
@@ -606,13 +606,13 @@ packages:
peerDependencies:
acorn: ^8.9.0
'@sveltejs/adapter-node@5.4.0':
resolution: {integrity: sha512-NMsrwGVPEn+J73zH83Uhss/hYYZN6zT3u31R3IHAn3MiKC3h8fjmIAhLfTSOeNHr5wPYfjjMg8E+1gyFgyrEcQ==}
'@sveltejs/adapter-node@5.5.1':
resolution: {integrity: sha512-VpZdPNRPQuZRtgfAMETPWWKpZx9JwXmUUsgz/+eSpw/Oh7+2O1uZHlsQTuyfxydJHPrRzjfu/ItcJjY4oscCiQ==}
peerDependencies:
'@sveltejs/kit': ^2.4.0
'@sveltejs/kit@2.49.4':
resolution: {integrity: sha512-JFtOqDoU0DI/+QSG8qnq5bKcehVb3tCHhOG4amsSYth5/KgO4EkJvi42xSAiyKmXAAULW1/Zdb6lkgGEgSxdZg==}
'@sveltejs/kit@2.49.5':
resolution: {integrity: sha512-dCYqelr2RVnWUuxc+Dk/dB/SjV/8JBndp1UovCyCZdIQezd8TRwFLNZctYkzgHxRJtaNvseCSRsuuHPeUgIN/A==}
engines: {node: '>=18.13'}
hasBin: true
peerDependencies:
@@ -679,8 +679,8 @@ packages:
'@types/node-schedule@2.1.8':
resolution: {integrity: sha512-k00g6Yj/oUg/CDC+MeLHUzu0+OFxWbIqrFfDiLi6OPKxTujvpv29mHGM8GtKr7B+9Vv92FcK/8mRqi1DK5f3hA==}
'@types/node@25.0.6':
resolution: {integrity: sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==}
'@types/node@25.0.9':
resolution: {integrity: sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==}
'@types/pg@8.16.0':
resolution: {integrity: sha512-RmhMd/wD+CF8Dfo+cVIy3RR5cl8CyfXQ0tGgW6XBL8L4LM/UTEbNXYRbLwU6w+CgrKBNbrQWt4FUtTfaU5jSYQ==}
@@ -688,63 +688,63 @@ packages:
'@types/resolve@1.20.2':
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
'@typescript-eslint/eslint-plugin@8.52.0':
resolution: {integrity: sha512-okqtOgqu2qmZJ5iN4TWlgfF171dZmx2FzdOv2K/ixL2LZWDStL8+JgQerI2sa8eAEfoydG9+0V96m7V+P8yE1Q==}
'@typescript-eslint/eslint-plugin@8.53.0':
resolution: {integrity: sha512-eEXsVvLPu8Z4PkFibtuFJLJOTAV/nPdgtSjkGoPpddpFk3/ym2oy97jynY6ic2m6+nc5M8SE1e9v/mHKsulcJg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/parser': ^8.52.0
'@typescript-eslint/parser': ^8.53.0
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/parser@8.52.0':
resolution: {integrity: sha512-iIACsx8pxRnguSYhHiMn2PvhvfpopO9FXHyn1mG5txZIsAaB6F0KwbFnUQN3KCiG3Jcuad/Cao2FAs1Wp7vAyg==}
'@typescript-eslint/parser@8.53.0':
resolution: {integrity: sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/project-service@8.52.0':
resolution: {integrity: sha512-xD0MfdSdEmeFa3OmVqonHi+Cciab96ls1UhIF/qX/O/gPu5KXD0bY9lu33jj04fjzrXHcuvjBcBC+D3SNSadaw==}
'@typescript-eslint/project-service@8.53.0':
resolution: {integrity: sha512-Bl6Gdr7NqkqIP5yP9z1JU///Nmes4Eose6L1HwpuVHwScgDPPuEWbUVhvlZmb8hy0vX9syLk5EGNL700WcBlbg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/scope-manager@8.52.0':
resolution: {integrity: sha512-ixxqmmCcc1Nf8S0mS0TkJ/3LKcC8mruYJPOU6Ia2F/zUUR4pApW7LzrpU3JmtePbRUTes9bEqRc1Gg4iyRnDzA==}
'@typescript-eslint/scope-manager@8.53.0':
resolution: {integrity: sha512-kWNj3l01eOGSdVBnfAF2K1BTh06WS0Yet6JUgb9Cmkqaz3Jlu0fdVUjj9UI8gPidBWSMqDIglmEXifSgDT/D0g==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/tsconfig-utils@8.52.0':
resolution: {integrity: sha512-jl+8fzr/SdzdxWJznq5nvoI7qn2tNYV/ZBAEcaFMVXf+K6jmXvAFrgo/+5rxgnL152f//pDEAYAhhBAZGrVfwg==}
'@typescript-eslint/tsconfig-utils@8.53.0':
resolution: {integrity: sha512-K6Sc0R5GIG6dNoPdOooQ+KtvT5KCKAvTcY8h2rIuul19vxH5OTQk7ArKkd4yTzkw66WnNY0kPPzzcmWA+XRmiA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/type-utils@8.52.0':
resolution: {integrity: sha512-JD3wKBRWglYRQkAtsyGz1AewDu3mTc7NtRjR/ceTyGoPqmdS5oCdx/oZMWD5Zuqmo6/MpsYs0wp6axNt88/2EQ==}
'@typescript-eslint/type-utils@8.53.0':
resolution: {integrity: sha512-BBAUhlx7g4SmcLhn8cnbxoxtmS7hcq39xKCgiutL3oNx1TaIp+cny51s8ewnKMpVUKQUGb41RAUWZ9kxYdovuw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/types@8.52.0':
resolution: {integrity: sha512-LWQV1V4q9V4cT4H5JCIx3481iIFxH1UkVk+ZkGGAV1ZGcjGI9IoFOfg3O6ywz8QqCDEp7Inlg6kovMofsNRaGg==}
'@typescript-eslint/types@8.53.0':
resolution: {integrity: sha512-Bmh9KX31Vlxa13+PqPvt4RzKRN1XORYSLlAE+sO1i28NkisGbTtSLFVB3l7PWdHtR3E0mVMuC7JilWJ99m2HxQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/typescript-estree@8.52.0':
resolution: {integrity: sha512-XP3LClsCc0FsTK5/frGjolyADTh3QmsLp6nKd476xNI9CsSsLnmn4f0jrzNoAulmxlmNIpeXuHYeEQv61Q6qeQ==}
'@typescript-eslint/typescript-estree@8.53.0':
resolution: {integrity: sha512-pw0c0Gdo7Z4xOG987u3nJ8akL9093yEEKv8QTJ+Bhkghj1xyj8cgPaavlr9rq8h7+s6plUJ4QJYw2gCZodqmGw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/utils@8.52.0':
resolution: {integrity: sha512-wYndVMWkweqHpEpwPhwqE2lnD2DxC6WVLupU/DOt/0/v+/+iQbbzO3jOHjmBMnhu0DgLULvOaU4h4pwHYi2oRQ==}
'@typescript-eslint/utils@8.53.0':
resolution: {integrity: sha512-XDY4mXTez3Z1iRDI5mbRhH4DFSt46oaIFsLg+Zn97+sYrXACziXSQcSelMybnVZ5pa1P6xYkPr5cMJyunM1ZDA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <6.0.0'
'@typescript-eslint/visitor-keys@8.52.0':
resolution: {integrity: sha512-ink3/Zofus34nmBsPjow63FP5M7IGff0RKAgqR6+CFpdk22M7aLwC9gOcLGYqr7MczLPzZVERW9hRog3O4n1sQ==}
'@typescript-eslint/visitor-keys@8.53.0':
resolution: {integrity: sha512-LZ2NqIHFhvFwxG0qZeLL9DvdNAHPGCY5dIRwBhyYeU+LfLhcStE1ImjsuTG/WaVh3XysGaeLW8Rqq7cGkPCFvw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@xmldom/xmldom@0.9.8':
@@ -961,8 +961,8 @@ packages:
destr@2.0.5:
resolution: {integrity: sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==}
devalue@5.6.1:
resolution: {integrity: sha512-jDwizj+IlEZBunHcOuuFVBnIMPAEHvTsJj0BcIp94xYguLRVBcXO853px/MyIJvbVzWdsGvrRweIUWJw8hBP7A==}
devalue@5.6.2:
resolution: {integrity: sha512-nPRkjWzzDQlsejL1WVifk5rvcFi/y1onBRxjaFMjZeR9mFpqu2gmAZ9xUB9/IEanEP/vBtGeGganC/GO1fmufg==}
dexie@4.2.1:
resolution: {integrity: sha512-Ckej0NS6jxQ4Po3OrSQBFddayRhTCic2DoCAG5zacOfOVB9P2Q5Xc5uL/nVa7ZVs+HdMnvUPzLFCB/JwpB6Csg==}
@@ -1089,8 +1089,8 @@ packages:
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
exifreader@4.35.0:
resolution: {integrity: sha512-qiMONyOObmwI6sIXy13vRGqlcoi9VUKr70iGI1aefP+xJsbcXp+hcyL/4J6hov/yG9UhS7Hq1OQ1hAoSEZl+RA==}
exifreader@4.36.0:
resolution: {integrity: sha512-A9LvILHKAlVyF8k/ThqcnvvWrtprcKLw2BRuesuqhWZzgPu+GLDfQwVlqK4QE9ytmZDC6C71mY8ij5w9fZOANg==}
exsolve@1.0.8:
resolution: {integrity: sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA==}
@@ -1304,8 +1304,8 @@ packages:
known-css-properties@0.37.0:
resolution: {integrity: sha512-JCDrsP4Z1Sb9JwG0aJ8Eo2r7k4Ou5MwmThS/6lcIe1ICyb7UBJKGRIUUdqc2ASdE/42lgz6zFUnzAIhtXnBVrQ==}
kysely-ctl@0.19.0:
resolution: {integrity: sha512-89hzOd1cy/H063jB2E9wYHq+uKYpaHv6Mb5RiNFpRZL6BYCah9ncsdl3x5b52eirxry4UyWSmGNN3sFv+gK+ig==}
kysely-ctl@0.20.0:
resolution: {integrity: sha512-JoUBvW0uaEvM7BbR/JKaePvjQqZ8sHGOgy1VSESCjCIh5tIjP6pCuSz/u35hWpZnWrqeonqTjndW7xC7UNzqPA==}
engines: {node: '>=20'}
hasBin: true
peerDependencies:
@@ -1509,30 +1509,30 @@ packages:
perfect-debounce@2.0.0:
resolution: {integrity: sha512-fkEH/OBiKrqqI/yIgjR92lMfs2K8105zt/VT6+7eTjNwisrsh47CeIED9z58zI7DfKdH3uHAn25ziRZn3kgAow==}
pg-cloudflare@1.2.7:
resolution: {integrity: sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==}
pg-cloudflare@1.3.0:
resolution: {integrity: sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ==}
pg-connection-string@2.9.1:
resolution: {integrity: sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==}
pg-connection-string@2.10.0:
resolution: {integrity: sha512-ur/eoPKzDx2IjPaYyXS6Y8NSblxM7X64deV2ObV57vhjsWiwLvUD6meukAzogiOsu60GO8m/3Cb6FdJsWNjwXg==}
pg-int8@1.0.1:
resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}
engines: {node: '>=4.0.0'}
pg-pool@3.10.1:
resolution: {integrity: sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==}
pg-pool@3.11.0:
resolution: {integrity: sha512-MJYfvHwtGp870aeusDh+hg9apvOe2zmpZJpyt+BMtzUWlVqbhFmMK6bOBXLBUPd7iRtIF9fZplDc7KrPN3PN7w==}
peerDependencies:
pg: '>=8.0'
pg-protocol@1.10.3:
resolution: {integrity: sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==}
pg-protocol@1.11.0:
resolution: {integrity: sha512-pfsxk2M9M3BuGgDOfuy37VNRRX3jmKgMjcvAcWqNDpZSf4cUmv8HSOl5ViRQFsfARFn0KuUQTgLxVMbNq5NW3g==}
pg-types@2.2.0:
resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==}
engines: {node: '>=4'}
pg@8.16.3:
resolution: {integrity: sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==}
pg@8.17.1:
resolution: {integrity: sha512-EIR+jXdYNSMOrpRp7g6WgQr7SaZNZfS7IzZIO0oTNEeibq956JxeD15t3Jk3zZH0KH8DmOIx38qJfQenoE8bXQ==}
engines: {node: '>= 16.0.0'}
peerDependencies:
pg-native: '>=3.0.1'
@@ -1724,8 +1724,8 @@ packages:
prettier-plugin-svelte:
optional: true
prettier@3.7.4:
resolution: {integrity: sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==}
prettier@3.8.0:
resolution: {integrity: sha512-yEPsovQfpxYfgWNhCfECjG5AQaO+K3dp6XERmOepyPDVqcJm+bjyCVO3pmU+nAPe0N5dDvekfGezt/EIiRe1TA==}
engines: {node: '>=14'}
hasBin: true
@@ -1857,8 +1857,8 @@ packages:
svelte:
optional: true
svelte@5.46.1:
resolution: {integrity: sha512-ynjfCHD3nP2el70kN5Pmg37sSi0EjOm9FgHYQdC4giWG/hzO3AatzXXJJgP305uIhGQxSufJLuYWtkY8uK/8RA==}
svelte@5.46.4:
resolution: {integrity: sha512-VJwdXrmv9L8L7ZasJeWcCjoIuMRVbhuxbss0fpVnR8yorMmjNDwcjIH08vS6wmSzzzgAG5CADQ1JuXPS2nwt9w==}
engines: {node: '>=18'}
tailwindcss@3.4.19:
@@ -1912,8 +1912,8 @@ packages:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
engines: {node: '>= 0.8.0'}
typescript-eslint@8.52.0:
resolution: {integrity: sha512-atlQQJ2YkO4pfTVQmQ+wvYQwexPDOIgo+RaVcD7gHgzy/IQA+XTyuxNM9M9TVXvttkF7koBHmcwisKdOAf2EcA==}
typescript-eslint@8.53.0:
resolution: {integrity: sha512-xHURCQNxZ1dsWn0sdOaOfCSQG0HKeqSj9OexIxrz6ypU6wHYOdX2I3D2b8s8wFSsSOYJb+6q283cLiLlkEsBYw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
@@ -1924,21 +1924,19 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
ufo@1.6.2:
resolution: {integrity: sha512-heMioaxBcG9+Znsda5Q8sQbWnLJSl98AFDXTO80wELWEzX3hordXsTdxrIfMQoO9IY1MEnoGoPjpoKpMj+Yx0Q==}
ufo@1.6.3:
resolution: {integrity: sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==}
undici-types@7.16.0:
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
unplugin-icons@22.5.0:
resolution: {integrity: sha512-MBlMtT5RuMYZy4TZgqUL2OTtOdTUVsS1Mhj6G1pEzMlFJlEnq6mhUfoIt45gBWxHcsOdXJDWLg3pRZ+YmvAVWQ==}
unplugin-icons@23.0.1:
resolution: {integrity: sha512-rv0XEJepajKzDLvRUWASM8K+8+/CCfZn2jtogXqg6RIp7kpatRc/aFrVJn8ANQA09e++lPEEv9yX8cC9enc+QQ==}
peerDependencies:
'@svgr/core': '>=7.0.0'
'@svgx/core': ^1.0.1
'@vue/compiler-sfc': ^3.0.2 || ^2.7.0
'@vue/compiler-sfc': ^3.0.2
svelte: ^3.0.0 || ^4.0.0 || ^5.0.0
vue-template-compiler: ^2.6.12
vue-template-es2015-compiler: ^1.9.0
peerDependenciesMeta:
'@svgr/core':
optional: true
@@ -1948,10 +1946,6 @@ packages:
optional: true
svelte:
optional: true
vue-template-compiler:
optional: true
vue-template-es2015-compiler:
optional: true
unplugin@2.3.11:
resolution: {integrity: sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==}
@@ -2382,23 +2376,23 @@ snapshots:
dependencies:
acorn: 8.15.0
'@sveltejs/adapter-node@5.4.0(@sveltejs/kit@2.49.4(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))':
'@sveltejs/adapter-node@5.5.1(@sveltejs/kit@2.49.5(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))':
dependencies:
'@rollup/plugin-commonjs': 28.0.9(rollup@4.55.1)
'@rollup/plugin-json': 6.1.0(rollup@4.55.1)
'@rollup/plugin-node-resolve': 16.0.3(rollup@4.55.1)
'@sveltejs/kit': 2.49.4(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
'@sveltejs/kit': 2.49.5(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
rollup: 4.55.1
'@sveltejs/kit@2.49.4(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))':
'@sveltejs/kit@2.49.5(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(typescript@5.9.3)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))':
dependencies:
'@standard-schema/spec': 1.1.0
'@sveltejs/acorn-typescript': 1.0.8(acorn@8.15.0)
'@sveltejs/vite-plugin-svelte': 6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
'@sveltejs/vite-plugin-svelte': 6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
'@types/cookie': 0.6.0
acorn: 8.15.0
cookie: 0.6.0
devalue: 5.6.1
devalue: 5.6.2
esm-env: 1.2.2
kleur: 4.1.5
magic-string: 0.30.21
@@ -2406,32 +2400,32 @@ snapshots:
sade: 1.8.1
set-cookie-parser: 2.7.2
sirv: 3.0.2
svelte: 5.46.1
vite: 7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)
svelte: 5.46.4
vite: 7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)
optionalDependencies:
typescript: 5.9.3
'@sveltejs/vite-plugin-svelte-inspector@5.0.2(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))':
'@sveltejs/vite-plugin-svelte-inspector@5.0.2(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))':
dependencies:
'@sveltejs/vite-plugin-svelte': 6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
'@sveltejs/vite-plugin-svelte': 6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
obug: 2.1.1
svelte: 5.46.1
vite: 7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)
svelte: 5.46.4
vite: 7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)
'@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))':
'@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))':
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 5.0.2(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.1)(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
'@sveltejs/vite-plugin-svelte-inspector': 5.0.2(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)))(svelte@5.46.4)(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
deepmerge: 4.3.1
magic-string: 0.30.21
obug: 2.1.1
svelte: 5.46.1
vite: 7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)
vitefu: 1.1.1(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0))
svelte: 5.46.4
vite: 7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)
vitefu: 1.1.1(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0))
'@tanstack/svelte-virtual@3.13.18(svelte@5.46.1)':
'@tanstack/svelte-virtual@3.13.18(svelte@5.46.4)':
dependencies:
'@tanstack/virtual-core': 3.13.18
svelte: 5.46.1
svelte: 5.46.4
'@tanstack/virtual-core@3.13.18': {}
@@ -2456,28 +2450,28 @@ snapshots:
'@types/node-schedule@2.1.8':
dependencies:
'@types/node': 25.0.6
'@types/node': 25.0.9
'@types/node@25.0.6':
'@types/node@25.0.9':
dependencies:
undici-types: 7.16.0
'@types/pg@8.16.0':
dependencies:
'@types/node': 25.0.6
pg-protocol: 1.10.3
'@types/node': 25.0.9
pg-protocol: 1.11.0
pg-types: 2.2.0
'@types/resolve@1.20.2': {}
'@typescript-eslint/eslint-plugin@8.52.0(@typescript-eslint/parser@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
'@typescript-eslint/eslint-plugin@8.53.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
dependencies:
'@eslint-community/regexpp': 4.12.2
'@typescript-eslint/parser': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/scope-manager': 8.52.0
'@typescript-eslint/type-utils': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/utils': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/visitor-keys': 8.52.0
'@typescript-eslint/parser': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/scope-manager': 8.53.0
'@typescript-eslint/type-utils': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/utils': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/visitor-keys': 8.53.0
eslint: 9.39.2(jiti@1.21.7)
ignore: 7.0.5
natural-compare: 1.4.0
@@ -2486,41 +2480,41 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
'@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.52.0
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/typescript-estree': 8.52.0(typescript@5.9.3)
'@typescript-eslint/visitor-keys': 8.52.0
'@typescript-eslint/scope-manager': 8.53.0
'@typescript-eslint/types': 8.53.0
'@typescript-eslint/typescript-estree': 8.53.0(typescript@5.9.3)
'@typescript-eslint/visitor-keys': 8.53.0
debug: 4.4.3
eslint: 9.39.2(jiti@1.21.7)
typescript: 5.9.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/project-service@8.52.0(typescript@5.9.3)':
'@typescript-eslint/project-service@8.53.0(typescript@5.9.3)':
dependencies:
'@typescript-eslint/tsconfig-utils': 8.52.0(typescript@5.9.3)
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/tsconfig-utils': 8.53.0(typescript@5.9.3)
'@typescript-eslint/types': 8.53.0
debug: 4.4.3
typescript: 5.9.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/scope-manager@8.52.0':
'@typescript-eslint/scope-manager@8.53.0':
dependencies:
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/visitor-keys': 8.52.0
'@typescript-eslint/types': 8.53.0
'@typescript-eslint/visitor-keys': 8.53.0
'@typescript-eslint/tsconfig-utils@8.52.0(typescript@5.9.3)':
'@typescript-eslint/tsconfig-utils@8.53.0(typescript@5.9.3)':
dependencies:
typescript: 5.9.3
'@typescript-eslint/type-utils@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
'@typescript-eslint/type-utils@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
dependencies:
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/typescript-estree': 8.52.0(typescript@5.9.3)
'@typescript-eslint/utils': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/types': 8.53.0
'@typescript-eslint/typescript-estree': 8.53.0(typescript@5.9.3)
'@typescript-eslint/utils': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
debug: 4.4.3
eslint: 9.39.2(jiti@1.21.7)
ts-api-utils: 2.4.0(typescript@5.9.3)
@@ -2528,14 +2522,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/types@8.52.0': {}
'@typescript-eslint/types@8.53.0': {}
'@typescript-eslint/typescript-estree@8.52.0(typescript@5.9.3)':
'@typescript-eslint/typescript-estree@8.53.0(typescript@5.9.3)':
dependencies:
'@typescript-eslint/project-service': 8.52.0(typescript@5.9.3)
'@typescript-eslint/tsconfig-utils': 8.52.0(typescript@5.9.3)
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/visitor-keys': 8.52.0
'@typescript-eslint/project-service': 8.53.0(typescript@5.9.3)
'@typescript-eslint/tsconfig-utils': 8.53.0(typescript@5.9.3)
'@typescript-eslint/types': 8.53.0
'@typescript-eslint/visitor-keys': 8.53.0
debug: 4.4.3
minimatch: 9.0.5
semver: 7.7.3
@@ -2545,20 +2539,20 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
'@typescript-eslint/utils@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)':
dependencies:
'@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@1.21.7))
'@typescript-eslint/scope-manager': 8.52.0
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/typescript-estree': 8.52.0(typescript@5.9.3)
'@typescript-eslint/scope-manager': 8.53.0
'@typescript-eslint/types': 8.53.0
'@typescript-eslint/typescript-estree': 8.53.0(typescript@5.9.3)
eslint: 9.39.2(jiti@1.21.7)
typescript: 5.9.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/visitor-keys@8.52.0':
'@typescript-eslint/visitor-keys@8.53.0':
dependencies:
'@typescript-eslint/types': 8.52.0
'@typescript-eslint/types': 8.53.0
eslint-visitor-keys: 4.2.1
'@xmldom/xmldom@0.9.8':
@@ -2765,7 +2759,7 @@ snapshots:
destr@2.0.5: {}
devalue@5.6.1: {}
devalue@5.6.2: {}
dexie@4.2.1: {}
@@ -2837,7 +2831,7 @@ snapshots:
dependencies:
eslint: 9.39.2(jiti@1.21.7)
eslint-plugin-svelte@3.14.0(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.1):
eslint-plugin-svelte@3.14.0(eslint@9.39.2(jiti@1.21.7))(svelte@5.46.4):
dependencies:
'@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@1.21.7))
'@jridgewell/sourcemap-codec': 1.5.5
@@ -2849,9 +2843,9 @@ snapshots:
postcss-load-config: 3.1.4(postcss@8.5.6)
postcss-safe-parser: 7.0.1(postcss@8.5.6)
semver: 7.7.3
svelte-eslint-parser: 1.4.1(svelte@5.46.1)
svelte-eslint-parser: 1.4.1(svelte@5.46.4)
optionalDependencies:
svelte: 5.46.1
svelte: 5.46.4
transitivePeerDependencies:
- ts-node
@@ -2937,7 +2931,7 @@ snapshots:
esutils@2.0.3: {}
exifreader@4.35.0:
exifreader@4.36.0:
optionalDependencies:
'@xmldom/xmldom': 0.9.8
@@ -3124,7 +3118,7 @@ snapshots:
known-css-properties@0.37.0: {}
kysely-ctl@0.19.0(kysely@0.28.9)(typescript@5.9.3):
kysely-ctl@0.20.0(kysely@0.28.9)(typescript@5.9.3):
dependencies:
c12: 3.3.3
citty: 0.1.6
@@ -3209,7 +3203,7 @@ snapshots:
acorn: 8.15.0
pathe: 2.0.3
pkg-types: 1.3.1
ufo: 1.6.2
ufo: 1.6.3
mri@1.2.0: {}
@@ -3261,7 +3255,7 @@ snapshots:
dependencies:
destr: 2.0.5
node-fetch-native: 1.6.7
ufo: 1.6.2
ufo: 1.6.3
ohash@2.0.11: {}
@@ -3302,18 +3296,18 @@ snapshots:
perfect-debounce@2.0.0: {}
pg-cloudflare@1.2.7:
pg-cloudflare@1.3.0:
optional: true
pg-connection-string@2.9.1: {}
pg-connection-string@2.10.0: {}
pg-int8@1.0.1: {}
pg-pool@3.10.1(pg@8.16.3):
pg-pool@3.11.0(pg@8.17.1):
dependencies:
pg: 8.16.3
pg: 8.17.1
pg-protocol@1.10.3: {}
pg-protocol@1.11.0: {}
pg-types@2.2.0:
dependencies:
@@ -3323,15 +3317,15 @@ snapshots:
postgres-date: 1.0.7
postgres-interval: 1.2.0
pg@8.16.3:
pg@8.17.1:
dependencies:
pg-connection-string: 2.9.1
pg-pool: 3.10.1(pg@8.16.3)
pg-protocol: 1.10.3
pg-connection-string: 2.10.0
pg-pool: 3.11.0(pg@8.17.1)
pg-protocol: 1.11.0
pg-types: 2.2.0
pgpass: 1.0.5
optionalDependencies:
pg-cloudflare: 1.2.7
pg-cloudflare: 1.3.0
pgpass@1.0.5:
dependencies:
@@ -3429,18 +3423,18 @@ snapshots:
prelude-ls@1.2.1: {}
prettier-plugin-svelte@3.4.1(prettier@3.7.4)(svelte@5.46.1):
prettier-plugin-svelte@3.4.1(prettier@3.8.0)(svelte@5.46.4):
dependencies:
prettier: 3.7.4
svelte: 5.46.1
prettier: 3.8.0
svelte: 5.46.4
prettier-plugin-tailwindcss@0.7.2(prettier-plugin-svelte@3.4.1(prettier@3.7.4)(svelte@5.46.1))(prettier@3.7.4):
prettier-plugin-tailwindcss@0.7.2(prettier-plugin-svelte@3.4.1(prettier@3.8.0)(svelte@5.46.4))(prettier@3.8.0):
dependencies:
prettier: 3.7.4
prettier: 3.8.0
optionalDependencies:
prettier-plugin-svelte: 3.4.1(prettier@3.7.4)(svelte@5.46.1)
prettier-plugin-svelte: 3.4.1(prettier@3.8.0)(svelte@5.46.4)
prettier@3.7.4: {}
prettier@3.8.0: {}
proxy-from-env@1.1.0: {}
@@ -3562,19 +3556,19 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
svelte-check@4.3.5(picomatch@4.0.3)(svelte@5.46.1)(typescript@5.9.3):
svelte-check@4.3.5(picomatch@4.0.3)(svelte@5.46.4)(typescript@5.9.3):
dependencies:
'@jridgewell/trace-mapping': 0.3.31
chokidar: 4.0.3
fdir: 6.5.0(picomatch@4.0.3)
picocolors: 1.1.1
sade: 1.8.1
svelte: 5.46.1
svelte: 5.46.4
typescript: 5.9.3
transitivePeerDependencies:
- picomatch
svelte-eslint-parser@1.4.1(svelte@5.46.1):
svelte-eslint-parser@1.4.1(svelte@5.46.4):
dependencies:
eslint-scope: 8.4.0
eslint-visitor-keys: 4.2.1
@@ -3583,9 +3577,9 @@ snapshots:
postcss-scss: 4.0.9(postcss@8.5.6)
postcss-selector-parser: 7.1.1
optionalDependencies:
svelte: 5.46.1
svelte: 5.46.4
svelte@5.46.1:
svelte@5.46.4:
dependencies:
'@jridgewell/remapping': 2.3.5
'@jridgewell/sourcemap-codec': 1.5.5
@@ -3595,7 +3589,7 @@ snapshots:
aria-query: 5.3.2
axobject-query: 4.1.0
clsx: 2.1.1
devalue: 5.6.1
devalue: 5.6.2
esm-env: 1.2.2
esrap: 2.2.1
is-reference: 3.0.3
@@ -3666,12 +3660,12 @@ snapshots:
dependencies:
prelude-ls: 1.2.1
typescript-eslint@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3):
typescript-eslint@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3):
dependencies:
'@typescript-eslint/eslint-plugin': 8.52.0(@typescript-eslint/parser@8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/parser': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/typescript-estree': 8.52.0(typescript@5.9.3)
'@typescript-eslint/utils': 8.52.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/eslint-plugin': 8.53.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/parser': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
'@typescript-eslint/typescript-estree': 8.53.0(typescript@5.9.3)
'@typescript-eslint/utils': 8.53.0(eslint@9.39.2(jiti@1.21.7))(typescript@5.9.3)
eslint: 9.39.2(jiti@1.21.7)
typescript: 5.9.3
transitivePeerDependencies:
@@ -3679,21 +3673,19 @@ snapshots:
typescript@5.9.3: {}
ufo@1.6.2: {}
ufo@1.6.3: {}
undici-types@7.16.0: {}
unplugin-icons@22.5.0(svelte@5.46.1):
unplugin-icons@23.0.1(svelte@5.46.4):
dependencies:
'@antfu/install-pkg': 1.1.0
'@iconify/utils': 3.1.0
debug: 4.4.3
local-pkg: 1.1.2
obug: 2.1.1
unplugin: 2.3.11
optionalDependencies:
svelte: 5.46.1
transitivePeerDependencies:
- supports-color
svelte: 5.46.4
unplugin@2.3.11:
dependencies:
@@ -3716,7 +3708,7 @@ snapshots:
uuid@13.0.0: {}
vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0):
vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0):
dependencies:
esbuild: 0.27.2
fdir: 6.5.0(picomatch@4.0.3)
@@ -3725,14 +3717,14 @@ snapshots:
rollup: 4.55.1
tinyglobby: 0.2.15
optionalDependencies:
'@types/node': 25.0.6
'@types/node': 25.0.9
fsevents: 2.3.3
jiti: 1.21.7
yaml: 2.8.0
vitefu@1.1.1(vite@7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)):
vitefu@1.1.1(vite@7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)):
optionalDependencies:
vite: 7.3.1(@types/node@25.0.6)(jiti@1.21.7)(yaml@2.8.0)
vite: 7.3.1(@types/node@25.0.9)(jiti@1.21.7)(yaml@2.8.0)
webpack-virtual-modules@0.6.2: {}

View File

@@ -9,8 +9,8 @@
class?: ClassValue;
onclick?: () => void;
onRemoveClick?: () => void;
selected?: boolean;
removable?: boolean;
selected?: boolean;
}
let {
@@ -38,7 +38,7 @@
<span>
{@render children()}
</span>
{#if selected && removable}
{#if removable && selected}
<button
onclick={(e) => {
e.stopPropagation();

View File

@@ -2,6 +2,8 @@
import { getFileThumbnail } from "$lib/modules/file";
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
import IconFavorite from "~icons/material-symbols/favorite";
interface Props {
info: SummarizedFileInfo;
onclick?: (file: SummarizedFileInfo) => void;
@@ -14,11 +16,19 @@
<button
onclick={onclick && (() => setTimeout(() => onclick(info), 100))}
class="aspect-square overflow-hidden rounded transition active:scale-95 active:brightness-90"
class="relative aspect-square overflow-hidden rounded transition active:scale-95 active:brightness-90"
>
{#if $thumbnail}
<img src={$thumbnail} alt={info.name} class="h-full w-full object-cover" />
{:else}
<div class="h-full w-full bg-gray-100"></div>
{/if}
{#if info.isFavorite}
<div class={["absolute bottom-0.5 right-0.5"]}>
<IconFavorite
class="text-sm text-red-500"
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white)"
/>
</div>
{/if}
</button>

View File

@@ -25,9 +25,9 @@
{#if showBackButton}
<button
onclick={onBackClick ?? (() => history.back())}
class="w-[2.3rem] flex-shrink-0 rounded-full p-1 active:bg-black active:bg-opacity-[0.04]"
class="w-full rounded-full p-1 text-2xl active:bg-black active:bg-opacity-[0.04]"
>
<IconArrowBack class="text-2xl" />
<IconArrowBack />
</button>
{/if}
</div>

View File

@@ -5,9 +5,11 @@
import IconFolder from "~icons/material-symbols/folder";
import IconDriveFolderUpload from "~icons/material-symbols/drive-folder-upload";
import IconDraft from "~icons/material-symbols/draft";
import IconFavorite from "~icons/material-symbols/favorite";
interface Props {
class?: ClassValue;
isFavorite?: boolean;
name: string;
subtext?: string;
textClass?: ClassValue;
@@ -17,6 +19,7 @@
let {
class: className,
isFavorite = false,
name,
subtext,
textClass: textClassName,
@@ -26,7 +29,7 @@
</script>
{#snippet iconSnippet()}
<div class="flex h-10 w-10 items-center justify-center text-xl">
<div class="relative flex h-10 w-10 items-center justify-center text-xl">
{#if thumbnail}
<img src={thumbnail} alt={name} loading="lazy" class="aspect-square rounded object-cover" />
{:else if type === "directory"}
@@ -36,6 +39,14 @@
{:else}
<IconDraft class="text-blue-400" />
{/if}
{#if isFavorite}
<div class={["absolute bottom-0 right-0", !thumbnail && "rounded-full bg-white p-0.5"]}>
<IconFavorite
class="text-xs text-red-500"
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white)"
/>
</div>
{/if}
</div>
{/snippet}

View File

@@ -4,3 +4,6 @@ export const ENCRYPTION_OVERHEAD = AES_GCM_IV_SIZE + AES_GCM_TAG_SIZE;
export const CHUNK_SIZE = 4 * 1024 * 1024; // 4 MiB
export const ENCRYPTED_CHUNK_SIZE = CHUNK_SIZE + ENCRYPTION_OVERHEAD;
export const MAX_FILE_SIZE = 512 * 1024 * 1024; // 512 MiB
export const MAX_CHUNKS = Math.ceil(MAX_FILE_SIZE / CHUNK_SIZE); // 128 chunks

View File

@@ -20,7 +20,12 @@ export const getFileCacheIndex = async () => {
};
export const storeFileCacheIndex = async (fileCacheIndex: FileCacheIndex) => {
await cacheIndex.fileCache.put(fileCacheIndex);
await cacheIndex.fileCache.put({
fileId: fileCacheIndex.fileId,
cachedAt: fileCacheIndex.cachedAt,
lastRetrievedAt: fileCacheIndex.lastRetrievedAt,
size: fileCacheIndex.size,
});
};
export const deleteFileCacheIndex = async (fileId: number) => {

View File

@@ -4,6 +4,7 @@ interface DirectoryInfo {
id: number;
parentId: DirectoryId;
name: string;
isFavorite: boolean;
}
interface FileInfo {
@@ -14,6 +15,7 @@ interface FileInfo {
createdAt?: Date;
lastModifiedAt: Date;
categoryIds?: number[];
isFavorite: boolean;
}
interface CategoryInfo {
@@ -46,6 +48,23 @@ filesystem
});
});
filesystem.version(4).upgrade(async (trx) => {
await Promise.all([
trx
.table("directory")
.toCollection()
.modify((directory) => {
directory.isFavorite = false;
}),
trx
.table("file")
.toCollection()
.modify((file) => {
file.isFavorite = false;
}),
]);
});
export const getDirectoryInfos = async (parentId: DirectoryId) => {
return await filesystem.directory.where({ parentId }).toArray();
};
@@ -55,7 +74,11 @@ export const getDirectoryInfo = async (id: number) => {
};
export const storeDirectoryInfo = async (directoryInfo: DirectoryInfo) => {
await filesystem.directory.upsert(directoryInfo.id, { ...directoryInfo });
await filesystem.directory.upsert(directoryInfo.id, {
parentId: directoryInfo.parentId,
name: directoryInfo.name,
isFavorite: directoryInfo.isFavorite,
});
};
export const deleteDirectoryInfo = async (id: number) => {
@@ -89,7 +112,15 @@ export const bulkGetFileInfos = async (ids: number[]) => {
};
export const storeFileInfo = async (fileInfo: FileInfo) => {
await filesystem.file.upsert(fileInfo.id, { ...fileInfo });
await filesystem.file.upsert(fileInfo.id, {
parentId: fileInfo.parentId,
name: fileInfo.name,
contentType: fileInfo.contentType,
createdAt: fileInfo.createdAt,
lastModifiedAt: fileInfo.lastModifiedAt,
categoryIds: fileInfo.categoryIds,
isFavorite: fileInfo.isFavorite,
});
};
export const deleteFileInfo = async (id: number) => {
@@ -116,7 +147,12 @@ export const getCategoryInfo = async (id: number) => {
};
export const storeCategoryInfo = async (categoryInfo: CategoryInfo) => {
await filesystem.category.upsert(categoryInfo.id, { ...categoryInfo });
await filesystem.category.upsert(categoryInfo.id, {
parentId: categoryInfo.parentId,
name: categoryInfo.name,
files: categoryInfo.files,
isFileRecursive: categoryInfo.isFileRecursive,
});
};
export const updateCategoryInfo = async (id: number, changes: { isFileRecursive?: boolean }) => {

View File

@@ -1,7 +1,6 @@
import * as IndexedDB from "$lib/indexedDB";
import { trpc, isTRPCClientError } from "$trpc/client";
import { decryptFileMetadata, decryptCategoryMetadata } from "./common";
import { FilesystemCache } from "./FilesystemCache.svelte";
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
import type { CategoryInfo, MaybeCategoryInfo } from "./types";
const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo>({
@@ -22,6 +21,7 @@ const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo>({
name: fileInfo.name,
createdAt: fileInfo.createdAt,
lastModifiedAt: fileInfo.lastModifiedAt,
isFavorite: fileInfo.isFavorite,
isRecursive: file.isRecursive,
}
: undefined;
@@ -65,6 +65,7 @@ const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo>({
id: file.id,
parentId: file.parent,
contentType: file.contentType,
isFavorite: file.isFavorite,
isRecursive: file.isRecursive,
...(await decryptFileMetadata(file, masterKey)),
})),

View File

@@ -1,50 +0,0 @@
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
export const decryptDirectoryMetadata = async (
metadata: { dek: string; dekVersion: Date; name: string; nameIv: string },
masterKey: CryptoKey,
) => {
const { dataKey } = await unwrapDataKey(metadata.dek, masterKey);
const name = await decryptString(metadata.name, metadata.nameIv, dataKey);
return {
dataKey: { key: dataKey, version: metadata.dekVersion },
name,
};
};
const decryptDate = async (ciphertext: string, iv: string, dataKey: CryptoKey) => {
return new Date(parseInt(await decryptString(ciphertext, iv, dataKey), 10));
};
export const decryptFileMetadata = async (
metadata: {
dek: string;
dekVersion: Date;
name: string;
nameIv: string;
createdAt?: string;
createdAtIv?: string;
lastModifiedAt: string;
lastModifiedAtIv: string;
},
masterKey: CryptoKey,
) => {
const { dataKey } = await unwrapDataKey(metadata.dek, masterKey);
const [name, createdAt, lastModifiedAt] = await Promise.all([
decryptString(metadata.name, metadata.nameIv, dataKey),
metadata.createdAt
? decryptDate(metadata.createdAt, metadata.createdAtIv!, dataKey)
: undefined,
decryptDate(metadata.lastModifiedAt, metadata.lastModifiedAtIv, dataKey),
]);
return {
dataKey: { key: dataKey, version: metadata.dekVersion },
name,
createdAt,
lastModifiedAt,
};
};
export const decryptCategoryMetadata = decryptDirectoryMetadata;

View File

@@ -1,7 +1,6 @@
import * as IndexedDB from "$lib/indexedDB";
import { trpc, isTRPCClientError } from "$trpc/client";
import { decryptDirectoryMetadata, decryptFileMetadata } from "./common";
import { FilesystemCache, type FilesystemCacheOptions } from "./FilesystemCache.svelte";
import { FilesystemCache, decryptDirectoryMetadata, decryptFileMetadata } from "./internal.svelte";
import type { DirectoryInfo, MaybeDirectoryInfo } from "./types";
const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
@@ -27,6 +26,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
name: directory.name,
subDirectories,
files,
isFavorite: directory.isFavorite,
};
}
},
@@ -39,6 +39,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
directory.subDirectories.map(async (directory) => ({
id: directory.id,
parentId: id,
isFavorite: directory.isFavorite,
...(await decryptDirectoryMetadata(directory, masterKey)),
})),
),
@@ -47,6 +48,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
id: file.id,
parentId: id,
contentType: file.contentType,
isFavorite: file.isFavorite,
...(await decryptFileMetadata(file, masterKey)),
})),
),
@@ -60,6 +62,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
parentId: directory.metadata!.parent,
subDirectories,
files,
isFavorite: directory.metadata!.isFavorite,
...metadata!,
}
: { id, subDirectories, files },
@@ -102,8 +105,30 @@ export const getDirectoryInfo = (
id: DirectoryId,
masterKey: CryptoKey,
options?: {
fetchFromServer?: FilesystemCacheOptions<DirectoryId, MaybeDirectoryInfo>["fetchFromServer"];
serverResponse?: {
parent: DirectoryId;
dek: string;
dekVersion: Date;
name: string;
nameIv: string;
isFavorite: boolean;
};
},
) => {
return cache.get(id, masterKey, options);
return cache.get(id, masterKey, {
fetchFromServer:
options?.serverResponse &&
(async (cachedValue) => {
const metadata = await decryptDirectoryMetadata(options!.serverResponse!, masterKey);
return storeToIndexedDB({
subDirectories: [],
files: [],
...cachedValue,
id: id as number,
parentId: options!.serverResponse!.parent,
isFavorite: options!.serverResponse!.isFavorite,
...metadata,
});
}),
});
};

View File

@@ -1,7 +1,6 @@
import * as IndexedDB from "$lib/indexedDB";
import { trpc, isTRPCClientError } from "$trpc/client";
import { decryptFileMetadata, decryptCategoryMetadata } from "./common";
import { FilesystemCache, type FilesystemCacheOptions } from "./FilesystemCache.svelte";
import { FilesystemCache, decryptFileMetadata, decryptCategoryMetadata } from "./internal.svelte";
import type { FileInfo, MaybeFileInfo } from "./types";
const cache = new FilesystemCache<number, MaybeFileInfo>({
@@ -28,6 +27,7 @@ const cache = new FilesystemCache<number, MaybeFileInfo>({
createdAt: file.createdAt,
lastModifiedAt: file.lastModifiedAt,
categories: categories?.filter((category) => !!category) ?? [],
isFavorite: file.isFavorite,
};
}
},
@@ -56,6 +56,7 @@ const cache = new FilesystemCache<number, MaybeFileInfo>({
createdAt: metadata.createdAt,
lastModifiedAt: metadata.lastModifiedAt,
categories,
isFavorite: file.isFavorite,
});
} catch (e) {
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
@@ -121,6 +122,7 @@ const cache = new FilesystemCache<number, MaybeFileInfo>({
parentId: metadataRaw.parent,
contentType: metadataRaw.contentType,
categories,
isFavorite: metadataRaw.isFavorite,
...metadata,
};
}),
@@ -172,9 +174,38 @@ const bulkStoreToIndexedDB = (infos: FileInfo[]) => {
export const getFileInfo = (
id: number,
masterKey: CryptoKey,
options?: { fetchFromServer?: FilesystemCacheOptions<number, MaybeFileInfo>["fetchFromServer"] },
options?: {
serverResponse?: {
parent: DirectoryId;
dek: string;
dekVersion: Date;
contentType: string;
name: string;
nameIv: string;
createdAt?: string;
createdAtIv?: string;
lastModifiedAt: string;
lastModifiedAtIv: string;
isFavorite: boolean;
};
},
) => {
return cache.get(id, masterKey, options);
return cache.get(id, masterKey, {
fetchFromServer:
options?.serverResponse &&
(async (cachedValue) => {
const metadata = await decryptFileMetadata(options!.serverResponse!, masterKey);
return storeToIndexedDB({
categories: [],
...cachedValue,
id,
parentId: options!.serverResponse!.parent,
contentType: options!.serverResponse!.contentType,
isFavorite: options!.serverResponse!.isFavorite,
...metadata,
});
}),
});
};
export const bulkGetFileInfo = (ids: number[], masterKey: CryptoKey) => {

View File

@@ -1,5 +1,4 @@
export * from "./category";
export * from "./common";
export * from "./directory";
export * from "./file";
export * from "./types";

View File

@@ -1,6 +1,7 @@
import { untrack } from "svelte";
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
export interface FilesystemCacheOptions<K, V> {
interface FilesystemCacheOptions<K, V> {
fetchFromIndexedDB: (key: K) => Promise<V | undefined>;
fetchFromServer: (key: K, cachedValue: V | undefined, masterKey: CryptoKey) => Promise<V>;
bulkFetchFromIndexedDB?: (keys: Set<K>) => Promise<Map<K, V>>;
@@ -18,7 +19,7 @@ export class FilesystemCache<K, V extends object> {
get(
key: K,
masterKey: CryptoKey,
options?: { fetchFromServer?: FilesystemCacheOptions<K, V>["fetchFromServer"] },
options?: { fetchFromServer?: (cachedValue: V | undefined) => Promise<V> },
) {
return untrack(() => {
let state = this.map.get(key);
@@ -33,7 +34,7 @@ export class FilesystemCache<K, V extends object> {
}
(state.value
? Promise.resolve(state.value)
? Promise.resolve($state.snapshot(state.value) as V)
: this.options.fetchFromIndexedDB(key).then((loadedInfo) => {
if (loadedInfo) {
state.value = loadedInfo;
@@ -42,8 +43,10 @@ export class FilesystemCache<K, V extends object> {
return loadedInfo;
})
)
.then((cachedInfo) =>
(options?.fetchFromServer ?? this.options.fetchFromServer)(key, cachedInfo, masterKey),
.then(
(cachedInfo) =>
options?.fetchFromServer?.(cachedInfo) ??
this.options.fetchFromServer(key, cachedInfo, masterKey),
)
.then((loadedInfo) => {
if (state.value) {
@@ -126,3 +129,52 @@ export class FilesystemCache<K, V extends object> {
});
}
}
export const decryptDirectoryMetadata = async (
metadata: { dek: string; dekVersion: Date; name: string; nameIv: string },
masterKey: CryptoKey,
) => {
const { dataKey } = await unwrapDataKey(metadata.dek, masterKey);
const name = await decryptString(metadata.name, metadata.nameIv, dataKey);
return {
dataKey: { key: dataKey, version: metadata.dekVersion },
name,
};
};
const decryptDate = async (ciphertext: string, iv: string, dataKey: CryptoKey) => {
return new Date(parseInt(await decryptString(ciphertext, iv, dataKey), 10));
};
export const decryptFileMetadata = async (
metadata: {
dek: string;
dekVersion: Date;
name: string;
nameIv: string;
createdAt?: string;
createdAtIv?: string;
lastModifiedAt: string;
lastModifiedAtIv: string;
},
masterKey: CryptoKey,
) => {
const { dataKey } = await unwrapDataKey(metadata.dek, masterKey);
const [name, createdAt, lastModifiedAt] = await Promise.all([
decryptString(metadata.name, metadata.nameIv, dataKey),
metadata.createdAt
? decryptDate(metadata.createdAt, metadata.createdAtIv!, dataKey)
: undefined,
decryptDate(metadata.lastModifiedAt, metadata.lastModifiedAtIv, dataKey),
]);
return {
dataKey: { key: dataKey, version: metadata.dekVersion },
name,
createdAt,
lastModifiedAt,
};
};
export const decryptCategoryMetadata = decryptDirectoryMetadata;

View File

@@ -1,5 +1,4 @@
export type DataKey = { key: CryptoKey; version: Date };
type AllUndefined<T> = { [K in keyof T]?: undefined };
export interface LocalDirectoryInfo {
id: number;
@@ -8,6 +7,7 @@ export interface LocalDirectoryInfo {
name: string;
subDirectories: SubDirectoryInfo[];
files: SummarizedFileInfo[];
isFavorite: boolean;
}
export interface RootDirectoryInfo {
@@ -17,6 +17,7 @@ export interface RootDirectoryInfo {
name?: undefined;
subDirectories: SubDirectoryInfo[];
files: SummarizedFileInfo[];
isFavorite?: undefined;
}
export type DirectoryInfo = LocalDirectoryInfo | RootDirectoryInfo;
@@ -36,6 +37,7 @@ export interface FileInfo {
createdAt?: Date;
lastModifiedAt: Date;
categories: FileCategoryInfo[];
isFavorite: boolean;
}
export type MaybeFileInfo =

View File

@@ -0,0 +1,278 @@
import type { Selectable } from "kysely";
import { IntegrityError } from "./error";
import db from "./kysely";
import type { Ciphertext, DirectoryTable } from "./schema";
interface Directory {
id: number;
parentId: DirectoryId;
userId: number;
mekVersion: number;
encDek: string;
dekVersion: Date;
encName: Ciphertext;
isFavorite: boolean;
}
const toDirectory = (row: Selectable<DirectoryTable>): Directory => ({
id: row.id,
parentId: row.parent_id ?? "root",
userId: row.user_id,
mekVersion: row.master_encryption_key_version,
encDek: row.encrypted_data_encryption_key,
dekVersion: row.data_encryption_key_version,
encName: row.encrypted_name,
isFavorite: row.is_favorite,
});
export const registerDirectory = async (params: Omit<Directory, "id" | "isFavorite">) => {
await db.transaction().execute(async (trx) => {
const mek = await trx
.selectFrom("master_encryption_key")
.select("version")
.where("user_id", "=", params.userId)
.where("state", "=", "active")
.limit(1)
.forUpdate()
.executeTakeFirst();
if (mek?.version !== params.mekVersion) {
throw new IntegrityError("Inactive MEK version");
}
const { directoryId } = await trx
.insertInto("directory")
.values({
parent_id: params.parentId !== "root" ? params.parentId : null,
user_id: params.userId,
master_encryption_key_version: params.mekVersion,
encrypted_data_encryption_key: params.encDek,
data_encryption_key_version: params.dekVersion,
encrypted_name: params.encName,
})
.returning("id as directoryId")
.executeTakeFirstOrThrow();
await trx
.insertInto("directory_log")
.values({
directory_id: directoryId,
timestamp: new Date(),
action: "create",
new_name: params.encName,
})
.execute();
});
};
export const getAllDirectoriesByParent = async (userId: number, parentId: DirectoryId) => {
const directories = await db
.selectFrom("directory")
.selectAll()
.where("user_id", "=", userId)
.$if(parentId === "root", (qb) => qb.where("parent_id", "is", null))
.$if(parentId !== "root", (qb) => qb.where("parent_id", "=", parentId as number))
.execute();
return directories.map(toDirectory);
};
export const getAllFavoriteDirectories = async (userId: number) => {
const directories = await db
.selectFrom("directory")
.selectAll()
.where("user_id", "=", userId)
.where("is_favorite", "=", true)
.execute();
return directories.map(toDirectory);
};
export const getDirectory = async (userId: number, directoryId: number) => {
const directory = await db
.selectFrom("directory")
.selectAll()
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.limit(1)
.executeTakeFirst();
return directory ? toDirectory(directory) : null;
};
export const searchDirectories = async (
userId: number,
filters: {
parentId: DirectoryId;
inFavorites: boolean;
},
) => {
const directories = await db
.withRecursive("directory_tree", (db) =>
db
.selectFrom("directory")
.select("id")
.where("user_id", "=", userId)
.$if(filters.parentId === "root", (qb) => qb.where((eb) => eb.lit(false))) // directory_tree will be empty if parentId is "root"
.$if(filters.parentId !== "root", (qb) => qb.where("id", "=", filters.parentId as number))
.unionAll(
db
.selectFrom("directory as d")
.innerJoin("directory_tree as dt", "d.parent_id", "dt.id")
.select("d.id"),
),
)
.withRecursive("favorite_directory_tree", (db) =>
db
.selectFrom("directory")
.select("id")
.where("user_id", "=", userId)
.$if(!filters.inFavorites, (qb) => qb.where((eb) => eb.lit(false))) // favorite_directory_tree will be empty if inFavorites is false
.$if(filters.inFavorites, (qb) => qb.where("is_favorite", "=", true))
.unionAll((db) =>
db
.selectFrom("directory as d")
.innerJoin("favorite_directory_tree as dt", "d.parent_id", "dt.id")
.select("d.id"),
),
)
.selectFrom("directory")
.selectAll()
.where("user_id", "=", userId)
.$if(filters.parentId !== "root", (qb) =>
qb.where((eb) =>
eb.exists(eb.selectFrom("directory_tree as dt").whereRef("dt.id", "=", "parent_id")),
),
)
.$if(filters.inFavorites, (qb) =>
qb.where((eb) =>
eb.exists(
eb.selectFrom("favorite_directory_tree as dt").whereRef("dt.id", "=", "directory.id"),
),
),
)
.execute();
return directories.map(toDirectory);
};
export const setDirectoryEncName = async (
userId: number,
directoryId: number,
dekVersion: Date,
encName: Ciphertext,
) => {
await db.transaction().execute(async (trx) => {
const directory = await trx
.selectFrom("directory")
.select("data_encryption_key_version")
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.limit(1)
.forUpdate()
.executeTakeFirst();
if (!directory) {
throw new IntegrityError("Directory not found");
} else if (directory.data_encryption_key_version.getTime() !== dekVersion.getTime()) {
throw new IntegrityError("Invalid DEK version");
}
await trx
.updateTable("directory")
.set({ encrypted_name: encName })
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.execute();
await trx
.insertInto("directory_log")
.values({
directory_id: directoryId,
timestamp: new Date(),
action: "rename",
new_name: encName,
})
.execute();
});
};
export const setDirectoryFavorite = async (
userId: number,
directoryId: number,
isFavorite: boolean,
) => {
await db.transaction().execute(async (trx) => {
const directory = await trx
.selectFrom("directory")
.select("is_favorite")
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.limit(1)
.forUpdate()
.executeTakeFirst();
if (!directory) {
throw new IntegrityError("Directory not found");
} else if (directory.is_favorite === isFavorite) {
throw new IntegrityError(
isFavorite ? "Directory already favorited" : "Directory not favorited",
);
}
await trx
.updateTable("directory")
.set({ is_favorite: isFavorite })
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.execute();
await trx
.insertInto("directory_log")
.values({
directory_id: directoryId,
timestamp: new Date(),
action: isFavorite ? "add-to-favorites" : "remove-from-favorites",
})
.execute();
});
};
export const unregisterDirectory = async (userId: number, directoryId: number) => {
return await db
.transaction()
.setIsolationLevel("repeatable read") // TODO: Sufficient?
.execute(async (trx) => {
const unregisterFiles = async (parentId: number) => {
const files = await trx
.selectFrom("file")
.leftJoin("thumbnail", "file.id", "thumbnail.file_id")
.select(["file.id", "file.path", "thumbnail.path as thumbnailPath"])
.where("file.parent_id", "=", parentId)
.where("file.user_id", "=", userId)
.forUpdate("file")
.execute();
await trx
.deleteFrom("file")
.where("parent_id", "=", parentId)
.where("user_id", "=", userId)
.execute();
return files;
};
const unregisterDirectoryRecursively = async (
directoryId: number,
): Promise<{ id: number; path: string; thumbnailPath: string | null }[]> => {
const files = await unregisterFiles(directoryId);
const subDirectories = await trx
.selectFrom("directory")
.select("id")
.where("parent_id", "=", directoryId)
.where("user_id", "=", userId)
.execute();
const subDirectoryFilePaths = await Promise.all(
subDirectories.map(async ({ id }) => await unregisterDirectoryRecursively(id)),
);
const deleteRes = await trx
.deleteFrom("directory")
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.executeTakeFirst();
if (deleteRes.numDeletedRows === 0n) {
throw new IntegrityError("Directory not found");
}
return files.concat(...subDirectoryFilePaths);
};
return await unregisterDirectoryRecursively(directoryId);
});
};

View File

@@ -8,10 +8,14 @@ type IntegrityErrorMessages =
| "User client already exists"
// File
| "Directory not found"
| "Directory already favorited"
| "Directory not favorited"
| "File not found"
| "File is not legacy"
| "File not found in category"
| "File already added to category"
| "File already favorited"
| "File not favorited"
| "Invalid DEK version"
// HSK
| "HSK already registered"

View File

@@ -1,19 +1,9 @@
import { sql } from "kysely";
import { sql, type Selectable } from "kysely";
import { jsonArrayFrom } from "kysely/helpers/postgres";
import pg from "pg";
import { IntegrityError } from "./error";
import db from "./kysely";
import type { Ciphertext } from "./schema";
interface Directory {
id: number;
parentId: DirectoryId;
userId: number;
mekVersion: number;
encDek: string;
dekVersion: Date;
encName: Ciphertext;
}
import type { Ciphertext, FileTable } from "./schema";
interface File {
id: number;
@@ -31,6 +21,7 @@ interface File {
encName: Ciphertext;
encCreatedAt: Ciphertext | null;
encLastModifiedAt: Ciphertext;
isFavorite: boolean;
}
interface FileCategory {
@@ -42,208 +33,26 @@ interface FileCategory {
encName: Ciphertext;
}
export const registerDirectory = async (params: Omit<Directory, "id">) => {
await db.transaction().execute(async (trx) => {
const mek = await trx
.selectFrom("master_encryption_key")
.select("version")
.where("user_id", "=", params.userId)
.where("state", "=", "active")
.limit(1)
.forUpdate()
.executeTakeFirst();
if (mek?.version !== params.mekVersion) {
throw new IntegrityError("Inactive MEK version");
}
const toFile = (row: Selectable<FileTable>): File => ({
id: row.id,
parentId: row.parent_id ?? "root",
userId: row.user_id,
path: row.path,
mekVersion: row.master_encryption_key_version,
encDek: row.encrypted_data_encryption_key,
dekVersion: row.data_encryption_key_version,
hskVersion: row.hmac_secret_key_version,
contentHmac: row.content_hmac,
contentType: row.content_type,
encContentIv: row.encrypted_content_iv,
encContentHash: row.encrypted_content_hash,
encName: row.encrypted_name,
encCreatedAt: row.encrypted_created_at,
encLastModifiedAt: row.encrypted_last_modified_at,
isFavorite: row.is_favorite,
});
const { directoryId } = await trx
.insertInto("directory")
.values({
parent_id: params.parentId !== "root" ? params.parentId : null,
user_id: params.userId,
master_encryption_key_version: params.mekVersion,
encrypted_data_encryption_key: params.encDek,
data_encryption_key_version: params.dekVersion,
encrypted_name: params.encName,
})
.returning("id as directoryId")
.executeTakeFirstOrThrow();
await trx
.insertInto("directory_log")
.values({
directory_id: directoryId,
timestamp: new Date(),
action: "create",
new_name: params.encName,
})
.execute();
});
};
export const getAllDirectoriesByParent = async (userId: number, parentId: DirectoryId) => {
let query = db.selectFrom("directory").selectAll().where("user_id", "=", userId);
query =
parentId === "root"
? query.where("parent_id", "is", null)
: query.where("parent_id", "=", parentId);
const directories = await query.execute();
return directories.map(
(directory) =>
({
id: directory.id,
parentId: directory.parent_id ?? "root",
userId: directory.user_id,
mekVersion: directory.master_encryption_key_version,
encDek: directory.encrypted_data_encryption_key,
dekVersion: directory.data_encryption_key_version,
encName: directory.encrypted_name,
}) satisfies Directory,
);
};
export const getAllRecursiveDirectoriesByParent = async (userId: number, parentId: DirectoryId) => {
const directories = await db
.withRecursive("directory_tree", (db) =>
db
.selectFrom("directory")
.selectAll()
.$if(parentId === "root", (qb) => qb.where("parent_id", "is", null))
.$if(parentId !== "root", (qb) => qb.where("parent_id", "=", parentId as number))
.where("user_id", "=", userId)
.unionAll((db) =>
db
.selectFrom("directory")
.innerJoin("directory_tree", "directory.parent_id", "directory_tree.id")
.selectAll("directory"),
),
)
.selectFrom("directory_tree")
.selectAll()
.execute();
return directories.map(
(directory) =>
({
id: directory.id,
parentId: directory.parent_id ?? "root",
userId: directory.user_id,
mekVersion: directory.master_encryption_key_version,
encDek: directory.encrypted_data_encryption_key,
dekVersion: directory.data_encryption_key_version,
encName: directory.encrypted_name,
}) satisfies Directory,
);
};
export const getDirectory = async (userId: number, directoryId: number) => {
const directory = await db
.selectFrom("directory")
.selectAll()
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.limit(1)
.executeTakeFirst();
return directory
? ({
id: directory.id,
parentId: directory.parent_id ?? "root",
userId: directory.user_id,
mekVersion: directory.master_encryption_key_version,
encDek: directory.encrypted_data_encryption_key,
dekVersion: directory.data_encryption_key_version,
encName: directory.encrypted_name,
} satisfies Directory)
: null;
};
export const setDirectoryEncName = async (
userId: number,
directoryId: number,
dekVersion: Date,
encName: Ciphertext,
) => {
await db.transaction().execute(async (trx) => {
const directory = await trx
.selectFrom("directory")
.select("data_encryption_key_version")
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.limit(1)
.forUpdate()
.executeTakeFirst();
if (!directory) {
throw new IntegrityError("Directory not found");
} else if (directory.data_encryption_key_version.getTime() !== dekVersion.getTime()) {
throw new IntegrityError("Invalid DEK version");
}
await trx
.updateTable("directory")
.set({ encrypted_name: encName })
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.execute();
await trx
.insertInto("directory_log")
.values({
directory_id: directoryId,
timestamp: new Date(),
action: "rename",
new_name: encName,
})
.execute();
});
};
export const unregisterDirectory = async (userId: number, directoryId: number) => {
return await db
.transaction()
.setIsolationLevel("repeatable read") // TODO: Sufficient?
.execute(async (trx) => {
const unregisterFiles = async (parentId: number) => {
const files = await trx
.selectFrom("file")
.leftJoin("thumbnail", "file.id", "thumbnail.file_id")
.select(["file.id", "file.path", "thumbnail.path as thumbnailPath"])
.where("file.parent_id", "=", parentId)
.where("file.user_id", "=", userId)
.forUpdate("file")
.execute();
await trx
.deleteFrom("file")
.where("parent_id", "=", parentId)
.where("user_id", "=", userId)
.execute();
return files;
};
const unregisterDirectoryRecursively = async (
directoryId: number,
): Promise<{ id: number; path: string; thumbnailPath: string | null }[]> => {
const files = await unregisterFiles(directoryId);
const subDirectories = await trx
.selectFrom("directory")
.select("id")
.where("parent_id", "=", directoryId)
.where("user_id", "=", userId)
.execute();
const subDirectoryFilePaths = await Promise.all(
subDirectories.map(async ({ id }) => await unregisterDirectoryRecursively(id)),
);
const deleteRes = await trx
.deleteFrom("directory")
.where("id", "=", directoryId)
.where("user_id", "=", userId)
.executeTakeFirst();
if (deleteRes.numDeletedRows === 0n) {
throw new IntegrityError("Directory not found");
}
return files.concat(...subDirectoryFilePaths);
};
return await unregisterDirectoryRecursively(directoryId);
});
};
export const registerFile = async (trx: typeof db, params: Omit<File, "id">) => {
export const registerFile = async (trx: typeof db, params: Omit<File, "id" | "isFavorite">) => {
if ((params.hskVersion && !params.contentHmac) || (!params.hskVersion && params.contentHmac)) {
throw new Error("Invalid arguments");
}
@@ -281,32 +90,14 @@ export const registerFile = async (trx: typeof db, params: Omit<File, "id">) =>
};
export const getAllFilesByParent = async (userId: number, parentId: DirectoryId) => {
let query = db.selectFrom("file").selectAll().where("user_id", "=", userId);
query =
parentId === "root"
? query.where("parent_id", "is", null)
: query.where("parent_id", "=", parentId);
const files = await query.execute();
return files.map(
(file) =>
({
id: file.id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
}) satisfies File,
);
const files = await db
.selectFrom("file")
.selectAll()
.where("user_id", "=", userId)
.$if(parentId === "root", (qb) => qb.where("parent_id", "is", null))
.$if(parentId !== "root", (qb) => qb.where("parent_id", "=", parentId as number))
.execute();
return files.map(toFile);
};
export const getAllFilesByCategory = async (
@@ -339,27 +130,10 @@ export const getAllFilesByCategory = async (
.orderBy("file_id")
.orderBy("depth")
.execute();
return files.map(
(file) =>
({
id: file.file_id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
return files.map((file) => ({
...toFile(file),
isRecursive: file.depth > 0,
}) satisfies File & { isRecursive: boolean },
);
}));
};
export const getAllFileIds = async (userId: number) => {
@@ -375,26 +149,7 @@ export const getLegacyFiles = async (userId: number, limit: number = 100) => {
.where("encrypted_content_iv", "is not", null)
.limit(limit)
.execute();
return files.map(
(file) =>
({
id: file.id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
}) satisfies File,
);
return files.map(toFile);
};
export const getFilesWithoutThumbnail = async (userId: number, limit: number = 100) => {
@@ -418,26 +173,7 @@ export const getFilesWithoutThumbnail = async (userId: number, limit: number = 1
)
.limit(limit)
.execute();
return files.map(
(file) =>
({
id: file.id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
}) satisfies File,
);
return files.map(toFile);
};
export const getAllFileIdsByContentHmac = async (
@@ -463,25 +199,7 @@ export const getFile = async (userId: number, fileId: number) => {
.where("user_id", "=", userId)
.limit(1)
.executeTakeFirst();
return file
? ({
id: file.id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
} satisfies File)
: null;
return file ? toFile(file) : null;
};
export const getFilesWithCategories = async (userId: number, fileIds: number[]) => {
@@ -500,40 +218,37 @@ export const getFilesWithCategories = async (userId: number, fileIds: number[])
.where("id", "=", (eb) => eb.fn.any(eb.val(fileIds)))
.where("user_id", "=", userId)
.execute();
return files.map(
(file) =>
return files.map((file) => ({
...toFile(file),
categories: file.categories.map(
(category) =>
({
id: file.id,
parentId: file.parent_id ?? "root",
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
categories: file.categories.map((category) => ({
id: category.id,
parentId: category.parent_id ?? "root",
mekVersion: category.master_encryption_key_version,
encDek: category.encrypted_data_encryption_key,
dekVersion: new Date(category.data_encryption_key_version),
encName: category.encrypted_name,
})),
}) satisfies File & { categories: FileCategory[] },
);
}) satisfies FileCategory,
),
}));
};
export const getAllFavoriteFiles = async (userId: number) => {
const files = await db
.selectFrom("file")
.selectAll()
.where("user_id", "=", userId)
.where("is_favorite", "=", true)
.execute();
return files.map(toFile);
};
export const searchFiles = async (
userId: number,
filters: {
parentId: DirectoryId;
inFavorites: boolean;
includeCategoryIds: number[];
excludeCategoryIds: number[];
},
@@ -544,7 +259,7 @@ export const searchFiles = async (
.selectFrom("directory")
.select("id")
.where("user_id", "=", userId)
.where((eb) => eb.val(filters.parentId !== "root")) // directory_tree will be empty if parentId is "root"
.$if(filters.parentId === "root", (qb) => qb.where((eb) => eb.lit(false))) // directory_tree will be empty if parentId is "root"
.$if(filters.parentId !== "root", (qb) => qb.where("id", "=", filters.parentId as number))
.unionAll(
db
@@ -553,6 +268,20 @@ export const searchFiles = async (
.select("d.id"),
),
)
.withRecursive("favorite_directory_tree", (db) =>
db
.selectFrom("directory")
.select("id")
.where("user_id", "=", userId)
.$if(!filters.inFavorites, (qb) => qb.where((eb) => eb.lit(false))) // favorite_directory_tree will be empty if inFavorites is false
.$if(filters.inFavorites, (qb) => qb.where("is_favorite", "=", true))
.unionAll((db) =>
db
.selectFrom("directory as d")
.innerJoin("favorite_directory_tree as dt", "d.parent_id", "dt.id")
.select("d.id"),
),
)
.withRecursive("include_category_tree", (db) =>
db
.selectFrom("category")
@@ -581,18 +310,30 @@ export const searchFiles = async (
)
.selectFrom("file")
.selectAll("file")
.$if(filters.parentId === "root", (qb) => qb.where("user_id", "=", userId)) // directory_tree isn't used if parentId is "root"
.where("user_id", "=", userId)
.$if(filters.parentId !== "root", (qb) =>
qb.where("parent_id", "in", (eb) => eb.selectFrom("directory_tree").select("id")),
qb.where((eb) =>
eb.exists(eb.selectFrom("directory_tree as dt").whereRef("dt.id", "=", "file.parent_id")),
),
)
.where((eb) =>
.$if(filters.inFavorites, (qb) =>
qb.where((eb) =>
eb.or([
eb("is_favorite", "=", true),
eb.exists(
eb.selectFrom("favorite_directory_tree as dt").whereRef("dt.id", "=", "file.parent_id"),
),
]),
),
)
.$if(filters.excludeCategoryIds.length > 0, (qb) =>
qb.where((eb) =>
eb.not(
eb.exists(
eb
.selectFrom("file_category")
.whereRef("file_id", "=", "file.id")
.where("category_id", "in", (eb) =>
eb.selectFrom("exclude_category_tree").select("id"),
.innerJoin("exclude_category_tree", "category_id", "exclude_category_tree.id")
.whereRef("file_id", "=", "file.id"),
),
),
),
@@ -614,23 +355,7 @@ export const searchFiles = async (
)
.execute()
: await baseQuery.execute();
return files.map((file) => ({
id: file.id,
parentId: file.parent_id ?? ("root" as const),
userId: file.user_id,
path: file.path,
mekVersion: file.master_encryption_key_version,
encDek: file.encrypted_data_encryption_key,
dekVersion: file.data_encryption_key_version,
hskVersion: file.hmac_secret_key_version,
contentHmac: file.content_hmac,
contentType: file.content_type,
encContentIv: file.encrypted_content_iv,
encContentHash: file.encrypted_content_hash,
encName: file.encrypted_name,
encCreatedAt: file.encrypted_created_at,
encLastModifiedAt: file.encrypted_last_modified_at,
}));
return files.map(toFile);
};
export const setFileEncName = async (
@@ -803,3 +528,36 @@ export const removeFileFromCategory = async (fileId: number, categoryId: number)
.execute();
});
};
export const setFileFavorite = async (userId: number, fileId: number, isFavorite: boolean) => {
await db.transaction().execute(async (trx) => {
const file = await trx
.selectFrom("file")
.select("is_favorite")
.where("id", "=", fileId)
.where("user_id", "=", userId)
.limit(1)
.forUpdate()
.executeTakeFirst();
if (!file) {
throw new IntegrityError("File not found");
} else if (file.is_favorite === isFavorite) {
throw new IntegrityError(isFavorite ? "File already favorited" : "File not favorited");
}
await trx
.updateTable("file")
.set({ is_favorite: isFavorite })
.where("id", "=", fileId)
.where("user_id", "=", userId)
.execute();
await trx
.insertInto("file_log")
.values({
file_id: fileId,
timestamp: new Date(),
action: isFavorite ? "add-to-favorites" : "remove-from-favorites",
})
.execute();
});
};

View File

@@ -1,5 +1,6 @@
export * as CategoryRepo from "./category";
export * as ClientRepo from "./client";
export * as DirectoryRepo from "./directory";
export * as FileRepo from "./file";
export * as HskRepo from "./hsk";
export * as MediaRepo from "./media";

View File

@@ -71,7 +71,7 @@ export const getAllValidClientMeks = async (userId: number, clientId: number) =>
.selectAll()
.where("client_master_encryption_key.user_id", "=", userId)
.where("client_master_encryption_key.client_id", "=", clientId)
.where((eb) => eb.or([eb("state", "=", "active"), eb("state", "=", "retired")]))
.where("state", "in", ["active", "retired"])
.execute();
return clientMeks.map(
({ user_id, client_id, version, state, encrypted_key, encrypted_key_signature }) =>

View File

@@ -135,7 +135,7 @@ export const up = async (db: Kysely<any>) => {
)
.execute();
// file.ts
// directory.ts
await db.schema
.createTable("directory")
.addColumn("id", "integer", (col) => col.primaryKey().generatedAlwaysAsIdentity())
@@ -162,6 +162,8 @@ export const up = async (db: Kysely<any>) => {
.addColumn("action", "text", (col) => col.notNull())
.addColumn("new_name", "json")
.execute();
// file.ts
await db.schema
.createTable("file")
.addColumn("id", "integer", (col) => col.primaryKey().generatedAlwaysAsIdentity())

View File

@@ -53,9 +53,7 @@ export const up = async (db: Kysely<any>) => {
export const down = async (db: Kysely<any>) => {
await db
.deleteFrom("file_log")
.where((eb) =>
eb.or([eb("action", "=", "add-to-category"), eb("action", "=", "remove-from-category")]),
)
.where("action", "in", ["add-to-category", "remove-from-category"])
.execute();
await db.schema.dropTable("file_category").execute();

View File

@@ -62,6 +62,8 @@ export const up = async (db: Kysely<any>) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const down = async (db: Kysely<any>) => {
await db.deleteFrom("file_log").where("action", "=", "migrate").execute();
await db.schema.dropTable("upload_session").execute();
await db.schema
.alterTable("thumbnail")

View File

@@ -0,0 +1,31 @@
import { Kysely } from "kysely";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const up = async (db: Kysely<any>) => {
// directory.ts
await db.schema
.alterTable("directory")
.addColumn("is_favorite", "boolean", (col) => col.notNull().defaultTo(false))
.execute();
// file.ts
await db.schema
.alterTable("file")
.addColumn("is_favorite", "boolean", (col) => col.notNull().defaultTo(false))
.execute();
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const down = async (db: Kysely<any>) => {
await db
.deleteFrom("file_log")
.where("action", "in", ["add-to-favorites", "remove-from-favorites"])
.execute();
await db
.deleteFrom("directory_log")
.where("action", "in", ["add-to-favorites", "remove-from-favorites"])
.execute();
await db.schema.alterTable("file").dropColumn("is_favorite").execute();
await db.schema.alterTable("directory").dropColumn("is_favorite").execute();
};

View File

@@ -2,10 +2,12 @@ import * as Initial1737357000 from "./1737357000-Initial";
import * as AddFileCategory1737422340 from "./1737422340-AddFileCategory";
import * as AddThumbnail1738409340 from "./1738409340-AddThumbnail";
import * as AddChunkedUpload1768062380 from "./1768062380-AddChunkedUpload";
import * as AddFavorites1768643000 from "./1768643000-AddFavorites";
export default {
"1737357000-Initial": Initial1737357000,
"1737422340-AddFileCategory": AddFileCategory1737422340,
"1738409340-AddThumbnail": AddThumbnail1738409340,
"1768062380-AddChunkedUpload": AddChunkedUpload1768062380,
"1768643000-AddFavorites": AddFavorites1768643000,
};

View File

@@ -1,7 +1,7 @@
import type { Generated } from "kysely";
import type { Ciphertext } from "./utils";
interface CategoryTable {
export interface CategoryTable {
id: Generated<number>;
parent_id: number | null;
user_id: number;
@@ -11,7 +11,7 @@ interface CategoryTable {
encrypted_name: Ciphertext;
}
interface CategoryLogTable {
export interface CategoryLogTable {
id: Generated<number>;
category_id: number;
timestamp: Date;

View File

@@ -1,6 +1,6 @@
import type { ColumnType, Generated } from "kysely";
interface ClientTable {
export interface ClientTable {
id: Generated<number>;
encryption_public_key: string; // Base64
signature_public_key: string; // Base64
@@ -8,13 +8,13 @@ interface ClientTable {
export type UserClientState = "challenging" | "pending" | "active";
interface UserClientTable {
export interface UserClientTable {
user_id: number;
client_id: number;
state: ColumnType<UserClientState, UserClientState | undefined>;
}
interface UserClientChallengeTable {
export interface UserClientChallengeTable {
id: Generated<number>;
user_id: number;
client_id: number;

View File

@@ -0,0 +1,28 @@
import type { ColumnType, Generated } from "kysely";
import type { Ciphertext } from "./utils";
export interface DirectoryTable {
id: Generated<number>;
parent_id: number | null;
user_id: number;
master_encryption_key_version: number;
encrypted_data_encryption_key: string; // Base64
data_encryption_key_version: Date;
encrypted_name: Ciphertext;
is_favorite: Generated<boolean>;
}
export interface DirectoryLogTable {
id: Generated<number>;
directory_id: number;
timestamp: ColumnType<Date, Date, never>;
action: "create" | "rename" | "add-to-favorites" | "remove-from-favorites";
new_name: Ciphertext | null;
}
declare module "./index" {
interface Database {
directory: DirectoryTable;
directory_log: DirectoryLogTable;
}
}

View File

@@ -1,25 +1,7 @@
import type { ColumnType, Generated } from "kysely";
import type { Ciphertext } from "./utils";
interface DirectoryTable {
id: Generated<number>;
parent_id: number | null;
user_id: number;
master_encryption_key_version: number;
encrypted_data_encryption_key: string; // Base64
data_encryption_key_version: Date;
encrypted_name: Ciphertext;
}
interface DirectoryLogTable {
id: Generated<number>;
directory_id: number;
timestamp: ColumnType<Date, Date, never>;
action: "create" | "rename";
new_name: Ciphertext | null;
}
interface FileTable {
export interface FileTable {
id: Generated<number>;
parent_id: number | null;
user_id: number;
@@ -35,26 +17,32 @@ interface FileTable {
encrypted_name: Ciphertext;
encrypted_created_at: Ciphertext | null;
encrypted_last_modified_at: Ciphertext;
is_favorite: Generated<boolean>;
}
interface FileLogTable {
export interface FileLogTable {
id: Generated<number>;
file_id: number;
timestamp: ColumnType<Date, Date, never>;
action: "create" | "rename" | "migrate" | "add-to-category" | "remove-from-category";
action:
| "create"
| "rename"
| "migrate"
| "add-to-category"
| "remove-from-category"
| "add-to-favorites"
| "remove-from-favorites";
new_name: Ciphertext | null;
category_id: number | null;
}
interface FileCategoryTable {
export interface FileCategoryTable {
file_id: number;
category_id: number;
}
declare module "./index" {
interface Database {
directory: DirectoryTable;
directory_log: DirectoryLogTable;
file: FileTable;
file_log: FileLogTable;
file_category: FileCategoryTable;

View File

@@ -2,7 +2,7 @@ import type { ColumnType, Generated } from "kysely";
export type HskState = "active";
interface HskTable {
export interface HskTable {
user_id: number;
version: number;
state: HskState;
@@ -10,7 +10,7 @@ interface HskTable {
encrypted_key: string; // Base64
}
interface HskLogTable {
export interface HskLogTable {
id: Generated<number>;
user_id: number;
hmac_secret_key_version: number;

View File

@@ -1,5 +1,6 @@
export * from "./category";
export * from "./client";
export * from "./directory";
export * from "./file";
export * from "./hsk";
export * from "./media";

View File

@@ -1,6 +1,6 @@
import type { Generated } from "kysely";
interface ThumbnailTable {
export interface ThumbnailTable {
id: Generated<number>;
directory_id: number | null;
file_id: number | null;

View File

@@ -2,13 +2,13 @@ import type { ColumnType, Generated } from "kysely";
export type MekState = "active" | "retired" | "dead";
interface MekTable {
export interface MekTable {
user_id: number;
version: number;
state: MekState;
}
interface MekLogTable {
export interface MekLogTable {
id: Generated<number>;
user_id: number;
master_encryption_key_version: number;
@@ -17,7 +17,7 @@ interface MekLogTable {
action_by: number | null;
}
interface ClientMekTable {
export interface ClientMekTable {
user_id: number;
client_id: number;
version: number;

View File

@@ -1,6 +1,6 @@
import type { ColumnType, Generated } from "kysely";
interface SessionTable {
export interface SessionTable {
id: string;
user_id: number;
client_id: number | null;
@@ -10,7 +10,7 @@ interface SessionTable {
last_used_by_agent: string | null;
}
interface SessionUpgradeChallengeTable {
export interface SessionUpgradeChallengeTable {
id: Generated<number>;
session_id: string;
client_id: number;

View File

@@ -1,7 +1,7 @@
import type { Generated } from "kysely";
import type { Ciphertext } from "./utils";
interface UploadSessionTable {
export interface UploadSessionTable {
id: string;
type: "file" | "thumbnail" | "migration";
user_id: number;

View File

@@ -1,6 +1,6 @@
import type { Generated } from "kysely";
interface UserTable {
export interface UserTable {
id: Generated<number>;
email: string;
nickname: string;

View File

@@ -0,0 +1,37 @@
import { appendFileSync, existsSync, mkdirSync } from "fs";
import { env } from "$env/dynamic/private";
const LOG_DIR = env.LOG_DIR || "log";
const getLogFilePath = () => {
const date = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
return `${LOG_DIR}/arkvault-${date}.log`;
};
const ensureLogDir = () => {
if (!existsSync(LOG_DIR)) {
mkdirSync(LOG_DIR, { recursive: true });
}
};
const formatLogLine = (type: string, data: Record<string, unknown>) => {
const timestamp = new Date().toISOString();
return JSON.stringify({ timestamp, type, ...data });
};
export const demoLogger = {
log: (type: string, data: Record<string, unknown>) => {
const line = formatLogLine(type, data);
// Output to stdout
console.log(line);
// Output to file
try {
ensureLogDir();
appendFileSync(getLogFilePath(), line + "\n", { encoding: "utf-8" });
} catch (e) {
console.error("Failed to write to log file:", e);
}
},
};

1
src/lib/types/utils.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
type AllUndefined<T> = { [K in keyof T]?: undefined };

View File

@@ -14,8 +14,8 @@
let { data } = $props();
let email = $state("");
let password = $state("");
let email = $state("arkvault-demo@minchan.me");
let password = $state("arkvault-demo");
let isForceLoginModalOpen = $state(false);

View File

@@ -18,6 +18,7 @@
requestThumbnailUpload,
requestFileAdditionToCategory,
requestVideoStream,
requestFavoriteToggle,
} from "./service";
import TopBarMenu from "./TopBarMenu.svelte";
@@ -75,6 +76,11 @@
void getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
};
const toggleFavorite = async () => {
await requestFavoriteToggle(data.id, !!info?.isFavorite);
void getFileInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
};
$effect(() => {
HybridPromise.resolve(getFileInfo(data.id, $masterKeyStore?.get(1)?.key!)).then((result) => {
if (data.id === result.id) {
@@ -144,13 +150,13 @@
<div onclick={(e) => e.stopPropagation()}>
<button
onclick={() => (isMenuOpen = !isMenuOpen)}
class="w-[2.3rem] flex-shrink-0 rounded-full p-1 active:bg-black active:bg-opacity-[0.04]"
class="w-full rounded-full p-1 text-2xl active:bg-black active:bg-opacity-[0.04]"
>
<IconMoreVert class="text-2xl" />
<IconMoreVert />
</button>
<TopBarMenu
bind:isOpen={isMenuOpen}
directoryId={["category", "gallery", "search"].includes(
directoryId={["category", "gallery", "search", "favorite"].includes(
page.url.searchParams.get("from") ?? "",
)
? info?.parentId
@@ -158,6 +164,8 @@
{fileBlob}
downloadUrl={videoStreamUrl}
filename={info?.name}
isFavorite={info?.isFavorite}
onToggleFavorite={toggleFavorite}
/>
</div>
</TopBar>

View File

@@ -5,6 +5,8 @@
import { fly } from "svelte/transition";
import { goto } from "$app/navigation";
import IconFavorite from "~icons/material-symbols/favorite";
import IconFavoriteOutline from "~icons/material-symbols/favorite-outline";
import IconFolderOpen from "~icons/material-symbols/folder-open";
import IconCloudDownload from "~icons/material-symbols/cloud-download";
@@ -13,10 +15,20 @@
downloadUrl?: string;
fileBlob?: Blob;
filename?: string;
isFavorite?: boolean;
isOpen: boolean;
onToggleFavorite?: () => void;
}
let { directoryId, downloadUrl, fileBlob, filename, isOpen = $bindable() }: Props = $props();
let {
directoryId,
downloadUrl,
fileBlob,
filename,
isFavorite,
isOpen = $bindable(),
onToggleFavorite,
}: Props = $props();
const handleDownload = () => {
if (fileBlob && filename) {
@@ -34,7 +46,7 @@
{#if isOpen && (directoryId || downloadUrl || fileBlob)}
<div
class="absolute right-2 top-full z-20 space-y-1 rounded-lg bg-white px-1 py-2 shadow-2xl"
class="absolute right-2 top-full z-20 min-w-44 space-y-1 rounded-lg bg-white px-1 py-2 shadow-2xl"
transition:fly={{ y: -8, duration: 200 }}
>
<p class="px-3 pt-2 text-sm font-semibold text-gray-600">더보기</p>
@@ -54,6 +66,13 @@
</button>
{/snippet}
{#if isFavorite !== undefined}
{@render menuButton(
isFavorite ? IconFavorite : IconFavoriteOutline,
isFavorite ? "즐겨찾기 해제" : "즐겨찾기",
onToggleFavorite ?? (() => {}),
)}
{/if}
{#if directoryId}
{@render menuButton(IconFolderOpen, "폴더에서 보기", () =>
goto(

View File

@@ -48,3 +48,17 @@ export const requestFileAdditionToCategory = async (fileId: number, categoryId:
return false;
}
};
export const requestFavoriteToggle = async (fileId: number, isFavorite: boolean) => {
try {
if (isFavorite) {
await trpc().favorites.removeFile.mutate({ id: fileId });
} else {
await trpc().favorites.addFile.mutate({ id: fileId });
}
return true;
} catch {
// TODO: Error Handling
return false;
}
};

View File

@@ -25,6 +25,7 @@
includeImages: boolean;
includeVideos: boolean;
includeDirectories: boolean;
searchInFavorites: boolean;
searchInDirectory: boolean;
categories: SearchFilter["categories"];
}
@@ -37,6 +38,7 @@
includeVideos: false,
includeDirectories: false,
searchInDirectory: false,
searchInFavorites: false,
categories: [],
});
let hasCategoryFilter = $derived(filters.categories.length > 0);
@@ -81,7 +83,7 @@
return sortEntries(
[...directories, ...files].filter(
({ name }) => !nameFilter || searchString(name, nameFilter),
(entry) => !nameFilter || searchString(entry.name, nameFilter),
),
);
});
@@ -118,7 +120,7 @@
},
};
$effect(() => {
$effect.pre(() => {
if (data.directoryId) {
HybridPromise.resolve(getDirectoryInfo(data.directoryId, $masterKeyStore?.get(1)?.key!)).then(
(res) => {
@@ -132,10 +134,15 @@
}
});
$effect.pre(() => {
filters.searchInFavorites = data.fromFavorites;
});
$effect(() => {
// Svelte sucks
hasAnyFilter;
filters.searchInDirectory;
filters.searchInFavorites;
filters.categories.length;
if (untrack(() => isRestoredFromSnapshot)) {
@@ -147,6 +154,7 @@
requestSearch(
{
ancestorId: filters.searchInDirectory ? data.directoryId! : "root",
inFavorites: filters.searchInFavorites,
categories: filters.categories,
},
$masterKeyStore?.get(1)?.key!,
@@ -172,6 +180,7 @@
{#if !hasCategoryFilter}
<Chip bind:selected={filters.includeDirectories}>폴더</Chip>
{/if}
<Chip bind:selected={filters.searchInFavorites}>즐겨찾기</Chip>
{#if directoryInfo?.exists}
<Chip bind:selected={filters.searchInDirectory}>
위치: {directoryInfo.name}
@@ -206,7 +215,12 @@
</div>
{#if hasAnyFilter}
<div class="flex flex-grow flex-col space-y-2 bg-white p-4">
<p class="text-lg font-bold text-gray-800">검색 결과</p>
<p class="text-lg font-bold text-gray-800">
검색 결과
{#if result.length > 0}
{" "}({result.length}개)
{/if}
</p>
{#if result.length > 0}
<RowVirtualizer
count={result.length}

View File

@@ -4,15 +4,18 @@ import type { PageLoad } from "./$types";
export const load: PageLoad = ({ url }) => {
const directoryId = url.searchParams.get("directoryId");
const from = url.searchParams.get("from");
const zodRes = z
.object({
directoryId: z.coerce.number().int().positive().nullable(),
from: z.enum(["favorites"]).nullable(),
})
.safeParse({ directoryId });
.safeParse({ directoryId, from });
if (!zodRes.success) error(400, "Invalid query parameters");
return {
directoryId: zodRes.data.directoryId,
fromFavorites: zodRes.data.from === "favorites",
};
};

View File

@@ -12,5 +12,5 @@
</script>
<ActionEntryButton class="h-14" {onclick}>
<DirectoryEntryLabel type="directory" name={info.name} />
<DirectoryEntryLabel type="directory" name={info.name} isFavorite={info.isFavorite} />
</ActionEntryButton>

View File

@@ -21,5 +21,6 @@
thumbnail={$thumbnail}
name={info.name}
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
isFavorite={info.isFavorite}
/>
</ActionEntryButton>

View File

@@ -1,17 +1,14 @@
<script lang="ts">
import type { ClassValue } from "svelte/elements";
import IconArrowBack from "~icons/material-symbols/arrow-back";
interface Props {
class?: ClassValue;
value: string;
}
let { class: className, value = $bindable() }: Props = $props();
let { value = $bindable() }: Props = $props();
</script>
<div class={["sticky top-0 z-10 flex items-center gap-x-2 px-2 py-3 backdrop-blur-2xl", className]}>
<div class={"sticky top-0 z-10 flex items-center gap-x-2 px-2 py-3 backdrop-blur-2xl"}>
<button
onclick={() => history.back()}
class="w-[2.3rem] flex-shrink-0 rounded-full p-1 active:bg-black active:bg-opacity-[0.04]"
@@ -22,6 +19,6 @@
bind:value
type="text"
placeholder="검색"
class="mr-1 h-[2.3rem] flex-grow rounded-lg bg-gray-100 px-3 py-1.5 placeholder-gray-600 focus:outline-none"
class="mr-1 h-[2.3rem] min-w-0 flex-grow rounded-lg bg-gray-100 px-3 py-1.5 placeholder-gray-600 focus:outline-none"
/>
</div>

View File

@@ -1,6 +1,4 @@
import {
decryptDirectoryMetadata,
decryptFileMetadata,
getDirectoryInfo,
getFileInfo,
type LocalDirectoryInfo,
@@ -12,6 +10,7 @@ import { trpc } from "$trpc/client";
export interface SearchFilter {
ancestorId: DirectoryId;
inFavorites: boolean;
categories: { info: LocalCategoryInfo; type: "include" | "exclude" }[];
}
@@ -23,6 +22,7 @@ export interface SearchResult {
export const requestSearch = async (filter: SearchFilter, masterKey: CryptoKey) => {
const { directories: directoriesRaw, files: filesRaw } = await trpc().search.search.query({
ancestor: filter.ancestorId,
inFavorites: filter.inFavorites,
includeCategories: filter.categories
.filter(({ type }) => type === "include")
.map(({ info }) => info.id),
@@ -30,47 +30,14 @@ export const requestSearch = async (filter: SearchFilter, masterKey: CryptoKey)
.filter(({ type }) => type === "exclude")
.map(({ info }) => info.id),
});
const [directories, files] = await HybridPromise.all([
HybridPromise.all(
directoriesRaw.map((directory) =>
HybridPromise.resolve(
getDirectoryInfo(directory.id, masterKey, {
async fetchFromServer(id, cachedInfo, masterKey) {
const metadata = await decryptDirectoryMetadata(directory, masterKey);
return {
subDirectories: [],
files: [],
...cachedInfo,
id: id as number,
exists: true,
parentId: directory.parent,
...metadata,
};
},
}),
),
getDirectoryInfo(directory.id, masterKey, { serverResponse: directory }),
),
),
HybridPromise.all(
filesRaw.map((file) =>
HybridPromise.resolve(
getFileInfo(file.id, masterKey, {
async fetchFromServer(id, cachedInfo, masterKey) {
const metadata = await decryptFileMetadata(file, masterKey);
return {
categories: [],
...cachedInfo,
id: id as number,
exists: true,
parentId: file.parent,
contentType: file.contentType,
...metadata,
};
},
}),
),
),
filesRaw.map((file) => getFileInfo(file.id, masterKey, { serverResponse: file })),
),
]);
return { directories, files } as SearchResult;

View File

@@ -1,12 +1,7 @@
import { limitFunction } from "p-limit";
import { SvelteMap } from "svelte/reactivity";
import { CHUNK_SIZE } from "$lib/constants";
import {
decryptFileMetadata,
getFileInfo,
type FileInfo,
type MaybeFileInfo,
} from "$lib/modules/filesystem";
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem";
import { uploadBlob } from "$lib/modules/upload";
import { requestFileDownload } from "$lib/services/file";
import { HybridPromise, Scheduler } from "$lib/utils";
@@ -35,28 +30,9 @@ export const requestLegacyFiles = async (
masterKey: CryptoKey,
) => {
const files = await HybridPromise.all(
filesRaw.map((file) =>
HybridPromise.resolve(
getFileInfo(file.id, masterKey, {
async fetchFromServer(id, cachedInfo, masterKey) {
const metadata = await decryptFileMetadata(file, masterKey);
return {
categories: [],
...cachedInfo,
id: id as number,
exists: true,
isLegacy: file.isLegacy,
parentId: file.parent,
contentType: file.contentType,
...metadata,
};
},
}),
),
),
filesRaw.map((file) => getFileInfo(file.id, masterKey, { serverResponse: file })),
);
return files as MaybeFileInfo[];
return files;
};
const createState = (status: MigrationStatus): MigrationState => {

View File

@@ -1,12 +1,7 @@
import { limitFunction } from "p-limit";
import { SvelteMap } from "svelte/reactivity";
import { storeFileThumbnailCache } from "$lib/modules/file";
import {
decryptFileMetadata,
getFileInfo,
type FileInfo,
type MaybeFileInfo,
} from "$lib/modules/filesystem";
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem";
import { generateThumbnail } from "$lib/modules/thumbnail";
import { requestFileDownload, requestFileThumbnailUpload } from "$lib/services/file";
import { HybridPromise, Scheduler } from "$lib/utils";
@@ -40,28 +35,9 @@ export const requestMissingThumbnailFiles = async (
masterKey: CryptoKey,
) => {
const files = await HybridPromise.all(
filesRaw.map((file) =>
HybridPromise.resolve(
getFileInfo(file.id, masterKey, {
async fetchFromServer(id, cachedInfo, masterKey) {
const metadata = await decryptFileMetadata(file, masterKey);
return {
categories: [],
...cachedInfo,
id: id as number,
exists: true,
isLegacy: file.isLegacy,
parentId: file.parent,
contentType: file.contentType,
...metadata,
};
},
}),
),
),
filesRaw.map((file) => getFileInfo(file.id, masterKey, { serverResponse: file })),
);
return files as MaybeFileInfo[];
return files;
};
const requestThumbnailUpload = limitFunction(

View File

@@ -12,7 +12,7 @@
const pages = [
{ path: "/home", label: "홈", icon: IconHome },
{ path: "/directory", label: "파일", icon: IconFolder },
{ path: "/favorite", label: "즐겨찾기", icon: IconFavorite },
{ path: "/favorites", label: "즐겨찾기", icon: IconFavorite },
{ path: "/category", label: "카테고리", icon: IconCategory },
{ path: "/menu", label: "전체", icon: IconMenu },
];

View File

@@ -3,6 +3,7 @@
import { DirectoryEntryLabel } from "$lib/components/molecules";
import { getFileThumbnail } from "$lib/modules/file";
import type { CategoryFileInfo } from "$lib/modules/filesystem";
import { formatDateTime } from "$lib/utils";
import type { SelectedFile } from "./service.svelte";
import IconClose from "~icons/material-symbols/close";
@@ -19,10 +20,16 @@
</script>
<ActionEntryButton
class="h-12"
class="h-14"
onclick={() => onclick(info)}
actionButtonIcon={onRemoveClick && IconClose}
onActionButtonClick={() => onRemoveClick?.(info)}
>
<DirectoryEntryLabel type="file" thumbnail={$thumbnail} name={info.name} />
<DirectoryEntryLabel
type="file"
thumbnail={$thumbnail}
name={info.name}
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
isFavorite={info.isFavorite}
/>
</ActionEntryButton>

View File

@@ -23,6 +23,7 @@
requestFileUpload,
requestEntryRename,
requestEntryDeletion,
requestFavoriteToggle,
} from "./service.svelte";
import IconSearch from "~icons/material-symbols/search";
@@ -45,7 +46,7 @@
let isEntryDeleteModalOpen = $state(false);
let showParentEntry = $derived(
["file", "search"].includes(page.url.searchParams.get("from") ?? ""),
["file", "search", "favorite"].includes(page.url.searchParams.get("from") ?? ""),
);
let showBackButton = $derived(data.id !== "root" || showParentEntry);
@@ -102,7 +103,7 @@
</script>
<svelte:head>
<title>파일</title>
<title>파일</title>
</svelte:head>
<input bind:this={fileInput} onchange={uploadFile} type="file" multiple class="hidden" />
@@ -194,6 +195,12 @@
isEntryMenuBottomSheetOpen = false;
isEntryDeleteModalOpen = true;
}}
onFavoriteClick={async () => {
if (await requestFavoriteToggle(context.selectedEntry!)) {
isEntryMenuBottomSheetOpen = false;
void getDirectoryInfo(data.id, $masterKeyStore?.get(1)?.key!); // TODO: FIXME
}
}}
/>
<EntryRenameModal
bind:isOpen={isEntryRenameModalOpen}

View File

@@ -19,7 +19,13 @@
let thumbnail = $derived(getFileThumbnail(info));
const action = (callback: typeof onclick) => {
callback({ type: "file", id: info.id, dataKey: info.dataKey, name: info.name });
callback({
type: "file",
id: info.id,
dataKey: info.dataKey,
name: info.name,
isFavorite: info.isFavorite,
});
};
</script>
@@ -34,5 +40,6 @@
thumbnail={$thumbnail}
name={info.name}
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
isFavorite={info.isFavorite}
/>
</ActionEntryButton>

View File

@@ -15,7 +15,13 @@
let { info, onclick, onOpenMenuClick }: Props = $props();
const action = (callback: typeof onclick) => {
callback({ type: "directory", id: info.id, dataKey: info.dataKey, name: info.name });
callback({
type: "directory",
id: info.id,
dataKey: info.dataKey,
name: info.name,
isFavorite: info.isFavorite,
});
};
</script>
@@ -25,5 +31,5 @@
actionButtonIcon={IconMoreVert}
onActionButtonClick={() => action(onOpenMenuClick)}
>
<DirectoryEntryLabel type="directory" name={info.name} />
<DirectoryEntryLabel type="directory" name={info.name} isFavorite={info.isFavorite} />
</ActionEntryButton>

View File

@@ -3,24 +3,35 @@
import { DirectoryEntryLabel, IconEntryButton } from "$lib/components/molecules";
import { useContext } from "./service.svelte";
import IconFavorite from "~icons/material-symbols/favorite";
import IconFavoriteBorder from "~icons/material-symbols/favorite-outline";
import IconEdit from "~icons/material-symbols/edit";
import IconDelete from "~icons/material-symbols/delete";
interface Props {
isOpen: boolean;
onDeleteClick: () => void;
onFavoriteClick: () => void;
onRenameClick: () => void;
}
let { isOpen = $bindable(), onDeleteClick, onRenameClick }: Props = $props();
let { isOpen = $bindable(), onDeleteClick, onFavoriteClick, onRenameClick }: Props = $props();
let context = useContext();
</script>
{#if context.selectedEntry}
{@const { name, type } = context.selectedEntry}
{@const { name, type, isFavorite } = context.selectedEntry}
<BottomSheet bind:isOpen class="p-4">
<DirectoryEntryLabel {type} {name} class="h-12 p-2" textClass="!font-semibold" />
<div class="my-2 h-px w-full bg-gray-200"></div>
<IconEntryButton
icon={isFavorite ? IconFavorite : IconFavoriteBorder}
onclick={onFavoriteClick}
class="h-12 w-full"
iconClass={isFavorite ? "text-red-500" : ""}
>
{isFavorite ? "즐겨찾기에서 해제하기" : "즐겨찾기에 추가하기"}
</IconEntryButton>
<IconEntryButton icon={IconEdit} onclick={onRenameClick} class="h-12 w-full">
이름 바꾸기
</IconEntryButton>

View File

@@ -17,6 +17,7 @@ export interface SelectedEntry {
id: number;
dataKey: DataKey | undefined;
name: string;
isFavorite: boolean;
}
export const createContext = () => {
@@ -149,3 +150,25 @@ export const requestEntryDeletion = async (entry: SelectedEntry) => {
return false;
}
};
export const requestFavoriteToggle = async (entry: SelectedEntry) => {
try {
if (entry.type === "directory") {
if (entry.isFavorite) {
await trpc().favorites.removeDirectory.mutate({ id: entry.id });
} else {
await trpc().favorites.addDirectory.mutate({ id: entry.id });
}
} else {
if (entry.isFavorite) {
await trpc().favorites.removeFile.mutate({ id: entry.id });
} else {
await trpc().favorites.addFile.mutate({ id: entry.id });
}
}
return true;
} catch {
// TODO: Error Handling
return false;
}
};

View File

@@ -1,3 +0,0 @@
<div class="flex h-full items-center justify-center p-4">
<p class="text-gray-500">아직 개발 중이에요.</p>
</div>

View File

@@ -0,0 +1,7 @@
import { createCaller } from "$trpc/router.server";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async (event) => {
const favorites = await createCaller(event).favorites.get();
return { favorites };
};

View File

@@ -0,0 +1,93 @@
<script lang="ts">
import { onMount } from "svelte";
import { goto } from "$app/navigation";
import { RowVirtualizer } from "$lib/components/atoms";
import { TopBar } from "$lib/components/molecules";
import { masterKeyStore } from "$lib/stores";
import Directory from "./Directory.svelte";
import File from "./File.svelte";
import { requestFavoriteEntries, requestRemoveFavorite, type FavoriteEntry } from "./service";
import IconSearch from "~icons/material-symbols/search";
let { data } = $props();
let entries: FavoriteEntry[] = $state([]);
let isLoading = $state(true);
onMount(async () => {
const masterKey = $masterKeyStore?.get(1)?.key;
if (masterKey) {
entries = await requestFavoriteEntries(data.favorites, masterKey);
}
isLoading = false;
});
const handleRemove = async (entry: FavoriteEntry) => {
if (await requestRemoveFavorite(entry.type, entry.details.id)) {
entries = entries.filter(
(e) => !(e.type === entry.type && e.details.id === entry.details.id),
);
}
};
const handleClick = (entry: FavoriteEntry) => {
goto(
entry.type === "file"
? `/file/${entry.details.id}?from=favorite`
: `/directory/${entry.details.id}?from=favorite`,
);
};
</script>
<svelte:head>
<title>즐겨찾기</title>
</svelte:head>
<div class="flex h-full flex-col">
<TopBar title="즐겨찾기" showBackButton={false}>
<button
onclick={() => goto("/search?from=favorites")}
class="w-full rounded-full p-1 text-2xl active:bg-black active:bg-opacity-[0.04]"
>
<IconSearch />
</button>
</TopBar>
<div class="flex flex-grow flex-col px-4 pb-4">
{#if entries.length > 0}
<RowVirtualizer
count={entries.length}
getItemKey={(index) => `${entries[index]!.type}-${entries[index]!.details.id}`}
estimateItemHeight={() => 56}
itemGap={4}
>
{#snippet item(index)}
{@const entry = entries[index]!}
{#if entry.type === "directory"}
<Directory
info={entry.details}
onclick={() => handleClick(entry)}
onRemoveClick={() => handleRemove(entry)}
/>
{:else}
<File
info={entry.details}
onclick={() => handleClick(entry)}
onRemoveClick={() => handleRemove(entry)}
/>
{/if}
{/snippet}
</RowVirtualizer>
{:else}
<div class="flex flex-grow items-center justify-center">
<p class="text-gray-500">
{#if isLoading}
즐겨찾기 목록을 불러오고 있어요.
{:else}
즐겨찾기한 항목이 없어요.
{/if}
</p>
</div>
{/if}
</div>
</div>

View File

@@ -0,0 +1,24 @@
<script lang="ts">
import { ActionEntryButton } from "$lib/components/atoms";
import { DirectoryEntryLabel } from "$lib/components/molecules";
import type { SubDirectoryInfo } from "$lib/modules/filesystem";
import IconClose from "~icons/material-symbols/close";
interface Props {
info: SubDirectoryInfo;
onclick: () => void;
onRemoveClick: () => void;
}
let { info, onclick, onRemoveClick }: Props = $props();
</script>
<ActionEntryButton
class="h-14"
{onclick}
actionButtonIcon={IconClose}
onActionButtonClick={onRemoveClick}
>
<DirectoryEntryLabel type="directory" name={info.name} isFavorite />
</ActionEntryButton>

View File

@@ -0,0 +1,34 @@
<script lang="ts">
import { ActionEntryButton } from "$lib/components/atoms";
import { DirectoryEntryLabel } from "$lib/components/molecules";
import { getFileThumbnail } from "$lib/modules/file";
import type { SummarizedFileInfo } from "$lib/modules/filesystem";
import { formatDateTime } from "$lib/utils";
import IconClose from "~icons/material-symbols/close";
interface Props {
info: SummarizedFileInfo;
onclick: () => void;
onRemoveClick: () => void;
}
let { info, onclick, onRemoveClick }: Props = $props();
let thumbnail = $derived(getFileThumbnail(info));
</script>
<ActionEntryButton
class="h-14"
{onclick}
actionButtonIcon={IconClose}
onActionButtonClick={onRemoveClick}
>
<DirectoryEntryLabel
type="file"
thumbnail={$thumbnail}
name={info.name}
subtext={formatDateTime(info.createdAt ?? info.lastModifiedAt)}
isFavorite
/>
</ActionEntryButton>

View File

@@ -0,0 +1,68 @@
import {
getDirectoryInfo,
getFileInfo,
type SummarizedFileInfo,
type SubDirectoryInfo,
type LocalDirectoryInfo,
} from "$lib/modules/filesystem";
import { HybridPromise, sortEntries } from "$lib/utils";
import { trpc } from "$trpc/client";
import type { RouterOutputs } from "$trpc/router.server";
export type FavoriteEntry =
| { type: "directory"; name: string; details: SubDirectoryInfo }
| { type: "file"; name: string; details: SummarizedFileInfo };
export const requestFavoriteEntries = async (
favorites: RouterOutputs["favorites"]["get"],
masterKey: CryptoKey,
) => {
const [directories, files] = await HybridPromise.all([
HybridPromise.all(
favorites.directories.map((directory) =>
getDirectoryInfo(directory.id, masterKey, {
serverResponse: { ...directory, isFavorite: true },
}),
),
),
HybridPromise.all(
favorites.files.map((file) =>
getFileInfo(file.id, masterKey, { serverResponse: { ...file, isFavorite: true } }),
),
),
]);
return [
...sortEntries(
directories.map(
(directory): FavoriteEntry => ({
type: "directory",
name: directory.name!,
details: directory as LocalDirectoryInfo,
}),
),
),
...sortEntries(
files.map(
(file): FavoriteEntry => ({
type: "file",
name: file.name!,
details: file as SummarizedFileInfo,
}),
),
),
];
};
export const requestRemoveFavorite = async (type: "file" | "directory", id: number) => {
try {
if (type === "directory") {
await trpc().favorites.removeDirectory.mutate({ id });
} else {
await trpc().favorites.removeFile.mutate({ id });
}
return true;
} catch {
// TODO: Error Handling
return false;
}
};

View File

@@ -52,13 +52,6 @@
</div>
<div class="space-y-2">
<p class="font-semibold">보안</p>
<MenuEntryButton
onclick={() => goto("/auth/changePassword")}
icon={IconPassword}
iconColor="text-blue-500"
>
비밀번호 바꾸기
</MenuEntryButton>
<MenuEntryButton onclick={logout} icon={IconLogout} iconColor="text-red-500">
로그아웃
</MenuEntryButton>

View File

@@ -62,9 +62,7 @@ const streamFromServer = async (
) => {
const totalSize = getDecryptedSize(metadata.encContentSize, metadata.isLegacy);
const start = range?.start ?? 0;
const end =
range?.end ??
(range && !metadata.isLegacy ? Math.min(start + CHUNK_SIZE, totalSize) : totalSize) - 1;
const end = range?.end ?? totalSize - 1;
if (start > end || start < 0 || end >= totalSize) {
return new Response("Invalid range", { status: 416 });
}

View File

@@ -6,6 +6,7 @@ import {
categoryRouter,
clientRouter,
directoryRouter,
favoritesRouter,
fileRouter,
hskRouter,
mekRouter,
@@ -19,6 +20,7 @@ export const appRouter = router({
category: categoryRouter,
client: clientRouter,
directory: directoryRouter,
favorites: favoritesRouter,
file: fileRouter,
hsk: hskRouter,
mek: mekRouter,

View File

@@ -5,6 +5,7 @@ import { ClientRepo, SessionRepo, UserRepo, IntegrityError } from "$lib/server/d
import env from "$lib/server/loadenv";
import { cookieOptions } from "$lib/server/modules/auth";
import { generateChallenge, verifySignature, issueSessionId } from "$lib/server/modules/crypto";
import { demoLogger } from "$lib/server/modules/logger";
import { router, publicProcedure, roleProcedure } from "../init.server";
const authRouter = router({
@@ -24,6 +25,10 @@ const authRouter = router({
const { sessionId, sessionIdSigned } = await issueSessionId(32, env.session.secret);
await SessionRepo.createSession(user.id, sessionId, ctx.locals.ip, ctx.locals.userAgent);
ctx.cookies.set("sessionId", sessionIdSigned, cookieOptions);
if (input.email === "arkvault-demo@minchan.me") {
demoLogger.log("demo:login", { ip: ctx.locals.ip, sessionId });
}
}),
logout: roleProcedure["any"].mutation(async ({ ctx }) => {
@@ -38,22 +43,8 @@ const authRouter = router({
newPassword: z.string().nonempty(),
}),
)
.mutation(async ({ ctx, input }) => {
if (input.oldPassword === input.newPassword) {
throw new TRPCError({ code: "BAD_REQUEST", message: "Same passwords" });
} else if (input.newPassword.length < 8) {
throw new TRPCError({ code: "BAD_REQUEST", message: "Too short password" });
}
const user = await UserRepo.getUser(ctx.session.userId);
if (!user) {
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR", message: "Invalid session id" });
} else if (!(await argon2.verify(user.password, input.oldPassword))) {
throw new TRPCError({ code: "FORBIDDEN", message: "Invalid password" });
}
await UserRepo.setUserPassword(ctx.session.userId, await argon2.hash(input.newPassword));
await SessionRepo.deleteAllOtherSessions(ctx.session.userId, ctx.session.sessionId);
.mutation(() => {
throw new TRPCError({ code: "NOT_IMPLEMENTED" });
}),
upgrade: roleProcedure["notClient"]

View File

@@ -57,6 +57,7 @@ const categoryRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
isRecursive: file.isRecursive,
})),
};

View File

@@ -1,8 +1,9 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { DirectoryIdSchema } from "$lib/schemas";
import { FileRepo, IntegrityError } from "$lib/server/db";
import { DirectoryRepo, FileRepo, IntegrityError } from "$lib/server/db";
import { safeUnlink } from "$lib/server/modules/filesystem";
import { demoLogger } from "$lib/server/modules/logger";
import { router, roleProcedure } from "../init.server";
const directoryRouter = router({
@@ -14,13 +15,15 @@ const directoryRouter = router({
)
.query(async ({ ctx, input }) => {
const directory =
input.id !== "root" ? await FileRepo.getDirectory(ctx.session.userId, input.id) : undefined;
input.id !== "root"
? await DirectoryRepo.getDirectory(ctx.session.userId, input.id)
: undefined;
if (directory === null) {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid directory id" });
}
const [directories, files] = await Promise.all([
FileRepo.getAllDirectoriesByParent(ctx.session.userId, input.id),
DirectoryRepo.getAllDirectoriesByParent(ctx.session.userId, input.id),
FileRepo.getAllFilesByParent(ctx.session.userId, input.id),
]);
return {
@@ -31,6 +34,7 @@ const directoryRouter = router({
dekVersion: directory.dekVersion,
name: directory.encName.ciphertext,
nameIv: directory.encName.iv,
isFavorite: directory.isFavorite,
},
subDirectories: directories.map((directory) => ({
id: directory.id,
@@ -39,6 +43,7 @@ const directoryRouter = router({
dekVersion: directory.dekVersion,
name: directory.encName.ciphertext,
nameIv: directory.encName.iv,
isFavorite: directory.isFavorite,
})),
files: files.map((file) => ({
id: file.id,
@@ -52,6 +57,7 @@ const directoryRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
})),
};
}),
@@ -75,7 +81,7 @@ const directoryRouter = router({
}
try {
await FileRepo.registerDirectory({
await DirectoryRepo.registerDirectory({
parentId: input.parent,
userId: ctx.session.userId,
mekVersion: input.mekVersion,
@@ -102,7 +108,7 @@ const directoryRouter = router({
)
.mutation(async ({ ctx, input }) => {
try {
await FileRepo.setDirectoryEncName(ctx.session.userId, input.id, input.dekVersion, {
await DirectoryRepo.setDirectoryEncName(ctx.session.userId, input.id, input.dekVersion, {
ciphertext: input.name,
iv: input.nameIv,
});
@@ -126,9 +132,10 @@ const directoryRouter = router({
)
.mutation(async ({ ctx, input }) => {
try {
const files = await FileRepo.unregisterDirectory(ctx.session.userId, input.id);
const files = await DirectoryRepo.unregisterDirectory(ctx.session.userId, input.id);
return {
deletedFiles: files.map((file) => {
demoLogger.log("file:delete", { ip: ctx.locals.ip, fileId: file.id, recursive: true });
safeUnlink(file.path); // Intended
safeUnlink(file.thumbnailPath); // Intended
return file.id;

View File

@@ -0,0 +1,124 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { DirectoryRepo, FileRepo, IntegrityError } from "$lib/server/db";
import { router, roleProcedure } from "../init.server";
const favoritesRouter = router({
get: roleProcedure["activeClient"].query(async ({ ctx }) => {
const [directories, files] = await Promise.all([
DirectoryRepo.getAllFavoriteDirectories(ctx.session.userId),
FileRepo.getAllFavoriteFiles(ctx.session.userId),
]);
return {
directories: directories.map((directory) => ({
id: directory.id,
parent: directory.parentId,
mekVersion: directory.mekVersion,
dek: directory.encDek,
dekVersion: directory.dekVersion,
name: directory.encName.ciphertext,
nameIv: directory.encName.iv,
})),
files: files.map((file) => ({
id: file.id,
parent: file.parentId,
mekVersion: file.mekVersion,
dek: file.encDek,
dekVersion: file.dekVersion,
contentType: file.contentType,
name: file.encName.ciphertext,
nameIv: file.encName.iv,
createdAt: file.encCreatedAt?.ciphertext,
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
})),
};
}),
addDirectory: roleProcedure["activeClient"]
.input(
z.object({
id: z.int().positive(),
}),
)
.mutation(async ({ ctx, input }) => {
try {
await DirectoryRepo.setDirectoryFavorite(ctx.session.userId, input.id, true);
} catch (e) {
if (e instanceof IntegrityError) {
if (e.message === "Directory not found") {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid directory id" });
} else if (e.message === "Directory already favorited") {
throw new TRPCError({ code: "BAD_REQUEST", message: e.message });
}
}
throw e;
}
}),
removeDirectory: roleProcedure["activeClient"]
.input(
z.object({
id: z.int().positive(),
}),
)
.mutation(async ({ ctx, input }) => {
try {
await DirectoryRepo.setDirectoryFavorite(ctx.session.userId, input.id, false);
} catch (e) {
if (e instanceof IntegrityError) {
if (e.message === "Directory not found") {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid directory id" });
} else if (e.message === "Directory not favorited") {
throw new TRPCError({ code: "BAD_REQUEST", message: e.message });
}
}
throw e;
}
}),
addFile: roleProcedure["activeClient"]
.input(
z.object({
id: z.int().positive(),
}),
)
.mutation(async ({ ctx, input }) => {
try {
await FileRepo.setFileFavorite(ctx.session.userId, input.id, true);
} catch (e) {
if (e instanceof IntegrityError) {
if (e.message === "File not found") {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid file id" });
} else if (e.message === "File already favorited") {
throw new TRPCError({ code: "BAD_REQUEST", message: e.message });
}
}
throw e;
}
}),
removeFile: roleProcedure["activeClient"]
.input(
z.object({
id: z.int().positive(),
}),
)
.mutation(async ({ ctx, input }) => {
try {
await FileRepo.setFileFavorite(ctx.session.userId, input.id, false);
} catch (e) {
if (e instanceof IntegrityError) {
if (e.message === "File not found") {
throw new TRPCError({ code: "NOT_FOUND", message: "Invalid file id" });
} else if (e.message === "File not favorited") {
throw new TRPCError({ code: "BAD_REQUEST", message: e.message });
}
}
throw e;
}
}),
});
export default favoritesRouter;

View File

@@ -2,6 +2,7 @@ import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { FileRepo, MediaRepo, IntegrityError } from "$lib/server/db";
import { safeUnlink } from "$lib/server/modules/filesystem";
import { demoLogger } from "$lib/server/modules/logger";
import { router, roleProcedure } from "../init.server";
const fileRouter = router({
@@ -31,6 +32,7 @@ const fileRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
categories: categories.map((category) => ({
id: category.id,
parent: category.parentId,
@@ -65,6 +67,7 @@ const fileRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
categories: file.categories.map((category) => ({
id: category.id,
parent: category.parentId,
@@ -112,6 +115,7 @@ const fileRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
}));
}),
@@ -131,6 +135,7 @@ const fileRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
}));
}),
@@ -170,6 +175,7 @@ const fileRouter = router({
.mutation(async ({ ctx, input }) => {
try {
const { path, thumbnailPath } = await FileRepo.unregisterFile(ctx.session.userId, input.id);
demoLogger.log("file:delete", { ip: ctx.locals.ip, fileId: input.id });
safeUnlink(path); // Intended
safeUnlink(thumbnailPath); // Intended
} catch (e) {

View File

@@ -2,6 +2,7 @@ export { default as authRouter } from "./auth";
export { default as categoryRouter } from "./category";
export { default as clientRouter } from "./client";
export { default as directoryRouter } from "./directory";
export { default as favoritesRouter } from "./favorites";
export { default as fileRouter } from "./file";
export { default as hskRouter } from "./hsk";
export { default as mekRouter } from "./mek";

View File

@@ -1,6 +1,6 @@
import { z } from "zod";
import { DirectoryIdSchema } from "$lib/schemas";
import { FileRepo } from "$lib/server/db";
import { DirectoryRepo, FileRepo } from "$lib/server/db";
import { router, roleProcedure } from "../init.server";
const searchRouter = router({
@@ -8,6 +8,7 @@ const searchRouter = router({
.input(
z.object({
ancestor: DirectoryIdSchema.default("root"),
inFavorites: z.boolean().default(false),
includeCategories: z.number().positive().array().default([]),
excludeCategories: z.number().positive().array().default([]),
}),
@@ -15,10 +16,14 @@ const searchRouter = router({
.query(async ({ ctx, input }) => {
const [directories, files] = await Promise.all([
input.includeCategories.length === 0 && input.excludeCategories.length === 0
? FileRepo.getAllRecursiveDirectoriesByParent(ctx.session.userId, input.ancestor)
? DirectoryRepo.searchDirectories(ctx.session.userId, {
parentId: input.ancestor,
inFavorites: input.inFavorites,
})
: [],
FileRepo.searchFiles(ctx.session.userId, {
parentId: input.ancestor,
inFavorites: input.inFavorites,
includeCategoryIds: input.includeCategories,
excludeCategoryIds: input.excludeCategories,
}),
@@ -32,6 +37,7 @@ const searchRouter = router({
dekVersion: directory.dekVersion,
name: directory.encName.ciphertext,
nameIv: directory.encName.iv,
isFavorite: directory.isFavorite,
})),
files: files.map((file) => ({
id: file.id,
@@ -46,6 +52,7 @@ const searchRouter = router({
createdAtIv: file.encCreatedAt?.iv,
lastModifiedAt: file.encLastModifiedAt.ciphertext,
lastModifiedAtIv: file.encLastModifiedAt.iv,
isFavorite: file.isFavorite,
})),
};
}),

View File

@@ -6,11 +6,13 @@ import mime from "mime";
import { dirname } from "path";
import { v4 as uuidv4 } from "uuid";
import { z } from "zod";
import { MAX_CHUNKS } from "$lib/constants";
import { DirectoryIdSchema } from "$lib/schemas";
import { FileRepo, MediaRepo, UploadRepo, IntegrityError } from "$lib/server/db";
import db from "$lib/server/db/kysely";
import env from "$lib/server/loadenv";
import { safeRecursiveRm, safeUnlink } from "$lib/server/modules/filesystem";
import { demoLogger } from "$lib/server/modules/logger";
import { router, roleProcedure } from "../init.server";
const UPLOADS_EXPIRES = 24 * 3600 * 1000; // 24 hours
@@ -28,7 +30,7 @@ const uploadRouter = router({
startFileUpload: roleProcedure["activeClient"]
.input(
z.object({
chunks: z.int().positive(),
chunks: z.int().positive().max(MAX_CHUNKS),
parent: DirectoryIdSchema,
mekVersion: z.int().positive(),
dek: z.base64().nonempty(),
@@ -76,6 +78,7 @@ const uploadRouter = router({
: null,
encLastModifiedAt: { ciphertext: input.lastModifiedAt, iv: input.lastModifiedAtIv },
});
demoLogger.log("upload:start", { ip: ctx.locals.ip, uploadId: id });
return { uploadId: id };
} catch (e) {
await safeRecursiveRm(path);
@@ -153,6 +156,7 @@ const uploadRouter = router({
});
await safeRecursiveRm(session.path);
demoLogger.log("upload:complete", { ip: ctx.locals.ip, uploadId, fileId });
return { file: fileId };
} catch (e) {
await safeUnlink(filePath);
@@ -183,6 +187,7 @@ const uploadRouter = router({
fileId: input.file,
dekVersion: input.dekVersion,
});
demoLogger.log("thumbnail:start", { ip: ctx.locals.ip, uploadId: id });
return { uploadId: id };
} catch (e) {
await safeRecursiveRm(path);
@@ -238,6 +243,11 @@ const uploadRouter = router({
await UploadRepo.deleteUploadSession(trx, uploadId);
return oldPath;
});
demoLogger.log("thumbnail:complete", {
ip: ctx.locals.ip,
uploadId,
fileId: session.fileId,
});
await Promise.all([safeUnlink(oldThumbnailPath), safeRecursiveRm(session.path)]);
} catch (e) {
await safeUnlink(thumbnailPath);

2
static/robots.txt Normal file
View File

@@ -0,0 +1,2 @@
User-agent: *
Disallow: /