@anon-rpc/浏览器harness
浏览器控制器 动画 ——允许钱包或应用程序生成的标准 匿名的RPC请求 在沙箱工人体内运行被散装的肛门客户密码.
执行 阳起角规格
版本 0.4.0 (中文(简体) ). (软件包版本保留) >= 已执行的光谱
版本;没有光谱变化的软件包发布会撞过它. )
绳子:
- 解决来自链上指定合同的动因客户捆绑——结束
https:科索沃警察部队本身通过kps:解析器条目(SPEC §4.1-4.2) - 并核实keccak256(bytes) == workerHash()执行单曲前 字节( 相信散列而不是 URL ); - 运行在一个 无效沙盒内网络工人,没有 环境访问您的 DOM、 存储、 饼干或密钥;
- 赋予它一个小型、明确的能力API——入境接听电话,a 科索沃警察部队 键控运输 (剪接后工人从不接触WebRTC),持续存储 (IndexedDB关于主机源头,每个指定点的名称空格),并记录;
- 将你带回一件事: 无名化
fetch。 。 。 .
安装
npm install @anon-rpc/browser-harness
使用
import { AnonRpcWorker } from "@anon-rpc/browser-harness";
const worker = new AnonRpcWorker({
// The IWorkerSpecifier contract identifying the anon-client by hash.
address: "0x…",
// Optional: a plain value (JSON, plus undefined, Uint8Array, ArrayBuffer)
// delivered to the worker exactly as `anonRpcWorker.config`. Opaque to the
// harness; schema is the worker's. Anything else throws a TypeError here.
config: { network: "mainnet" },
// Bootstrap provider used only to read the specifier (breaks the circular
// "need the chain to reach the chain" dependency).
preExisting: { rpcProvider },
});
// Optional: Wait for the worker to report that it is ready. You can start
// making fetch calls before this - they'll just get buffered.
// await worker.ready;
// A standard fetch, routed through the sandboxed anon-client.
// It is this-bound, so passing it around as a free function is fine.
const res = await worker.fetch("https://rpc.example/", {
method: "POST",
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_blockNumber" }),
});
worker.close(); // tears down the iframe and worker
按呼选项
anonOptions 在一个 fetch 它被传递给工人,而不是目的地
(SPEC 第9.3节):
await worker.fetch(url, { method: "POST", body, anonOptions: { isolationKey: "account-1" } });
isolationKey 要求不同密钥下的通话不能连接到一个
另一个 支持不尽相同——如果是的话,请检查您的网络对这个密钥做了什么
对你很重要.
收集工人的日志
工人第13节 log 呼叫控制台,除非你收到 拉他们
与 acceptLog() (SPEC §5, 第13.1段) 并且不再被重复:
for (;;) {
// Resolves with the next entry; waits when there is none. Rejects once the
// worker has failed or closed AND its retained entries are drained — so the
// lines explaining a failure arrive before the rejection does.
const { level, args } = await worker.acceptLog();
render(level, args);
}
从工人开始就保留了条目,所以有一条线被记录 当你第一次问起的时候,靴子还在那里。 缓冲器是被绑定的(1 000) 条目),并放出最古老的; 第13.1节使这里成为一个 磁带可能会失去它已经接受的日志呼叫.
严格内容安全政策
默认情况下,这个带子用 srcdoc 和内线
脚本,不需要你帮忙 如果你的页面 CSP 省略
'unsafe-inline' 页:1 script-src这靴子不会跑.. srcdoc
文档继承嵌入者的政策,而政策只能收紧
从文件里面,永远不要放松。 症状是 ready 从来没有
和解,加CSP违反 控制台.
自己把绳子的靴子绑好,指点一下 iframeUrl (SPEC 第5条)
内容:
new AnonRpcWorker({ address, preExisting, iframeUrl: "/anon-rpc-iframe.html" });
这页只需要带子的脚本 里面有船
软件包为 dist/iframe-boot.js数字 :
<!doctype html><meta charset="utf-8"><script src="/anon-rpc-iframe.js"></script>
绳子仍然适用 sandbox="allow-scripts" 因此文档是
放置在不透明来源, 无论来自哪条路由, 第6节要求 URL
与你的页面同源 跨出源的靴子会让
与第三方隔离,所以绳子拒绝一个.
在Firefox上,允许 data: 在靴子的页面 script-src 无论政策如何
在此应用: Firefox 拒绝 importScripts(blob:) 在不透明来源中
工人们,所以绳子上载了经证实的捆绑 data: URL 代替( 它
检测到这一点;其他浏览器继续使用 blob:) (中文(简体) ).
MV3 浏览器扩展名不是可选的, 页面必须附加
将在名单中宣布 sandbox.pages· ;
@anon-rpc/browser-extension-harness 软件包
这一切.
页:1
- 仅浏览器: 隔离模型是无效的 Iframe 和 KPS 运输通过WebRTC. 本地/节点的牵引装置是单独的 软件包.
- 提高工人的适应能力
anonRpcWorker)和所有符合规定 所需经费的定义见 规格。 。 。 . 复制住址的 anon 客户端模板impl/passthrough-worker。 。 。 . - 现状:样板草稿的原型级参考执行;接口 跟踪谱并可能改变.
许可证
麻省理工学院埃特鲁姆基金会