API reference › @evolu/common › local‑first/Owner › ownerSecretToOwnerId

function ownerSecretToOwnerId(
  secret: (
    | (Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length16">)
    | (Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length24">)
    | (Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length32">)
    | (Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length20">)
    | (Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length28">)
  ) &
    Brand<"OwnerSecret">,
): string & Brand<"Id"> & Brand<"OwnerId">;

Defined in: packages/common/src/local-first/Owner.ts:274

Converts an OwnerSecret to the OwnerId of the owners it creates, without deriving their keys or mnemonic, such as to tell whether a backup's AppOwner is already on the device.

Example

import {
  assertTrue,
  mnemonicToOwnerSecret,
  ownerSecretToOwnerId,
  testAppOwner,
  type OwnerId,
} from "@evolu/common";

// The IDs of the AppOwners on this device.
const appOwnerIds: ReadonlySet<OwnerId> = new Set([testAppOwner.id]);

// A backup's mnemonic, of an AppOwner that's already on this device.
const secret = mnemonicToOwnerSecret(testAppOwner.mnemonic);

assertTrue(appOwnerIds.has(ownerSecretToOwnerId(secret)));