import { stripUrlUserInfo } from "../shared/net/url-userinfo.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import { isRecord } from "../utils.js"; import type { ChannelAccountSnapshot } from "./plugins/types.core.js";
// Read-only status commands project a safe subset of account fields into snapshots // so renderers can preserve "configured but unavailable" state without touching // strict runtime-only credential helpers.
function readNumber(record: Record<string, unknown>, key: string): number | undefined { const value = record[key]; returntypeof value === "number" && Number.isFinite(value) ? value : undefined;
}
function readCredentialStatus(record: Record<string, unknown>, key: CredentialStatusKey) { const value = record[key]; return value === "available" || value === "configured_unavailable" || value === "missing"
? value
: undefined;
}
export function resolveConfiguredFromCredentialStatuses(account: unknown): boolean | undefined { const record = isRecord(account) ? account : null; if (!record) { return undefined;
}
let sawCredentialStatus = false; for (const key of CREDENTIAL_STATUS_KEYS) { const status = readCredentialStatus(record, key); if (!status) { continue;
}
sawCredentialStatus = true; if (status !== "missing") { returntrue;
}
} return sawCredentialStatus ? false : undefined;
}
export function resolveConfiguredFromRequiredCredentialStatuses(
account: unknown,
requiredKeys: CredentialStatusKey[],
): boolean | undefined { const record = isRecord(account) ? account : null; if (!record) { return undefined;
}
let sawCredentialStatus = false; for (const key of requiredKeys) { const status = readCredentialStatus(record, key); if (!status) { continue;
}
sawCredentialStatus = true; if (status === "missing") { returnfalse;
}
} return sawCredentialStatus ? true : undefined;
}
export function hasConfiguredUnavailableCredentialStatus(account: unknown): boolean { const record = isRecord(account) ? account : null; if (!record) { returnfalse;
} return CREDENTIAL_STATUS_KEYS.some(
(key) => readCredentialStatus(record, key) === "configured_unavailable",
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.