···5151 ;;
5252 esac
53535454- setup_identities() {
5555- # Check if bulk key file should be used for decryption
5656- if [[ -n "''${PASS_BULK_KEY_FILE:-}" ]]; then
5757- if [[ ! -f "$PASS_BULK_KEY_FILE" ]] || [[ ! -s "$PASS_BULK_KEY_FILE" ]]; then
5858- mkdir -p "$(dirname "$PASS_BULK_KEY_FILE")"
5959- ${exePath} show bulk-operations/age-key > "$PASS_BULK_KEY_FILE" 2>/dev/null || true
6060- fi
6161- fi
6262-6363- # Set up identities for age decryption
6464- if [[ -n "''${PASS_BULK_KEY_FILE:-}" ]] && [[ -f "$PASS_BULK_KEY_FILE" ]] && [[ -s "$PASS_BULK_KEY_FILE" ]]; then
6565- # Use bulk key if available
6666- export PASSAGE_IDENTITIES_FILE="$PASS_BULK_KEY_FILE"
6767- else
6868- # Detect available age keys
6969- export AGE_DETECT_KEYS_DIR="${self}/keys"
7070- eval "$(age-detect)"
7171-7272- # Set up identity file if detected
7373- if [[ -n "''${IDENTITY_FILE:-}" ]]; then
7474- export PASSAGE_IDENTITIES_FILE="$IDENTITY_FILE"
7575- trap 'rm -f "$IDENTITY_FILE"' EXIT
7676- fi
7777- fi
7878- }
7979-8080- if [[ "$needs_decrypt" == true ]]; then
8181- setup_identities
8282- fi
8383-8454 ${
8555 if pkgs.stdenv.isLinux then
8656 ''
···9565 AGE_TPM_PIN="$(${self.packages.${system}.pinentry-rofi-age}/bin/pinentry-rofi-age "$target")"
9666 export AGE_TPM_PIN
9767 }
6868+ ''
6969+ else
7070+ ''
7171+ # No TPM on Darwin, define no-op
7272+ maybe_set_tpm_pin() { :; }
7373+ ''
7474+ }
98757676+ setup_identities() {
7777+ # Always detect available age keys first
7878+ export AGE_DETECT_KEYS_DIR="${self}/keys"
7979+ eval "$(age-detect)"
8080+8181+ # Set up identity file if detected
8282+ if [[ -n "''${IDENTITY_FILE:-}" ]]; then
8383+ export PASSAGE_IDENTITIES_FILE="$IDENTITY_FILE"
8484+ trap 'rm -f "$IDENTITY_FILE"' EXIT
8585+ fi
8686+8787+ # Try to decrypt and cache the bulk key using the detected identity
8888+ if [[ -n "''${PASS_BULK_KEY_FILE:-}" ]]; then
8989+ if [[ ! -f "$PASS_BULK_KEY_FILE" ]] || [[ ! -s "$PASS_BULK_KEY_FILE" ]]; then
9090+ mkdir -p "$(dirname "$PASS_BULK_KEY_FILE")"
9191+ maybe_set_tpm_pin "bulk-operations/age-key"
9292+ ${exePath} show bulk-operations/age-key > "$PASS_BULK_KEY_FILE" 2>/dev/null || true
9393+ fi
9494+ # Switch to bulk key for subsequent operations if available
9595+ if [[ -f "$PASS_BULK_KEY_FILE" ]] && [[ -s "$PASS_BULK_KEY_FILE" ]]; then
9696+ export PASSAGE_IDENTITIES_FILE="$PASS_BULK_KEY_FILE"
9797+ fi
9898+ fi
9999+ }
100100+101101+ if [[ "$needs_decrypt" == true ]]; then
102102+ setup_identities
103103+ fi
104104+105105+ ${
106106+ if pkgs.stdenv.isLinux then
107107+ ''
99108 decrypt_target=""
100109 if [[ "''${1:-}" == "show" ]]; then
101110 decrypt_target="''${2:-}"
···120129 fi
121130 ''
122131 else
123123- ''
124124- # No TPM on Darwin, define no-op
125125- maybe_set_tpm_pin() { :; }
126126- ''
132132+ ""
127133 }
128134129135 # Handle OTP commands by delegating to pass-otp