Compare commits

..

No commits in common. "9b48d39c825ecd8658cd0103c6740b9fbe9ed38f" and "fc3938701e2e18368bafe589bda403b77c2ed4c9" have entirely different histories.

12 changed files with 81 additions and 110 deletions

View File

@ -13,13 +13,13 @@ RUN pnpm run build
# BACKEND
FROM rust:1.76-alpine as backend
WORKDIR /tmp
RUN apk add --no-cache libc-dev openssl-dev alpine-sdk
RUN apk add libc-dev openssl-dev alpine-sdk
COPY ./packages/backend ./
RUN cargo build --release
# RUNNER
FROM alpine:3.19
FROM alpine
WORKDIR /app
RUN apk add --no-cache curl
COPY --from=backend /tmp/target/release/cryptgeon .

View File

@ -62,21 +62,19 @@ of the notes even if it tried to.
## Environment Variables
| Variable | Default | Description |
| ----------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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. |
| `MAX_VIEWS` | `100` | Maximal number of views. |
| `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_FILES` | `true` | Allow uploading files. If set to `false`, users will only be allowed to create text notes. |
| `THEME_NEW_NOTE_NOTICE` | `true` | Show the message about how notes are stored in the memory and may be evicted after creating a new note. Defaults to `true`. |
| `ID_LENGTH` | `32` | Set the size of the note `id` in bytes. By default this is `32` bytes. This is useful for reducing link size. _This setting does not affect encryption strength_. |
| `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_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 |
| Variable | Default | Description |
| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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. |
| `MAX_VIEWS` | `100` | Maximal number of views. |
| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. |
| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. |
| `ID_LENGTH` | `32` | Set the size of the note `id` in bytes. By default this is `32` bytes. This is useful for reducing link size. _This setting does not affect encryption strength_. |
| `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_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

View File

@ -13,7 +13,7 @@
},
"devDependencies": {
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.28",
"@types/node": "^20.11.24",
"npm-run-all": "^4.1.5",
"shelljs": "^0.8.5"
},

View File

@ -14,34 +14,26 @@ lazy_static! {
// CONFIG
lazy_static! {
pub static ref LIMIT: usize =
Byte::from_str(std::env::var("SIZE_LIMIT").unwrap_or("1 KiB".to_string()))
.unwrap()
.get_bytes() as usize;
pub static ref MAX_VIEWS: u32 = std::env::var("MAX_VIEWS")
.unwrap_or("100".to_string())
.parse()
.unwrap();
pub static ref MAX_EXPIRATION: u32 = std::env::var("MAX_EXPIRATION")
.unwrap_or("360".to_string()) // 6 hours in minutes
.parse()
.unwrap();
pub static ref ALLOW_ADVANCED: bool = std::env::var("ALLOW_ADVANCED")
.unwrap_or("true".to_string())
.parse()
.unwrap();
pub static ref ID_LENGTH: u32 = std::env::var("ID_LENGTH")
.unwrap_or("32".to_string())
.parse()
.unwrap();
pub static ref ALLOW_FILES: bool = std::env::var("ALLOW_FILES")
.unwrap_or("true".to_string())
.parse()
.unwrap();
pub static ref THEME_NEW_NOTE_NOTICE: bool = std::env::var("THEME_NEW_NOTE_NOTICE")
.unwrap_or("true".to_string())
.parse()
.unwrap();
pub static ref LIMIT: usize =
Byte::from_str(std::env::var("SIZE_LIMIT").unwrap_or("1 KiB".to_string()))
.unwrap()
.get_bytes() as usize;
pub static ref MAX_VIEWS: u32 = std::env::var("MAX_VIEWS")
.unwrap_or("100".to_string())
.parse()
.unwrap();
pub static ref MAX_EXPIRATION: u32 = std::env::var("MAX_EXPIRATION")
.unwrap_or("360".to_string()) // 6 hours in minutes
.parse()
.unwrap();
pub static ref ALLOW_ADVANCED: bool = std::env::var("ALLOW_ADVANCED")
.unwrap_or("true".to_string())
.parse()
.unwrap();
pub static ref ID_LENGTH: u32 = std::env::var("ID_LENGTH")
.unwrap_or("32".to_string())
.parse()
.unwrap();
}
// THEME

View File

@ -9,8 +9,6 @@ pub struct Status {
pub max_views: u32,
pub max_expiration: u32,
pub allow_advanced: bool,
pub allow_files: bool,
pub theme_new_note_notice: bool,
// Theme
pub theme_image: String,
pub theme_text: String,

View File

@ -11,12 +11,10 @@ async fn get_status() -> impl Responder {
max_views: *config::MAX_VIEWS,
max_expiration: *config::MAX_EXPIRATION,
allow_advanced: *config::ALLOW_ADVANCED,
allow_files: *config::ALLOW_FILES,
theme_new_note_notice: *config::THEME_NEW_NOTE_NOTICE,
theme_image: config::THEME_IMAGE.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(),
theme_favicon: config::THEME_FAVICON.to_string()
});
}

