@poe-platform/safe-js 0.1.714 → 0.1.715

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.
@@ -1,2 +1,4 @@
1
- import type { CreateSecretStoreInput, CreateSecretStoreResult } from "./types.js";
1
+ import type { CreateSecretStoreInput, CreateSecretStoreResult, StoreBackend } from "./types.js";
2
2
  export declare function createSecretStore(input: CreateSecretStoreInput): CreateSecretStoreResult;
3
+ /** Select and validate a backend without constructing a store or accessing credentials. */
4
+ export declare function resolveSecretStoreBackend(input: CreateSecretStoreInput): StoreBackend;
@@ -1,9 +1,11 @@
1
1
  import type { SecretStore } from "./types.js";
2
+ import { type SecretStoreLockOptions } from "./transaction-lock.js";
2
3
  export interface MachineIdentity {
3
4
  hostname: string;
4
5
  username: string;
5
6
  }
6
7
  export interface EncryptedFileStoreFileSystem {
8
+ readdir?(path: string): Promise<string[]>;
7
9
  readFile(path: string, encoding: BufferEncoding): Promise<string>;
8
10
  writeFile(path: string, data: string | NodeJS.ArrayBufferView, options?: {
9
11
  encoding?: BufferEncoding;
@@ -29,6 +31,8 @@ export interface EncryptedFileStoreInput {
29
31
  getMachineIdentity?: () => MachineIdentity | Promise<MachineIdentity>;
30
32
  getHomeDirectory?: () => string;
31
33
  getRandomBytes?: (size: number) => Buffer;
34
+ /** Fail closed instead of treating malformed or unauthenticated documents as absent. */
35
+ throwOnInvalidDocument?: boolean;
32
36
  }
33
37
  export declare class EncryptedFileStore implements SecretStore {
34
38
  private readonly fs;
@@ -38,8 +42,10 @@ export declare class EncryptedFileStore implements SecretStore {
38
42
  private readonly getMachineIdentity;
39
43
  private readonly getRandomBytes;
40
44
  private keyPromise;
45
+ private readonly throwOnInvalidDocument;
41
46
  constructor(input: EncryptedFileStoreInput);
42
47
  get(): Promise<string | null>;
48
+ withLock<T>(operation: () => Promise<T>, options?: SecretStoreLockOptions): Promise<T>;
43
49
  set(value: string): Promise<void>;
44
50
  delete(): Promise<void>;
45
51
  private assertCredentialPathHasNoSymbolicLinks;
@@ -1,6 +1,7 @@
1
- export { createSecretStore } from "./create-secret-store.js";
1
+ export { createSecretStore, resolveSecretStoreBackend } from "./create-secret-store.js";
2
2
  export { EncryptedFileStore } from "./encrypted-file-store.js";
3
3
  export { KeychainStore } from "./keychain-store.js";
4
+ export type { SecretStoreLockOptions, SecretStoreLockFileSystem } from "./transaction-lock.js";
4
5
  export { key, MigratingSecretStore } from "./provider-store.js";
5
6
  export type { SecretStore, StoreBackend, CreateSecretStoreInput, CreateSecretStoreResult } from "./types.js";
6
7
  export type { MachineIdentity, EncryptedFileStoreInput, EncryptedFileStoreFileSystem } from "./encrypted-file-store.js";
@@ -1,4 +1,5 @@
1
1
  import type { SecretStore } from "./types.js";
2
+ import { type SecretStoreLockFileSystem, type SecretStoreLockOptions } from "./transaction-lock.js";
2
3
  export interface KeychainCommandResult {
3
4
  stdout: string;
4
5
  stderr: string;
@@ -12,13 +13,20 @@ export interface KeychainStoreInput {
12
13
  runCommand?: KeychainCommandRunner;
13
14
  service: string;
14
15
  account: string;
16
+ lock?: {
17
+ fs?: SecretStoreLockFileSystem;
18
+ directory?: string;
19
+ };
15
20
  }
16
21
  export declare class KeychainStore implements SecretStore {
17
22
  private readonly runCommand;
18
23
  private readonly service;
19
24
  private readonly account;
25
+ private readonly lockFs;
26
+ private readonly lockDirectory;
20
27
  constructor(input: KeychainStoreInput);
21
28
  get(): Promise<string | null>;
29
+ withLock<T>(operation: () => Promise<T>, options?: SecretStoreLockOptions): Promise<T>;
22
30
  set(value: string): Promise<void>;
23
31
  delete(): Promise<void>;
24
32
  private executeSecurityCommand;
@@ -0,0 +1,24 @@
1
+ export interface SecretStoreLockOptions {
2
+ signal?: AbortSignal;
3
+ timeoutMs?: number;
4
+ }
5
+ export interface SecretStoreLockFileSystem {
6
+ mkdir(path: string, options?: {
7
+ recursive?: boolean;
8
+ mode?: number;
9
+ }): Promise<unknown>;
10
+ readdir(path: string): Promise<string[]>;
11
+ readFile(path: string, encoding: BufferEncoding): Promise<string>;
12
+ writeFile(path: string, value: string, options: {
13
+ encoding: BufferEncoding;
14
+ flag: string;
15
+ mode: number;
16
+ }): Promise<void>;
17
+ rename(from: string, to: string): Promise<void>;
18
+ unlink(path: string): Promise<void>;
19
+ lstat(path: string): Promise<{
20
+ isSymbolicLink(): boolean;
21
+ }>;
22
+ }
23
+ /** Filesystem bakery lock: unique claims allow dead-owner cleanup without deleting a replacement owner's lock. */
24
+ export declare function withSecretStoreFileLock<T>(fs: SecretStoreLockFileSystem, lockDirectory: string, operation: () => Promise<T>, options?: SecretStoreLockOptions): Promise<T>;
@@ -1,11 +1,13 @@
1
1
  import type { EncryptedFileStoreInput } from "./encrypted-file-store.js";
2
2
  import type { KeychainStoreInput } from "./keychain-store.js";
3
+ import type { SecretStoreLockOptions } from "./transaction-lock.js";
3
4
  export interface SecretStore {
4
5
  get(options?: {
5
6
  readOnly?: boolean;
6
7
  }): Promise<string | null>;
7
8
  set(value: string): Promise<void>;
8
9
  delete(): Promise<void>;
10
+ withLock?<T>(operation: () => Promise<T>, options?: SecretStoreLockOptions): Promise<T>;
9
11
  }
10
12
  export type StoreBackend = "file" | "keychain";
11
13
  export interface CreateSecretStoreInput {