/** * Session transitions invalidate the store's cached HTTP authorization * metadata. * * `UpdateManager.editable()` is a synchronous read of the responses recorded * under `fetcher.appNode`. Those responses are not keyed by identity, so a * document fetched anonymously (before a restore completed) or under a * previous WebID keeps answering for the old identity: a writable document can * look read-only after login, and a read-only one can look writable after * logout. * * `UpdateManager.flagAuthorizationMetadata()` marks every recorded response * out-of-date, so `editable()` answers "unknown" instead of the previous * identity's access. It is wired HERE, once, subscribed to the session's * identity state — so it covers every transition whichever path noticed it (a * session event, a token update, a refocus resync, a cookie probe), rather * than whichever events a call site remembered to listen for. * * The repair is then a plain `load()`: rdflib refetches a document whose * recorded answers are ALL flagged (linkeddata/rdflib.js#871, in 2.4.1), which * is exactly the state a transition leaves behind — and `checkEditable()` * heals the same way. Nothing forces a fetch by hand any more. * * REQUIRES rdflib >= 2.4.1: on 2.4.0 `load()` answered such a document from * the cache, so the decision points below could not re-establish an answer. */ import { type SessionLike } from './identityState'; export type TransitionStore = { updater?: { flagAuthorizationMetadata?: () => void; }; }; export type AuthorizationStore = { fetcher?: { load?: (doc: unknown) => unknown; }; updater?: { editable?: (uri: unknown) => string | boolean | undefined; flagAuthorizationMetadata?: () => void; }; }; /** * Flags the store's authorization metadata on every identity transition. * * @returns the unsubscribe function — the caller owns the lifetime (it ends * with the session's subscription). */ export declare function flagAuthorizationOnSessionTransitions(store: TransitionStore, session: SessionLike): () => void; /** * Make the store able to answer for `doc` under the current identity before * its cached triples are read or its editability gates a write. A flagged * store answers `undefined` and is repaired here; a store whose invalidation * FAILED still answers definitively for the previous identity, so it is * repaired too (and keeps being repaired until a later transition flags * successfully, since the failure says nothing about which other documents are * stale). * * Returns whether the answer was established. `false` means a repair was * needed and could not complete: the caller must not consume cached triples * from that document and must not offer a write on it. */ export declare function ensureDocumentAuthorization(store: AuthorizationStore, doc: unknown): Promise; /** * Load a document and make sure its cached triples can be read under the * current identity. The load itself is generation-checked: a response begun * under the previous identity can be recorded AFTER * `flagAuthorizationMetadata()` ran (the flag only marks response nodes that * already existed), which leaves a definitive-looking answer from the old * identity behind — so an overtaken load is repaired instead of being trusted. * * Returns whether the document can be consumed (see * ensureDocumentAuthorization). Load errors propagate, as a plain `load()` * would. */ export declare function loadAuthorizedDocument(store: AuthorizationStore, doc: unknown): Promise; //# sourceMappingURL=flagAuthorizationOnTransitions.d.ts.map