@pengzi/kms 1.3.2 → 1.3.3

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 (2) hide show
  1. package/README.md +23 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -67,7 +67,29 @@ kms
67
67
 
68
68
  详细 CLI 使用说明请查看:[CLI 工具指南](./docs/guides/cli-guide.md)
69
69
 
70
- ### 方式 2: 使用 Node.js SDK
70
+ ### 方式 3: 极简 API(推荐 SDK 使用)
71
+
72
+ ```typescript
73
+ import { KMSClient } from '@pengzi/kms';
74
+
75
+ const kms = new KMSClient({
76
+ connectionString: 'mongodb://localhost:27017',
77
+ databaseName: 'kms',
78
+ defaultProjectName: 'my-app', // 配置默认项目
79
+ masterPassword: 'MyPassword123!' // 配置主密码
80
+ });
81
+
82
+ await kms.connect();
83
+
84
+ // 设置密钥(项目不存在自动创建)
85
+ await kms.setKey('api-key', 'secret123');
86
+
87
+ // 获取密钥(返回解密后的字符串)
88
+ const value = await kms.getKey('api-key');
89
+ console.log(value); // 'secret123'
90
+ ```
91
+
92
+ ### 方式 2: 使用 Node.js SDK(完整版)
71
93
 
72
94
  #### 1. 初始化客户端
73
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pengzi/kms",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "High-security Key Management System for Node.js applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",