@adobe/coriolis

中文文档
2.1.2发布于 2025/05/16Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 2273

A library for cross iframe communication with high level API and features.

原始使用文档
文档目录18 节
  1. A library for cross iframe communication with high level AP…
  2. Useful Links
  3. Key Features
  4. How To Use it
  5. Architecture
  6. Security
  7. Related projects
  8. penpal
  9. postmate
  10. Contributing
  11. Licensing
  12. Changelog
  13. Version 2.1.2
  14. Version 2.1.1
  15. Version 2.1.0
  16. Version 2.0.0
  17. Future Developments
  18. Ideas to explore

Coriolis

A library for cross iframe communication with high level API and features.

Usefull Links • Key Features • How To Use • Architecture • Related projects • Contributing • Licensing • Changelog • Future developments • Ideas to explore

Key Features

  • Cross browser compatibility (see version 1.X for IE support)
  • Low number of dependencies and lightweight (~ 10kb minified & gzipped)
  • Extensible and modularized (you can add module and serializer)
  • Handshake with event for connection, disconnection and reconnection
  • Handle most security checks out of the box for you
  • Multiple high-level functional API with:
    • Query module for easy cross domain function calls
    • Event module to share state changes
    • Store module to share states with observable support
    • Plugin module to provide you a base plugin system
    • Content module to allow basic operation on child content
  • Serializer system for non JavaScript primitive data type like:
    • Map / Set objects
    • Error objects
    • Date objects
    • KeyboardEvent
    • MouseEvent
    • DomRect (with auto translation of coordinate)
    • ArrayBuffer

How To Use it

In your main domain (Asset domain):

<script src="polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="coriolis.js" type="text/javascript" charset="utf-8"></script>
<div id="coriolisContainer"></div>
<script type="text/javascript">
    var coriolis = Coriolis.createIframe(
        document.querySelector('#coriolisContainer'),
        'https://your-ugc-hostname.example.com',
        '<html><head></head><body>Initial Coriolis Content</div></body></html>'
    );

    coriolis.query.call('addition', 12, 30).then(function(result) {
        console.log(result);
    });
</script>

In your user generated content domain:

<script src="polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="coriolis.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var coriolis = new Coriolis(
        window.parent,
        'https://your-asset-hostname.example.com',
    );

    coriolis.query.register('addition', function(a, b) {
        return Promise.resolve(a + b);
    })
</script>

This will load Coriolis on both of the domains, do a handshake, override the content of the Iframe with the Initial Coriolis Content and finally print the result of addition in the main domain (while the computation is done in the iframe).

For more example of Coriolis, you could start the project (npm start) and/or check the demo folder. You could also look the generated documentation (build it locally with npm run doc && open reporting/doc/index.html).

Architecture

Coriolis in composed of multiple components and allows for Modules and Serializers to be configured. Here is a high level class diagram that explains how the Class interact.

The DataSerializer and ModuleLoader are abstract enough to be used outside of a context of Postmessage if you have other functional needs (for example, webSocket) and are responsible of the extensibility of Coriolis.

Security

Even if Coriolis alone couldn't protect your Assets (replace Assets by what is important for you to protect, eg: IMS token), it should help when you deal with customer data that you couldn't escape (Customer JS code, Customer plugin, Non-Adobe integration, RichText Editors...). It enhances security with 3 main ideas:

  • Easy usage prevent developers to bypass security
  • Use a specific protocol are reject non expected data
  • Configured by default related security setting (sandbox attributes)

The other part that you are in charge of is to ensure a full protection of your Asset is:

  • Correctly configure your Cross Origin Resource Sharing (CORS) and Content Security Policy (CSP) on your server
  • Use two different domains, one for your main domain with your Assets and one for User Generated Content (UGC)
  • Do a security code review of code that used or extends Coriolis on the main domain
  • Do not shared your Assets through Coriolis

If you used Coriolis and applied all of these advises, you should be secured as described in that threat model diagram:

penpal

Open source project that allow implementing query feature. It is used inside Adobe by Adobe Launch in the Reactor Bridge. It only support primitive javascript information transfer. It doesn't preconfigure any security parameters by default.

postmate

A popular Open source project. It has an handshake support. It only support primitive JavaScript information transfer. It's only designed to have parent to child exchange and it's not designed for by-directional communication.

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

Changelog

Version 2.1.2

  • Fix missing Readme on npmjs package

Version 2.1.1

  • Allow to bypass origin verification with the '*' as input URL.

Version 2.1.0

  • Fix Map and Set serializer
  • Allow to defer the target of PostMessage (create coriolis object before the iframe)
  • Fix contentModule that rewrite the content even when not used
  • Allow contentModule and StoreModule to handle reconnect or not
  • Make StoreModule sync the store at connection with mergeCallback in conflict or use parent value if mergeCallback was not defined.
  • Send a disconnect event if the connection is lost (eventlistener for unload)
  • Improve typescript definition
  • Update connection system to alert in version mismatch
  • Add channel listener support and global listener support in store and event module

Version 2.0.0

  • Drop support of Internet Explorer
  • Addition of TypeScript
  • Reduce checks on usage (will be checked by TypeScript)

Future Developments

Here is a list of some idea / improvement for future version of Coriolis. Any contribution is welcome and if you have interest for one of the item, event without the ability to contribute, please contact us.

  • Add security configuration
    • Add warning when two frame are on the same domain
    • Allow to have multiple whitelisted hosts for parent / child
    • Allow personalization of sandbox attribute
  • Move some dependencies into peerDependency (allow main project to use they own polyfill)
  • Allow configure target param for the DomRectSerializaer from Coriolis constructor

Ideas to explore

  • Add a strict mode for store (need declare store object before use them)
  • Add a tool for help debugging what is inside store, history of event and query
  • Make a postMessage decorator for multiple frames forwarder

版本与发布记录

@adobe/coriolis 共发布 14 个版本,首次发布于 2022/01/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.2latest2025/05/161.5 年前
2.1.12025/05/161.5 年前
2.1.1-beta.02024/12/121.9 年前
2.1.02024/11/142 年前
2.1.0-beta.62024/06/272 年前
2.1.0-beta.52024/05/302 年前

关于 @adobe/coriolis 的常见问题

@adobe/coriolis 是什么?

A library for cross iframe communication with high level API and features.

如何安装 @adobe/coriolis?

在项目目录运行 npm install @adobe/coriolis,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eventemitter3(^5.0.0)、babel-polyfill(^6.26.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adobe/coriolis 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adobe/coriolis 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@adobe/coriolis 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/coriolis 可以商用吗?

@adobe/coriolis 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/coriolis 的下载量有多少?

根据 npm 官方下载统计,@adobe/coriolis 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,273 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/coriolis 还在维护吗?

最新版本 2.1.2 发布于 2025/05/16(1.5 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/01/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。