Skip to content

Commit dc1c03d

Browse files
authored
Merge pull request #90 from cupcakearmy/feature/52-Add-note-id-size-option
feat: add note id size option
2 parents 2bff6a3 + 2a75aca commit dc1c03d

7 files changed

Lines changed: 26 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.3.0] - 2023-05-XX
8+
## [2.3.0] - 2023-05-30
99

1010
### Added
1111

12-
- New CLI 🎉
13-
- Russian language
12+
- New CLI 🎉.
13+
- Russian language.
14+
- Option for reducing note id size (`ID_LENGTH`).
1415

1516
### Changed
1617

17-
- Moved to monorepo
18-
19-
## [2.2.0] - 2023-01-14
18+
- Moved to monorepo.
2019

2120
### Changed
2221

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ of the notes even if it tried to.
6969
| `MAX_VIEWS` | `100` | Maximal number of views. |
7070
| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. |
7171
| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. |
72+
| `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_. |
7273
| `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` |
7374
| `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable |
7475
| `THEME_TEXT` | `""` | Custom text for replacing the description below the logo |
@@ -163,7 +164,9 @@ Running `pnpm run dev` in the root folder will start the following things:
163164

164165
You can see the app under [localhost:1234](http://localhost:1234).
165166

166-
## Tests
167+
> There is a Postman collection with some example requests [available in the repo](./Cryptgeon.postman_collection.json)
168+
169+
### Tests
167170

168171
Tests are end to end tests written with Playwright.
169172

packages/backend/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cryptgeon"
3-
version = "2.3.0-beta.6"
3+
version = "2.3.0"
44
authors = ["cupcakearmy <hi@nicco.io>"]
55
edition = "2021"
66

packages/backend/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ lazy_static! {
3030
.unwrap_or("true".to_string())
3131
.parse()
3232
.unwrap();
33+
pub static ref ID_LENGTH: u32 = std::env::var("ID_LENGTH")
34+
.unwrap_or("32".to_string())
35+
.parse()
36+
.unwrap();
3337
}
3438

3539
// THEME

packages/backend/src/note/model.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use bs62;
22
use ring::rand::SecureRandom;
33
use serde::{Deserialize, Serialize};
44

5+
use crate::config;
6+
57
#[derive(Serialize, Deserialize, Clone)]
68
pub struct Note {
79
pub meta: String,
@@ -22,8 +24,13 @@ pub struct NotePublic {
2224
}
2325

2426
pub fn generate_id() -> String {
25-
let mut id: [u8; 32] = [0; 32];
27+
let mut result = "".to_owned();
28+
let mut id: [u8; 1] = [0; 1];
2629
let sr = ring::rand::SystemRandom::new();
27-
let _ = sr.fill(&mut id);
28-
return bs62::encode_data(&id);
30+
31+
for _ in 0..*config::ID_LENGTH {
32+
let _ = sr.fill(&mut id);
33+
result.push_str(&bs62::encode_data(&id));
34+
}
35+
return result;
2936
}

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.3.0-beta.6",
2+
"version": "2.3.0",
33
"name": "cryptgeon",
44
"repository": {
55
"type": "git",

0 commit comments

Comments
 (0)