/** * Two refusals that keep a fixed `scopePath` honest. * * 1. `ensureIdsMatchPath`: per-call ids must agree with the path. * The server lets the path win: it takes `user_id` and `customer_id` from the * path keys `user` and `customer` over the flat ids it is also sent. A package * that fixes a path when it is built but takes the user per call (an eve * session principal) would let one caller read and write another's memory * while believing it addressed its own. Call this before every SDK call that * sends both, and once at construction where the ids are fixed too. * * 2. `assertSdkSupportsScopePath`: an SDK older than 0.7.1 silently ignores the * path (`sdk.fetch` sends ids only; `send_message` drops it), so a call that * was meant for one level would be filed and read at another. Refuse at * construction instead. The marker is `get_scope_ladder`, which exists on * every SDK that carries the path and on none that does not. * * `ensureIdsMatchPath` mirrors `ensure_ids_match_path` in * `synap_integrations_common/scope.py`: same rules, same message text. Keep * them in step. * * ⚠ This file is vendored, not imported: byte-identical in `synap-eve`, * `synap-mastra`, `synap-claude-agent-ts` and `synap-vercel-adk`, for the * reason `stream-events.ts` is (no shared runtime package). The vendoring tests * fail the build if a copy drifts. Change one, copy it to the other three. */ /** The lowest `@maximem/synap-js-sdk` that sends `scope_path`. */ export declare const MIN_SDK_VERSION_FOR_SCOPE_PATH = "0.7.1"; /** * Raised when per-call ids disagree with a fixed scope path, or the path is * malformed. Same shape as Python's `SynapIntegrationError`: `operation`, * `context`, message `": "`. Never carries a raw id. */ export declare class SynapScopeError extends Error { readonly operation: string; readonly context: Record; constructor(operation: string, message: string, context?: Record); } /** A short hash of an id, safe to put in an error message or a log. */ export declare function fingerprint(value: unknown): string; /** * Refuse per-call ids that disagree with a scope path fixed elsewhere. * * - `scopePath` falsy or empty: no-op. * - For each reserved key (`user`, `customer`) present in the path: an id that * is set and differs throws; an empty / absent id is fine (the path supplies it). * - B2C: a path whose `customer` equals its `user` with `customerId` left out * passes, as does a `customerId` equal to that value. * - The path itself must map non-empty string keys to non-empty string values * without `/`; otherwise it throws. * * Messages carry short fingerprints of the ids, never the ids themselves. */ export declare function ensureIdsMatchPath(scopePath: Readonly> | null | undefined, ids?: { userId?: string | null; customerId?: string | null; where?: string; }): void; /** * Throw at construction when a `scopePath` is set on an SDK that cannot carry * it. No-op without a path, so a package used without one never changes. */ export declare function assertSdkSupportsScopePath(sdk: unknown, scopePath: Readonly> | null | undefined, where: string): void; //# sourceMappingURL=scope-guard.d.ts.map