Skip to content

Function: validateOriginWithConfig()

ts
function validateOriginWithConfig(
   event, 
   config, 
   expectedSource?): boolean;

Validate an incoming MessageEvent against a SecurityConfig.

This is the public config-driven replacement for the legacy validateOrigin(event, origin, source, strict) signature.

Validation: if (!effectiveWhitelist.includes(event.origin)) { if (strictMode) throw; else warn }

Where effectiveWhitelist = allowedOrigins ∪ additionalOrigins (see getEffectiveWhitelist for the deduplication + order contract).

Parameters

ParameterTypeDefault valueDescription
eventMessageEventundefinedThe raw MessageEvent from the message handler.
configSecurityConfigundefinedThe resolved SecurityConfig. Callers typically pass the result of resolveConfig at init time, not the raw user-supplied object.
expectedSourceWindow | nullnullOptional iframe contentWindow reference to enforce source-window identity. Defaults to null (skip source check).

Returns

boolean

true if the event passes; false on mismatch in non-strict mode.

Throws

MAPSTED-1303 (ERR_SECURITY_CONFIG_ORIGIN_MISMATCH) in strict mode when the origin is not in the effective whitelist.