Cotal TypeScript packages
    Preparing search index...

    Function rotateSystemCreds

    • Rotate the space's system account and re-mint both $SYS creds against it.

      expectedSpace is validated by getSpaceAuth against the store's signer, the same cross-space guard remintDaemonCreds runs: rotating with a foreign space's operator would re-issue an operator JWT this broker does not trust and strand every account under it.

      Ordering is the safety property, and it is a DIRECTIONAL one, not atomicity. All MINTING (the rotation and both creds) happens in memory before anything is persisted, so a mint failure changes nothing on disk. Then the trust record commits, where putSpaceAuth's generation guard refuses a stale or non-successor write. Then the creds land. What this buys is a single failure direction: a cred file is never overwritten for a system account the record does not already carry, because the inverse order could clobber the last-good creds with creds for an authority the broker will never load, which is the availability loss remintDaemonCreds guards on its own class.

      It does NOT make the persistence atomic. putSpaceAuth is two puts and the creds are two more, so a crash leaves the record AHEAD of the creds. That state is detected rather than prevented (see staleSystemCreds) and is repaired by re-running the rotation.

      THROWS rather than degrading: a stripped signer (no operator seed) cannot rotate, and a caller that ignored the throw would boot a broker whose config still carries the retired system account.

      Parameters

      • root: string
      • expectedSpace: string

      Returns Promise<SystemRotationResult>