* Parse the friendly-display `user` block. Every field is optional and * lenient — a wrong-typed or empty value is simply skipped rather than * rejected, because this is additive METADATA, not a credential, and a * malformed sub-field must never block resolving a perfectly good * api_key / oauth
(raw: unknown)
| 319 | * access_token is a hard error.) Unknown keys round-trip. |
| 320 | */ |
| 321 | function parseUser(raw: unknown): StoredUserInfo { |
| 322 | const obj = asJsonObject(raw, "user"); |
| 323 | const out: StoredUserInfo = {}; |
| 324 | assignOptionalStrings(out, obj, USER_OPTIONAL); |
| 325 | const unknownUser = collectUnknown(obj, KNOWN_USER_KEYS); |
| 326 | if (unknownUser) out[UNKNOWN] = unknownUser; |
| 327 | return out; |
| 328 | } |
| 329 | |
| 330 | /** Narrow `raw` to a plain JSON object or throw a labelled error. */ |
| 331 | function asJsonObject(raw: unknown, label: string): Record<string, unknown> { |
no test coverage detected