Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): store Clerk tokens with owner-only permissions #22190

Mergedmacodev00(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/22190/headmerged by maria-rcks View on GitHub

Showing 4 changed files with 189 additions and 0 deletions (loading 3).

x
0 of 4 viewed, 4 left
189 additions and 0 deletionsapps/desktop/src/app/ClerkTokenStore.test.tsAdded
View file
@@ -0,0 +1,189 @@
+// @effect-diagnostics nodeBuiltinImport:off -- These tests assert real POSIX modes on a temporary directory.
+import * as NodeFS from "node:fs";
+import * as NodeOS from "node:os";
+import * as NodePath from "node:path";
+import { assert, describe, it } from "@effect/vitest";
+import { vi } from "vite-plus/test";
+​
+vi.mock("node:fs", { spy: true });
+​
+import { openClerkTokenStorage, type ClerkTokenStorage } from "./ClerkTokenStore.ts";
+​
+// oxlint-disable-next-line t3code/no-global-process-runtime -- Unix mode bits are the assertion; Windows reports them through ACLs.
+const describePosix = describe.skipIf(process.platform === "win32");
+​
+const modeOf = (path: string): number => NodeFS.statSync(path).mode & 0o777;
+​
+function writeLoose(path: string, contents: string): void {
+ NodeFS.writeFileSync(path, contents, { mode: 0o666 });
+ NodeFS.chmodSync(path, 0o666);
+}
+​
+async function withStateDir(run: (stateDir: string) => Promise<void> | void): Promise<void> {
+ const stateDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-clerk-tokens-"));
+ try {
+ await run(stateDir);
+ } finally {
+ NodeFS.rmSync(stateDir, { recursive: true, force: true });
+ }
+}
+​