@diap/sdk 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/package.json +66 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 DIAP SDK Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # DIAP TypeScript SDK
2
+
3
+ 基于零知识证明的去中心化智能体身份协议 TypeScript SDK。
4
+
5
+ 这是 DIAP Rust SDK 的 TypeScript 翻译版本,保持相同的功能逻辑和 API 设计,但使用 TypeScript/Node.js 生态系统的依赖。
6
+
7
+ ## 功能特性
8
+
9
+ - 🔐 密钥管理:Ed25519 密钥对生成、存储和管理
10
+ - 🌐 IPFS 集成:轻量级 Helia 客户端,支持文件上传和检索
11
+ - 🆔 DID 构建:符合 W3C 规范的 DID 文档构建和发布
12
+ - 🔒 零知识证明:基于 o1js 的 ZKP 证明生成和验证
13
+ - 🤖 智能体认证:完整的身份注册和验证流程
14
+ - 🌍 libp2p 网络:点对点网络通信支持
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ npm install @diap/sdk
20
+ ```
21
+
22
+ ### Windows 用户注意事项
23
+
24
+ 如果在 Windows 上遇到安装问题,请参考 [INSTALL.md](./INSTALL.md) 获取详细的解决方案。
25
+
26
+ 推荐使用以下命令安装:
27
+
28
+ ```bash
29
+ npm install --legacy-peer-deps
30
+ ```
31
+
32
+ ## 快速开始
33
+
34
+ ```typescript
35
+ import { AgentAuthManager } from '@diap/sdk';
36
+
37
+ async function main() {
38
+ // 创建认证管理器
39
+ const authManager = await AgentAuthManager.new();
40
+
41
+ // 创建智能体
42
+ const { agentInfo, keypair, peerId } = authManager.createAgent('MyAgent');
43
+
44
+ // 注册身份
45
+ const registration = await authManager.registerAgent(agentInfo, keypair, peerId);
46
+ console.log('Agent registered:', registration.did);
47
+ console.log('CID:', registration.cid);
48
+ }
49
+
50
+ main().catch(console.error);
51
+ ```
52
+
53
+ ## 开发
54
+
55
+ ```bash
56
+ # 安装依赖
57
+ npm install
58
+
59
+ # 构建项目
60
+ npm run build
61
+
62
+ # 运行测试
63
+ npm test
64
+
65
+ # 代码检查
66
+ npm run lint
67
+
68
+ # 格式化代码
69
+ npm run format
70
+ ```
71
+
72
+ ## 文档
73
+
74
+ 详细文档请参考:
75
+ - [API 文档](./docs/API.md)
76
+ - [使用指南](./docs/GUIDE.md)
77
+ - [架构文档](./docs/ARCHITECTURE.md)
78
+
79
+ ## 许可证
80
+
81
+ MIT License
82
+
83
+ ## 链接
84
+
85
+ - [Rust SDK](https://github.com/logos-42/DIAP_TS_SDK)
86
+ - [项目主页](https://alou.fun)
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@diap/sdk",
3
+ "version": "0.1.1",
4
+ "description": "DIAP TypeScript SDK - Decentralized Intelligent Agent Protocol",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "test": "vitest",
16
+ "test:watch": "vitest --watch",
17
+ "test:coverage": "vitest --coverage",
18
+ "lint": "eslint src/**/*.ts",
19
+ "lint:fix": "eslint src/**/*.ts --fix",
20
+ "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
21
+ "format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
22
+ "clean": "rm -rf dist",
23
+ "prepublishOnly": "npm run build && npm run test"
24
+ },
25
+ "keywords": [
26
+ "diap",
27
+ "agent",
28
+ "decentralized",
29
+ "p2p",
30
+ "ipfs",
31
+ "zkp",
32
+ "did",
33
+ "hyperswarm",
34
+ "snarkjs"
35
+ ],
36
+ "author": "",
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/logos-42/DIAP-TS-SDK"
41
+ },
42
+ "dependencies": {
43
+ "@noble/ed25519": "^2.0.0",
44
+ "@noble/hashes": "^1.3.0",
45
+ "bs58": "^5.0.0",
46
+ "hyperswarm": "^4.17.0",
47
+ "snarkjs": "^0.7.6",
48
+ "winston": "^3.11.0",
49
+ "node-fetch": "^3.3.2"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^20.10.0",
53
+ "@types/bs58": "^5.0.0",
54
+ "@types/node-fetch": "^2.6.9",
55
+ "typescript": "^5.3.3",
56
+ "vitest": "^1.0.4",
57
+ "@vitest/coverage-v8": "^1.0.4",
58
+ "eslint": "^8.55.0",
59
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
60
+ "@typescript-eslint/parser": "^6.13.0",
61
+ "prettier": "^3.1.0"
62
+ },
63
+ "engines": {
64
+ "node": ">=18.0.0"
65
+ }
66
+ }