MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / pickRequiredStringOrAbsent

Function pickRequiredStringOrAbsent

packages/cli/src/auth/store.ts:401–412  ·  view source on GitHub ↗

* Strict variant: returns the string when present and non-empty, * `undefined` when the key is absent or null, and throws when the * field is present-but-invalid (wrong type or empty string).

(
  obj: Record<string, unknown>,
  key: string,
  errorLabel: string,
)

Source from the content-addressed store, hash-verified

399 * field is present-but-invalid (wrong type or empty string).
400 */
401function pickRequiredStringOrAbsent(
402 obj: Record<string, unknown>,
403 key: string,
404 errorLabel: string,
405): string | undefined {
406 const v = obj[key];
407 if (v === undefined || v === null) return undefined;
408 if (typeof v !== "string" || v.length === 0) {
409 throw ErrInvalidStore(`${errorLabel} must be a non-empty string`);
410 }
411 return v;
412}
413
414function serializeCredentials(c: Credentials): Record<string, unknown> {
415 // Re-emit unrecognized top-level keys first so the known fields below

Callers 1

parseJsonStoreFunction · 0.85

Calls 1

ErrInvalidStoreFunction · 0.85

Tested by

no test coverage detected