0n-decoy

中文文档
1.4.0发布于 2026/10/29BUSL-1.1ES Module零依赖

Deception for APIs that AI agents and scanners attack: honey paths, self-verifying canary tokens, a believable fake world, tarpits and alerts. From 0n3.

原始使用文档

0n-decoy

Deception for APIs that AI agents and scanners attack. Zero dependencies.

Real defences keep attackers out. 0n-decoy adds the layer that wastes their time and tells you they came:

What it does
Honey paths/secure-keys, /api/vault/export, /.env, /.git/config, /wp-login.php, /api/internal/… (plus robotsLures() for robots.txt, and your own private ones via extraHoney) — no real client asks for these. A hit flags the address for 24 h.
Canary tokensLook exactly like your real tokens. Recognised without a database: the token carries an HMAC tag only your secret can produce. Plant them anywhere (docs, CRM notes, repos); any use is a critical alert naming where it leaked from.
Decoy worldBelievable JSON and config files full of canary credentials and "internal notes" that lead an automated agent to more honey paths.
TarpitFlagged addresses get slow answers. Brute force — many different bad tokens — gets the decoy world. One stale token retried forever does not.

It never feeds fake data to a request with a valid credential, never changes what real users receive, and never hacks back.

import { createDecoy, middleware } from '0n-decoy';

const decoy = createDecoy({
  secret: process.env.DECOY_SECRET,          // keep it OUT of your database
  host: 'api.example.com',
  onEvent: (e) => alertMe(e),                // { kind, severity, ip, path, ... }
});

app.use(middleware(decoy, { checkToken: async (t) => !!(await lookUp(t)) }));

const { token } = decoy.mint('planted in the Q3 board doc');   // a canary to plant

guarded: (path) => boolean limits the fake world for flagged addresses to the paths that hand out data, so sign-in pages stay real for people sharing an address.

Personal links and permanent bans (1.4). Pass beaconBase (and optionally hopUrl, an offsite page such as a Google Apps Script web app). Every lure then carries links unique to that visitor. Following one from any address ties that address to the visitor, and both are banned. Bans also follow a canary use, a private trap hit, or a high trap score. neverBan(ip) protects addresses you trust, such as ones that recently used a valid token.

Bring your own store (add banned/ban/remember/recall for bans and links) for multi-instance deployments (get(ip), bump(ip, { weight, flagMinutes, distinct })); memoryStore() is included.

Built for and running on 0n3.

版本与发布记录

0n-decoy 共发布 6 个版本,首次发布于 2026/10/29;过去 12 个月发布了 6 个版本。

版本发布日期距今
1.4.0latest2026/10/295 天前
1.3.02026/10/295 天前
1.2.02026/10/295 天前
1.1.02026/10/295 天前
1.0.02026/10/295 天前
0.0.0-stage2026/10/295 天前

关于 0n-decoy 的常见问题

0n-decoy 是什么?

对AI代理和扫描仪攻击的api进行欺骗:蜂蜜路径、自我验证的金丝雀令牌、可信的假世界、tarpits和警报。从0 n3。

如何安装 0n-decoy?

在项目目录运行 npm install 0n-decoy,或使用 pnpm add / yarn add / bun add。

0n-decoy 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/0n-decoy 是否存在。

0n-decoy 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

0n-decoy 需要什么版本的 Node.js?

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

0n-decoy 可以商用吗?

0n-decoy 使用 BUSL-1.1 许可。声明的许可为 BUSL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

0n-decoy 还在维护吗?

最新版本 1.4.0 发布于 2026/10/29(5 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/10/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。