LibreChat/packages/api/src/actions
Oliver Faust 5e49868f0a
🔑 fix: Decode Action OAuth Credentials After Decryption (#14698)
* 🔑 fix: Decode Action OAuth Credentials After Decryption

Action client credentials are URL-encoded before encryption, but the OAuth
token exchange decrypted them with `decryptV2` alone, sending values like
`abc%40domain.com` to the provider and causing 401s for secrets containing
`@`, `+`, `=`, `/` or `:`. Decoding falls back to the raw decrypted value so
legacy secrets stored before 299cabd6e (which contain an unescaped `%`) still work.

Fixes #14636

* 🔑 fix: Share Action Credential Codec Between Read Paths

The encode-before-encrypt convention had two readers with different
behaviour. `ActionService.decryptSensitiveValue` decoded unconditionally,
so a credential stored before encoding was introduced (299cabd6e, March
2025) containing a stray `%` threw `URIError` and failed every read of the
action, not just the token exchange.

Extract the pair into `packages/api/src/actions/crypto.ts` as the single
implementation and consume it from both `ActionService` and the OAuth token
exchange, so the two paths cannot drift again.

Tests cover the codec against real crypto: reserved characters and literal
percent escapes round-trip, pre-encoding values are returned unchanged, and
a pre-encoding value with a stray `%` no longer throws.

A version marker on newly encrypted values was prototyped and dropped: it
changes the stored format for every action credential while fixing nothing,
since values written by the encoding convention already decode correctly
and pre-encoding values stay unmarked either way.

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2026-09-01 18:42:28 -04:00
..
credentials.spec.ts
credentials.ts
crypto.spec.ts 🔑 fix: Decode Action OAuth Credentials After Decryption (#14698) 2026-09-01 18:42:28 -04:00
crypto.ts 🔑 fix: Decode Action OAuth Credentials After Decryption (#14698) 2026-09-01 18:42:28 -04:00
index.ts 🔑 fix: Decode Action OAuth Credentials After Decryption (#14698) 2026-09-01 18:42:28 -04:00
protection.spec.ts
protection.ts
tools.spec.ts 🔌 feat: Background Execution Toggles for Actions & Plugin Tools (#14407) 2026-08-25 08:13:13 -04:00
tools.ts 🔌 feat: Background Execution Toggles for Actions & Plugin Tools (#14407) 2026-08-25 08:13:13 -04:00
update.spec.ts
update.ts