Release 2.3.0
A share can now hold a private text (a password, a key, a short note) with its files or on its own. The upload page's new "Private text" card takes up to 100 KB; the browser encrypts the text and sends it through the same chunk pipeline as a file, flagged is_text on share_files, so it gets the share's password, expiry, download limit and cleanup. The recipient sees the text only after pressing "Show text", which counts as their download, so a messenger link preview cannot use up a share limited to one download. The text is left out of the file list, the ZIP and the file counts; the admin dashboard marks shares that hold one with "Text". The website gains a Private text feature card and a fifth phone screenshot; every screenshot is retaken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
202813a1e6
commit
f9a7839ad3
@@ -332,7 +332,7 @@ test('completing a share without files is rejected', function () {
|
||||
$share = Share::factory()->pending()->create();
|
||||
|
||||
expect(fn () => $this->service->completeShare($share))
|
||||
->toThrow(ValidationException::class, 'Please select at least one file to upload.');
|
||||
->toThrow(ValidationException::class, 'Add files or a text to share.');
|
||||
});
|
||||
|
||||
test('completing a share with a password wraps its data key instead of storing it', function () {
|
||||
@@ -355,3 +355,47 @@ test('create share stores an empty file', function () {
|
||||
expect($share->files->first()->completed_at)->not->toBeNull();
|
||||
expect(filesize($this->service->storedFilePath($share->files->first())))->toBe(FileEncryptionService::HEADER_LENGTH + FileEncryptionService::TAG_LENGTH);
|
||||
});
|
||||
|
||||
test('a private text over the maximum length is rejected', function () {
|
||||
$text = str_repeat('a', ShareFile::MAX_TEXT_BYTES + 1);
|
||||
|
||||
expect(fn () => $this->service->registerFile(null, 'text.txt', strlen($text), null, isText: true))
|
||||
->toThrow(ValidationException::class, 'The text is too long (maximum 100 KB).');
|
||||
expect(Share::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
test('a private text does not count against the admin limit of files per share', function () {
|
||||
Setting::set('max_files_per_share', 1);
|
||||
$file = $this->service->registerFile(null, 'one.txt', 10, null);
|
||||
|
||||
$text = $this->service->registerFile($file->share, 'text.txt', 20, null, isText: true);
|
||||
|
||||
expect($text->share_id)->toBe($file->share_id);
|
||||
expect(ShareFile::query()->count())->toBe(2);
|
||||
});
|
||||
|
||||
test('create share with no files and a text completes a text-only share', function () {
|
||||
$share = $this->service->createShare([], [], 'hi');
|
||||
|
||||
expect($share->isCompleted())->toBeTrue();
|
||||
expect($share->files)->toHaveCount(1);
|
||||
expect($share->files->first()->is_text)->toBeTrue();
|
||||
expect($share->total_size)->toBe(2);
|
||||
});
|
||||
|
||||
test('readText decrypts a share\'s private text without a password', function () {
|
||||
$share = $this->service->createShare([], [], 'the secret note');
|
||||
|
||||
$text = $this->service->readText($share, $share->encryption_key);
|
||||
|
||||
expect($text)->toBe('the secret note');
|
||||
});
|
||||
|
||||
test('readText decrypts a share\'s private text with the unwrapped key of a password share', function () {
|
||||
$share = $this->service->createShare([], ['password' => 'a-long-password'], 'the secret note');
|
||||
$key = $this->service->getDecryptionKey($share, 'a-long-password');
|
||||
|
||||
$text = $this->service->readText($share, $key);
|
||||
|
||||
expect($text)->toBe('the secret note');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user