MCPcopy
hub / github.com/claude-code-best/claude-code / loadModule

Function loadModule

src/services/localVault/keychain.ts:29–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27let _mod: KeyringModule | null | 'not-tried' = 'not-tried'
28
29async function loadModule(): Promise<KeyringModule> {
30 if (_mod !== 'not-tried') {
31 if (_mod === null)
32 throw new KeychainUnavailableError('module load failed previously')
33 return _mod
34 }
35 try {
36 // Dynamic import so the rest of the codebase compiles even without the module.
37 const m = (await import('@napi-rs/keyring')) as unknown as KeyringModule
38 if (!m || typeof m.Entry !== 'function') {
39 _mod = null
40 throw new KeychainUnavailableError('module does not export Entry')
41 }
42 _mod = m
43 return m
44 } catch (err: unknown) {
45 if (err instanceof KeychainUnavailableError) throw err
46 _mod = null
47 throw new KeychainUnavailableError(
48 err instanceof Error ? err.message : String(err),
49 )
50 }
51}
52
53/**
54 * Reset module cache — for testing only.

Callers 6

setFunction · 0.70
getFunction · 0.70
deleteFunction · 0.70
listFunction · 0.70
_addToIndexFunction · 0.70
_removeFromIndexFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected