
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
unicorn-rpa
Advanced tools
强大的跨域iframe自动化控制工具
这个动作会点击指定元素,然后等待并捕获可能触发的接口响应。
// 示例:点击提交按钮并等待接口响应
{
"type": "clickAndWaitForResponse",
"selector": ".submit-btn",
"timeout": 10000, // 可选,默认10秒超时
"delay": 1000 // 可选,动作完成后的延迟
}
这个动作会等待并捕获接口响应,通常与 click 动作配合使用。
// 示例:先点击按钮,再等待接口响应
[
{
"type": "click",
"selector": ".submit-btn"
},
{
"type": "waitForApiResponse",
"timeout": 10000, // 可选,默认10秒超时
"delay": 1000 // 可选,动作完成后的延迟
}
]
当捕获到接口响应时,会在 results 数组中添加以下格式的数据:
// 成功响应
{
"type": "apiResponse",
"selector": ".submit-btn", // 仅 clickAndWaitForResponse 包含
"data": {
"type": "fetch", // 或 "xmlhttprequest"
"url": "https://api.example.com/submit",
"status": 200,
"statusText": "OK",
"responseText": "{\"success\": true, \"message\": \"提交成功\"}",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache"
}
}
}
// 请求失败
{
"type": "apiError",
"selector": ".submit-btn", // 仅 clickAndWaitForResponse 包含
"error": "NetworkError: Failed to fetch"
}
// 等待超时
{
"type": "apiTimeout",
"selector": ".submit-btn", // 仅 clickAndWaitForResponse 包含
"message": "等待接口响应超时"
}
fetch 和 XMLHttpRequest 两种请求方式unicorn-rpa 是一个基于 postMessage 的跨域 iframe 自动化控制工具,支持多种 UI 自动化操作,适用于前端页面自动化测试、RPA 机器人、跨系统表单自动填充等场景。
npm install unicorn-rpa
# 或
pnpm add unicorn-rpa
# 或
yarn add unicorn-rpa
import CryptoJS from 'crypto-js';
const AUTH_AES_KEY = 'unicorn-rpa-2024-very-secret-key-1234'; // 与接收端一致
const authPlain = '优霓空(重庆)科技有限公司';
const authEncrypted = CryptoJS.AES.encrypt(authPlain, AUTH_AES_KEY).toString();
const fillData = {
auth: authEncrypted,
iframeSelector: '#targetFrame',
actions: [
{ type: 'fill', selector: '.input', value: 'hello', delay: 500 },
{ type: 'click', selector: '.btn', delay: 500 }
]
};
const iframe = document.getElementById('targetFrame');
iframe.contentWindow.postMessage(fillData, '*');
在目标页面引入 unicorn-rpa 并初始化:
const injectRPA = require('unicorn-rpa');
injectRPA();
| type | 说明 |
|---|---|
| fill | 文本输入 |
| select | 下拉选择 |
| click | 点击 |
| doubleClick | 双击 |
| rightClick | 右键点击 |
| hover | 悬停 |
| scroll | 滚动 |
| screenshot | 截图 |
| waitFor | 等待元素出现 |
| wait | 等待固定时长 |
| treeSelect | 树形选择 |
| checkAllCheckboxes | 批量勾选复选框 |
| getText | 获取文本 |
| getValue | 获取值 |
auth 字段const SECURITY_CONFIG = {
ALLOWED_ORIGINS: [
'http://localhost:5000',
'http://localhost:5173',
'http://localhost:8080',
'http://127.0.0.1:5000',
'http://127.0.0.1:5173',
'http://127.0.0.1:8080'
],
RATE_LIMIT: {
INTERVAL: 10000 // 10秒
}
};
const AUTH_AES_KEY = process.env.AUTH_AES_KEY;
const AUTH_HASH = process.env.AUTH_HASH;
Q: 为什么我的消息被拒绝?
Q: 如何自定义动作?
Q: 如何调试安全校验?
如需定制功能、发现 bug 或有建议,欢迎 issue 或 PR。
MIT
FAQs
🦄 Unicorn RPA - 强大的跨域iframe自动化控制工具
We found that unicorn-rpa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.