View File

@ -7,7 +7,7 @@
<script lang="ts">
import { t } from 'svelte-intl-precompile'
import { status } from '$lib/stores/status'
import Button from '$lib/ui/Button.svelte'
import TextInput from '$lib/ui/TextInput.svelte'
import Canvas from './Canvas.svelte'
@ -35,11 +35,9 @@
<Canvas value={url} />
</div>
{#if $status?.theme_new_note_notice}
<p>
{@html $t('home.theme_new_note_notice')}
</p>
{/if}
<p>
{@html $t('home.new_note_notice')}
</p>
<br />
<Button on:click={reset}>{$t('home.new_note')}</Button>

View File

@ -3,8 +3,7 @@
</script>
<script lang="ts">
import pkg from 'file-saver'
const { saveAs } = pkg
import { saveAs } from 'file-saver'
import prettyBytes from 'pretty-bytes'
import { t } from 'svelte-intl-precompile'

View File

@ -118,14 +118,12 @@
{/if}
<div class="bottom">
{#if $status?.allow_files}
<Switch
data-testid="switch-file"
class="file"
label={$t('common.file')}
bind:value={isFile}
/>
{/if}
<Switch
data-testid="switch-file"
class="file"
label={$t('common.file')}
bind:value={isFile}
/>
{#if $status?.allow_advanced}
<Switch
data-testid="switch-advanced"

View File

@ -1,13 +1,9 @@
<script lang="ts">
import { status } from '$lib/stores/status'
function reset() {
window.location.reload()
}
</script>
<header>
<a on:click={reset} href="/">
<a href="/">
{#if $status?.theme_image}
<img alt="logo" src={$status.theme_image} />
{:else}

View File

@ -40,8 +40,8 @@
<br />
you are welcomed to check & audit the
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener noreferrer">
source code</a
>.
source code
</a>.
</span>
</AboutParagraph>

66
pnpm-lock.yaml generated
View File

@ -12,8 +12,8 @@ importers:
specifier: ^1.42.1
version: 1.42.1
'@types/node':
specifier: ^20.11.28
version: 20.11.28
specifier: ^20.11.24
version: 20.11.24
npm-run-all:
specifier: ^4.1.5
version: 4.1.5
@ -127,7 +127,7 @@ importers:
version: 5.3.3
vite:
specifier: ^5.1.4
version: 5.1.4(@types/node@20.11.28)
version: 5.1.4(@types/node@20.11.24)
packages/proxy:
dependencies:
@ -1016,7 +1016,7 @@ packages:
sirv: 2.0.4
svelte: 4.2.12
tiny-glob: 0.2.9
vite: 5.1.4(@types/node@20.11.28)
vite: 5.1.4(@types/node@20.11.24)
dev: true
/@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.2)(svelte@4.2.12)(vite@5.1.4):
@ -1030,7 +1030,7 @@ packages:
'@sveltejs/vite-plugin-svelte': 3.0.2(svelte@4.2.12)(vite@5.1.4)
debug: 4.3.4
svelte: 4.2.12
vite: 5.1.4(@types/node@20.11.28)
vite: 5.1.4(@types/node@20.11.24)
transitivePeerDependencies:
- supports-color
dev: true
@ -1049,7 +1049,7 @@ packages:
magic-string: 0.30.7
svelte: 4.2.12
svelte-hmr: 0.15.3(svelte@4.2.12)
vite: 5.1.4(@types/node@20.11.28)
vite: 5.1.4(@types/node@20.11.24)
vitefu: 0.2.5(vite@5.1.4)
transitivePeerDependencies:
- supports-color
@ -1084,12 +1084,6 @@ packages:
undici-types: 5.26.5
dev: true
/@types/node@20.11.28:
resolution: {integrity: sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==}
dependencies:
undici-types: 5.26.5
dev: true
/@types/pug@2.0.10:
resolution: {integrity: sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==}
dev: true
@ -1248,8 +1242,8 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
dependencies:
caniuse-lite: 1.0.30001597
electron-to-chromium: 1.4.707
caniuse-lite: 1.0.30001591
electron-to-chromium: 1.4.690
node-releases: 2.0.14
update-browserslist-db: 1.0.13(browserslist@4.23.0)
dev: true
@ -1281,8 +1275,8 @@ packages:
engines: {node: '>=6'}
dev: true
/caniuse-lite@1.0.30001597:
resolution: {integrity: sha512-7LjJvmQU6Sj7bL0j5b5WY/3n7utXUJvAe1lxhsHDbLmwX9mdL86Yjtr+5SRCyf8qME4M7pU2hswj0FpyBVCv9w==}
/caniuse-lite@1.0.30001591:
resolution: {integrity: sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==}
dev: true
/chalk@2.4.2:
@ -1482,8 +1476,8 @@ packages:
engines: {node: '>=12'}
dev: true
/electron-to-chromium@1.4.707:
resolution: {integrity: sha512-qRq74Mo7ChePOU6GHdfAJ0NREXU8vQTlVlfWz3wNygFay6xrd/fY2J7oGHwrhFeU30OVctGLdTh/FcnokTWpng==}
/electron-to-chromium@1.4.690:
resolution: {integrity: sha512-+2OAGjUx68xElQhydpcbqH50hE8Vs2K6TkAeLhICYfndb67CVH0UsZaijmRUE3rHlIxU1u0jxwhgVe6fK3YANA==}
dev: true
/emoji-regex@8.0.0:
@ -1516,7 +1510,7 @@ packages:
has-property-descriptors: 1.0.2
has-proto: 1.0.3
has-symbols: 1.0.3
hasown: 2.0.2
hasown: 2.0.1
internal-slot: 1.0.7
is-array-buffer: 3.0.4
is-callable: 1.2.7
@ -1530,7 +1524,7 @@ packages:
object-keys: 1.1.1
object.assign: 4.1.5
regexp.prototype.flags: 1.5.2
safe-array-concat: 1.1.2
safe-array-concat: 1.1.0
safe-regex-test: 1.0.3
string.prototype.trim: 1.2.8
string.prototype.trimend: 1.0.7
@ -1540,7 +1534,7 @@ packages:
typed-array-byte-offset: 1.0.2
typed-array-length: 1.0.5
unbox-primitive: 1.0.2
which-typed-array: 1.1.15
which-typed-array: 1.1.14
dev: true
/es-define-property@1.0.0:
@ -1561,7 +1555,7 @@ packages:
dependencies:
get-intrinsic: 1.2.4
has-tostringtag: 1.0.2
hasown: 2.0.2
hasown: 2.0.1
dev: true
/es-to-primitive@1.2.1:
@ -1890,15 +1884,15 @@ packages:
function-bind: 1.1.1
dev: true
/hasown@2.0.1:
resolution: {integrity: sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==}
/hasown@2.0.0:
resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==}
engines: {node: '>= 0.4'}
dependencies:
function-bind: 1.1.2
dev: true
/hasown@2.0.2:
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
/hasown@2.0.1:
resolution: {integrity: sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==}
engines: {node: '>= 0.4'}
dependencies:
function-bind: 1.1.2
@ -1979,7 +1973,7 @@ packages:
engines: {node: '>= 0.4'}
dependencies:
es-errors: 1.3.0
hasown: 2.0.2
hasown: 2.0.1
side-channel: 1.0.6
dev: true
@ -2029,7 +2023,7 @@ packages:
/is-core-module@2.13.1:
resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==}
dependencies:
hasown: 2.0.2
hasown: 2.0.0
dev: true
/is-date-object@1.0.5:
@ -2117,7 +2111,7 @@ packages:
resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==}
engines: {node: '>= 0.4'}
dependencies:
which-typed-array: 1.1.15
which-typed-array: 1.1.14
dev: true
/is-unicode-supported@0.1.0:
@ -2630,8 +2624,8 @@ packages:
mri: 1.2.0
dev: true
/safe-array-concat@1.1.2:
resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==}
/safe-array-concat@1.1.0:
resolution: {integrity: sha512-ZdQ0Jeb9Ofti4hbt5lX3T2JcAamT9hfzYU1MNB+z/jaEbB6wfFfPIR/zEORmZqobkCCJhSjodobH6WHNmJ97dg==}
engines: {node: '>=0.4'}
dependencies:
call-bind: 1.0.7
@ -3127,7 +3121,7 @@ packages:
spdx-expression-parse: 3.0.1
dev: true
/vite@5.1.4(@types/node@20.11.28):
/vite@5.1.4(@types/node@20.11.24):
resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@ -3155,7 +3149,7 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 20.11.28
'@types/node': 20.11.24
esbuild: 0.19.12
postcss: 8.4.35
rollup: 4.12.0
@ -3171,7 +3165,7 @@ packages:
vite:
optional: true
dependencies:
vite: 5.1.4(@types/node@20.11.28)
vite: 5.1.4(@types/node@20.11.24)
dev: true
/wcwidth@1.0.1:
@ -3190,8 +3184,8 @@ packages:
is-symbol: 1.0.4
dev: true
/which-typed-array@1.1.15:
resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==}
/which-typed-array@1.1.14:
resolution: {integrity: sha512-VnXFiIW8yNn9kIHN88xvZ4yOWchftKDsRJ8fEPacX/wl1lOvBrhsJ/OeJCXq7B0AaijRuqgzSKalJoPk+D8MPg==}
engines: {node: '>= 0.4'}
dependencies:
available-typed-arrays: 1.0.7