πŸ“„ File detail

utils/authPortable.ts

🧩 .tsπŸ“ 20 linesπŸ’Ύ 674 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes maybeRemoveApiKeyFromMacOSKeychainThrows and normalizeApiKeyForConfig β€” mainly functions, hooks, or classes. Dependencies touch child processes and src.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

import { execa } from 'execa' import { getMacOsKeychainStorageServiceName } from 'src/utils/secureStorage/macOsKeychainHelpers.js' export async function maybeRemoveApiKeyFromMacOSKeychainThrows(): Promise<void> { if (process.platform === 'darwin') {

πŸ“€ Exports (heuristic)

  • maybeRemoveApiKeyFromMacOSKeychainThrows
  • normalizeApiKeyForConfig

πŸ“š External import roots

Package roots from from "…" (relative paths omitted).

  • execa
  • src

πŸ–₯️ Source preview

import { execa } from 'execa'
import { getMacOsKeychainStorageServiceName } from 'src/utils/secureStorage/macOsKeychainHelpers.js'

export async function maybeRemoveApiKeyFromMacOSKeychainThrows(): Promise<void> {
  if (process.platform === 'darwin') {
    const storageServiceName = getMacOsKeychainStorageServiceName()
    const result = await execa(
      `security delete-generic-password -a $USER -s "${storageServiceName}"`,
      { shell: true, reject: false },
    )
    if (result.exitCode !== 0) {
      throw new Error('Failed to delete keychain entry')
    }
  }
}

export function normalizeApiKeyForConfig(apiKey: string): string {
  return apiKey.slice(-20)
}