Saxonberg Server API
    Preparing search index...
    Index

    Methods

    • Walk the call stack and return the first frame's URL for which predicate returns true, or null if no frame matches. Useful for "is any caller in a test file?" / "is anyone in mud/api/...?" style searches where the immediate caller isn't what matters.

      Frames inside ModuleApi itself are skipped automatically. URLs are normalized to forward slashes before the predicate runs.

      Parameters

      • predicate: (url: string) => boolean

      Returns string | null

    • Find the first frame on the current call stack whose source URL doesn't match skipModule, and return that URL. Use this when you need "the file that called me" for a URL allowlist (e.g. the construction-gate, frame-mutator, or branch-registration gates) — pass a regex matching your own module so frames inside your file (the helper that wraps this call, the policy method, etc.) are skipped past.

      Returns null when the stack can't be parsed or every frame is inside ModuleApi itself or skipModule.

      URLs are normalized to forward slashes before skipModule is applied — write your pattern with /, not \\, regardless of platform.

      Parameters

      • skipModule: RegExp

      Returns string | null

    • Look up the canonical module-id string for cls. Returns null if the class wasn't stamped. Identity-keyed policies that need a module-id should fail closed (deny) on null — that's the tamper-resistance contract.

      Parameters

      • cls: object | null

      Returns string | null

    • Stamp every entry in exports with declaredUrl (normalised). Called once per module by the source transform's appended snippet.

      Rejects (silently — no throw) if declaredUrl doesn't match the caller's stack-derived URL: a manual stamp(fakeUrl, …) from another file fails the check. The transform always passes import.meta.url, which equals the caller's URL, so legit stamping never trips the check.

      For each newly-stamped class: also runs the @Final validator. Throws FinalViolationError if the class overrides an ancestor's @Final method. Bad modules fail at import time.

      Parameters

      • declaredUrl: string
      • exports: Record<string, unknown>

      Returns void