mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
theres only one format, no need for versioning
This commit is contained in:
1 parent
e6acf05e8d
commit
d8b195e624
1 file changed
+2
-6
@@ -6,7 +6,7 @@ import type { NostrEvent } from '@nostrify/nostrify';
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
const DB_NAME = 'nostr-dm-store';
|
const DB_NAME = 'nostr-dm-store';
|
||||||
const DB_VERSION = 2; // Bump version for encrypted cache format
|
const DB_VERSION = 1;
|
||||||
const STORE_NAME = 'messages';
|
const STORE_NAME = 'messages';
|
||||||
|
|
||||||
// Signer interface for NIP-44 encryption/decryption
|
// Signer interface for NIP-44 encryption/decryption
|
||||||
@@ -32,7 +32,6 @@ export interface MessageStore {
|
|||||||
|
|
||||||
// Wrapper for encrypted storage
|
// Wrapper for encrypted storage
|
||||||
interface EncryptedStore {
|
interface EncryptedStore {
|
||||||
version: 2; // Format version
|
|
||||||
encrypted: true;
|
encrypted: true;
|
||||||
data: string; // NIP-44 encrypted MessageStore JSON
|
data: string; // NIP-44 encrypted MessageStore JSON
|
||||||
}
|
}
|
||||||
@@ -43,9 +42,7 @@ function isEncryptedStore(data: unknown): data is EncryptedStore {
|
|||||||
typeof data === 'object' &&
|
typeof data === 'object' &&
|
||||||
data !== null &&
|
data !== null &&
|
||||||
'encrypted' in data &&
|
'encrypted' in data &&
|
||||||
(data as EncryptedStore).encrypted === true &&
|
(data as EncryptedStore).encrypted === true
|
||||||
'version' in data &&
|
|
||||||
(data as EncryptedStore).version === 2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +82,6 @@ export async function writeMessagesToDB(
|
|||||||
const encrypted = await signer.nip44.encrypt(userPubkey, plaintext);
|
const encrypted = await signer.nip44.encrypt(userPubkey, plaintext);
|
||||||
|
|
||||||
const encryptedStore: EncryptedStore = {
|
const encryptedStore: EncryptedStore = {
|
||||||
version: 2,
|
|
||||||
encrypted: true,
|
encrypted: true,
|
||||||
data: encrypted,
|
data: encrypted,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user