Skip to content

Commit 2045358

Browse files
juliusmarmingecodex
andcommitted
Generate desktop bootstrap token from random bytes
Co-authored-by: codex <[email protected]>
1 parent a3ce862 commit 2045358

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { parsePersistedServerObservabilitySettings } from "@t3tools/shared/serve
22
import * as Context from "effect/Context";
33
import * as Crypto from "effect/Crypto";
44
import * as Effect from "effect/Effect";
5+
import * as Encoding from "effect/Encoding";
56
import * as FileSystem from "effect/FileSystem";
67
import * as Layer from "effect/Layer";
78
import * as Option from "effect/Option";
@@ -143,11 +144,7 @@ export const layer = Layer.effect(
143144
return existing.value;
144145
}
145146

146-
let token = "";
147-
while (token.length < 48) {
148-
token += (yield* crypto.randomUUIDv4).replace(/-/g, "");
149-
}
150-
token = token.slice(0, 48);
147+
const token = Encoding.encodeHex(yield* crypto.randomBytes(24));
151148
yield* Ref.set(tokenRef, Option.some(token));
152149
return token;
153150
});

0 commit comments

Comments
 (0)