@cortexkit/common-auth 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,13 @@ export interface SidebarFileOptions<T> {
9
9
  defaultValue: T;
10
10
  normalize: (parsed: unknown) => T;
11
11
  timeoutMs?: number;
12
+ /**
13
+ * Tighten an existing parent directory to 0o700 before each write. Defaults
14
+ * to true. Pass false for a directory the user chose (an override path),
15
+ * whose permissions are theirs to set. A parent this library has to create
16
+ * is always created private, either way.
17
+ */
18
+ secureDir?: boolean;
12
19
  logger?: {
13
20
  warn: (message: string, payload?: unknown) => void;
14
21
  debug: (message: string, payload?: unknown) => void;
@@ -41,12 +41,13 @@ export function createSidebarFile(options) {
41
41
  };
42
42
  const persist = async (merge, hooks) => {
43
43
  const parent = dirname(path);
44
+ const secureDir = options.secureDir ?? true;
44
45
  await mkdir(parent, { recursive: true, mode: 0o700 });
45
- await chmod(parent, 0o700).catch((error) => {
46
- options.logger?.warn('sidebar directory permission remediation failed', {
47
- error: error instanceof Error ? error.message : String(error),
46
+ if (secureDir) {
47
+ await chmod(parent, 0o700).catch((error) => {
48
+ options.logger?.warn('sidebar directory permission remediation failed', { error: error instanceof Error ? error.message : String(error) });
48
49
  });
49
- });
50
+ }
50
51
  await withLock(path, {
51
52
  ...WRITER_LOCK_CONSTANTS.sidebar,
52
53
  timeoutMs: options.timeoutMs ?? WRITER_LOCK_CONSTANTS.sidebar.timeoutMs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/common-auth",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Shared plumbing for the CortexKit auth plugins: loopback RPC, file locks and atomic writes, logger, sidebar state file, TUI preferences and TUI build.",
5
5
  "license": "MIT",
6
6
  "repository": {