@f2a/network 0.1.3 → 0.2.0
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.
- package/README.md +278 -63
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +29 -2
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/config.d.ts +176 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +386 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/daemon.d.ts +54 -0
- package/dist/cli/daemon.d.ts.map +1 -0
- package/dist/cli/daemon.js +572 -0
- package/dist/cli/daemon.js.map +1 -0
- package/dist/cli/index.js +90 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts +13 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +352 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/core/e2ee-crypto.d.ts +127 -1
- package/dist/core/e2ee-crypto.d.ts.map +1 -1
- package/dist/core/e2ee-crypto.js +446 -12
- package/dist/core/e2ee-crypto.js.map +1 -1
- package/dist/core/f2a.d.ts +2 -1
- package/dist/core/f2a.d.ts.map +1 -1
- package/dist/core/f2a.js +6 -2
- package/dist/core/f2a.js.map +1 -1
- package/dist/core/identity/encrypted-key-store.d.ts +19 -0
- package/dist/core/identity/encrypted-key-store.d.ts.map +1 -0
- package/dist/core/identity/encrypted-key-store.js +72 -0
- package/dist/core/identity/encrypted-key-store.js.map +1 -0
- package/dist/core/identity/identity-manager.d.ts +133 -0
- package/dist/core/identity/identity-manager.d.ts.map +1 -0
- package/dist/core/identity/identity-manager.js +454 -0
- package/dist/core/identity/identity-manager.js.map +1 -0
- package/dist/core/identity/index.d.ts +8 -0
- package/dist/core/identity/index.d.ts.map +1 -0
- package/dist/core/identity/index.js +7 -0
- package/dist/core/identity/index.js.map +1 -0
- package/dist/core/identity/types.d.ts +70 -0
- package/dist/core/identity/types.d.ts.map +1 -0
- package/dist/core/identity/types.js +17 -0
- package/dist/core/identity/types.js.map +1 -0
- package/dist/core/p2p-network.d.ts +26 -0
- package/dist/core/p2p-network.d.ts.map +1 -1
- package/dist/core/p2p-network.js +434 -105
- package/dist/core/p2p-network.js.map +1 -1
- package/dist/core/reputation-security.d.ts +15 -0
- package/dist/core/reputation-security.d.ts.map +1 -1
- package/dist/core/reputation-security.js +73 -3
- package/dist/core/reputation-security.js.map +1 -1
- package/dist/core/reputation.d.ts +129 -4
- package/dist/core/reputation.d.ts.map +1 -1
- package/dist/core/reputation.js +294 -1
- package/dist/core/reputation.js.map +1 -1
- package/dist/core/review-committee.d.ts +2 -2
- package/dist/core/review-committee.d.ts.map +1 -1
- package/dist/core/review-committee.js +17 -0
- package/dist/core/review-committee.js.map +1 -1
- package/dist/daemon/control-server.d.ts.map +1 -1
- package/dist/daemon/control-server.js +44 -1
- package/dist/daemon/control-server.js.map +1 -1
- package/dist/daemon/webhook.d.ts +3 -0
- package/dist/daemon/webhook.d.ts.map +1 -1
- package/dist/daemon/webhook.js +318 -6
- package/dist/daemon/webhook.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/result.d.ts +1 -1
- package/dist/types/result.d.ts.map +1 -1
- package/dist/types/result.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +17 -0
- package/dist/utils/crypto-utils.d.ts.map +1 -0
- package/dist/utils/crypto-utils.js +28 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +9 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/rate-limiter.d.ts.map +1 -1
- package/dist/utils/rate-limiter.js +3 -1
- package/dist/utils/rate-limiter.js.map +1 -1
- package/dist/utils/signature.d.ts +47 -1
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +166 -11
- package/dist/utils/signature.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Manager
|
|
3
|
+
* Manages libp2p PeerId (Ed25519) and E2EE key pair (X25519)
|
|
4
|
+
* Persists identity to local filesystem
|
|
5
|
+
*/
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
import { homedir } from 'os';
|
|
9
|
+
import { generateKeyPair, unmarshalPrivateKey, marshalPrivateKey } from '@libp2p/crypto/keys';
|
|
10
|
+
import { peerIdFromKeys } from '@libp2p/peer-id';
|
|
11
|
+
import { x25519 } from '@noble/curves/ed25519.js';
|
|
12
|
+
import { Logger } from '../../utils/logger.js';
|
|
13
|
+
import { success, failure, failureFromError, createError } from '../../types/index.js';
|
|
14
|
+
import { encryptIdentity, decryptIdentity } from './encrypted-key-store.js';
|
|
15
|
+
import { DEFAULT_DATA_DIR, IDENTITY_FILE } from './types.js';
|
|
16
|
+
import { isValidBase64, secureWipe } from '../../utils/crypto-utils.js';
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to validate EncryptedIdentity structure
|
|
19
|
+
* P2 修复:使用类型守卫替代类型断言链
|
|
20
|
+
*/
|
|
21
|
+
function isEncryptedIdentity(obj) {
|
|
22
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const record = obj;
|
|
26
|
+
return (record.encrypted === true &&
|
|
27
|
+
typeof record.salt === 'string' &&
|
|
28
|
+
typeof record.iv === 'string' &&
|
|
29
|
+
typeof record.authTag === 'string' &&
|
|
30
|
+
typeof record.ciphertext === 'string');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Identity Manager
|
|
34
|
+
*
|
|
35
|
+
* Responsibilities:
|
|
36
|
+
* - Manage libp2p PeerId (Ed25519 key pair)
|
|
37
|
+
* - Manage E2EE key pair (X25519)
|
|
38
|
+
* - Persist identity to local filesystem
|
|
39
|
+
* - Support password-encrypted storage
|
|
40
|
+
*/
|
|
41
|
+
export class IdentityManager {
|
|
42
|
+
dataDir;
|
|
43
|
+
password;
|
|
44
|
+
peerId = null;
|
|
45
|
+
privateKey = null;
|
|
46
|
+
e2eePublicKey = null;
|
|
47
|
+
e2eePrivateKey = null;
|
|
48
|
+
createdAt = null;
|
|
49
|
+
logger;
|
|
50
|
+
/** P0 修复:并发锁,防止 loadOrCreate 重复调用 */
|
|
51
|
+
loadPromise = null;
|
|
52
|
+
/** P1-2 修复:exportIdentity 调用计数器,用于频率限制 */
|
|
53
|
+
exportCallCount = 0;
|
|
54
|
+
/** P2 修复:滑动窗口 - 记录所有导出调用的时间戳 */
|
|
55
|
+
exportTimestamps = [];
|
|
56
|
+
/** P2 修复:滑动窗口大小(毫秒)- 1分钟窗口 */
|
|
57
|
+
static EXPORT_WINDOW_MS = 60000;
|
|
58
|
+
/** P2 修复:窗口内最大调用次数 */
|
|
59
|
+
static EXPORT_MAX_IN_WINDOW = 5;
|
|
60
|
+
/** P1-2 修复:exportIdentity 最大调用次数警告阈值 */
|
|
61
|
+
static EXPORT_MAX_CALLS_WARN = 10;
|
|
62
|
+
constructor(options = {}) {
|
|
63
|
+
this.dataDir = options.dataDir || join(homedir(), DEFAULT_DATA_DIR);
|
|
64
|
+
this.password = options.password;
|
|
65
|
+
this.logger = new Logger({ component: 'Identity' });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get identity data file path
|
|
69
|
+
*/
|
|
70
|
+
getIdentityFilePath() {
|
|
71
|
+
return join(this.dataDir, IDENTITY_FILE);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Ensure data directory exists with secure permissions
|
|
75
|
+
*/
|
|
76
|
+
async ensureDataDir() {
|
|
77
|
+
try {
|
|
78
|
+
await fs.mkdir(this.dataDir, { recursive: true });
|
|
79
|
+
// Set directory permissions to 700 (owner only)
|
|
80
|
+
await fs.chmod(this.dataDir, 0o700);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
this.logger.error('Failed to create data directory', { error });
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Load or create identity
|
|
89
|
+
*
|
|
90
|
+
* - If identity file exists, load it
|
|
91
|
+
* - If not, create new identity
|
|
92
|
+
* - P0 修复:添加并发保护,防止重复调用
|
|
93
|
+
* - P1 修复:已加载时直接返回现有身份
|
|
94
|
+
*/
|
|
95
|
+
async loadOrCreate() {
|
|
96
|
+
// P1 修复:如果已加载,直接返回现有身份
|
|
97
|
+
if (this.isLoaded()) {
|
|
98
|
+
return success(this.exportIdentityInternal());
|
|
99
|
+
}
|
|
100
|
+
// P0 修复:并发保护 - 如果正在加载,等待现有操作完成
|
|
101
|
+
if (this.loadPromise) {
|
|
102
|
+
return this.loadPromise;
|
|
103
|
+
}
|
|
104
|
+
// 创建新的加载操作
|
|
105
|
+
this.loadPromise = this.doLoadOrCreate();
|
|
106
|
+
try {
|
|
107
|
+
const result = await this.loadPromise;
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
// 清除锁,允许后续调用
|
|
112
|
+
this.loadPromise = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 实际的加载或创建逻辑(内部方法)
|
|
117
|
+
*/
|
|
118
|
+
async doLoadOrCreate() {
|
|
119
|
+
try {
|
|
120
|
+
await this.ensureDataDir();
|
|
121
|
+
const identityFile = this.getIdentityFilePath();
|
|
122
|
+
try {
|
|
123
|
+
// Try to read existing identity
|
|
124
|
+
const data = await fs.readFile(identityFile, 'utf-8');
|
|
125
|
+
// P1 修复:安全解析 JSON,处理文件损坏
|
|
126
|
+
let parsed;
|
|
127
|
+
try {
|
|
128
|
+
parsed = JSON.parse(data);
|
|
129
|
+
}
|
|
130
|
+
catch (parseError) {
|
|
131
|
+
this.logger.error('Identity file is corrupted - invalid JSON', {
|
|
132
|
+
error: parseError instanceof Error ? parseError.message : String(parseError)
|
|
133
|
+
});
|
|
134
|
+
return failure(createError('IDENTITY_CORRUPTED', 'Identity file is corrupted and cannot be parsed. The file may need to be deleted and a new identity created.'));
|
|
135
|
+
}
|
|
136
|
+
// P1 修复:类型安全检查 - 验证解析结果是否为有效对象
|
|
137
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
138
|
+
this.logger.error('Identity file is corrupted - not an object');
|
|
139
|
+
return failure(createError('IDENTITY_CORRUPTED', 'Identity file is corrupted: invalid data structure.'));
|
|
140
|
+
}
|
|
141
|
+
// Check if file is encrypted
|
|
142
|
+
const parsedObj = parsed;
|
|
143
|
+
// P2 修复:类型守卫验证 - 检查 encrypted 字段是否为布尔值
|
|
144
|
+
const encryptedValue = parsedObj.encrypted;
|
|
145
|
+
const isEncrypted = typeof encryptedValue === 'boolean' && encryptedValue === true;
|
|
146
|
+
if (isEncrypted) {
|
|
147
|
+
// File is encrypted, password is required
|
|
148
|
+
if (this.password === undefined || this.password === '') {
|
|
149
|
+
this.logger.error('Identity file is encrypted but no password provided');
|
|
150
|
+
return failure(createError('IDENTITY_PASSWORD_REQUIRED', 'Identity file is encrypted but no password was provided. Please provide a password to decrypt.'));
|
|
151
|
+
}
|
|
152
|
+
// Attempt decryption
|
|
153
|
+
try {
|
|
154
|
+
// P2 修复:使用类型守卫验证 EncryptedIdentity 结构
|
|
155
|
+
if (!isEncryptedIdentity(parsedObj)) {
|
|
156
|
+
this.logger.error('Identity file is corrupted - invalid encrypted identity structure');
|
|
157
|
+
return failure(createError('IDENTITY_CORRUPTED', 'Identity file is corrupted: invalid encrypted identity structure.'));
|
|
158
|
+
}
|
|
159
|
+
const persisted = decryptIdentity(parsedObj, this.password);
|
|
160
|
+
await this.loadPersistedIdentity(persisted);
|
|
161
|
+
// Update last used time
|
|
162
|
+
await this.saveIdentity();
|
|
163
|
+
this.logger.info('Loaded existing encrypted identity', {
|
|
164
|
+
peerId: this.peerId?.toString().slice(0, 16),
|
|
165
|
+
createdAt: this.createdAt?.toISOString()
|
|
166
|
+
});
|
|
167
|
+
return success(this.exportIdentityInternal());
|
|
168
|
+
}
|
|
169
|
+
catch (decryptError) {
|
|
170
|
+
this.logger.error('Failed to decrypt identity with provided password', {
|
|
171
|
+
error: decryptError instanceof Error ? decryptError.message : String(decryptError)
|
|
172
|
+
});
|
|
173
|
+
return failure(createError('IDENTITY_DECRYPT_FAILED', 'Failed to decrypt identity. The password may be incorrect.'));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Plaintext identity data (backward compatible)
|
|
177
|
+
const persisted = parsed;
|
|
178
|
+
await this.loadPersistedIdentity(persisted);
|
|
179
|
+
// Update last used time
|
|
180
|
+
await this.saveIdentity();
|
|
181
|
+
this.logger.info('Loaded existing plaintext identity', {
|
|
182
|
+
peerId: this.peerId?.toString().slice(0, 16),
|
|
183
|
+
createdAt: this.createdAt?.toISOString()
|
|
184
|
+
});
|
|
185
|
+
// Warn about plaintext storage
|
|
186
|
+
this.logger.warn('Identity is stored in plaintext. Consider setting a password for encryption.');
|
|
187
|
+
return success(this.exportIdentityInternal());
|
|
188
|
+
}
|
|
189
|
+
catch (readError) {
|
|
190
|
+
// File doesn't exist or parse failed, create new identity
|
|
191
|
+
if (readError.code === 'ENOENT') {
|
|
192
|
+
this.logger.info('No existing identity found, creating new one');
|
|
193
|
+
return await this.createNewIdentity();
|
|
194
|
+
}
|
|
195
|
+
throw readError;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return failureFromError('IDENTITY_LOAD_FAILED', 'Failed to load or create identity', error);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Load identity from persisted data
|
|
204
|
+
*/
|
|
205
|
+
async loadPersistedIdentity(persisted) {
|
|
206
|
+
// P4 修复:验证字段是否为有效的 base64
|
|
207
|
+
if (!isValidBase64(persisted.peerId)) {
|
|
208
|
+
throw new Error('Invalid persisted identity: peerId is not valid base64');
|
|
209
|
+
}
|
|
210
|
+
if (!isValidBase64(persisted.e2eePrivateKey)) {
|
|
211
|
+
throw new Error('Invalid persisted identity: e2eePrivateKey is not valid base64');
|
|
212
|
+
}
|
|
213
|
+
if (!isValidBase64(persisted.e2eePublicKey)) {
|
|
214
|
+
throw new Error('Invalid persisted identity: e2eePublicKey is not valid base64');
|
|
215
|
+
}
|
|
216
|
+
// Restore private key and PeerId
|
|
217
|
+
const privateKeyBytes = Buffer.from(persisted.peerId, 'base64');
|
|
218
|
+
this.privateKey = await unmarshalPrivateKey(privateKeyBytes);
|
|
219
|
+
this.peerId = await peerIdFromKeys(this.privateKey.public.bytes, this.privateKey.bytes);
|
|
220
|
+
// Securely wipe temporary private key bytes after use
|
|
221
|
+
secureWipe(privateKeyBytes);
|
|
222
|
+
// Restore E2EE key pair
|
|
223
|
+
this.e2eePrivateKey = Buffer.from(persisted.e2eePrivateKey, 'base64');
|
|
224
|
+
this.e2eePublicKey = Buffer.from(persisted.e2eePublicKey, 'base64');
|
|
225
|
+
// P1-1 修复:验证 createdAt 日期格式有效性
|
|
226
|
+
const parsedDate = new Date(persisted.createdAt);
|
|
227
|
+
if (isNaN(parsedDate.getTime())) {
|
|
228
|
+
throw new Error('Invalid persisted identity: createdAt is not a valid date format');
|
|
229
|
+
}
|
|
230
|
+
this.createdAt = parsedDate;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Create new identity
|
|
234
|
+
*/
|
|
235
|
+
async createNewIdentity() {
|
|
236
|
+
try {
|
|
237
|
+
// Generate Ed25519 key pair for libp2p PeerId
|
|
238
|
+
this.privateKey = await generateKeyPair('Ed25519');
|
|
239
|
+
this.peerId = await peerIdFromKeys(this.privateKey.public.bytes, this.privateKey.bytes);
|
|
240
|
+
// Generate X25519 key pair for E2EE
|
|
241
|
+
this.e2eePrivateKey = x25519.utils.randomSecretKey();
|
|
242
|
+
this.e2eePublicKey = x25519.getPublicKey(this.e2eePrivateKey);
|
|
243
|
+
this.createdAt = new Date();
|
|
244
|
+
// Save identity
|
|
245
|
+
await this.saveIdentity();
|
|
246
|
+
this.logger.info('Created new identity', {
|
|
247
|
+
peerId: this.peerId.toString().slice(0, 16),
|
|
248
|
+
createdAt: this.createdAt.toISOString()
|
|
249
|
+
});
|
|
250
|
+
return success(this.exportIdentityInternal());
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
return failureFromError('IDENTITY_CREATE_FAILED', 'Failed to create new identity', error);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Save identity to file
|
|
258
|
+
*/
|
|
259
|
+
async saveIdentity() {
|
|
260
|
+
if (!this.privateKey || !this.peerId || !this.e2eePrivateKey || !this.e2eePublicKey || !this.createdAt) {
|
|
261
|
+
throw new Error('Identity not initialized');
|
|
262
|
+
}
|
|
263
|
+
const persisted = {
|
|
264
|
+
peerId: Buffer.from(marshalPrivateKey(this.privateKey)).toString('base64'),
|
|
265
|
+
e2eePrivateKey: Buffer.from(this.e2eePrivateKey).toString('base64'),
|
|
266
|
+
e2eePublicKey: Buffer.from(this.e2eePublicKey).toString('base64'),
|
|
267
|
+
createdAt: this.createdAt.toISOString(),
|
|
268
|
+
lastUsedAt: new Date().toISOString()
|
|
269
|
+
};
|
|
270
|
+
// Medium 修复:提取公共文件写入逻辑,避免重复代码
|
|
271
|
+
const shouldEncrypt = this.password !== undefined && this.password !== '';
|
|
272
|
+
if (!shouldEncrypt) {
|
|
273
|
+
// Warn about plaintext storage
|
|
274
|
+
this.logger.warn('Saving identity without encryption. Consider setting a password for better security.');
|
|
275
|
+
}
|
|
276
|
+
const data = shouldEncrypt
|
|
277
|
+
? JSON.stringify(encryptIdentity(persisted, this.password))
|
|
278
|
+
: JSON.stringify(persisted, null, 2);
|
|
279
|
+
await this.writeIdentityFile(data);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 写入身份文件(内部方法)
|
|
283
|
+
* @param data 要写入的数据
|
|
284
|
+
*/
|
|
285
|
+
async writeIdentityFile(data) {
|
|
286
|
+
const identityFile = this.getIdentityFilePath();
|
|
287
|
+
await fs.writeFile(identityFile, data, 'utf-8');
|
|
288
|
+
// Set file permissions to 600 (owner only)
|
|
289
|
+
await fs.chmod(identityFile, 0o600);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Export identity information (internal version, no rate limiting)
|
|
293
|
+
* 用于内部调用,不触发频率限制和审计日志
|
|
294
|
+
*/
|
|
295
|
+
exportIdentityInternal() {
|
|
296
|
+
if (!this.peerId || !this.privateKey || !this.e2eePublicKey || !this.e2eePrivateKey || !this.createdAt) {
|
|
297
|
+
throw new Error('Identity not initialized');
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
peerId: this.peerId.toString(),
|
|
301
|
+
privateKey: Buffer.from(marshalPrivateKey(this.privateKey)).toString('base64'),
|
|
302
|
+
e2eeKeyPair: {
|
|
303
|
+
publicKey: Buffer.from(this.e2eePublicKey).toString('base64'),
|
|
304
|
+
privateKey: Buffer.from(this.e2eePrivateKey).toString('base64')
|
|
305
|
+
},
|
|
306
|
+
createdAt: this.createdAt
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Export identity information
|
|
311
|
+
*
|
|
312
|
+
* WARNING: This returns sensitive private key material in plaintext.
|
|
313
|
+
* - Do not log or expose the returned data
|
|
314
|
+
* - Clear from memory when no longer needed
|
|
315
|
+
* - Only call when absolutely necessary
|
|
316
|
+
*
|
|
317
|
+
* P1-2 修复:添加调用频率限制和审计日志
|
|
318
|
+
* P2 修复:实现滑动窗口限制,防止频率限制绕过
|
|
319
|
+
*/
|
|
320
|
+
exportIdentity() {
|
|
321
|
+
if (!this.peerId || !this.privateKey || !this.e2eePublicKey || !this.e2eePrivateKey || !this.createdAt) {
|
|
322
|
+
throw new Error('Identity not initialized');
|
|
323
|
+
}
|
|
324
|
+
// P2 修复:滑动窗口频率限制
|
|
325
|
+
const now = Date.now();
|
|
326
|
+
// 1. 清理过期的时间戳(超过60秒窗口的)
|
|
327
|
+
this.exportTimestamps = this.exportTimestamps.filter(timestamp => now - timestamp < IdentityManager.EXPORT_WINDOW_MS);
|
|
328
|
+
// 2. 检查当前窗口内的调用次数
|
|
329
|
+
if (this.exportTimestamps.length >= IdentityManager.EXPORT_MAX_IN_WINDOW) {
|
|
330
|
+
const oldestInWindow = this.exportTimestamps[0];
|
|
331
|
+
const retryAfterMs = IdentityManager.EXPORT_WINDOW_MS - (now - oldestInWindow);
|
|
332
|
+
const retryAfterSec = Math.ceil(retryAfterMs / 1000);
|
|
333
|
+
this.logger.warn('SECURITY: exportIdentity rate limit exceeded', {
|
|
334
|
+
callCountInWindow: this.exportTimestamps.length,
|
|
335
|
+
maxAllowed: IdentityManager.EXPORT_MAX_IN_WINDOW,
|
|
336
|
+
retryAfterSeconds: retryAfterSec
|
|
337
|
+
});
|
|
338
|
+
throw new Error(`exportIdentity rate limit exceeded. Maximum ${IdentityManager.EXPORT_MAX_IN_WINDOW} calls per minute. ` +
|
|
339
|
+
`Please try again in ${retryAfterSec} seconds.`);
|
|
340
|
+
}
|
|
341
|
+
// 3. 记录本次调用时间戳
|
|
342
|
+
this.exportTimestamps.push(now);
|
|
343
|
+
// P1-2 修复:审计日志 - 记录敏感操作
|
|
344
|
+
this.exportCallCount++;
|
|
345
|
+
this.logger.warn('SECURITY: exportIdentity called - private key material exported', {
|
|
346
|
+
peerId: this.peerId.toString().slice(0, 16),
|
|
347
|
+
callCount: this.exportCallCount,
|
|
348
|
+
callsInWindow: this.exportTimestamps.length,
|
|
349
|
+
timestamp: new Date().toISOString()
|
|
350
|
+
});
|
|
351
|
+
// P1-2 修复:调用次数警告
|
|
352
|
+
if (this.exportCallCount >= IdentityManager.EXPORT_MAX_CALLS_WARN) {
|
|
353
|
+
this.logger.warn('SECURITY: exportIdentity has been called many times', {
|
|
354
|
+
callCount: this.exportCallCount,
|
|
355
|
+
warning: 'Frequent exports of private key material may indicate a security issue'
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
peerId: this.peerId.toString(),
|
|
360
|
+
privateKey: Buffer.from(marshalPrivateKey(this.privateKey)).toString('base64'),
|
|
361
|
+
e2eeKeyPair: {
|
|
362
|
+
publicKey: Buffer.from(this.e2eePublicKey).toString('base64'),
|
|
363
|
+
privateKey: Buffer.from(this.e2eePrivateKey).toString('base64')
|
|
364
|
+
},
|
|
365
|
+
createdAt: this.createdAt
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Get PeerId
|
|
370
|
+
*/
|
|
371
|
+
getPeerId() {
|
|
372
|
+
return this.peerId;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get PeerId string
|
|
376
|
+
*/
|
|
377
|
+
getPeerIdString() {
|
|
378
|
+
return this.peerId?.toString() || null;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Get libp2p private key
|
|
382
|
+
*/
|
|
383
|
+
getPrivateKey() {
|
|
384
|
+
return this.privateKey;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get E2EE key pair
|
|
388
|
+
*
|
|
389
|
+
* @敏感 此方法返回敏感的私钥材料
|
|
390
|
+
* - 不要记录或暴露返回的数据
|
|
391
|
+
* - 使用完毕后从内存中清除
|
|
392
|
+
* - 仅在必要时调用
|
|
393
|
+
*/
|
|
394
|
+
getE2EEKeyPair() {
|
|
395
|
+
if (!this.e2eePublicKey || !this.e2eePrivateKey)
|
|
396
|
+
return null;
|
|
397
|
+
return {
|
|
398
|
+
publicKey: this.e2eePublicKey,
|
|
399
|
+
privateKey: this.e2eePrivateKey
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Get E2EE public key (base64)
|
|
404
|
+
*/
|
|
405
|
+
getE2EEPublicKeyBase64() {
|
|
406
|
+
return this.e2eePublicKey ? Buffer.from(this.e2eePublicKey).toString('base64') : null;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Check if identity is fully loaded
|
|
410
|
+
*/
|
|
411
|
+
isLoaded() {
|
|
412
|
+
return (this.peerId !== null &&
|
|
413
|
+
this.privateKey !== null &&
|
|
414
|
+
this.e2eePublicKey !== null &&
|
|
415
|
+
this.e2eePrivateKey !== null &&
|
|
416
|
+
this.createdAt !== null);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Delete identity file and securely wipe memory (dangerous operation)
|
|
420
|
+
*/
|
|
421
|
+
async deleteIdentity() {
|
|
422
|
+
try {
|
|
423
|
+
const identityFile = this.getIdentityFilePath();
|
|
424
|
+
await fs.unlink(identityFile);
|
|
425
|
+
// Securely wipe private key data from memory
|
|
426
|
+
if (this.e2eePrivateKey) {
|
|
427
|
+
secureWipe(this.e2eePrivateKey);
|
|
428
|
+
}
|
|
429
|
+
// Securely wipe libp2p Ed25519 private key bytes
|
|
430
|
+
if (this.privateKey) {
|
|
431
|
+
// Access the raw bytes of the Ed25519 private key and wipe them
|
|
432
|
+
const privateKeyBytes = this.privateKey.bytes;
|
|
433
|
+
if (privateKeyBytes) {
|
|
434
|
+
secureWipe(privateKeyBytes);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// Clear all identity data from memory
|
|
438
|
+
this.peerId = null;
|
|
439
|
+
this.privateKey = null;
|
|
440
|
+
this.e2eePublicKey = null;
|
|
441
|
+
this.e2eePrivateKey = null;
|
|
442
|
+
this.createdAt = null;
|
|
443
|
+
this.logger.warn('Identity deleted and memory cleared');
|
|
444
|
+
return success(undefined);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
if (error.code === 'ENOENT') {
|
|
448
|
+
return success(undefined);
|
|
449
|
+
}
|
|
450
|
+
return failureFromError('IDENTITY_DELETE_FAILED', 'Failed to delete identity', error);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
//# sourceMappingURL=identity-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-manager.js","sourceRoot":"","sources":["../../../src/core/identity/identity-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAU,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO5E,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;GAGG;AACH,SAAS,mBAAmB,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,OAAO,CACL,MAAM,CAAC,SAAS,KAAK,IAAI;QACzB,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,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C;gBACxB,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,CAAC;YAED,iDAAiD;YACjD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,gEAAgE;gBAChE,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;gBAC9C,IAAI,eAAe,EAAE,CAAC;oBACpB,UAAU,CAAC,eAAe,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;YAED,sCAAsC;YACtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YAEtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,gBAAgB,CAAC,wBAAwB,EAAE,2BAA2B,EAAE,KAAc,CAAC,CAAC;QACjG,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 身份管理模块导出
|
|
3
|
+
*/
|
|
4
|
+
export { IdentityManager } from './identity-manager.js';
|
|
5
|
+
export { encryptIdentity, decryptIdentity } from './encrypted-key-store.js';
|
|
6
|
+
export type { PersistedIdentity, IdentityManagerOptions, ExportedIdentity, EncryptedIdentity } from './types.js';
|
|
7
|
+
export { DEFAULT_DATA_DIR, IDENTITY_FILE, AES_KEY_SIZE, AES_IV_SIZE, AES_TAG_SIZE } from './types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 身份管理模块导出
|
|
3
|
+
*/
|
|
4
|
+
export { IdentityManager } from './identity-manager.js';
|
|
5
|
+
export { encryptIdentity, decryptIdentity } from './encrypted-key-store.js';
|
|
6
|
+
export { DEFAULT_DATA_DIR, IDENTITY_FILE, AES_KEY_SIZE, AES_IV_SIZE, AES_TAG_SIZE } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO5E,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity manager type definitions
|
|
3
|
+
*/
|
|
4
|
+
/** AES-256-GCM parameters */
|
|
5
|
+
export declare const AES_KEY_SIZE = 32;
|
|
6
|
+
export declare const AES_IV_SIZE = 12;
|
|
7
|
+
export declare const AES_TAG_SIZE = 16;
|
|
8
|
+
/** Scrypt parameters for key derivation */
|
|
9
|
+
export declare const SCRYPT_N = 16384;
|
|
10
|
+
export declare const SCRYPT_R = 8;
|
|
11
|
+
export declare const SCRYPT_P = 1;
|
|
12
|
+
/** Salt size for key derivation */
|
|
13
|
+
export declare const SALT_SIZE = 16;
|
|
14
|
+
/** Data directory */
|
|
15
|
+
export declare const DEFAULT_DATA_DIR = ".f2a";
|
|
16
|
+
export declare const IDENTITY_FILE = "identity.json";
|
|
17
|
+
/**
|
|
18
|
+
* Persisted identity data structure
|
|
19
|
+
*/
|
|
20
|
+
export interface PersistedIdentity {
|
|
21
|
+
/** libp2p PeerId (Ed25519) protobuf encoded (base64) */
|
|
22
|
+
peerId: string;
|
|
23
|
+
/** E2EE private key (X25519, base64) */
|
|
24
|
+
e2eePrivateKey: string;
|
|
25
|
+
/** E2EE public key (X25519, base64) */
|
|
26
|
+
e2eePublicKey: string;
|
|
27
|
+
/** Creation time (ISO string) */
|
|
28
|
+
createdAt: string;
|
|
29
|
+
/** Last used time (ISO string) */
|
|
30
|
+
lastUsedAt: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Identity configuration options
|
|
34
|
+
*/
|
|
35
|
+
export interface IdentityManagerOptions {
|
|
36
|
+
/** Data directory (default ~/.f2a/) */
|
|
37
|
+
dataDir?: string;
|
|
38
|
+
/** Encryption password (optional, for encrypted storage) */
|
|
39
|
+
password?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Exported identity information
|
|
43
|
+
*
|
|
44
|
+
* WARNING: This contains sensitive private key material.
|
|
45
|
+
* Handle with care and avoid logging or exposing this data.
|
|
46
|
+
*/
|
|
47
|
+
export interface ExportedIdentity {
|
|
48
|
+
/** PeerId string */
|
|
49
|
+
peerId: string;
|
|
50
|
+
/** libp2p private key (protobuf encoded, base64) - SENSITIVE */
|
|
51
|
+
privateKey: string;
|
|
52
|
+
/** E2EE key pair */
|
|
53
|
+
e2eeKeyPair: {
|
|
54
|
+
publicKey: string;
|
|
55
|
+
privateKey: string;
|
|
56
|
+
};
|
|
57
|
+
/** Creation time */
|
|
58
|
+
createdAt: Date;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Encrypted identity data structure
|
|
62
|
+
*/
|
|
63
|
+
export interface EncryptedIdentity {
|
|
64
|
+
encrypted: true;
|
|
65
|
+
salt: string;
|
|
66
|
+
iv: string;
|
|
67
|
+
authTag: string;
|
|
68
|
+
ciphertext: string;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/identity/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6BAA6B;AAC7B,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,2CAA2C;AAC3C,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,eAAO,MAAM,QAAQ,IAAI,CAAC;AAE1B,mCAAmC;AACnC,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,qBAAqB;AACrB,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,WAAW,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,oBAAoB;IACpB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity manager type definitions
|
|
3
|
+
*/
|
|
4
|
+
/** AES-256-GCM parameters */
|
|
5
|
+
export const AES_KEY_SIZE = 32;
|
|
6
|
+
export const AES_IV_SIZE = 12;
|
|
7
|
+
export const AES_TAG_SIZE = 16;
|
|
8
|
+
/** Scrypt parameters for key derivation */
|
|
9
|
+
export const SCRYPT_N = 16384; // CPU/memory cost parameter (default, ~64MB memory)
|
|
10
|
+
export const SCRYPT_R = 8; // Block size
|
|
11
|
+
export const SCRYPT_P = 1; // Parallelization parameter
|
|
12
|
+
/** Salt size for key derivation */
|
|
13
|
+
export const SALT_SIZE = 16;
|
|
14
|
+
/** Data directory */
|
|
15
|
+
export const DEFAULT_DATA_DIR = '.f2a';
|
|
16
|
+
export const IDENTITY_FILE = 'identity.json';
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/identity/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6BAA6B;AAC7B,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,2CAA2C;AAC3C,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,oDAAoD;AACnF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAK,aAAa;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAK,4BAA4B;AAE3D,mCAAmC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAE5B,qBAAqB;AACrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC"}
|