acdp——节点.js SDK
紧紧的NAPI - rs 绑起 acdp
鲁斯特图书馆. 执行生产者和消费者方面关于
代理上下文分发协议——0.1.0-0.0. 最后线加
RFC-ACDP-0016 外部锚;参见 spec's
版本矩阵 确切地说
哪个协议行每个发布工具。 HTTP被故意留给
呼叫者,把这个配给 fetch 编号 : undici 用于运输.
软件包以同一版本发布
acdp 货箱.
安装
npm install @agentcontextdistributionprotocol/acdp
为macOS(x64/arm64)和Linux出版预建的本地二进制 (x64/arm64-gnu);加载器包在安装时选择正确的一个.
要求数 22号节点或更新 (单位:千美元)engines.node: ">=22"; 节点 20 是
后被降入0.15.1级. CI测试节点22和24.
安装( 开发)
package-lock.json 已执行; 使用 npm ci (如CI所做的) 精确安装
包括准确的 @napi-rs/cli 版本——它失败
而不是默默地重新解决 package.json 锁文件不同意.
npm ci # installs @napi-rs/cli from the lockfile
npm run build:debug # produces index.js + acdp.<platform>.node
node --test tests/*.mjs # in-process unit tests, no HTTP
构建释放二进制
npm run build # release mode (LTO + strip)
快速启动
import { AcdpProducer, AcdpVerifier } from '@agentcontextdistributionprotocol/acdp';
const producer = AcdpProducer.generate(
'did:web:agents.example.com:my-agent',
'did:web:agents.example.com:my-agent#key-1',
);
const raw = producer.buildPublishRequest({
title: 'Q1 snapshot',
contextType: 'data_snapshot',
summary: 'Quarter-end inventory',
});
// POST `raw` (the JSON string) to your registry's /contexts endpoint.
// On retrieve:
const body = (await response.json()).body;
AcdpVerifier.verifyContentHash(JSON.stringify(body), body.content_hash);
AcdpVerifier.verifySignature(
pubKeyB64, // resolved from the producer's did:web doc
body.signature.value,
body.content_hash,
);
校验取回的正文
ctx_id 登记并列入RFC-ACDP-0001§5.7排除条款
设定,所以它被剥去之前 content_hash 两者都是计算出来的
重新计算上面, 或制作人的签名覆盖它。 没有
明确比较,登记处可为任何其他有效签字机构服务
由同一生产商根据 ctx_id 您想要的 URL, 以及每个
上面的检查还是会过去的 打电话 verifyCtxIdBinding 缩小这一差距
(RFC-ACDP-0006 第4.1节,步骤7,规范):
// Argument order matters: `bodyJson` carries the *served* ctx_id,
// `expectedCtxId` is the one you requested.
AcdpVerifier.verifyCtxIdBinding(JSON.stringify(body), requestedCtxId);
像其他人一样 AcdpVerifier 布尔表面, 此返回 true 打开
成功和失败——永远不会 false 这样啊
if (AcdpVerifier.verifyCtxIdBinding(...)) 守卫一个不可能的分行
已经到达.
核实登记收据
verifyReceipt (RFC-ACDP-0010 第8节) bodyJson 作为
所需经费 第二个论点——它约束收据 lineage_id, (中文(简体) ),
origin_registry,以及 created_at (第8节)
步骤 3 :
AcdpVerifier.verifyReceipt(
receiptJson, // the `registry_receipt` object, as received
bodyJson, // the accompanying `body`, same retrieval
registryPublicKeyB64, // resolved via AcdpDid.webToUrl + fetch
expectedCtxId, // the ctx_id you actually requested
recomputedBodyHash, // YOUR OWN verifyContentHash result — never
// the body's echoed content_hash field
producerKeyFingerprint, // fingerprint of the resolved producer key
);
扔出一个畸形 bodyJson (主机输入)或身体/接收不匹配
(核查失败)同样——从未 false还有两张支票
HOST的义务,因为两者都不需要身体:服务机构
装订( a)receipt.registry_did 必须等于您实际的权威
从那里取来,然后用你所递归的躯干来补偿.
核查表面
AcdpVerifier 涵盖除基本内容外的全部核查表面
以上: 身份约束(verifyCtxIdBinding,参见
校验取回的正文 页:1,
离线 did:key 核查verifyBodyOffline, (中文(简体) ),
verifyPublishRequestOffline),登记收据
(单位:千美元)verifyReceipt(receiptJson, bodyJson, registryPublicKeyB64, expectedCtxId, recomputedBodyHash, producerKeyFingerprint), (中文(简体) ),
见 核实登记收据 以上;
verifyLineageHeadReceipt),透明度记录(verifyLogCheckpoint, (中文(简体) ),
verifyLogInclusion, (中文(简体) ), verifyLogConsistency),生命周期事件
(单位:千美元)verifyLifecycleEvent),键撤销(parseKeyRevocation, (中文(简体) ),
classifyUnderRevocation和见证的盟誓
(单位:千美元)buildWitnessCosignature, (中文(简体) ), verifyWitnessCosignature, (中文(简体) ),
evaluateWitnessQuorum) (中文(简体) ). AcdpP256Producer, (中文(简体) ), AcdpDid, (中文(简体) ),
AcdpDidDocument, (中文(简体) ), AcdpCanonicalizer, (中文(简体) ), AcdpMerkle,以及 AcdpSsrfPolicy
也被导出.
设计规则
- JSON穿越FFI边界. 每一种方法都接受并返回 JSON弦——从来不是Rust型,你也不会是JS级的 发送前必须序列化.
- (原始内容存档于2017-09-21). Crypto in Rust, HTTP in JS. 键生成器,JCS + SHA-256活塞,
Ed25519 签字,签字核查在下面
acdp货箱。 运输、退货和观察都是你的. AcdpProducer存储了32字节种子. 鲁斯特SigningKey实值ZeroizeOnDrop没有Clone,所以绑定重建签名 键.- 黄金矢量等同.
golden content_hash + signature match sig-001刺穿JS边content_hash财务报告和审定财务报表signature.value反光谱sig-001固定- 相同的常数 Rust 套房声称。 两边的漂移就是协议中断.
公众表面
出口类别和方法清单(及其数量)
bindings/interop/expected_surface.json, (中文(简体) ),
通过对等测试执行此软件包 .