fix(shared): drop .js extensions from relative imports for Metro

packages/shared/src/index.ts and all sub-modules used .js extensions on
relative imports (e.g. './admin/index.js') pointing at .ts source files.
TypeScript with moduleResolution: "Bundler" doesn't need them, and
Metro's eager exporter (used for preview / production builds) reads
them literally and fails — only the dev-server Metro fell back to .ts.

Workspace typecheck remains 8/8 green; Vite and TS Bundler resolution
already accept both styles, so desktop is unaffected.
This commit is contained in:
byGalax
2026-05-15 01:52:14 +02:00
parent b0967dd2c5
commit b61f929cf7
25 changed files with 108 additions and 108 deletions
+12 -12
View File
@@ -1,12 +1,12 @@
import {
import {
decryptWithConvKey,
encryptWithConvKey,
generateConvKey,
unwrapConvKey,
wrapConvKeyForRecipient,
} from '../crypto/sessionKeys.js';
import { bytesToPgHex, pgHexToBytes } from '../supabase/bytea.js';
import type { AppSupabaseClient } from '../supabase/client.js';
} from '../crypto/sessionKeys';
import { bytesToPgHex, pgHexToBytes } from '../supabase/bytea';
import type { AppSupabaseClient } from '../supabase/client';
// db-types in this monorepo is a static snapshot generated against the older
// schema. The new `conversation_keys` table + `active_key_version` column on
@@ -135,7 +135,7 @@ function hexNoPrefix(bytes: Uint8Array): string {
// Bootstraps a brand-new conv-key, wrapping it for every member device that
// currently exists (including the caller's own devices). Used the first time
// a conversation needs a key, or when rotation is requested. All inserts go
// through `share_conv_keys` (SECURITY DEFINER) silently skips invalid
// through `share_conv_keys` (SECURITY DEFINER) — silently skips invalid
// recipients, no per-row 403 console spam.
export async function bootstrapConvKey(
client: AppSupabaseClient,
@@ -146,7 +146,7 @@ export async function bootstrapConvKey(
const convKey = generateConvKey();
const recipients = await listDeviceKeys(client, conversationId);
if (recipients.length === 0) {
throw new Error('cannot bootstrap conv key no recipient devices');
throw new Error('cannot bootstrap conv key — no recipient devices');
}
const bundles: Array<{ recipient_device_id: string; encrypted_key: string; nonce: string }> = [];
@@ -176,9 +176,9 @@ export async function bootstrapConvKey(
// Resolves the current conv-key for `conversationId`. Order:
// 1) cache hit
// 2) DB row for own device unwrap
// 2) DB row for own device → unwrap
// 3) bootstrap a brand-new key (only valid path if NO existing keys exist
// for any device i.e. this is the conversation's very first message)
// for any device — i.e. this is the conversation's very first message)
export async function getOrCreateConvKey(
client: AppSupabaseClient,
conversationId: string,
@@ -202,8 +202,8 @@ export async function getOrCreateConvKey(
}
// No bundle yet for THIS device. Two cases:
// - I'm the first ever sender bootstrap.
// - Conversation already has keys but my device wasn't included yet I
// - I'm the first ever sender → bootstrap.
// - Conversation already has keys but my device wasn't included yet → I
// have to wait until an existing device wraps the key for me.
const { count, error: cntErr } = await rawFrom(client, 'conversation_keys')
.select('recipient_device_id', { count: 'exact', head: true })
@@ -213,7 +213,7 @@ export async function getOrCreateConvKey(
if ((count ?? 0) > 0) {
throw new Error(
'Awaiting conversation key another device must share it with this device.',
'Awaiting conversation key — another device must share it with this device.',
);
}
return bootstrapConvKey(client, conversationId, own, version);
@@ -259,7 +259,7 @@ export async function shareConvKeyToDevice(
cache.get(cacheKey(conversationId, version)) ??
(await tryGetConvKey(client, conversationId, own.deviceId, own.privateKey, version));
if (!handle) {
throw new Error('cannot share conv key own device does not have it yet');
throw new Error('cannot share conv key — own device does not have it yet');
}
const wrapped = await wrapConvKeyForRecipient(