Remotable Contracts for Web Iframe Type Safety
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional postMessage method between iframes is limited to passing unstructured text strings, lacks object identity, and is dynamically typed, leading to runtime errors and restricted control flow patterns, such as asynchronous methods and events, due to security restrictions across different domains.
Innovation Solution
The Remotable Contract Implementation annotates and translates structured code or control flow into text messages that can be passed across postMessage channels, enabling static type-checking and rich control flow interactions between iframes using statically typed proxies and dynamic reflection, allowing for the transmission of structured data and executable code.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the postMessage method is used to communicate between iframes from different domains, then security is maintained through domain restriction, but the ability to pass structured data and executable code is lost
Solution Approach 1:
The patent introduces a mediator layer that translates structured data and executable code into text string representations for transmission via postMessage, then reconstructs them at the receiving end. This intermediary translation mechanism allows complex data types to pass through the restricted channel while maintaining security boundaries.
Solution Approach 2:
The invention changes the parameter format of data being transmitted by converting structured objects and code into serialized text strings that conform to postMessage constraints, while preserving the ability to reconstruct the original data structure and functionality at the destination.
2Reliability
If only text strings are passed between iframes using postMessage, then security restrictions are satisfied, but object identity and structured field access are lost
Solution Approach 1:
The patent creates a copy mechanism where objects are serialized into text representations that include identity information, transmitted via postMessage, then deserialized into proxy objects that maintain references to the original objects. This copying approach preserves object identity across the security boundary while satisfying text-only transmission constraints.
3Ease of manufacture
If dynamic typing is used in postMessage communication, then ease of implementation is maintained, but runtime errors cannot be prevented
Solution Approach 1:
The patent implements preliminary type checking and validation during the serialization and deserialization processes, before data is transmitted and executed. This preliminary action catches type errors early in the process rather than allowing them to manifest as runtime errors during execution, while still maintaining the dynamic typing framework.
4Adaptability or versatility
If conventional postMessage is used for communication, then browser compatibility is maintained, but rich control flow patterns like asynchronous methods and events are not available
Solution Approach 1:
The patent substitutes the limited mechanical postMessage text transmission with a more sophisticated system that uses serialization, deserialization, and proxy creation to enable advanced control flow patterns. This replacement maintains compatibility with the existing postMessage mechanism while adding capabilities for asynchronous methods, events, and other rich control flow patterns through the translation layer.
Data Source
AI summary
A “Remotable Contract Implementation”, as described herein, provides various techniques for implementing static type checking of remoted contracts across iframes using scripts such as TypeScript, JavaScript, AJAX, etc., thereby enabling structured data and rich patterns of control flow across iframe boundaries. The Remotable Contract Implementation enables the static type-checking over the limited browser postMessage channel of communication across iframes, by generating statically type-checked proxies at runtime based on dynamic reflection, and allowing for full fidelity of JavaScript control flow interactions (e.g. methods, events, asynchronous communications, etc.) over that channel. Further, in various embodiments, the Remotable Contract Implementation provides various methods that can be used to produce useful application context for otherwise isolated applications by providing access to particular browser resources or information that would otherwise be unavailable over the postMessage communication channel using conventional scripting techniques.


