UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

45 lines (44 loc) • 2.23 kB
import { r as identityFromCredentialResult, s as storedDeviceIdentityToRow } from "./device-identity-material-BGzHHiUD.mjs"; import { i as runClientCredentialOperation } from "./client-credential-store-rd7DZXgD.mjs"; import { n as resolveDeviceIdentityStore, t as resolveDeviceIdentityEnvironment } from "./device-identity-store-options-Bz70uEBm.mjs"; //#region src/infra/device-identity-store.ts /** Synchronous access is reserved for offline Doctor/CLI one-shots. Runtime callers use the worker. */ function readStoredDeviceIdentity(e = {}) { const { identityKey: t } = resolveDeviceIdentityStore(e); return identityFromCredentialResult(runClientCredentialOperation(resolveDeviceIdentityEnvironment(e), { kind: "identity.read", identity_key: t })); } /** Inspection cannot settle import claims or initialize local credential state. */ function readStoredDeviceIdentityReadOnly(e = {}) { const { identityKey: t } = resolveDeviceIdentityStore(e); return identityFromCredentialResult(runClientCredentialOperation(resolveDeviceIdentityEnvironment(e), { kind: "identity.read", identity_key: t }, { readOnly: true })); } function insertStoredDeviceIdentityIfAbsent(e, t = {}) { const { identityKey: n } = resolveDeviceIdentityStore(t); const r = identityFromCredentialResult(runClientCredentialOperation(resolveDeviceIdentityEnvironment(t), { kind: "identity.create", identity: storedDeviceIdentityToRow(n, e) })); if (!r) throw new Error(`Client credential owner did not persist identity "${n}".`); return r; } /** Doctor preserves valid key bytes and only replaces irreparable identities. */ function repairInvalidStoredDeviceIdentity(e, t = {}) { const { identityKey: n } = resolveDeviceIdentityStore(t); const r = runClientCredentialOperation(resolveDeviceIdentityEnvironment(t), { kind: "identity.repair", identity: storedDeviceIdentityToRow(n, e) }); if (r.kind !== "identityRepair") throw new Error("Client credential owner returned an unexpected repair result."); return { repaired: r.repaired, rotated: r.rotated }; } //#endregion export { repairInvalidStoredDeviceIdentity as i, readStoredDeviceIdentity as n, readStoredDeviceIdentityReadOnly as r, insertStoredDeviceIdentityIfAbsent as t };