Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature] Adding support for custom link expiration duration #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion server/src/app.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ describe("POST /api/note", () => {
});
expect(writeEvents.length).toBe(1);
expect(writeEvents[0].success).toBe(true);
expect(writeEvents[0].expire_window_days).toBe(30);
expect(writeEvents[0].expire_window_days).toBeGreaterThan(0);
expect(writeEvents[0].expire_window_days).toBeLessThan(32);

expect(writeEvents[0].size_bytes).toBe(
testNote.ciphertext.length + testNote.hmac.length
);
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/note/note.post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function postNoteController(
}

// Create note object
const EXPIRE_WINDOW_DAYS = 30;
const EXPIRE_WINDOW_DAYS = notePostRequest.expiration;
const secret_token = generateToken();

const note = {
Expand Down
4 changes: 4 additions & 0 deletions server/src/validation/Request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
IsBase64,
IsHexadecimal,
IsInt,
IsNotEmpty,
Matches,
ValidateIf,
Expand Down Expand Up @@ -31,6 +32,9 @@ export class NotePostRequest extends NoteRequestBody {

@Matches("^v[0-9]+$")
crypto_version: string = "v1";

@IsInt()
expiration: number = 31;
}

export class NoteDeleteRequest extends NoteRequestBody {
Expand Down