mwg API
    Preparing search index...

    Function parseInbound

    • The whole inbound pass in one call: sanitizeInboundText, then JSON.parse with a reviver that refuses __proto__/constructor/prototype at any depth. Every path in core that reads JSON it did not just produce goes through this (save slots, Collection, stored values, LockstepClient messages, NewsClient), because under file:// Chromium gives every local page one shared localStorage: a value this game wrote can have been rewritten by any other HTML file opened on the same machine. Throws a named Error for every failure.

      Parameters

      Returns unknown

      import { parseInbound } from '@datamoc/mwg/core';

      parseInbound('{"hp": 3}'); // { hp: 3 }
      parseInbound('{"__proto__": {"admin": true}}'); // throws: $ contains a forbidden key "__proto__"