Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
7ee1b8370a | |||
e7750699cc | |||
e14042ea28 | |||
6fb7518b6a | |||
436ae2a7e5 | |||
fe5ce580ab | |||
0f882da5d1 | |||
ad6f136dd0 | |||
da527a0857 | |||
a95931ae77 | |||
d6c2236673 | |||
42a8ab5d0f | |||
0934808a59 | |||
88ea828b66 | |||
41ed5c0e23 | |||
0a98481991 | |||
5d62c48a35 | |||
0ab39023b0 | |||
7b202962e8 | |||
7a045b3f34 | |||
cb80c8bfe4 | |||
74c3197e47 | |||
6ae927ce71 | |||
9d13e607f5 | |||
0db3ef4a1f | |||
03e9fb431f | |||
b84df2866b | |||
3d4fef7c23 | |||
9d787008a4 | |||
687f26bb40 | |||
371a869800 | |||
321c303a8a | |||
2f176d84e9 | |||
67d4f09bd7 | |||
c40f009523 | |||
026f8c69d7 | |||
cacb808117 | |||
2d573edcac | |||
4287cd429d | |||
024dfeeeb7 | |||
f24bcba20b | |||
1d95edc455 | |||
|
ec24ab3edd |
@@ -1,15 +1,15 @@
|
|||||||
*
|
*
|
||||||
|
|
||||||
!/backend/src
|
!/packages/backend/src
|
||||||
!/backend/Cargo.lock
|
!/packages/backend/Cargo.lock
|
||||||
!/backend/Cargo.toml
|
!/packages/backend/Cargo.toml
|
||||||
|
|
||||||
!/frontend/locales
|
!/packages/frontend/locales
|
||||||
!/frontend/src
|
!/packages/frontend/src
|
||||||
!/frontend/static
|
!/packages/frontend/static
|
||||||
!/frontend/.npmrc
|
!/packages/frontend/.npmrc
|
||||||
!/frontend/package.json
|
!/packages/frontend/package.json
|
||||||
!/frontend/pnpm-lock.yaml
|
!/packages/frontend/pnpm-lock.yaml
|
||||||
!/frontend/svelte.config.js
|
!/packages/frontend/svelte.config.js
|
||||||
!/frontend/tsconfig.json
|
!/packages/frontend/tsconfig.json
|
||||||
!/frontend/vite.config.js
|
!/packages/frontend/vite.config.js
|
||||||
|
5
.github/workflows/docker.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: ci
|
name: Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -31,11 +31,8 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
- name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
|
38
.github/workflows/test.yaml
vendored
@@ -1,36 +1,36 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
ports:
|
|
||||||
- 6379:6379
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: "16"
|
node-version: "16"
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
|
- uses: docker/setup-qemu-action@v1
|
||||||
|
- uses: docker/setup-buildx-action@v1
|
||||||
with:
|
with:
|
||||||
version: 7
|
install: true
|
||||||
- uses: actions-rs/toolchain@v1
|
- name: Build docker image
|
||||||
with:
|
run: npm run test:prepare
|
||||||
toolchain: 1.61
|
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install
|
npm install playwright
|
||||||
pnpm run ci:prepare
|
npx playwright install --with-deps
|
||||||
- name: Install Playwright
|
|
||||||
run: npx playwright install --with-deps
|
|
||||||
- name: Run your tests
|
- name: Run your tests
|
||||||
run: pnpm run test
|
run: npm test
|
||||||
- name: Upload test results
|
- uses: actions/upload-artifact@v2
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
with:
|
||||||
name: playwright-report
|
name: test-results
|
||||||
path: playwright-report
|
path: test-results
|
||||||
|
6
.vscode/settings.json
vendored
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"cSpell.words": ["ciphertext", "cryptgeon"],
|
|
||||||
"i18n-ally.localesPaths": ["frontend/locales"],
|
|
||||||
"i18n-ally.enabledFrameworks": ["svelte"],
|
|
||||||
"i18n-ally.keystyle": "nested"
|
|
||||||
}
|
|
62
CHANGELOG.md
@@ -5,13 +5,73 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.2.0] - 2023-01-14
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Default port is now 8000, not 5000.
|
||||||
|
- Moved to generic encryption library `occulto`.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Bad chinese language code.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
- Updated dependencies.
|
||||||
|
|
||||||
|
## [2.1.0] - 2023-01-04
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- QR Code to more easily copy and share links.
|
||||||
|
|
||||||
|
## [2.0.7] - 2022-12-26
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Svelte Kit now stable 🎉
|
||||||
|
|
||||||
|
## [2.0.6] - 2022-11-12
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- #66 Set minimum a view.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
- Updated dependencies.
|
||||||
|
|
||||||
|
## [2.0.5] - 2022-11-04
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Docker build pipeline.
|
||||||
|
|
||||||
|
## [2.0.4] - 2022-10-29
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `THEME_PAGE_TITLE`.
|
||||||
|
- `THEME_FAVICON`.
|
||||||
|
|
||||||
|
## [2.0.3] - 2022-10-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Flag for verbosity.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- #58 Fixed bug in the max views frontend form.
|
||||||
|
|
||||||
## [2.0.2] - 2022-07-20
|
## [2.0.2] - 2022-07-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Toasts for events.
|
- Toasts for events.
|
||||||
- E2E Tests.
|
- E2E Tests.
|
||||||
- Make backend more configurable
|
- Make backend more configurable.
|
||||||
|
|
||||||
## [2.0.1] - 2022-07-18
|
## [2.0.1] - 2022-07-18
|
||||||
|
|
||||||
|
17
Dockerfile
@@ -2,20 +2,23 @@
|
|||||||
FROM node:16-alpine as client
|
FROM node:16-alpine as client
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN npm install -g pnpm@7
|
RUN npm install -g pnpm@7
|
||||||
COPY ./frontend ./
|
COPY ./packages/frontend ./
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
RUN pnpm exec svelte-kit sync
|
RUN pnpm exec svelte-kit sync
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
|
|
||||||
# BACKEND
|
# BACKEND
|
||||||
FROM rust:1.61-alpine as backend
|
FROM rust:1.64-alpine as backend
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN apk add libc-dev openssl-dev alpine-sdk
|
RUN apk add libc-dev openssl-dev alpine-sdk
|
||||||
COPY ./backend/Cargo.* ./
|
COPY ./packages/backend/Cargo.* ./
|
||||||
RUN cargo fetch
|
# https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html
|
||||||
COPY ./backend ./
|
RUN rustup update nightly
|
||||||
RUN cargo build --release
|
ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true
|
||||||
|
RUN cargo +nightly fetch
|
||||||
|
COPY ./packages/backend ./
|
||||||
|
RUN cargo +nightly build --release
|
||||||
|
|
||||||
|
|
||||||
# RUNNER
|
# RUNNER
|
||||||
@@ -25,5 +28,5 @@ COPY --from=backend /tmp/target/release/cryptgeon .
|
|||||||
COPY --from=client /tmp/build ./frontend
|
COPY --from=client /tmp/build ./frontend
|
||||||
ENV FRONTEND_PATH="./frontend"
|
ENV FRONTEND_PATH="./frontend"
|
||||||
ENV REDIS="redis://redis/"
|
ENV REDIS="redis://redis/"
|
||||||
EXPOSE 5000
|
EXPOSE 8000
|
||||||
ENTRYPOINT [ "/app/cryptgeon" ]
|
ENTRYPOINT [ "/app/cryptgeon" ]
|
||||||
|
65
README.md
@@ -24,9 +24,9 @@ _cryptgeon_ is a secure, open source sharing note or file service inspired by [_
|
|||||||
>
|
>
|
||||||
> Thanks to [Lokalise](https://lokalise.com/) for providing free access to their platform.
|
> Thanks to [Lokalise](https://lokalise.com/) for providing free access to their platform.
|
||||||
|
|
||||||
## Demo
|
## Live Service / Demo
|
||||||
|
|
||||||
Check out the demo and see for yourself https://cryptgeon.nicco.io.
|
Check out the live service / demo and see for yourself [cryptgeon.org](https://cryptgeon.org)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -51,14 +51,17 @@ of the notes even if it tried to.
|
|||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
| ---------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `REDIS` | `redis://redis/` | Redis URL to connect to. |
|
| `REDIS` | `redis://redis/` | Redis URL to connect to. [According to format](https://docs.rs/redis/latest/redis/#connection-parameters) |
|
||||||
| `SIZE_LIMIT` | `1 KiB` | Max size for body. Accepted values according to [byte-unit](https://docs.rs/byte-unit/). <br> `512 MiB` is the maximum allowed. <br> The frontend will show that number including the ~35% encoding overhead. |
|
| `SIZE_LIMIT` | `1 KiB` | Max size for body. Accepted values according to [byte-unit](https://docs.rs/byte-unit/). <br> `512 MiB` is the maximum allowed. <br> The frontend will show that number including the ~35% encoding overhead. |
|
||||||
| `MAX_VIEWS` | `100` | Maximal number of views. |
|
| `MAX_VIEWS` | `100` | Maximal number of views. |
|
||||||
| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. |
|
| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. |
|
||||||
| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. |
|
| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. |
|
||||||
|
| `VERBOSITY` | `warn` | Verbosity level for the backend. [Possible values](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) are: `error`, `warn`, `info`, `debug`, `trace` |
|
||||||
| `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable |
|
| `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable |
|
||||||
| `THEME_TEXT` | `""` | Custom text for replacing the description below the logo |
|
| `THEME_TEXT` | `""` | Custom text for replacing the description below the logo |
|
||||||
|
| `THEME_PAGE_TITLE` | `""` | Custom text the page title |
|
||||||
|
| `THEME_FAVICON` | `""` | Custom url for the favicon. Must be publicly reachable |
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
@@ -76,15 +79,19 @@ version: '3.8'
|
|||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
|
# Set a size limit. See link below on how to customise.
|
||||||
|
# https://redis.io/docs/manual/eviction/
|
||||||
|
command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru
|
||||||
|
|
||||||
app:
|
app:
|
||||||
image: cupcakearmy/cryptgeon:latest
|
image: cupcakearmy/cryptgeon:latest
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
|
# Size limit for a single note.
|
||||||
SIZE_LIMIT: 4 MiB
|
SIZE_LIMIT: 4 MiB
|
||||||
ports:
|
ports:
|
||||||
- 80:5000
|
- 80:8000
|
||||||
```
|
```
|
||||||
|
|
||||||
### NGINX Proxy
|
### NGINX Proxy
|
||||||
@@ -93,39 +100,20 @@ See the [examples/nginx](https://github.com/cupcakearmy/cryptgeon/tree/main/exam
|
|||||||
|
|
||||||
### Traefik 2
|
### Traefik 2
|
||||||
|
|
||||||
Assumptions:
|
See the [examples/traefik](https://github.com/cupcakearmy/cryptgeon/tree/main/examples/traefik) folder.
|
||||||
|
|
||||||
- External proxy docker network `proxy`
|
### Scratch
|
||||||
- A certificate resolver `le`
|
|
||||||
- A https entrypoint `secure`
|
|
||||||
- Domain name `example.org`
|
|
||||||
|
|
||||||
```yaml
|
See the [examples/scratch](https://github.com/cupcakearmy/cryptgeon/tree/main/examples/scratch) folder. There you'll find a guide how to setup a server and install cryptgeon from scratch.
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
networks:
|
### Synology
|
||||||
proxy:
|
|
||||||
external: true
|
|
||||||
|
|
||||||
services:
|
There is a [guide](https://mariushosting.com/how-to-install-cryptgeon-on-your-synology-nas/) you can follow.
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
app:
|
### YouTube Guides
|
||||||
image: cupcakearmy/cryptgeon:latest
|
|
||||||
restart: unless-stopped
|
- English by [DB Tech](https://www.youtube.com/watch?v=S0jx7wpOfNM) [Previous Video](https://www.youtube.com/watch?v=JhpIatD06vE)
|
||||||
depends_on:
|
- German by [ApfelCast](https://www.youtube.com/watch?v=84ZMbE9AkHg)
|
||||||
- redis
|
|
||||||
networks:
|
|
||||||
- default
|
|
||||||
- proxy
|
|
||||||
labels:
|
|
||||||
- traefik.enable=true
|
|
||||||
- traefik.http.routers.cryptgeon.rule=Host(`example.org`)
|
|
||||||
- traefik.http.routers.cryptgeon.entrypoints=secure
|
|
||||||
- traefik.http.routers.cryptgeon.tls.certresolver=le
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -150,9 +138,6 @@ cargo install cargo-watch
|
|||||||
|
|
||||||
Make sure you have docker running.
|
Make sure you have docker running.
|
||||||
|
|
||||||
> If you are on `macOS` you might need to disable AirPlay Receiver as it uses port 5000 (So stupid...)
|
|
||||||
> https://developer.apple.com/forums/thread/682332
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run dev
|
pnpm run dev
|
||||||
```
|
```
|
||||||
@@ -170,15 +155,19 @@ You can see the app under [localhost:1234](http://localhost:1234).
|
|||||||
Tests are end to end tests written with Playwright.
|
Tests are end to end tests written with Playwright.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm run ci:prepare
|
pnpm run test:prepare
|
||||||
docker compose up redis -d
|
docker compose up redis -d
|
||||||
pnpm run ci:server
|
pnpm run test:server
|
||||||
|
|
||||||
# In another terminal.
|
# In another terminal.
|
||||||
# Use the test or test:local script. The local version only runs in one browser for quicker development.
|
# Use the test or test:local script. The local version only runs in one browser for quicker development.
|
||||||
pnpm run test:local
|
pnpm run test:local
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
Please refer to the security section [here](./SECURITY.md).
|
||||||
|
|
||||||
###### Attributions
|
###### Attributions
|
||||||
|
|
||||||
- Test data:
|
- Test data:
|
||||||
|
@@ -26,7 +26,7 @@ _加密鸽_ 是一个受 [_PrivNote_](https://privnote.com)项目启发的安全
|
|||||||
|
|
||||||
## 演示示例
|
## 演示示例
|
||||||
|
|
||||||
查看加密鸽的在线演示 demo: https://cryptgeon.nicco.io.
|
查看加密鸽的在线演示 demo: [cryptgeon.org](https://cryptgeon.org)
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
||||||
@@ -49,11 +49,13 @@ _加密鸽_ 是一个受 [_PrivNote_](https://privnote.com)项目启发的安全
|
|||||||
|
|
||||||
| 变量名称 | 默认值 | 描述 |
|
| 变量名称 | 默认值 | 描述 |
|
||||||
| ----------------- | ---------------- | --------------------------------------------------------------------------------- |
|
| ----------------- | ---------------- | --------------------------------------------------------------------------------- |
|
||||||
| `REDIS` | `redis://redis/` | Redis URL to connect to. |
|
| `REDIS` | `redis://redis/` | Redis 连接 URL。 |
|
||||||
| `SIZE_LIMIT` | `1 KiB` | 最大请求体(body)限制。有关支持的数值请查看 [字节单位](https://docs.rs/byte-unit/) |
|
| `SIZE_LIMIT` | `1 KiB` | 最大请求体(body)限制。有关支持的数值请查看 [字节单位](https://docs.rs/byte-unit/) |
|
||||||
| `MAX_VIEWS` | `100` | 密信最多查看次数限制 |
|
| `MAX_VIEWS` | `100` | 密信最多查看次数限制 |
|
||||||
| ` MAX_EXPIRATION` | `360` | 密信最长过期时间限制(分钟) |
|
| ` MAX_EXPIRATION` | `360` | 密信最长过期时间限制(分钟) |
|
||||||
| `ALLOW_ADVANCED` | `true` | 是否允许自定义设置,该项如果设为`false`,则不会显示自定义设置模块 |
|
| `ALLOW_ADVANCED` | `true` | 是否允许自定义设置,该项如果设为`false`,则不会显示自定义设置模块 |
|
||||||
|
| `THEME_IMAGE` | `""` | 自定义 Logo 图片,你在这里填写的的图片链接必须是可以公开访问的。 |
|
||||||
|
| `THEME_TEXT` | `""` | 自定义在 Logo 下方的文本。 |
|
||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
SIZE_LIMIT: 4 MiB
|
SIZE_LIMIT: 4 MiB
|
||||||
ports:
|
ports:
|
||||||
- 80:5000
|
- 80:8000
|
||||||
```
|
```
|
||||||
|
|
||||||
### NGINX 反向代理
|
### NGINX 反向代理
|
||||||
@@ -137,7 +139,7 @@ services:
|
|||||||
pnpm install
|
pnpm install
|
||||||
pnpm --prefix frontend install
|
pnpm --prefix frontend install
|
||||||
|
|
||||||
# Also you need cargo watch if you don't already have it installed.
|
# 你还需要安装CargoWatch.
|
||||||
# https://lib.rs/crates/cargo-watch
|
# https://lib.rs/crates/cargo-watch
|
||||||
cargo install cargo-watch
|
cargo install cargo-watch
|
||||||
```
|
```
|
||||||
@@ -146,9 +148,6 @@ cargo install cargo-watch
|
|||||||
|
|
||||||
确保你的 Docker 正在运行
|
确保你的 Docker 正在运行
|
||||||
|
|
||||||
> If you are on `macOS` you might need to disable AirPlay Receiver as it uses port 5000 (So stupid...)
|
|
||||||
> https://developer.apple.com/forums/thread/682332
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run dev
|
pnpm run dev
|
||||||
```
|
```
|
||||||
@@ -161,6 +160,25 @@ pnpm run dev
|
|||||||
|
|
||||||
你可以通过 1234 端口进入该应用,即 [localhost:1234](http://localhost:1234).
|
你可以通过 1234 端口进入该应用,即 [localhost:1234](http://localhost:1234).
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
这些测试是用 Playwright 实现的一些端到端测试用例。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm run test:prepare
|
||||||
|
docker compose up redis -d
|
||||||
|
pnpm run test:server
|
||||||
|
|
||||||
|
# 在另一个终端中:
|
||||||
|
# 使用test或者test:local script。为了更快的开发,本地版本只会在一个浏览器中运行。
|
||||||
|
pnpm run test:local
|
||||||
|
```
|
||||||
|
|
||||||
###### Attributions
|
###### Attributions
|
||||||
|
|
||||||
本项目所使用的图标由<a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com 的<a href="https://www.freepik.com" title="Freepik">freepik</a>制作</a>
|
- 测试数据:
|
||||||
|
- 测试文本 [Nietzsche Ipsum](https://nietzsche-ipsum.com/)
|
||||||
|
- [AES Paper](https://www.cs.miami.edu/home/burt/learning/Csc688.012/rijndael/rijndael_doc_V2.pdf)
|
||||||
|
- [Unsplash Pictures](https://unsplash.com/)
|
||||||
|
- 加载动画由 [Nikhil Krishnan](https://codepen.io/nikhil8krishnan/pen/rVoXJa) 提供
|
||||||
|
- 图标由来自 <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> 的 <a href="https://www.freepik.com" title="Freepik">freepik</a> 提供
|
||||||
|
18
SECURITY.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Please ensure that you are using the latest major version available.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | --------- |
|
||||||
|
| 2.x | ✅ |
|
||||||
|
| < 1.x | ❌ |
|
||||||
|
|
||||||
|
## Reporting a vulnerability
|
||||||
|
|
||||||
|
_cryptgeon_ has a full disclosure vulnerability policy.
|
||||||
|
Report any bug / vulnerability directly to the [issue tracker](https://github.com/cupcakearmy/cryptgeon/issues).
|
||||||
|
Please do NOT attempt to report any security vulnerability in this code privately to anybody.
|
||||||
|
|
||||||
|
> Shamefully copied of the [ring security section](https://github.com/briansmith/ring#bug-reporting).
|
16
cryptgeon.code-workspace
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "packages/backend"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"cSpell.words": ["ciphertext", "cryptgeon"],
|
||||||
|
"i18n-ally.enabledFrameworks": ["svelte"],
|
||||||
|
"i18n-ally.keystyle": "nested",
|
||||||
|
"i18n-ally.localesPaths": ["packages/frontend/locales"]
|
||||||
|
}
|
||||||
|
}
|
@@ -10,10 +10,10 @@ services:
|
|||||||
- 6379:6379
|
- 6379:6379
|
||||||
|
|
||||||
app:
|
app:
|
||||||
|
image: cupcakearmy/cryptgeon:test
|
||||||
build: .
|
build: .
|
||||||
|
env_file: .dev.env
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
|
||||||
SIZE_LIMIT: 128 MiB
|
|
||||||
ports:
|
ports:
|
||||||
- 1234:5000
|
- 1234:8000
|
18
docker-compose.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
# Set a size limit. See link below on how to customise.
|
||||||
|
# https://redis.io/docs/manual/eviction/
|
||||||
|
# command: redis-server --maxmemory 1gb --maxmemory-policy allkeys-lru
|
||||||
|
|
||||||
|
app:
|
||||||
|
image: cupcakearmy/cryptgeon:latest
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
environment:
|
||||||
|
# Size limit for a single note.
|
||||||
|
SIZE_LIMIT: 4 MiB
|
||||||
|
ports:
|
||||||
|
- 80:8000
|
@@ -4,7 +4,7 @@ server {
|
|||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://app:5000/;
|
proxy_pass http://app:8000/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
@@ -20,7 +20,7 @@ server {
|
|||||||
ssl_trusted_certificate /path/to/fullchain.pem;
|
ssl_trusted_certificate /path/to/fullchain.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://app:5000/;
|
proxy_pass http://app:8000/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
36
examples/traefik/README.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Install Cryptgeon with Traefik
|
||||||
|
|
||||||
|
Assumptions:
|
||||||
|
|
||||||
|
- Traefik 2 installed.
|
||||||
|
- External proxy docker network `proxy`.
|
||||||
|
- A certificate resolver `le`.
|
||||||
|
- A https entrypoint `secure`.
|
||||||
|
- Domain name `example.org`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
app:
|
||||||
|
image: cupcakearmy/cryptgeon:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
- proxy
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.http.routers.cryptgeon.rule=Host(`example.org`)
|
||||||
|
- traefik.http.routers.cryptgeon.entrypoints=secure
|
||||||
|
- traefik.http.routers.cryptgeon.tls.certresolver=le
|
||||||
|
```
|
@@ -1,5 +0,0 @@
|
|||||||
.DS_Store
|
|
||||||
node_modules
|
|
||||||
/.svelte
|
|
||||||
/build
|
|
||||||
/functions
|
|
@@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "vite dev",
|
|
||||||
"build": "vite build",
|
|
||||||
"preview": "vite preview --port 3000",
|
|
||||||
"check": "svelte-check --tsconfig tsconfig.json",
|
|
||||||
"licenses": "license-checker --summary > licenses.csv",
|
|
||||||
"locale:download": "node scripts/locale.js"
|
|
||||||
},
|
|
||||||
"type": "module",
|
|
||||||
"devDependencies": {
|
|
||||||
"@lokalise/node-api": "^7.3.1",
|
|
||||||
"@sveltejs/adapter-static": "^1.0.0-next.38",
|
|
||||||
"@sveltejs/kit": "^1.0.0-next.384",
|
|
||||||
"@types/dompurify": "^2.3.3",
|
|
||||||
"@types/file-saver": "^2.0.5",
|
|
||||||
"@zerodevx/svelte-toast": "^0.7.2",
|
|
||||||
"adm-zip": "^0.5.9",
|
|
||||||
"dotenv": "^16.0.1",
|
|
||||||
"svelte": "^3.49.0",
|
|
||||||
"svelte-check": "^2.8.0",
|
|
||||||
"svelte-intl-precompile": "^0.10.1",
|
|
||||||
"svelte-preprocess": "^4.10.7",
|
|
||||||
"tslib": "^2.4.0",
|
|
||||||
"typescript": "^4.7.4",
|
|
||||||
"vite": "^3.0.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@fontsource/fira-mono": "^4.5.8",
|
|
||||||
"copy-to-clipboard": "^3.3.1",
|
|
||||||
"dompurify": "^2.3.10",
|
|
||||||
"file-saver": "^2.0.5",
|
|
||||||
"pretty-bytes": "^5.6.0"
|
|
||||||
}
|
|
||||||
}
|
|
1615
frontend/pnpm-lock.yaml
generated
@@ -1,97 +0,0 @@
|
|||||||
export class Hex {
|
|
||||||
static encode(buffer: ArrayBuffer): string {
|
|
||||||
let s = ''
|
|
||||||
for (const i of new Uint8Array(buffer)) {
|
|
||||||
s += i.toString(16).padStart(2, '0')
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
static decode(s: string): ArrayBuffer {
|
|
||||||
const size = s.length / 2
|
|
||||||
const buffer = new Uint8Array(size)
|
|
||||||
for (let i = 0; i < size; i++) {
|
|
||||||
const idx = i * 2
|
|
||||||
const segment = s.slice(idx, idx + 2)
|
|
||||||
buffer[i] = parseInt(segment, 16)
|
|
||||||
}
|
|
||||||
return buffer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ArrayBufferUtils {
|
|
||||||
static async toString(buffer: ArrayBuffer): Promise<string> {
|
|
||||||
const reader = new window.FileReader()
|
|
||||||
reader.readAsDataURL(new Blob([buffer]))
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
reader.onloadend = () => resolve(reader.result as string)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
static async fromString(s: string): Promise<ArrayBuffer> {
|
|
||||||
return fetch(s)
|
|
||||||
.then((r) => r.blob())
|
|
||||||
.then((b) => b.arrayBuffer())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Crypto {
|
|
||||||
private static ALG = 'AES-GCM'
|
|
||||||
private static DELIMITER = ':::'
|
|
||||||
|
|
||||||
public static getRandomBytes(size: number): Uint8Array {
|
|
||||||
return window.crypto.getRandomValues(new Uint8Array(size))
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getKeyFromString(password: string) {
|
|
||||||
return window.crypto.subtle.importKey(
|
|
||||||
'raw',
|
|
||||||
new TextEncoder().encode(password),
|
|
||||||
'PBKDF2',
|
|
||||||
false,
|
|
||||||
['deriveBits', 'deriveKey']
|
|
||||||
)
|
|
||||||
}
|
|
||||||
public static async getDerivedForKey(key: CryptoKey, salt: ArrayBuffer) {
|
|
||||||
const iterations = 100_000
|
|
||||||
return window.crypto.subtle.deriveKey(
|
|
||||||
{
|
|
||||||
name: 'PBKDF2',
|
|
||||||
salt,
|
|
||||||
iterations,
|
|
||||||
hash: 'SHA-512',
|
|
||||||
},
|
|
||||||
key,
|
|
||||||
{ name: this.ALG, length: 256 },
|
|
||||||
true,
|
|
||||||
['encrypt', 'decrypt']
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async encrypt(plaintext: ArrayBuffer, key: CryptoKey): Promise<string> {
|
|
||||||
const salt = this.getRandomBytes(16)
|
|
||||||
const derived = await this.getDerivedForKey(key, salt)
|
|
||||||
const iv = this.getRandomBytes(16)
|
|
||||||
const encrypted: ArrayBuffer = await window.crypto.subtle.encrypt(
|
|
||||||
{ name: this.ALG, iv },
|
|
||||||
derived,
|
|
||||||
plaintext
|
|
||||||
)
|
|
||||||
const data = [
|
|
||||||
Hex.encode(salt),
|
|
||||||
Hex.encode(iv),
|
|
||||||
await ArrayBufferUtils.toString(encrypted),
|
|
||||||
].join(this.DELIMITER)
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async decrypt(ciphertext: string, key: CryptoKey): Promise<ArrayBuffer> {
|
|
||||||
const splitted = ciphertext.split(this.DELIMITER)
|
|
||||||
const salt = Hex.decode(splitted[0])
|
|
||||||
const iv = Hex.decode(splitted[1])
|
|
||||||
const encrypted = await ArrayBufferUtils.fromString(splitted[2])
|
|
||||||
const derived = await this.getDerivedForKey(key, salt)
|
|
||||||
const plaintext = await window.crypto.subtle.decrypt({ name: this.ALG, iv }, derived, encrypted)
|
|
||||||
return plaintext
|
|
||||||
}
|
|
||||||
}
|
|
18
package.json
@@ -1,23 +1,17 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:docker": "docker-compose up redis",
|
"dev:docker": "docker-compose -f docker-compose.dev.yaml up redis",
|
||||||
"dev:backend": "cd backend && cargo watch -x 'run --bin cryptgeon'",
|
"dev:packages": "pnpm --parallel run dev",
|
||||||
"dev:front": "pnpm --prefix frontend run dev",
|
|
||||||
"dev:proxy": "node proxy.mjs",
|
"dev:proxy": "node proxy.mjs",
|
||||||
"dev": "run-p dev:*",
|
"dev": "run-p dev:*",
|
||||||
"test": "playwright test --project chrome firefox safari",
|
"test": "playwright test --project chrome firefox safari",
|
||||||
"test:local": "playwright test --project local",
|
"test:local": "playwright test --project local",
|
||||||
"ci:server": "cd backend && SIZE_LIMIT=10MiB LISTEN_ADDR=0.0.0.0:1234 cargo run",
|
"test:server": "docker compose -f docker-compose.dev.yaml up",
|
||||||
"ci:server:backend": "cd backend && cargo run",
|
"test:prepare": "docker compose -f docker-compose.dev.yaml build"
|
||||||
"ci:server:front": "pnpm --prefix frontend run preview",
|
|
||||||
"ci:server:proxy": "node proxy.mjs",
|
|
||||||
"ci:prepare": "run-p ci:prepare:*",
|
|
||||||
"ci:prepare:backend": "cd backend && cargo build",
|
|
||||||
"ci:prepare:front": "pnpm --prefix frontend install && pnpm --prefix frontend run build"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.23.4",
|
"@playwright/test": "^1.29.2",
|
||||||
"@types/node": "16",
|
"@types/node": "^16.18.11",
|
||||||
"http-proxy": "^1.18.1",
|
"http-proxy": "^1.18.1",
|
||||||
"npm-run-all": "^4.1.5"
|
"npm-run-all": "^4.1.5"
|
||||||
}
|
}
|
||||||
|
479
backend/Cargo.lock → packages/backend/Cargo.lock
generated
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cryptgeon"
|
name = "cryptgeon"
|
||||||
version = "2.0.2"
|
version = "2.2.0"
|
||||||
authors = ["cupcakearmy <hi@nicco.io>"]
|
authors = ["cupcakearmy <hi@nicco.io>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
10
packages/backend/package.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "cargo watch -x 'run --bin cryptgeon'",
|
||||||
|
"build": "cargo build --release",
|
||||||
|
"test:server": "SIZE_LIMIT=10MiB LISTEN_ADDR=0.0.0.0:1234 cargo run",
|
||||||
|
"test:prepare": "cargo build"
|
||||||
|
}
|
||||||
|
}
|
@@ -8,7 +8,8 @@ lazy_static! {
|
|||||||
pub static ref FRONTEND_PATH: String =
|
pub static ref FRONTEND_PATH: String =
|
||||||
std::env::var("FRONTEND_PATH").unwrap_or("../frontend/build".to_string());
|
std::env::var("FRONTEND_PATH").unwrap_or("../frontend/build".to_string());
|
||||||
pub static ref LISTEN_ADDR: String =
|
pub static ref LISTEN_ADDR: String =
|
||||||
std::env::var("LISTEN_ADDR").unwrap_or("0.0.0.0:5000".to_string());
|
std::env::var("LISTEN_ADDR").unwrap_or("0.0.0.0:8000".to_string());
|
||||||
|
pub static ref VERBOSITY: String = std::env::var("VERBOSITY").unwrap_or("warn".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONFIG
|
// CONFIG
|
||||||
@@ -41,4 +42,12 @@ lazy_static! {
|
|||||||
.unwrap_or("".to_string())
|
.unwrap_or("".to_string())
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
pub static ref THEME_PAGE_TITLE: String = std::env::var("THEME_PAGE_TITLE")
|
||||||
|
.unwrap_or("".to_string())
|
||||||
|
.parse()
|
||||||
|
.unwrap();
|
||||||
|
pub static ref THEME_FAVICON: String = std::env::var("THEME_FAVICON")
|
||||||
|
.unwrap_or("".to_string())
|
||||||
|
.parse()
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
@@ -18,10 +18,11 @@ mod store;
|
|||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("warning"));
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or(config::VERBOSITY.as_str()));
|
||||||
|
|
||||||
return HttpServer::new(|| {
|
return HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(Logger::new("%a \"%r\" %s %b %T"))
|
.wrap(Logger::new("\"%r\" %s %b %T"))
|
||||||
.wrap(middleware::Compress::default())
|
.wrap(middleware::Compress::default())
|
||||||
.wrap(middleware::DefaultHeaders::default())
|
.wrap(middleware::DefaultHeaders::default())
|
||||||
.configure(size::init)
|
.configure(size::init)
|
@@ -49,7 +49,7 @@ async fn create(note: web::Json<Note>) -> impl Responder {
|
|||||||
}
|
}
|
||||||
match n.views {
|
match n.views {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
if v > *config::MAX_VIEWS {
|
if v > *config::MAX_VIEWS || v < 1 {
|
||||||
return bad_req;
|
return bad_req;
|
||||||
}
|
}
|
||||||
n.expiration = None; // views overrides expiration
|
n.expiration = None; // views overrides expiration
|
@@ -7,5 +7,6 @@ pub fn init(cfg: &mut web::ServiceConfig) {
|
|||||||
let plain = web::PayloadConfig::default()
|
let plain = web::PayloadConfig::default()
|
||||||
.limit(*config::LIMIT)
|
.limit(*config::LIMIT)
|
||||||
.mimetype(mime::STAR_STAR);
|
.mimetype(mime::STAR_STAR);
|
||||||
|
// cfg.app_data(plain);
|
||||||
cfg.app_data(json).app_data(plain);
|
cfg.app_data(json).app_data(plain);
|
||||||
}
|
}
|
@@ -12,4 +12,6 @@ pub struct Status {
|
|||||||
// Theme
|
// Theme
|
||||||
pub theme_image: String,
|
pub theme_image: String,
|
||||||
pub theme_text: String,
|
pub theme_text: String,
|
||||||
|
pub theme_page_title: String,
|
||||||
|
pub theme_favicon: String,
|
||||||
}
|
}
|
@@ -13,6 +13,8 @@ async fn get_status() -> impl Responder {
|
|||||||
allow_advanced: *config::ALLOW_ADVANCED,
|
allow_advanced: *config::ALLOW_ADVANCED,
|
||||||
theme_image: config::THEME_IMAGE.to_string(),
|
theme_image: config::THEME_IMAGE.to_string(),
|
||||||
theme_text: config::THEME_TEXT.to_string(),
|
theme_text: config::THEME_TEXT.to_string(),
|
||||||
|
theme_page_title: config::THEME_PAGE_TITLE.to_string(),
|
||||||
|
theme_favicon: config::THEME_FAVICON.to_string()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@@ -1,8 +1,8 @@
|
|||||||
├─ MIT: 12
|
├─ MIT: 13
|
||||||
|
├─ ISC: 2
|
||||||
├─ BSD-3-Clause: 1
|
├─ BSD-3-Clause: 1
|
||||||
├─ (MPL-2.0 OR Apache-2.0): 1
|
├─ (MPL-2.0 OR Apache-2.0): 1
|
||||||
├─ BSD-2-Clause: 1
|
├─ BSD-2-Clause: 1
|
||||||
├─ ISC: 1
|
|
||||||
├─ 0BSD: 1
|
├─ 0BSD: 1
|
||||||
└─ Apache-2.0: 1
|
└─ Apache-2.0: 1
|
||||||
|
|
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "verschlüsseln",
|
"encrypting": "verschlüsseln",
|
||||||
"decrypting": "entschlüsselt",
|
"decrypting": "entschlüsselt",
|
||||||
"uploading": "hochladen",
|
"uploading": "hochladen",
|
||||||
"downloading": "wird heruntergeladen"
|
"downloading": "wird heruntergeladen",
|
||||||
|
"qr_code": "qr-code"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "Senden Sie ganz einfach <i>vollständig verschlüsselte</i>, sichere Notizen oder Dateien mit einem Klick. Erstellen Sie einfach eine Notiz und teilen Sie den Link.",
|
"intro": "Senden Sie ganz einfach <i>vollständig verschlüsselte</i>, sichere Notizen oder Dateien mit einem Klick. Erstellen Sie einfach eine Notiz und teilen Sie den Link.",
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "encrypting",
|
"encrypting": "encrypting",
|
||||||
"decrypting": "decrypting",
|
"decrypting": "decrypting",
|
||||||
"uploading": "uploading",
|
"uploading": "uploading",
|
||||||
"downloading": "downloading"
|
"downloading": "downloading",
|
||||||
|
"qr_code": "qr code"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "Easily send <i>fully encrypted</i>, secure notes or files with one click. Just create a note and share the link.",
|
"intro": "Easily send <i>fully encrypted</i>, secure notes or files with one click. Just create a note and share the link.",
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "encriptando",
|
"encrypting": "encriptando",
|
||||||
"decrypting": "descifrando",
|
"decrypting": "descifrando",
|
||||||
"uploading": "cargando",
|
"uploading": "cargando",
|
||||||
"downloading": "descargando"
|
"downloading": "descargando",
|
||||||
|
"qr_code": "código qr"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "Envía fácilmente notas o archivos <i>totalmente encriptados</i> y seguros con un solo clic. Solo tienes que crear una nota y compartir el enlace.",
|
"intro": "Envía fácilmente notas o archivos <i>totalmente encriptados</i> y seguros con un solo clic. Solo tienes que crear una nota y compartir el enlace.",
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "cryptage",
|
"encrypting": "cryptage",
|
||||||
"decrypting": "déchiffrer",
|
"decrypting": "déchiffrer",
|
||||||
"uploading": "téléchargement",
|
"uploading": "téléchargement",
|
||||||
"downloading": "téléchargement"
|
"downloading": "téléchargement",
|
||||||
|
"qr_code": "code qr"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "Envoyez facilement des notes ou des fichiers <i>entièrement cryptés</i> et sécurisés en un seul clic. Il suffit de créer une note et de partager le lien.",
|
"intro": "Envoyez facilement des notes ou des fichiers <i>entièrement cryptés</i> et sécurisés en un seul clic. Il suffit de créer une note et de partager le lien.",
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "criptando",
|
"encrypting": "criptando",
|
||||||
"decrypting": "decifrando",
|
"decrypting": "decifrando",
|
||||||
"uploading": "caricamento",
|
"uploading": "caricamento",
|
||||||
"downloading": "scaricando"
|
"downloading": "scaricando",
|
||||||
|
"qr_code": "codice qr"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "Invia facilmente note o file <i>completamente criptati</i> e sicuri con un solo clic. Basta creare una nota e condividere il link.",
|
"intro": "Invia facilmente note o file <i>completamente criptati</i> e sicuri con un solo clic. Basta creare una nota e condividere il link.",
|
@@ -15,7 +15,8 @@
|
|||||||
"encrypting": "加密",
|
"encrypting": "加密",
|
||||||
"decrypting": "解密",
|
"decrypting": "解密",
|
||||||
"uploading": "上传",
|
"uploading": "上传",
|
||||||
"downloading": "下载"
|
"downloading": "下载",
|
||||||
|
"qr_code": "二维码"
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"intro": "一键轻松发送 <i>完全加密的</i> 密信或者文件。只需创建一个密信然后分享链接。",
|
"intro": "一键轻松发送 <i>完全加密的</i> 密信或者文件。只需创建一个密信然后分享链接。",
|
39
packages/frontend/package.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"check": "svelte-check --tsconfig tsconfig.json",
|
||||||
|
"licenses": "license-checker --summary > licenses.csv",
|
||||||
|
"locale:download": "node scripts/locale.js",
|
||||||
|
"test:prepare": "pnpm run build"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@lokalise/node-api": "^9.5.0",
|
||||||
|
"@sveltejs/adapter-static": "^1.0.2",
|
||||||
|
"@sveltejs/kit": "^1.1.0",
|
||||||
|
"@types/dompurify": "^2.4.0",
|
||||||
|
"@types/file-saver": "^2.0.5",
|
||||||
|
"@zerodevx/svelte-toast": "^0.7.2",
|
||||||
|
"adm-zip": "^0.5.10",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"svelte": "^3.55.1",
|
||||||
|
"svelte-check": "^2.10.3",
|
||||||
|
"svelte-intl-precompile": "^0.10.1",
|
||||||
|
"svelte-preprocess": "^4.10.7",
|
||||||
|
"tslib": "^2.4.1",
|
||||||
|
"typescript": "^4.9.4",
|
||||||
|
"vite": "^4.0.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fontsource/fira-mono": "^4.5.10",
|
||||||
|
"copy-to-clipboard": "^3.3.3",
|
||||||
|
"dompurify": "^2.4.3",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
|
"occulto": "2.0.0",
|
||||||
|
"pretty-bytes": "^6.0.0",
|
||||||
|
"qrious": "^4.0.2"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
import dotenv from 'dotenv'
|
|
||||||
import { LokaliseApi } from '@lokalise/node-api'
|
import { LokaliseApi } from '@lokalise/node-api'
|
||||||
import https from 'https'
|
|
||||||
import AdmZip from 'adm-zip'
|
import AdmZip from 'adm-zip'
|
||||||
|
import dotenv from 'dotenv'
|
||||||
|
import https from 'https'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
@@ -87,6 +87,8 @@ button {
|
|||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
background: inherit;
|
background: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
border: none;
|
||||||
|
padding-inline: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
*:disabled,
|
*:disabled,
|
@@ -2,7 +2,6 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="/favicon.png" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
@@ -1,34 +1,33 @@
|
|||||||
|
import { AES, Bytes, type TypedArray } from 'occulto'
|
||||||
import type { EncryptedFileDTO, FileDTO } from './api'
|
import type { EncryptedFileDTO, FileDTO } from './api'
|
||||||
import { Crypto } from './crypto'
|
|
||||||
|
|
||||||
abstract class CryptAdapter<T> {
|
abstract class CryptAdapter<T> {
|
||||||
abstract encrypt(plaintext: T, key: CryptoKey): Promise<string>
|
abstract encrypt(plaintext: T, key: TypedArray): Promise<string>
|
||||||
abstract decrypt(ciphertext: string, key: CryptoKey): Promise<T>
|
abstract decrypt(ciphertext: string, key: TypedArray): Promise<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
class CryptTextAdapter implements CryptAdapter<string> {
|
class CryptTextAdapter implements CryptAdapter<string> {
|
||||||
async encrypt(plaintext: string, key: CryptoKey) {
|
async encrypt(plaintext: string, key: TypedArray) {
|
||||||
return await Crypto.encrypt(new TextEncoder().encode(plaintext), key)
|
return await AES.encrypt(Bytes.encode(plaintext), key)
|
||||||
}
|
}
|
||||||
async decrypt(ciphertext: string, key: CryptoKey) {
|
async decrypt(ciphertext: string, key: TypedArray) {
|
||||||
const plaintext = await Crypto.decrypt(ciphertext, key)
|
return Bytes.decode(await AES.decrypt(ciphertext, key))
|
||||||
return new TextDecoder().decode(plaintext)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CryptBlobAdapter implements CryptAdapter<Blob> {
|
class CryptBlobAdapter implements CryptAdapter<Blob> {
|
||||||
async encrypt(plaintext: Blob, key: CryptoKey) {
|
async encrypt(plaintext: Blob, key: TypedArray) {
|
||||||
return await Crypto.encrypt(await plaintext.arrayBuffer(), key)
|
return await AES.encrypt(new Uint8Array(await plaintext.arrayBuffer()), key)
|
||||||
}
|
}
|
||||||
|
|
||||||
async decrypt(ciphertext: string, key: CryptoKey) {
|
async decrypt(ciphertext: string, key: TypedArray) {
|
||||||
const plaintext = await Crypto.decrypt(ciphertext, key)
|
const plaintext = await AES.decrypt(ciphertext, key)
|
||||||
return new Blob([plaintext], { type: 'application/octet-stream' })
|
return new Blob([plaintext], { type: 'application/octet-stream' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CryptFilesAdapter implements CryptAdapter<FileDTO[]> {
|
class CryptFilesAdapter implements CryptAdapter<FileDTO[]> {
|
||||||
async encrypt(plaintext: FileDTO[], key: CryptoKey) {
|
async encrypt(plaintext: FileDTO[], key: TypedArray) {
|
||||||
const adapter = new CryptBlobAdapter()
|
const adapter = new CryptBlobAdapter()
|
||||||
const data: Promise<EncryptedFileDTO>[] = plaintext.map(async (file) => ({
|
const data: Promise<EncryptedFileDTO>[] = plaintext.map(async (file) => ({
|
||||||
name: file.name,
|
name: file.name,
|
||||||
@@ -39,7 +38,7 @@ class CryptFilesAdapter implements CryptAdapter<FileDTO[]> {
|
|||||||
return JSON.stringify(await Promise.all(data))
|
return JSON.stringify(await Promise.all(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
async decrypt(ciphertext: string, key: CryptoKey) {
|
async decrypt(ciphertext: string, key: TypedArray) {
|
||||||
const adapter = new CryptBlobAdapter()
|
const adapter = new CryptBlobAdapter()
|
||||||
const data: EncryptedFileDTO[] = JSON.parse(ciphertext)
|
const data: EncryptedFileDTO[] = JSON.parse(ciphertext)
|
||||||
const files: FileDTO[] = await Promise.all(
|
const files: FileDTO[] = await Promise.all(
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 325 B |
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 736 B |
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 732 B After Width: | Height: | Size: 732 B |
@@ -9,6 +9,8 @@ export type Status = {
|
|||||||
allow_advanced: boolean
|
allow_advanced: boolean
|
||||||
theme_image: string
|
theme_image: string
|
||||||
theme_text: string
|
theme_text: string
|
||||||
|
theme_favicon: string
|
||||||
|
theme_page_title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const status = writable<null | Status>(null)
|
export const status = writable<null | Status>(null)
|
@@ -18,8 +18,9 @@
|
|||||||
bind:value={note.views}
|
bind:value={note.views}
|
||||||
disabled={timeExpiration}
|
disabled={timeExpiration}
|
||||||
max={$status?.max_views}
|
max={$status?.max_views}
|
||||||
|
min={1}
|
||||||
validate={(v) =>
|
validate={(v) =>
|
||||||
($status && v < $status?.max_views) ||
|
($status && v <= $status?.max_views && v > 0) ||
|
||||||
$t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })}
|
$t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })}
|
||||||
/>
|
/>
|
||||||
<div class="middle-switch">
|
<div class="middle-switch">
|
41
packages/frontend/src/lib/ui/Canvas.svelte
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import QR from 'qrious'
|
||||||
|
import { t } from 'svelte-intl-precompile'
|
||||||
|
|
||||||
|
import { getCSSVariable } from '$lib/utils'
|
||||||
|
|
||||||
|
export let value: string
|
||||||
|
|
||||||
|
let canvas: HTMLCanvasElement
|
||||||
|
|
||||||
|
$: {
|
||||||
|
new QR({
|
||||||
|
value,
|
||||||
|
level: 'Q',
|
||||||
|
size: 800,
|
||||||
|
background: getCSSVariable('--ui-bg-0'),
|
||||||
|
foreground: getCSSVariable('--ui-text-0'),
|
||||||
|
element: canvas,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<small>{$t('common.qr_code')}</small>
|
||||||
|
<div>
|
||||||
|
<canvas bind:this={canvas} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
padding: 0.5rem;
|
||||||
|
width: fit-content;
|
||||||
|
border: 2px solid var(--ui-bg-1);
|
||||||
|
background-color: var(--ui-bg-0);
|
||||||
|
margin-top: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 784 B |
@@ -10,9 +10,12 @@
|
|||||||
|
|
||||||
import Button from '$lib/ui/Button.svelte'
|
import Button from '$lib/ui/Button.svelte'
|
||||||
import TextInput from '$lib/ui/TextInput.svelte'
|
import TextInput from '$lib/ui/TextInput.svelte'
|
||||||
|
import Canvas from './Canvas.svelte'
|
||||||
|
|
||||||
export let result: NoteResult
|
export let result: NoteResult
|
||||||
|
|
||||||
|
$: url = `${window.location.origin}/note/${result.id}#${result.password}`
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
@@ -22,11 +25,15 @@
|
|||||||
type="text"
|
type="text"
|
||||||
readonly
|
readonly
|
||||||
label={$t('common.share_link')}
|
label={$t('common.share_link')}
|
||||||
value="{window.location.origin}/note/{result.id}#{result.password}"
|
value={url}
|
||||||
copy
|
copy
|
||||||
data-testid="share-link"
|
data-testid="share-link"
|
||||||
/>
|
/>
|
||||||
<br />
|
|
||||||
|
<div>
|
||||||
|
<Canvas value={url} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{@html $t('home.new_note_notice')}
|
{@html $t('home.new_note_notice')}
|
||||||
</p>
|
</p>
|
||||||
@@ -34,4 +41,9 @@
|
|||||||
<Button on:click={reset}>{$t('home.new_note')}</Button>
|
<Button on:click={reset}>{$t('home.new_note')}</Button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
div {
|
||||||
|
width: min(12rem, 100%);
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@@ -53,7 +53,9 @@
|
|||||||
{:else}
|
{:else}
|
||||||
{#each files as file}
|
{#each files as file}
|
||||||
<div class="note file">
|
<div class="note file">
|
||||||
<b on:click={() => downloadFile(file)}>↓ {file.name}</b>
|
<button on:click={() => downloadFile(file)}>
|
||||||
|
<b>↓ {file.name}</b>
|
||||||
|
</button>
|
||||||
<small> {file.type} - {prettyBytes(file.size)}</small>
|
<small> {file.type} - {prettyBytes(file.size)}</small>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Crypto, Hex } from '$lib/crypto'
|
|
||||||
import Icon from '$lib/ui/Icon.svelte'
|
import Icon from '$lib/ui/Icon.svelte'
|
||||||
import { copy as copyFN } from '$lib/utils'
|
import { copy as copyFN } from '$lib/utils'
|
||||||
|
import { getRandomBytes, Hex } from 'occulto'
|
||||||
|
|
||||||
export let label: string = ''
|
export let label: string = ''
|
||||||
export let value: any
|
export let value: any
|
||||||
@@ -23,8 +23,9 @@
|
|||||||
function toggle() {
|
function toggle() {
|
||||||
hidden = !hidden
|
hidden = !hidden
|
||||||
}
|
}
|
||||||
function randomFN() {
|
|
||||||
value = Hex.encode(Crypto.getRandomBytes(20))
|
async function randomFN() {
|
||||||
|
value = Hex.encode(await getRandomBytes(32))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@@ -40,19 +40,19 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={change}>
|
<button on:click={change}>
|
||||||
<Icon class="icon" icon="contrast" />
|
<Icon class="icon" icon="contrast" />
|
||||||
{$theme}
|
{$theme}
|
||||||
</div>
|
</button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div :global(.icon) {
|
button :global(.icon) {
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
div {
|
button {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
@@ -9,3 +9,8 @@ export function copy(value: string) {
|
|||||||
const msg = get(t)('common.copied_to_clipboard')
|
const msg = get(t)('common.copied_to_clipboard')
|
||||||
notify.success(msg)
|
notify.success(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCSSVariable(variable: string): string {
|
||||||
|
if (typeof window === 'undefined') return ''
|
||||||
|
return window.getComputedStyle(window.document.body).getPropertyValue(variable)
|
||||||
|
}
|
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { AES, Hex } from 'occulto'
|
||||||
import { t } from 'svelte-intl-precompile'
|
import { t } from 'svelte-intl-precompile'
|
||||||
import { blur } from 'svelte/transition'
|
import { blur } from 'svelte/transition'
|
||||||
|
|
||||||
import { Adapters } from '$lib/adapters'
|
import { Adapters } from '$lib/adapters'
|
||||||
import type { FileDTO, Note } from '$lib/api'
|
import type { FileDTO, Note } from '$lib/api'
|
||||||
import { create, PayloadToLargeError } from '$lib/api'
|
import { create, PayloadToLargeError } from '$lib/api'
|
||||||
import { Crypto, Hex } from '$lib/crypto'
|
|
||||||
import { status } from '$lib/stores/status'
|
import { status } from '$lib/stores/status'
|
||||||
import { notify } from '$lib/toast'
|
import { notify } from '$lib/toast'
|
||||||
import AdvancedParameters from '$lib/ui/AdvancedParameters.svelte'
|
import AdvancedParameters from '$lib/ui/AdvancedParameters.svelte'
|
||||||
@@ -58,8 +58,8 @@
|
|||||||
try {
|
try {
|
||||||
loading = $t('common.encrypting')
|
loading = $t('common.encrypting')
|
||||||
|
|
||||||
const password = Hex.encode(Crypto.getRandomBytes(32))
|
const key = await AES.generateKey()
|
||||||
const key = await Crypto.getKeyFromString(password)
|
const password = await Hex.encode(key)
|
||||||
|
|
||||||
const data: Note = {
|
const data: Note = {
|
||||||
contents: '',
|
contents: '',
|
@@ -7,7 +7,9 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<a href="/">/home</a>
|
<a href="/">/home</a>
|
||||||
<a href="/about">/about</a>
|
<a href="/about">/about</a>
|
||||||
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener">/code</a>
|
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener noreferrer">
|
||||||
|
code
|
||||||
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
@@ -1,18 +1,11 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
import { getLocaleFromNavigator, init, waitLocale } from 'svelte-intl-precompile'
|
|
||||||
// @ts-ignore
|
|
||||||
import { registerAll } from '$locales'
|
|
||||||
registerAll()
|
|
||||||
init({ initialLocale: getLocaleFromNavigator() ?? undefined, fallbackLocale: 'en' })
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { SvelteToast } from '@zerodevx/svelte-toast'
|
import { SvelteToast } from '@zerodevx/svelte-toast'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
import { waitLocale } from 'svelte-intl-precompile'
|
||||||
|
|
||||||
import '../app.css'
|
import '../app.css'
|
||||||
|
|
||||||
import { init as initStores } from '$lib/stores/status'
|
import { init as initStores, status } from '$lib/stores/status'
|
||||||
import Footer from '$lib/views/Footer.svelte'
|
import Footer from '$lib/views/Footer.svelte'
|
||||||
import Header from '$lib/views/Header.svelte'
|
import Header from '$lib/views/Header.svelte'
|
||||||
|
|
||||||
@@ -22,7 +15,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>cryptgeon</title>
|
<title>{$status?.theme_page_title || 'cryptgeon'}</title>
|
||||||
|
<link rel="icon" href={$status?.theme_favicon || '/favicon.png'} />
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#await waitLocale() then _}
|
{#await waitLocale() then _}
|
5
packages/frontend/src/routes/+layout.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { getLocaleFromNavigator, init } from 'svelte-intl-precompile'
|
||||||
|
// @ts-ignore
|
||||||
|
import { registerAll } from '$locales'
|
||||||
|
registerAll()
|
||||||
|
init({ initialLocale: getLocaleFromNavigator() ?? undefined, fallbackLocale: 'en' })
|
@@ -1,10 +1,6 @@
|
|||||||
<script context="module">
|
<script lang="ts">
|
||||||
import { browser, dev } from '$app/env'
|
|
||||||
import { status } from '$lib/stores/status'
|
import { status } from '$lib/stores/status'
|
||||||
import AboutParagraph from '$lib/ui/AboutParagraph.svelte'
|
import AboutParagraph from '$lib/ui/AboutParagraph.svelte'
|
||||||
|
|
||||||
export const hydrate = dev
|
|
||||||
export const router = browser
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -43,7 +39,7 @@
|
|||||||
the backend is written in rust and the frontend is svelte and typescript.
|
the backend is written in rust and the frontend is svelte and typescript.
|
||||||
<br />
|
<br />
|
||||||
you are welcomed to check & audit the
|
you are welcomed to check & audit the
|
||||||
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener">
|
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener noreferrer">
|
||||||
source code
|
source code
|
||||||
</a>.
|
</a>.
|
||||||
</span>
|
</span>
|
||||||
@@ -51,9 +47,12 @@
|
|||||||
|
|
||||||
<AboutParagraph title="translations">
|
<AboutParagraph title="translations">
|
||||||
<span
|
<span
|
||||||
>translations are managed on <a href="https://lokalise.com/" target="_blank">Lokalise</a>,
|
>translations are managed on <a
|
||||||
which granted an open source license to use the paid version. If you are interested in helping
|
href="https://lokalise.com/"
|
||||||
translating don't hesitate to contact me!
|
target="_blank"
|
||||||
|
rel="noopener noreferrer">Lokalise</a
|
||||||
|
>, which granted an open source license to use the paid version. If you are interested in
|
||||||
|
helping translating don't hesitate to contact me!
|
||||||
</span>
|
</span>
|
||||||
</AboutParagraph>
|
</AboutParagraph>
|
||||||
|
|
@@ -1,26 +1,18 @@
|
|||||||
<script context="module" lang="ts">
|
|
||||||
import type { Load } from '@sveltejs/kit'
|
|
||||||
|
|
||||||
export const load: Load = async ({ params }) => {
|
|
||||||
return {
|
|
||||||
props: params,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Hex } from 'occulto'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { t } from 'svelte-intl-precompile'
|
import { t } from 'svelte-intl-precompile'
|
||||||
|
|
||||||
import { Adapters } from '$lib/adapters'
|
import { Adapters } from '$lib/adapters'
|
||||||
import { get, info } from '$lib/api'
|
import { get, info } from '$lib/api'
|
||||||
import { Crypto } from '$lib/crypto'
|
|
||||||
import Button from '$lib/ui/Button.svelte'
|
import Button from '$lib/ui/Button.svelte'
|
||||||
import Loader from '$lib/ui/Loader.svelte'
|
import Loader from '$lib/ui/Loader.svelte'
|
||||||
import ShowNote, { type DecryptedNote } from '$lib/ui/ShowNote.svelte'
|
import ShowNote, { type DecryptedNote } from '$lib/ui/ShowNote.svelte'
|
||||||
|
import type { PageData } from './$types'
|
||||||
|
|
||||||
export let id: string
|
export let data: PageData
|
||||||
|
|
||||||
|
let id = data.id
|
||||||
let password: string
|
let password: string
|
||||||
let note: DecryptedNote | null = null
|
let note: DecryptedNote | null = null
|
||||||
let exists = false
|
let exists = false
|
||||||
@@ -51,7 +43,7 @@
|
|||||||
loading = $t('common.downloading')
|
loading = $t('common.downloading')
|
||||||
const data = await get(id)
|
const data = await get(id)
|
||||||
loading = $t('common.decrypting')
|
loading = $t('common.decrypting')
|
||||||
const key = await Crypto.getKeyFromString(password)
|
const key = await Hex.decode(password)
|
||||||
switch (data.meta.type) {
|
switch (data.meta.type) {
|
||||||
case 'text':
|
case 'text':
|
||||||
note = {
|
note = {
|
5
packages/frontend/src/routes/note/[id]/+page.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import type { PageLoad } from './$types'
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ params }) => {
|
||||||
|
return params
|
||||||
|
}
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
@@ -1,11 +1,13 @@
|
|||||||
import { sveltekit } from '@sveltejs/kit/vite'
|
import { sveltekit } from '@sveltejs/kit/vite'
|
||||||
import precompileIntl from 'svelte-intl-precompile/sveltekit-plugin'
|
import precompileIntl from 'svelte-intl-precompile/sveltekit-plugin'
|
||||||
|
|
||||||
|
const port = 8001
|
||||||
|
|
||||||
/** @type {import('vite').UserConfig} */
|
/** @type {import('vite').UserConfig} */
|
||||||
const config = {
|
const config = {
|
||||||
server: {
|
clearScreen: false,
|
||||||
port: 3000,
|
server: { port },
|
||||||
},
|
preview: { port },
|
||||||
plugins: [sveltekit(), precompileIntl('locales')],
|
plugins: [sveltekit(), precompileIntl('locales')],
|
||||||
}
|
}
|
||||||
|
|
@@ -9,12 +9,15 @@ const config: PlaywrightTestConfig = {
|
|||||||
|
|
||||||
outputDir: './test-results',
|
outputDir: './test-results',
|
||||||
testDir: './test',
|
testDir: './test',
|
||||||
|
timeout: 60_000,
|
||||||
|
testIgnore: ['file/too-big.spec.ts'],
|
||||||
|
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'pnpm run ci:server',
|
command: 'docker compose -f docker-compose.dev.yaml up',
|
||||||
port: 1234,
|
port: 1234,
|
||||||
reuseExistingServer: true,
|
reuseExistingServer: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
projects: [
|
projects: [
|
||||||
{ name: 'chrome', use: { ...devices['Desktop Chrome'] } },
|
{ name: 'chrome', use: { ...devices['Desktop Chrome'] } },
|
||||||
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
||||||
|
1816
pnpm-lock.yaml
generated
2
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
packages:
|
||||||
|
- "packages/**"
|
@@ -3,12 +3,13 @@ import httpProxy from 'http-proxy'
|
|||||||
|
|
||||||
const proxy = httpProxy.createProxyServer()
|
const proxy = httpProxy.createProxyServer()
|
||||||
proxy.on('error', function (err, req, res) {
|
proxy.on('error', function (err, req, res) {
|
||||||
|
console.error(err)
|
||||||
res.writeHead(500, { 'Content-Type': 'text/plain' })
|
res.writeHead(500, { 'Content-Type': 'text/plain' })
|
||||||
res.end('500 Internal Server Error')
|
res.end('500 Internal Server Error')
|
||||||
})
|
})
|
||||||
|
|
||||||
const server = http.createServer(function (req, res) {
|
const server = http.createServer(function (req, res) {
|
||||||
const target = req.url.startsWith('/api/') ? 'http://localhost:5000' : 'http://localhost:3000'
|
const target = req.url.startsWith('/api/') ? 'http://127.0.0.1:8000' : 'http://localhost:8001'
|
||||||
proxy.web(req, res, { target })
|
proxy.web(req, res, { target })
|
||||||
})
|
})
|
||||||
server.listen(1234)
|
server.listen(1234)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
PDF: 'test/assets/AES.pdf',
|
PDF: 'test/assets/AES.pdf',
|
||||||
Image: 'test/assets/alfred-kenneally-UIu4RmMxnHU-unsplash.jpg',
|
Image: 'test/assets/image.jpg',
|
||||||
Zip: 'test/assets/Pigeons.zip',
|
Zip: 'test/assets/Pigeons.zip',
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,6 @@ test('multiple', async ({ page }) => {
|
|||||||
const files = [Files.PDF, Files.Image]
|
const files = [Files.PDF, Files.Image]
|
||||||
const checksums = await Promise.all(files.map(getFileChecksum))
|
const checksums = await Promise.all(files.map(getFileChecksum))
|
||||||
const link = await createNote(page, { files, views: 2 })
|
const link = await createNote(page, { files, views: 2 })
|
||||||
await checkLinkForDownload(page, link, 'alfred-kenneally', checksums[1])
|
await checkLinkForDownload(page, link, 'image.jpg', checksums[1])
|
||||||
await checkLinkForDownload(page, link, 'AES.pdf', checksums[0])
|
await checkLinkForDownload(page, link, 'AES.pdf', checksums[0])
|
||||||
})
|
})
|
||||||
|
@@ -20,5 +20,5 @@ test('image content', async ({ page }) => {
|
|||||||
const files = [Files.Image]
|
const files = [Files.Image]
|
||||||
const checksum = await getFileChecksum(files[0])
|
const checksum = await getFileChecksum(files[0])
|
||||||
const link = await createNote(page, { files })
|
const link = await createNote(page, { files })
|
||||||
await checkLinkForDownload(page, link, 'alfred-kenneally', checksum)
|
await checkLinkForDownload(page, link, 'image.jpg', checksum)
|
||||||
})
|
})
|
||||||
|
8
test/file/too-big.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '@playwright/test'
|
||||||
|
import { createNote } from '../utils'
|
||||||
|
import Files from './files'
|
||||||
|
|
||||||
|
test('to big zip', async ({ page }) => {
|
||||||
|
const files = [Files.Zip]
|
||||||
|
const link = await createNote(page, { files, error: 'note is to big' })
|
||||||
|
})
|