mirror of
https://github.com/EthanShoeDev/fressh.git
synced 2026-01-11 06:12:51 +00:00
fmt
This commit is contained in:
@@ -1,25 +1,25 @@
|
|||||||
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: {
|
||||||
debug: 0,
|
debug: 0,
|
||||||
info: 1,
|
info: 1,
|
||||||
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,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ export const useSshConnMutation = (opts?: {
|
|||||||
const security =
|
const security =
|
||||||
connectionDetails.security.type === 'password'
|
connectionDetails.security.type === 'password'
|
||||||
? {
|
? {
|
||||||
type: 'password' as const,
|
type: 'password' as const,
|
||||||
password: connectionDetails.security.password,
|
password: connectionDetails.security.password,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
type: 'key' as const,
|
type: 'key' as const,
|
||||||
privateKey: await secretsManager.keys.utils
|
privateKey: await secretsManager.keys.utils
|
||||||
.getPrivateKey(connectionDetails.security.keyId)
|
.getPrivateKey(connectionDetails.security.keyId)
|
||||||
.then((e) => e.value),
|
.then((e) => e.value),
|
||||||
};
|
};
|
||||||
|
|
||||||
const sshConnection = await connect({
|
const sshConnection = await connect({
|
||||||
host: connectionDetails.host,
|
host: connectionDetails.host,
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ function makeBetterSecureStore<
|
|||||||
const unsafedRootManifest: unknown = rawRootManifestString
|
const unsafedRootManifest: unknown = rawRootManifestString
|
||||||
? JSON.parse(rawRootManifestString)
|
? JSON.parse(rawRootManifestString)
|
||||||
: {
|
: {
|
||||||
manifestVersion: rootManifestVersion,
|
manifestVersion: rootManifestVersion,
|
||||||
manifestChunksIds: [],
|
manifestChunksIds: [],
|
||||||
};
|
};
|
||||||
const rootManifest = rootManifestSchema.parse(unsafedRootManifest);
|
const rootManifest = rootManifestSchema.parse(unsafedRootManifest);
|
||||||
const manifestChunks = await Promise.all(
|
const manifestChunks = await Promise.all(
|
||||||
rootManifest.manifestChunksIds.map(async (manifestChunkId) => {
|
rootManifest.manifestChunksIds.map(async (manifestChunkId) => {
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -15,11 +15,10 @@ 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) {
|
||||||
throw new Error('Context not found');
|
throw new Error('Context not found');
|
||||||
}
|
}
|
||||||
return contextValue;
|
return contextValue;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user