Vana SDK - v4.4.0
    Preparing search index...

    Function buildWeb3SignedHeader

    • Build a Web3Signed Authorization header value.

      Parameters

      • params: {
            signMessage: Web3SignedSignFn;
            aud: string;
            method: string;
            uri: string;
            body?: Uint8Array<ArrayBufferLike>;
            iat?: number;
            exp?: number;
            grantId?: string;
            nonce?: string;
            bodyHash?: string;
        }
        • signMessage: Web3SignedSignFn

          EIP-191 signer (e.g. viem account.signMessage).

        • aud: string

          Expected origin (e.g. "https://ps.example.com").

        • method: string

          HTTP method (e.g. "GET").

        • uri: string

          Request URI/path (e.g. "/v1/data/instagram.profile").

        • Optionalbody?: Uint8Array<ArrayBufferLike>

          Optional request body — when present, used to compute bodyHash.

        • Optionaliat?: number

          Issued-at (unix seconds). Defaults to now.

        • Optionalexp?: number

          Expiry (unix seconds). Defaults to iat + 300. Verifiers reject a window longer than 15 minutes after iat (see verifyWeb3Signed).

        • OptionalgrantId?: string

          Optional grant id, attached as the grantId claim.

        • Optionalnonce?: string

          Optional uniqueness claim, attached as the nonce claim (a uuid is the intended shape; the Personal Server bounds it at 128 characters).

          A payload is otherwise fully determined by { aud, bodyHash, exp, grantId, iat, method, uri }, so two identical requests signed inside the same second produce the same bytes. On the routes that keep a replay store (the MCP and write-session handshakes and delegated writes) the Personal Server refuses the second as a replay; with a nonce the replay key becomes (signer, nonce) instead, which is what lets a poll loop send the same request twice. The nonce is then single use itself: re-using one is a replay even when the rest of the payload changed. Plain data reads keep no replay store; their exposure is bounded by the lifetime cap.

        • OptionalbodyHash?: string

          Pre-computed bodyHash claim — overrides body.

      Returns Promise<string>

      The full header value ("Web3Signed <base64url>.<sig>").