import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs'; import { KeystoneData_V1, KeystoneIbGib_V1, KeystonePoolConfig, KeystoneClaim, KeystoneChallengePool, DelegateKeystoneStatus, KeystoneFrameDetails } from './keystone-types.mjs'; import { IbGibSpaceAny } from '../witness/space/space-base-v1.mjs'; import { MetaspaceService } from '../witness/space/metaspace/metaspace-types.mjs'; import { FlatIbGibGraph } from '../common/other/graph-types.mjs'; /** * Facade for managing Keystone Identities. * * Handles Genesis, Authorized Evolution (Signing), and Validation. */ export declare class KeystoneService_V1 { protected lc: string; /** * Creates a brand new Keystone Identity Timeline. */ genesis({ masterSecret, emails, frameDetails, credentialIds, dataToPatch, configs, metaspace, space, isPrimary, }: { masterSecret: string; emails?: string[]; frameDetails?: KeystoneFrameDetails; credentialIds?: string[]; dataToPatch?: Partial; configs: KeystonePoolConfig[]; metaspace: MetaspaceService; space: IbGibSpaceAny; isPrimary?: boolean; }): Promise; /** * Signs a claim by solving challenges from a specific pool and evolving the Keystone timeline. * * Uses a hybrid selection strategy: Mandatory IDs (Alice) + Sequential (FIFO) + Random (Stochastic). * * Supports Delegation via `poolFilter` to find specific foreign pools. * * todo: wrap this and other entire keystone sign/method implementations in locks on the keystone's tjpGib. */ sign({ latestKeystone, masterSecret, claim, poolId, poolFilter, requiredChallengeIds, frameDetails, metaspace, space, dataToPatch, }: { latestKeystone: KeystoneIbGib_V1; /** * The secret used to solve the challenges. * If signing with a native pool, this is the User's Master Secret. * If signing with a foreign/delegated pool, this is the Delegate's Secret. */ masterSecret: string; claim: Partial; /** * Explicit ID of the pool to use. */ poolId?: string; /** * Optional predicate to find a pool. * Useful for finding delegates via metadata without knowing the exact ID. * e.g. (p) => p.metadata?.delegate === 'Bob' */ poolFilter?: (pool: KeystoneChallengePool) => boolean; requiredChallengeIds?: string[]; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; dataToPatch?: Partial; }): Promise; /** * Validates a keystone. * * ## NOTES * * Atow (12/22/2025) this only validates the transition from Prev -> Curr. * * @returns Array of validation error strings. Empty array means Valid. * * @see {@link validateKeystoneTransition} */ validate({ currentIbGib, prevIbGib, }: { currentIbGib: KeystoneIbGib_V1; prevIbGib: KeystoneIbGib_V1; }): Promise; /** * Registers a delegate keystone on the parent keystone by appending its information * to the parent's `delegates` map. This operation is signed using the parent's `manage` pool. * Validates the delegate keystone's entire graph/timeline before registering. */ registerDelegate({ parentKeystone, delegateKeystone, masterSecret, signingPoolId, frameDetails, metaspace, space, allowedVerbs, deviceName, expirationUTC, ttlSeconds, }: { parentKeystone: KeystoneIbGib_V1; delegateKeystone: KeystoneIbGib_V1; masterSecret: string; /** * The specific challenge pool ID used to authorize this delegation. * (e.g. 'manage', 'passkey-manage-1234', or 'custodian-google-manage') */ signingPoolId: string; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; allowedVerbs: string[]; deviceName?: string; expirationUTC?: string; ttlSeconds?: number; }): Promise; /** * Unregisters a delegate keystone from the parent keystone by removing its entry * from the parent's `delegates` map. */ unregisterDelegate({ parentKeystone, delegateTjpAddr, masterSecret, signingPoolId, frameDetails, metaspace, space, }: { parentKeystone: KeystoneIbGib_V1; delegateTjpAddr: IbGibAddr; masterSecret: string; /** * The specific challenge pool ID used to authorize this unregistration. */ signingPoolId: string; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Gets the registration status of a delegate keystone from the parent's latest tip frame. */ getDelegateStatus({ parentTjpAddr, delegateTjpAddr, metaspace, space, }: { parentTjpAddr: IbGibAddr; delegateTjpAddr: IbGibAddr; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Validates a genesis keystone. * * @returns Array of validation error strings. Empty array means Valid. */ validateGenesisKeystone({ keystoneIbGib, }: { keystoneIbGib: KeystoneIbGib_V1; }): Promise; /** * Retrieves the latest keystone frame for the given address. * * Uses `metaspace.getLatestAddr` to find the actual tip instead of trusting * an incoming payload's `past` rel8n. * * @see `ibgib-get-pattern` SKILL.md */ getLatestKeystone({ addr, metaspace, space, }: { addr: string; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Validates an entire keystone graph from tip to genesis. * * @returns Array of validation error strings. Empty array means Valid. */ validateKeystoneGraph({ keystoneIbGib, dependencyGraph, getLatest, invalidIfMoreRecentKeystoneFoundInSpace, space, }: { keystoneIbGib: KeystoneIbGib_V1; /** * set this if you already have a reference to the graph. It is the caller's * responsibility to enforce {@link getLatest}. */ dependencyGraph?: FlatIbGibGraph; /** * if true, then this will get the latest keystone known in the incoming * {@link keystoneIbGib} timeline, as found in {@link space}. */ getLatest: boolean; invalidIfMoreRecentKeystoneFoundInSpace: boolean; space: IbGibSpaceAny; }): Promise; /** * Permanently revokes the Identity. * * Logic: * 1. Locates the 'revoke' pool. * 2. Solves required challenges to prove ownership. * 3. Wipes the pool (via the delete all strategy in solveAndReplenish). * 4. Sets the revocationInfo on the new frame. */ revoke({ latestKeystone, masterSecret, reason, frameDetails, metaspace, space, }: { latestKeystone: KeystoneIbGib_V1; masterSecret: string; reason?: string; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Structural evolution: Adds new challenge pools to the keystone. * * Use Case: Adding a delegate (Server) for SSO, adding a recovery key, * or rotating to a new set of pools. * * Requires the Master Secret to authorize the change via a pool containing * the 'manage' verb. */ addPools({ latestKeystone, masterSecret, signingPoolId, newPools, frameDetails, dataToPatch, metaspace, space, }: { latestKeystone: KeystoneIbGib_V1; /** * Alice's Master Secret. * Required to solve challenges from the Admin/Manage pool to authorize this change. */ masterSecret: string; /** * The specific pool ID authorized to perform management operations (e.g. 'manage' or 'passkey-manage-*'). */ signingPoolId: string; /** * The pools to add. * NOTE: These are fully constructed Pool objects. * If they are foreign (Bob's), Alice must have constructed them * using Bob's challenges + Her config restrictions + isForeign=true. */ newPools: KeystoneChallengePool[]; frameDetails?: KeystoneFrameDetails; dataToPatch?: Partial; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Structural evolution: Removes challenge pools from the keystone. * * Use Case: Unlinking a custodian or delegate SSO pool. * * Requires the Master Secret to authorize the change via a pool containing * the 'manage' verb (the administrative manage pool). */ removePools({ latestKeystone, masterSecret, signingPoolId, poolIds, frameDetails, dataToPatch, metaspace, space, }: { latestKeystone: KeystoneIbGib_V1; /** * Alice's Master Secret. * Required to solve challenges from the Admin/Manage pool to authorize this change. */ masterSecret: string; /** * The specific pool ID authorized to perform management operations (e.g. 'manage' or 'passkey-manage-*'). */ signingPoolId: string; /** * The IDs of the pools to remove. */ poolIds: string[]; frameDetails?: KeystoneFrameDetails; dataToPatch?: Partial; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Consolidates the state of a Keystone identity across its history. * Walks back until it hits a checkpoint or genesis. */ getAggregateDetails({ latestKeystone, metaspace, space, }: { latestKeystone: KeystoneIbGib_V1; metaspace: MetaspaceService; space?: IbGibSpaceAny; }): Promise; /** * Retrieves common aggregated info for a keystone timeline. */ getKeystoneCommonInfo({ addr, ibGib, metaspace, space, }: { addr?: string; ibGib?: KeystoneIbGib_V1; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise<{ name: string; description: string; isPrimary: boolean; aggregateDetails: any; latestFrameDetails: any; n: number; timestamp?: string; timestampMs?: number; }>; /** * Replaces a challenge pool (such as manage or custodian-manage) with a new pool, * authorizing the transition via the specified signing pool. * * @param latestKeystone The current tip frame of the keystone timeline. * - Visibility: Public (Public Merkle frame, safe for logs/ledger). * - Generator: Client/Server (Constructed locally and synced). * * @param newPool The fully constructed new pool to place in the next frame. * - Visibility: Public (Public configuration and public challenges, safe for ledger). * - Generator: Client/Server (Generated dynamically by the party proposing the update). * * @param signingSecret The master secret or derived KDF secret of the pool authorizing the change. * - Visibility: Private (Confidential secret credential. Must never go over the wire). * - Generator: Client/Server (Known only to the signing party). * * @param signingPoolId The ID of the pool used to authorize the transition (defaults to 'manage'). * - Visibility: Public (Non-sensitive configuration string). * - Generator: Client/Server (From pool configuration). */ replacePool({ latestKeystone, newPool, signingSecret, signingPoolId, frameDetails, metaspace, space, }: { latestKeystone: KeystoneIbGib_V1; newPool: KeystoneChallengePool; signingSecret: string; signingPoolId?: string; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Evolve the keystone by rotating the primary user manage pool (`manage`) to a new master secret (password). * This creates a new frame signed by the specified `signingPoolId` using `signingSecret`. * * Supports recovery (signing via `custodian-manage` using the custodian secret) and normal rotation * (signing via `manage` using the old password). **I DONT THINK THIS IS POSSIBLE. WE WOULD NEED CUSTODIAN MANAGE POOLS ON ALL THE DELEGATES AS WELL** * * @param signingSecret * * @param signingPoolId */ changePassword({ keystoneIbGib, keystoneAddr, newMasterSecret, signingSecret, signingPoolId, poolIds, frameDetails, metaspace, space, }: { /** * The keystone IBGIB whose password we are changing. Does NOT have to * be the tip, as we will get the latest keystone in the implementation * of this function. * - Visibility: Public (Public Merkle frame, safe for ledger). * - Generator: Client/Server (Constructed locally and synced). * * NOTE: You can provide {@link keystoneIbGib} or {@link keystoneAddr}, * but either way the latest keystone ibgib will be gotten first. */ keystoneIbGib?: KeystoneIbGib_V1; /** * The keystone ADDRESS whose password we are changing. Does NOT have to * be the tip, as we will get the latest keystone in the implementation * of this function. * - Visibility: Public (Public Merkle frame, safe for ledger). * - Generator: Client/Server (Constructed locally and synced). * * NOTE: You can provide {@link keystoneIbGib} or {@link keystoneAddr}, * but either way the latest keystone ibgib will be gotten first. */ keystoneAddr?: IbGibAddr; /** * The new password/master secret to set for the user's primary pools. * - Visibility: Private (Confidential secret credential. Must never go * over the wire). * - Generator: Client (From user input in settings). */ newMasterSecret: string; /** * The secret of the pool authorizing this change (either old password * or derived custodian secret). * - Visibility: Private (Confidential secret. Never over the wire). * - Generator: Client/Server (Known only to the signing party). */ signingSecret: string; /** * The ID of the pool used to authorize the rotation. Defaults to * "manage" for user password changes, or if rotating custodian, should * be the custodian's corresponding manage pool. * - Visibility: Public (Non-sensitive ID string). * - Generator: Client/Server (From pool configuration). */ signingPoolId?: string; /** * If provided, password will only be changed for these pools. * NOTE: **delegate passwords will NOT be changed if poolIds are * explicitly provided.** */ poolIds?: string[]; frameDetails?: any; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise<{ newKeystone: KeystoneIbGib_V1; newDelegates?: KeystoneIbGib_V1[]; }>; /** * Verifies if a candidate signing secret (password) is correct for a specific challenge pool. * Does not mutate any state. */ /** * Verifies if a given secret successfully solves challenges in the specified pool * (or any candidate manage pool if poolId is omitted). */ verifySigningSecret({ keystoneIbGib, signingSecret, poolId, verb, }: { keystoneIbGib: KeystoneIbGib_V1; signingSecret: string; poolId?: string; verb?: string; }): Promise; /** * Recursively prunes keys whose value is strictly `null` (tombstone records) * from aggregated detail maps/arrays. */ private pruneTombstoneNulls; } //# sourceMappingURL=keystone-service-v1.d.mts.map