Skip to content
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
3 changes: 2 additions & 1 deletion app/src/components/BlinkoCard/cardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AvatarAccount, CommentButton, UserAvatar } from './commentButton';
import { HistoryButton } from '../BlinkoNoteHistory/HistoryButton';
import { api } from '@/lib/trpc';
import { PromiseCall } from '@/store/standard/PromiseState';
import { getBlinkoShareUrl } from '@/lib/blinkoEndpoint';

interface CardHeaderProps {
blinkoItem: Note;
Expand Down Expand Up @@ -210,7 +211,7 @@ const ShareButton = observer(({ blinkoItem, isIOSDevice }: { blinkoItem: Note, i
size: 'md',
title: t('share'),
content: <BlinkoShareDialog defaultSettings={{
shareUrl: blinkoItem.shareEncryptedUrl ? window.location.origin + '/share/' + blinkoItem.shareEncryptedUrl : undefined,
shareUrl: blinkoItem.shareEncryptedUrl ? getBlinkoShareUrl(blinkoItem.shareEncryptedUrl) : undefined,
expiryDate: blinkoItem.shareExpiryDate ?? undefined,
password: blinkoItem.sharePassword ?? '',
isShare: blinkoItem.isShare
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/BlinkoRightClickMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { ContextMenu, ContextMenuItem } from '@/components/Common/ContextMenu';
import { Icon } from '@/components/Common/Iconify/icons';
import { PromiseCall } from '@/store/standard/PromiseState';
import { getBlinkoShareUrl } from '@/lib/blinkoEndpoint';
import { api } from '@/lib/trpc';
import { RootStore } from "@/store";
import { DialogStore } from "@/store/module/Dialog";
Expand Down Expand Up @@ -250,7 +251,7 @@ const handlePublic = () => {
title: i18n.t('share'),
isDismissable: false,
content: <BlinkoShareDialog defaultSettings={{
shareUrl: blinko.curSelectedNote?.shareEncryptedUrl ? window.location.origin + '/share/' + blinko.curSelectedNote?.shareEncryptedUrl : undefined,
shareUrl: blinko.curSelectedNote?.shareEncryptedUrl ? getBlinkoShareUrl(blinko.curSelectedNote.shareEncryptedUrl) : undefined,
expiryDate: blinko.curSelectedNote?.shareExpiryDate ?? undefined,
password: blinko.curSelectedNote?.sharePassword ?? '',
isShare: blinko.curSelectedNote?.isShare
Expand Down
4 changes: 4 additions & 0 deletions app/src/lib/blinkoEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function getBlinkoEndpoint(path: string = ''): string {
}
}

export function getBlinkoShareUrl(shareEncryptedUrl: string): string {
return getBlinkoEndpoint('/share/' + shareEncryptedUrl);
}

export function isTauriAndEndpointUndefined(): boolean {
const isTauri = !!(window as any).__TAURI__;
const blinkoEndpoint = window.localStorage.getItem('blinkoEndpoint')
Expand Down
11 changes: 10 additions & 1 deletion server/__tests__/security/file-urls.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, expect, mock, test } from 'bun:test';
import { fileUrl, isBlinkoUrl } from '../../../app/src/lib/fileUrl';
import { getBlinkoFileUrl } from '../../../app/src/lib/blinkoEndpoint';
import { getBlinkoFileUrl, getBlinkoShareUrl } from '../../../app/src/lib/blinkoEndpoint';

mock.module('../../lib/helper', () => ({
getNextAuthSecret: async () => 'TEST_ONLY_FILE_URL_SIGNING_KEY',
Expand Down Expand Up @@ -124,3 +124,12 @@ test('browser and Tauri consumers use the configured backend origin', () => {
expect(url.searchParams.get('shareToken')).toBe('grant');
expect(url.searchParams.get('download')).toBe('true');
});

test('reopened share links use the configured desktop endpoint, not the Tauri origin', () => {
(globalThis as any).window = {
__TAURI__: {},
location: { origin: 'http://tauri.localhost' },
localStorage: { getItem: () => '"https://desktop-blinko.example/"' },
};
expect(getBlinkoShareUrl('abc123')).toBe('https://desktop-blinko.example/share/abc123');
});