import { Ib, IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs"; import { KeystoneData_V1, KeystoneIbGib_V1, KeystoneIb_V1, KeystoneChallengePool, DeterministicResult, KeystoneProof, KeystonePoolConfig, KeystoneClaim, DelegateKeystoneInfo } from "./keystone-types.mjs"; import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs"; import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs"; import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs"; import { FlatIbGibGraph } from "../common/other/graph-types.mjs"; /** * space-delimited keystone ib containing select keystone metadata. * * NOTE: This must match {@link parseKeystoneIb} * @see {@link KeystoneIb_V1} */ export declare function getKeystoneIb({ keystoneData, }: { keystoneData: KeystoneData_V1; }): Promise; /** * NOTE: This must match {@link getKeystoneIb} * @see {@link KeystoneIb_V1} */ export declare function parseKeystoneIb({ ib, }: { ib: Ib; }): Promise; /** * Helper to validate if an ib string is a well-formed keystone ib. */ export declare function validateKeystoneIb({ ib, }: { ib: Ib; }): Promise; /** * Validates if a string is a well-formed email address. * Uses a broad, non-restrictive regex to avoid rejecting valid custom email formats. */ export declare function validateEmail(email: string): boolean; /** * The Policy Engine. * Calculates exactly which challenges MUST be consumed based on config and demands. * Enforces STRICT DISTINCTNESS (No double-dipping). */ export declare function getDeterministicRequirements({ pool, requiredChallengeIds, targetAddr }: { pool: KeystoneChallengePool; requiredChallengeIds?: string[]; targetAddr?: string; }): Promise; /** * Selects the specific pool to use for an operation based on ID, filter criteria, or verb authorization. * * @returns The matching KeystoneChallengePool * @throws If no pool matches or if multiple pools match but one was expected. */ export declare function resolveTargetPool({ pools, poolId, poolFilter, verb, }: { pools: KeystoneChallengePool[]; /** * Explicit ID of the pool to use. */ poolId?: string; /** * Optional predicate to find a pool. * Useful for finding delegates via metadata. */ poolFilter?: (pool: KeystoneChallengePool) => boolean; /** * The verb being performed (e.g. 'revoke', 'manage', 'post'). * Used for authorization checks and auto-resolution. */ verb?: string; }): KeystoneChallengePool; /** * Calculates the complete list of Challenge IDs to solve for a given operation. * Combines Deterministic requirements (Mandatory/Binding/FIFO) with Stochastic requirements. * * @returns Array of unique challenge IDs. */ export declare function selectChallengeIds({ pool, targetAddr, requiredChallengeIds, }: { pool: KeystoneChallengePool; /** * The address of the target ibgib (used for binding entropy). */ targetAddr?: string; /** * Explicit demands from a verifier. */ requiredChallengeIds?: string[]; }): Promise; /** * Generates an opaque, collision-resistant ID for a challenge. * atow (2025/12/22) - Hash(Salt + Timestamp + Index) */ export declare function generateOpaqueChallengeId({ salt, timestamp, index }: { salt: string; timestamp: string; index: number; }): Promise; /** * Calculates the NEXT state of the Challenge Pools given a specific consumption event. * Handles TopUp, ReplaceAll, Consume, and ScorchedEarth strategies. * * @returns The new array of KeystoneChallengePools (including the modified one). */ export declare function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, verb, }: { prevPools: KeystoneChallengePool[]; targetPoolId: string; consumedIds: string[]; masterSecret: string; /** * The instantiated KeystoneStrategy (e.g. HashRevealV1) used to generate new challenges. */ strategy: any; config: KeystonePoolConfig; verb?: string; }): Promise; /** * High-level orchestration helper. * 1. Instantiates Strategy. * 2. Derives Secret. * 3. Solves Challenges (Generates Solutions). * 4. Replenishes Pool (Calculates the next state of ALL pools). * 5. Constructs Proof. * * @returns The resulting Proof and the full list of Next Pools. */ export declare function solveAndReplenish({ targetPoolId, prevPools, masterSecret, challengeIds, claim, requiredChallengeIds, }: { /** * The ID of the pool to use for signing. */ targetPoolId: string; /** * The full list of pools from the previous Keystone frame. * Required to reconstruct the full state for the next frame. */ prevPools: KeystoneChallengePool[]; masterSecret: string; challengeIds: string[]; claim: Partial; requiredChallengeIds?: string[]; }): Promise<{ proof: KeystoneProof; nextPools: KeystoneChallengePool[]; }>; export declare function validateChallengePool_typeHashRevealV1({ pool }: { pool: KeystoneChallengePool; }): Promise; export declare function validateChallengePool({ pool }: { pool: KeystoneChallengePool; }): Promise; export declare function validateKeystoneMetadata({ data }: { data: KeystoneData_V1; }): string[]; export declare function validateGenesisKeystone({ keystoneIbGib }: { keystoneIbGib: KeystoneIbGib_V1; }): Promise; /** * Helper to determine if two delegates maps differ. */ export declare function isDelegatesChanged({ currDelegates, prevDelegates, }: { currDelegates?: Record; prevDelegates?: Record; }): boolean; /** * Validates the structure and constraints of the delegates map. */ export declare function validateDelegates({ currDelegates, prevIbGib, lc, errors, }: { currDelegates: Record; prevIbGib: KeystoneIbGib_V1; lc: string; errors: string[]; }): Promise; /** * Resolves the DelegateKeystoneInfo entry from primaryKeystone.data.delegates matching the local spaceId. */ export declare function getLocalSyncDelegateInfo({ primaryKeystone, metaspace, space, }: { primaryKeystone: KeystoneIbGib_V1; metaspace: MetaspaceService; space?: IbGibSpaceAny; }): Promise; /** * Validates the transition from Prev -> Curr. * Enforces Cryptography AND Behavioral Policy. * * @returns Array of validation error strings. Empty array means Valid. */ export declare function validateKeystoneTransition({ currentIbGib, prevIbGib, }: { currentIbGib: KeystoneIbGib_V1; prevIbGib: KeystoneIbGib_V1; }): Promise; /** * Helper to verify a single proof against a specific pool. */ export declare function verifyProofAgainstPool({ proof, pool, errors, }: { proof: KeystoneProof; pool: KeystoneChallengePool; errors: string[]; }): Promise; export declare function evolvePersistAndRegisterKeystone({ prevIbGib, newData, metaspace, space, }: { prevIbGib: KeystoneIbGib_V1; newData: KeystoneData_V1; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Creates a new keystone ibgib that has no dna and no past. */ export declare function createKeystoneIbGibImpl({ data, metaspace, space, }: { data: KeystoneData_V1; metaspace: MetaspaceService; space?: IbGibSpaceAny; }): Promise; export declare function 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; export declare function getIdentity({ addr, metaspace, space, }: { addr: IbGibAddr; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; export declare function getIdentity_throwIfUndefined({ addr, metaspace, space, }: { addr: IbGibAddr; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Pure helper to generate challenges map for a pool configuration using a masterSecret. */ export declare function generatePoolChallenges({ config, masterSecret }: { config: KeystonePoolConfig; masterSecret: string; }): Promise<{ [challengeId: string]: any; }>; /** * Pure helper to rotate a pool to a new masterSecret. * Takes the previous pool config, generates a new salt, and builds a new pool with refreshed challenges. */ export declare function rotatePoolChallenges({ prevPool, newMasterSecret }: { prevPool: KeystoneChallengePool; newMasterSecret: string; }): Promise; /** * Pure helper to verify if a candidate signing secret (password) is correct for a specific challenge pool. * Does not mutate any state. */ export declare function verifyPoolSecret({ pool, signingSecret }: { pool: KeystoneChallengePool; signingSecret: string; }): Promise; /** * Type guard / helper checking whether an ibGib is a Keystone stone (atom starts with 'keystone'). */ export declare function isKeystone(ibGib?: IbGib_V1 | null): boolean; //# sourceMappingURL=keystone-helpers.d.mts.map