import type { DIDDoc, DIDLog } from '@interop/did-method-webvh'; import type { PublishedWebvhLog } from './didWebvh.js'; import { type WebvhResourceLogController } from '../resourceLog/controller.js'; import { type ResourceLogHeadPin, type ResourceLogPinStore } from '@interop/vh-resource-log'; /** * The pin-slot key for the did:webvh log (`did.jsonl`) of one collection -- * the one derivation every log store shares, so the root-invoked and the * delegated store families over the same collection check the same slot. * Host-free like every pin-slot key. * * @param options {object} * @param options.spaceId {string} the Space holding the collection * @param options.collectionId {string} the collection holding the log (the * account's `id` collection, or an annex generation's `gen-` collection) * @returns {string} */ export declare function logResourcePinId({ spaceId, collectionId }: { spaceId: string; collectionId: string; }): string; /** * The pin-slot key for an account's did:webvh log (`id/did.jsonl`) -- what * {@link verifyAccountLog}, which fetches by URL and holds no store, derives * internally. * * @param options {object} * @param options.spaceId {string} the account's Space id * @returns {string} */ export declare function accountLogPinId({ spaceId }: { spaceId: string; }): string; /** * The substituted-account refusal on its own: a resolved head that is not the * DID the caller expected is refused rather than built on. Stated once so a * fresh read and a caller-threaded head refuse identically. * * A ceremony that takes an already-read head from its caller (the transient * visit's one-read composition, where the readiness stage hands its verified * head to the enrollment) runs this explicitly: the read that would otherwise * have run it never happened, and a head resolving to another DID must not * become the entry's basis just because it arrived by parameter. * * @param options {object} * @param options.published {PublishedWebvhLog} the resolved head * @param [options.expectedDid] {string} the DID it must resolve to; absent, * the head is accepted (the caller discovering the DID from the log itself) * @returns {PublishedWebvhLog} the head verbatim */ export declare function assertPublishedLogDid({ published, expectedDid }: { published: PublishedWebvhLog; expectedDid?: string; }): PublishedWebvhLog; /** * Thrown when the account has published no DID log at all (the resource is * absent). Distinguished from every other failure because it is the one * expected state of an in-flight ceremony -- a client completing its * enrollment before the other side has approved it reads this as "not yet", * not as a broken account. */ export declare class AccountLogMissingError extends Error { constructor(message?: string); } /** * Refuses a served log that conflicts with the pinned head, and returns the * pin the served log establishes. A method or SCID that differs from the pin * is a substituted log under the account's location; a served history shorter * than the pinned ordinal is a rollback; a differing `versionId` at the pinned * ordinal is a fork, whose served entries ride along as evidence (every entry * is signed, so a conflicting pair under one SCID is transferable proof of * equivocation). A pin whose head does not parse as `N-` is treated as * a fork rather than trusted. * * Exported for the ceremony-side reads in `didWebvh.ts`, which take the same * check on their own read of `did.jsonl`; it is deliberately absent from the * module barrel. * * @param options {object} * @param options.log {DIDLog} the served, already-resolved log * @param options.pin {ResourceLogHeadPin | null} the pin held for this log * @returns {ResourceLogHeadPin} the pin the served log establishes */ export declare function checkAccountLogContinuity({ log, pin }: { log: DIDLog; pin: ResourceLogHeadPin | null; }): ResourceLogHeadPin; /** * Checks a served account log against the pin held for it and advances the * pin to the served head, which the check has just proven is genuinely ahead. * * The one implementation of the account log's check-and-advance step, shared * by {@link verifyAccountLog} and by the ceremony-side reads in `didWebvh.ts`: * a rollback, a fork, or an SCID / method switch refuses inside * {@link checkAccountLogContinuity}, so nothing that is not ahead ever * reaches the write. * * @param options {object} * @param options.pinStore {ResourceLogPinStore} * @param options.logId {string} this log's slot in the store * @param options.log {DIDLog} the served, already-resolved log * @returns {Promise} */ export declare function checkAndAdvanceAccountLogPin({ pinStore, logId, log }: { pinStore: ResourceLogPinStore; logId: string; log: DIDLog; }): Promise; /** * Fetches and locally verifies the account's world-readable DID log. * * Throws {@link AccountLogMissingError} when the log resource is absent, and * an ordinary error when the fetch fails, the log does not resolve, or it * resolves to a DID other than the one named. * * Supplied a `pinStore`, the resolved log is additionally checked for * continuity against this client's chain-head pin and refused with a * {@link ResourceLogContinuityError} when it is a rollback, a fork, or an * SCID/method switch; the pin is established at first contact * (trust-on-first-use) and advanced only by a log that verifies past it, * never regressed. A `rollback` is the one refusal that may be nothing worse * than replication lag, exactly as on a governed resource log: nothing * rolled back is ever adopted here, and a caller holding a cached view of the * document may treat that reason as a transport hiccup and carry on with what * it has. Every other reason is a security signal. No `pinStore`, no * continuity check -- the pin lives app-side beside the account-pointer pin, * and a caller that has none keeps one-shot verification. This is the one * reader that takes the pin store as an argument: it fetches by URL and holds * no {@link WebvhIdStore}, whose `pin` member is where every ceremony read * and publish finds it. A ceremony that holds a store hands this function * that store's pin store. * * @param options {object} * @param options.did {string} the account's did:webvh, as the caller's * stored account pointer names it * @param options.spaceId {string} the account's Space id * @param options.host {string} the storage server the account lives on * @param [options.pinStore] {ResourceLogPinStore} this client's chain-head * pins; the account log's slot is keyed by {@link accountLogPinId} over the * `spaceId` above * @param [options.published] {PublishedWebvhLog} a head this same run * already read and resolved (an establishment handing its `accountLog` * forward), reused in place of the fetch. Every check below still runs on * it: the substituted-account refusal, and the chain-head check-and-advance * under the same slot, so a supplied head behind the pin is refused with a * {@link ResourceLogContinuityError} exactly as a served one would be. * Reuse is only ever WITHIN one run or visit, never across writers: the * head is evidence of what this client itself just saw or published, and a * head carried in from anywhere else would defeat the freshness the fetch * exists for * @returns {Promise} the resolved document, the raw * log, and the log's effective `updateKeys` / `nextKeyHashes` */ export declare function verifyAccountLog({ did, spaceId, host, pinStore, published }: { did: string; spaceId: string; host: string; pinStore?: ResourceLogPinStore; published?: PublishedWebvhLog; }): Promise; /** * What {@link verifyAccountLog} returns: the account document as the log * resolves it, the raw log, and the log's effective update-key parameters. * Named because it is also what a caller seeds a session-scoped verified-log * memo with, from a head a ceremony handed it. */ export interface VerifiedAccountLog { doc: DIDDoc; log: DIDLog; updateKeys: string[]; nextKeyHashes: string[]; } /** * The {@link VerifiedAccountLog} view of a head a ceremony already read or * published -- a projection, not a check. The caller that seeds a memo from * an establishment's own `accountLog` uses it rather than re-fetching the log * that run just wrote; a caller wanting the DID and pin checks too calls * {@link verifyAccountLog} with the head instead. * * @param options {object} * @param options.published {PublishedWebvhLog} the resolved head * @returns {VerifiedAccountLog} */ export declare function verifiedAccountLogOf({ published }: { published: PublishedWebvhLog; }): VerifiedAccountLog; /** * Builds the memoized controller resolver an account-shaped store builder * takes ({@link userKeyRosterDescriptorStore}'s `resolveController`, and * `accountCollectionStores`' own): the account's verified controller view, * resolved once for the life of the resolver and shared by every store * built over it, so a roster store and its per-collection twin built from * the same parts verify the account log once between them. * * Nothing runs until the first call. With `log` given, the view is built * from it and `did.jsonl` is never fetched: it is what the run itself * published or adopted, so a fetch could only serve something the run has * not built on. Otherwise the first call runs one {@link verifyAccountLog} * under the pin store handed in, memoized as the in-flight promise; a failed * verification clears the memo, so the next call retries rather than * replaying the refusal. * * @param options {object} * @param options.did {string} the account's did:webvh * @param options.spaceId {string} the data Space id * @param options.host {string} the storage server the account lives on * @param options.pinStore {ResourceLogPinStore} the account log's * chain-head pin, checked and advanced when the log is fetched here * @param [options.log] {DIDLog} the account log this run already stands on * (a ceremony that just read or published it); given, no fetch runs * @returns {function} `() => Promise` */ export declare function accountControllerResolver({ did, spaceId, host, pinStore, log }: { did: string; spaceId: string; host: string; pinStore: ResourceLogPinStore; log?: DIDLog; }): () => Promise; //# sourceMappingURL=verifyLog.d.ts.map