This commit is contained in:
EthanShoeDev
2025-10-04 16:53:08 -04:00
parent d3f492facb
commit cabc3bb55d
4 changed files with 48 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import { logger, consoleTransport } from "react-native-logs"; import { logger, consoleTransport } from 'react-native-logs';
export const rootLogger = logger.createLogger({ export const rootLogger = logger.createLogger({
levels: { levels: {
@@ -7,17 +7,17 @@ export const rootLogger = logger.createLogger({
warn: 2, warn: 2,
error: 3, error: 3,
}, },
severity: "debug", severity: 'debug',
transport: consoleTransport, transport: consoleTransport,
transportOptions: { transportOptions: {
colors: { colors: {
info: "blueBright", info: 'blueBright',
warn: "yellowBright", warn: 'yellowBright',
error: "redBright", error: 'redBright',
}, },
}, },
async: true, async: true,
dateFormat: "time", dateFormat: 'time',
printLevel: true, printLevel: true,
printDate: true, printDate: true,
fixedExtLvlLength: false, fixedExtLvlLength: false,

View File

@@ -202,7 +202,10 @@ function makeBetterSecureStore<
(mChunk) => mChunk.manifestChunk.entries.length === 0, (mChunk) => mChunk.manifestChunk.entries.length === 0,
); );
if (emptyManifestChunks.length > 0) { if (emptyManifestChunks.length > 0) {
logger.debug('removing empty manifest chunks', emptyManifestChunks.length); logger.debug(
'removing empty manifest chunks',
emptyManifestChunks.length,
);
manifest.rootManifest.manifestChunksIds = manifest.rootManifest.manifestChunksIds =
manifest.rootManifest.manifestChunksIds.filter( manifest.rootManifest.manifestChunksIds.filter(
(mChunkId) => (mChunkId) =>
@@ -247,7 +250,10 @@ function makeBetterSecureStore<
const existingManifestChunkWithRoom = manifest.manifestChunks.find( const existingManifestChunkWithRoom = manifest.manifestChunks.find(
(mChunk) => sizeLimit > mChunk.manifestChunkSize + newManifestEntrySize, (mChunk) => sizeLimit > mChunk.manifestChunkSize + newManifestEntrySize,
); );
logger.debug('existingManifestChunkWithRoom', existingManifestChunkWithRoom); logger.debug(
'existingManifestChunkWithRoom',
existingManifestChunkWithRoom,
);
const manifestChunkWithRoom = const manifestChunkWithRoom =
existingManifestChunkWithRoom ?? existingManifestChunkWithRoom ??
(await (async () => { (await (async () => {
@@ -259,7 +265,9 @@ function makeBetterSecureStore<
manifestChunkId: Crypto.randomUUID(), manifestChunkId: Crypto.randomUUID(),
manifestChunkSize: 0, manifestChunkSize: 0,
} satisfies NonNullable<(typeof manifest.manifestChunks)[number]>; } satisfies NonNullable<(typeof manifest.manifestChunks)[number]>;
logger.info(`Adding new manifest chunk ${newManifestChunk.manifestChunkId}`); logger.info(
`Adding new manifest chunk ${newManifestChunk.manifestChunkId}`,
);
manifest.rootManifest.manifestChunksIds.push( manifest.rootManifest.manifestChunksIds.push(
newManifestChunk.manifestChunkId, newManifestChunk.manifestChunkId,
); );
@@ -336,7 +344,9 @@ async function upsertPrivateKey(params: {
throw new Error('Invalid private key', { cause: validateKeyResult.error }); throw new Error('Invalid private key', { cause: validateKeyResult.error });
} }
const keyId = params.keyId ?? `key_${Crypto.randomUUID()}`; const keyId = params.keyId ?? `key_${Crypto.randomUUID()}`;
logger.info(`${params.keyId ? 'Upserting' : 'Creating'} private key ${keyId}`); logger.info(
`${params.keyId ? 'Upserting' : 'Creating'} private key ${keyId}`,
);
// Preserve createdAtMs if the entry already exists // Preserve createdAtMs if the entry already exists
const existing = await betterKeyStorage const existing = await betterKeyStorage
.getEntry(keyId) .getEntry(keyId)

View File

@@ -15,7 +15,6 @@ export const AbortSignalTimeout = (timeout: number) => {
return controller.signal; return controller.signal;
}; };
export const useContextSafe = <T>(context: Context<T>) => { export const useContextSafe = <T>(context: Context<T>) => {
const contextValue = use(context); const contextValue = use(context);
if (!contextValue) { if (!contextValue) {