()
| 176 | } satisfies SecureStorage |
| 177 | |
| 178 | async function doReadAsync(): Promise<SecureStorageData | null> { |
| 179 | try { |
| 180 | const storageServiceName = getMacOsKeychainStorageServiceName( |
| 181 | CREDENTIALS_SERVICE_SUFFIX, |
| 182 | ) |
| 183 | const username = getUsername() |
| 184 | const { stdout, code } = await execFileNoThrow( |
| 185 | 'security', |
| 186 | ['find-generic-password', '-a', username, '-w', '-s', storageServiceName], |
| 187 | { useCwd: false, preserveOutputOnError: false }, |
| 188 | ) |
| 189 | if (code === 0 && stdout) { |
| 190 | return jsonParse(stdout.trim()) |
| 191 | } |
| 192 | } catch (_e) { |
| 193 | // fall through |
| 194 | } |
| 195 | return null |
| 196 | } |
| 197 | |
| 198 | let keychainLockedCache: boolean | undefined |
| 199 |
no test coverage detected