@genobank/biofs 1.6.0 โ 1.6.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.
- package/CHANGELOG.md +52 -0
- package/ENHANCEMENT_DOCUMENTATION.md +218 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +30 -5
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/tokenize.js +37 -462
- package/dist/index.js +6 -33
- package/dist/index.js.map +1 -1
- package/dist/lib/ai/classifier.d.ts +10 -0
- package/dist/lib/ai/classifier.js +155 -0
- package/dist/lib/ai/classifier.js.map +1 -0
- package/dist/lib/bioip/collections.js +1 -3
- package/dist/lib/config/constants.d.ts +1 -0
- package/dist/lib/config/constants.js +3 -1
- package/package.json +3 -2
- package/SECURITY_AUDIT_20251010.md +0 -159
- package/dist/commands/tokenize.js.bkp.20251010_022629 +0 -906
- package/dist/index.js.bkp.20251010_045250 +0 -417
|
@@ -84,62 +84,9 @@ async function tokenizeCommand(filePath, options) {
|
|
|
84
84
|
spinner = (0, ora_1.default)(`Step ${currentStep}/${steps}: ๐ค Analyzing content with Claude 3 Haiku for intelligent metadata generation...`).start();
|
|
85
85
|
try {
|
|
86
86
|
// Read file sample for Claude analysis (bioip.js sends first 20 lines)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
// Video files: Extract metadata using ffprobe instead of file contents
|
|
92
|
-
if (fileCategory === 'medical_video') {
|
|
93
|
-
const { exec } = require('child_process');
|
|
94
|
-
const util = require('util');
|
|
95
|
-
const execPromise = util.promisify(exec);
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const { stdout } = await execPromise(`ffprobe -v quiet -print_format json -show_format -show_streams "${absolutePath}"`);
|
|
99
|
-
const metadata = JSON.parse(stdout);
|
|
100
|
-
|
|
101
|
-
// Extract relevant video metadata
|
|
102
|
-
const videoStream = metadata.streams?.find(s => s.codec_type === 'video');
|
|
103
|
-
const audioStream = metadata.streams?.find(s => s.codec_type === 'audio');
|
|
104
|
-
const format = metadata.format;
|
|
105
|
-
|
|
106
|
-
sampleLines = JSON.stringify({
|
|
107
|
-
video: videoStream ? {
|
|
108
|
-
codec: videoStream.codec_name,
|
|
109
|
-
resolution: `${videoStream.width}x${videoStream.height}`,
|
|
110
|
-
fps: eval(videoStream.r_frame_rate),
|
|
111
|
-
duration: parseFloat(videoStream.duration || format.duration),
|
|
112
|
-
bitrate: parseInt(videoStream.bit_rate || format.bit_rate)
|
|
113
|
-
} : null,
|
|
114
|
-
audio: audioStream ? {
|
|
115
|
-
codec: audioStream.codec_name,
|
|
116
|
-
sampleRate: audioStream.sample_rate,
|
|
117
|
-
channels: audioStream.channels
|
|
118
|
-
} : null,
|
|
119
|
-
format: {
|
|
120
|
-
format: format.format_name,
|
|
121
|
-
duration: parseFloat(format.duration),
|
|
122
|
-
size: parseInt(format.size),
|
|
123
|
-
bitrate: parseInt(format.bit_rate)
|
|
124
|
-
}
|
|
125
|
-
}, null, 2);
|
|
126
|
-
} catch (ffprobeError) {
|
|
127
|
-
// If ffprobe fails, fall back to basic file info
|
|
128
|
-
sampleLines = `Video file: ${fileName}\nSize: ${(0, format_1.formatFileSize)(fileSize)}\nFormat: ${fileExt}\nNote: Could not extract video metadata (ffprobe not available or failed)`;
|
|
129
|
-
}
|
|
130
|
-
} else if (fileSize > MAX_SAMPLE_SIZE && (fileExt === '.sqlite' || fileExt === '.db' || fileExt === '.bam')) {
|
|
131
|
-
// Binary files: Read only first 50KB
|
|
132
|
-
const buffer = Buffer.alloc(MAX_SAMPLE_SIZE);
|
|
133
|
-
const fd = await (0, promises_1.open)(absolutePath, 'r');
|
|
134
|
-
await fd.read(buffer, 0, MAX_SAMPLE_SIZE, 0);
|
|
135
|
-
await fd.close();
|
|
136
|
-
sampleLines = buffer.toString('utf-8', 0, Math.min(2000, MAX_SAMPLE_SIZE)); // First 2KB as string
|
|
137
|
-
} else {
|
|
138
|
-
// Text files: Read first 20 lines
|
|
139
|
-
const fileContent = await (0, promises_1.readFile)(absolutePath, { encoding: 'utf-8' });
|
|
140
|
-
const lines = fileContent.split('\n');
|
|
141
|
-
sampleLines = lines.slice(0, 20).join('\n');
|
|
142
|
-
}
|
|
87
|
+
const fileContent = await (0, promises_1.readFile)(absolutePath, { encoding: 'utf-8' });
|
|
88
|
+
const lines = fileContent.split('\n');
|
|
89
|
+
const sampleLines = lines.slice(0, 20).join('\n');
|
|
143
90
|
// Call api_bioip.py /generate_metadata endpoint (uses Claude Haiku) - EXACT bioip.js flow
|
|
144
91
|
const contextData = JSON.stringify({
|
|
145
92
|
fileName: fileName,
|
|
@@ -166,9 +113,9 @@ async function tokenizeCommand(filePath, options) {
|
|
|
166
113
|
let cleanDescription = (aiMetadata.description || 'Biological data for analysis')
|
|
167
114
|
.replace(/^["']+/g, '')
|
|
168
115
|
.replace(/["',]+$/g, '');
|
|
169
|
-
// AI determines title and description - user options are
|
|
170
|
-
aiTitle =
|
|
171
|
-
aiDescription =
|
|
116
|
+
// AI determines title and description - user options are OVERRIDES only (bioip.js pattern)
|
|
117
|
+
aiTitle = options.title || cleanTitle;
|
|
118
|
+
aiDescription = options.description || cleanDescription;
|
|
172
119
|
spinner.succeed(`Step ${currentStep}/${steps}: โ Claude Haiku generated metadata`);
|
|
173
120
|
console.log(chalk_1.default.cyan(` ๐ AI Title: "${aiTitle}"`));
|
|
174
121
|
console.log(chalk_1.default.gray(` ๐ AI Description: ${aiDescription.substring(0, 60)}...`));
|
|
@@ -206,8 +153,8 @@ async function tokenizeCommand(filePath, options) {
|
|
|
206
153
|
let collectionName = getCollectionName(collectionAddress);
|
|
207
154
|
spinner.succeed(`Step ${currentStep}/${steps}: โ Selected "${collectionName}" collection (${collectionAddress.substring(0, 10)}...)`);
|
|
208
155
|
currentStep++;
|
|
209
|
-
// Preview and Confirmation Step (only if not in quiet mode
|
|
210
|
-
if (!options.quiet && !options.yes
|
|
156
|
+
// Preview and Confirmation Step (only if not in quiet mode and not auto-confirmed)
|
|
157
|
+
if (!options.quiet && !options.yes) {
|
|
211
158
|
const imageUrl = (0, collections_1.getDefaultImageForCategory)(detectedCategory);
|
|
212
159
|
const licenseType = (0, licenses_1.getLicenseType)(options.license || 'non-commercial');
|
|
213
160
|
const licenseDisplayName = getLicenseDisplayName(options.license || 'non-commercial');
|
|
@@ -336,404 +283,37 @@ async function tokenizeCommand(filePath, options) {
|
|
|
336
283
|
}
|
|
337
284
|
console.log(chalk_1.default.green('\nโ
Proceeding with tokenization...\n'));
|
|
338
285
|
}
|
|
339
|
-
|
|
340
|
-
// DRYRUN MODE: Validate infrastructure before stopping
|
|
341
|
-
if (options.dryrun) {
|
|
342
|
-
currentStep++;
|
|
343
|
-
spinner = (0, ora_1.default)(`Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Validating infrastructure (S3, blockchain, wallet)...`).start();
|
|
344
|
-
|
|
345
|
-
const validationResults = {
|
|
346
|
-
s3Access: false,
|
|
347
|
-
s3Bucket: false,
|
|
348
|
-
awsCredentials: false,
|
|
349
|
-
walletValid: false,
|
|
350
|
-
rpcConnection: false,
|
|
351
|
-
collectionExists: false,
|
|
352
|
-
apiConnection: false
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
try {
|
|
356
|
-
// 1. Validate AWS Credentials
|
|
357
|
-
const AWS = require('aws-sdk');
|
|
358
|
-
// Check if credentials are available
|
|
359
|
-
if (!process.env.S3_ACCESS_KEY || !process.env.S3_SECRET_KEY) {
|
|
360
|
-
validationResults.awsCredentials = false;
|
|
361
|
-
validationResults.s3Bucket = false;
|
|
362
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - AWS credentials not found in environment`;
|
|
363
|
-
} else {
|
|
364
|
-
const s3 = new AWS.S3({
|
|
365
|
-
accessKeyId: process.env.S3_ACCESS_KEY,
|
|
366
|
-
secretAccessKey: process.env.S3_SECRET_KEY,
|
|
367
|
-
region: 'us-west-1'
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Checking AWS credentials...`;
|
|
371
|
-
try {
|
|
372
|
-
// Test credentials by listing buckets
|
|
373
|
-
await s3.listBuckets().promise();
|
|
374
|
-
validationResults.awsCredentials = true;
|
|
375
|
-
} catch (e) {
|
|
376
|
-
validationResults.awsCredentials = false;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// 2. Check S3 bucket existence
|
|
380
|
-
const bucket = networkName === 'mainnet' ? 'test.vault.genoverse.io' : 'test.vault.genoverse.io';
|
|
381
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Checking S3 bucket: ${bucket}...`;
|
|
382
|
-
try {
|
|
383
|
-
await s3.headBucket({ Bucket: bucket }).promise();
|
|
384
|
-
validationResults.s3Bucket = true;
|
|
385
|
-
} catch (e) {
|
|
386
|
-
validationResults.s3Bucket = false;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// 3. Check S3 write access by testing path construction
|
|
391
|
-
const testRegistrationId = `bioip_dryrun_${Date.now()}`;
|
|
392
|
-
const testS3Path = `biowallet/${credentials.wallet_address}/bioip/${testRegistrationId}/test.txt`;
|
|
393
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Validating S3 path access...`;
|
|
394
|
-
validationResults.s3Access = true; // Path is valid
|
|
395
|
-
|
|
396
|
-
// 4. Validate wallet format
|
|
397
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Validating wallet address...`;
|
|
398
|
-
validationResults.walletValid = /^0x[a-fA-F0-9]{40}$/.test(credentials.wallet_address);
|
|
399
|
-
|
|
400
|
-
// 5. Check Story Protocol RPC connection
|
|
401
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Connecting to Story Protocol RPC...`;
|
|
402
|
-
const https = require('https');
|
|
403
|
-
const rpcUrl = networkName === 'mainnet' ? 'https://mainnet.storyrpc.io/' : 'https://aeneid.storyrpc.io/';
|
|
404
|
-
|
|
405
|
-
try {
|
|
406
|
-
await new Promise((resolve, reject) => {
|
|
407
|
-
const postData = JSON.stringify({
|
|
408
|
-
jsonrpc: '2.0',
|
|
409
|
-
method: 'eth_blockNumber',
|
|
410
|
-
params: [],
|
|
411
|
-
id: 1
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
const url = new URL(rpcUrl);
|
|
415
|
-
const options = {
|
|
416
|
-
hostname: url.hostname,
|
|
417
|
-
port: url.port || 443,
|
|
418
|
-
path: url.pathname,
|
|
419
|
-
method: 'POST',
|
|
420
|
-
headers: {
|
|
421
|
-
'Content-Type': 'application/json',
|
|
422
|
-
'Content-Length': Buffer.byteLength(postData)
|
|
423
|
-
},
|
|
424
|
-
timeout: 5000
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
const req = https.request(options, (res) => {
|
|
428
|
-
let data = '';
|
|
429
|
-
res.on('data', (chunk) => { data += chunk; });
|
|
430
|
-
res.on('end', () => {
|
|
431
|
-
try {
|
|
432
|
-
const parsed = JSON.parse(data);
|
|
433
|
-
if (parsed.result) {
|
|
434
|
-
validationResults.rpcConnection = true;
|
|
435
|
-
resolve();
|
|
436
|
-
} else {
|
|
437
|
-
reject(new Error('No result from RPC'));
|
|
438
|
-
}
|
|
439
|
-
} catch (e) {
|
|
440
|
-
reject(e);
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
req.on('error', reject);
|
|
446
|
-
req.on('timeout', () => {
|
|
447
|
-
req.destroy();
|
|
448
|
-
reject(new Error('RPC timeout'));
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
req.write(postData);
|
|
452
|
-
req.end();
|
|
453
|
-
});
|
|
454
|
-
} catch (e) {
|
|
455
|
-
validationResults.rpcConnection = false;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// 6. Check collection exists on-chain (if collectionAddress provided)
|
|
459
|
-
if (collectionAddress && collectionAddress !== '0x0000000000000000000000000000000000000000') {
|
|
460
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Verifying collection on-chain...`;
|
|
461
|
-
try {
|
|
462
|
-
await new Promise((resolve, reject) => {
|
|
463
|
-
const postData = JSON.stringify({
|
|
464
|
-
jsonrpc: '2.0',
|
|
465
|
-
method: 'eth_getCode',
|
|
466
|
-
params: [collectionAddress, 'latest'],
|
|
467
|
-
id: 1
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
const url = new URL(rpcUrl);
|
|
471
|
-
const options = {
|
|
472
|
-
hostname: url.hostname,
|
|
473
|
-
port: url.port || 443,
|
|
474
|
-
path: url.pathname,
|
|
475
|
-
method: 'POST',
|
|
476
|
-
headers: {
|
|
477
|
-
'Content-Type': 'application/json',
|
|
478
|
-
'Content-Length': Buffer.byteLength(postData)
|
|
479
|
-
},
|
|
480
|
-
timeout: 5000
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
const req = https.request(options, (res) => {
|
|
484
|
-
let data = '';
|
|
485
|
-
res.on('data', (chunk) => { data += chunk; });
|
|
486
|
-
res.on('end', () => {
|
|
487
|
-
try {
|
|
488
|
-
const parsed = JSON.parse(data);
|
|
489
|
-
if (parsed.result && parsed.result !== '0x' && parsed.result !== '0x0') {
|
|
490
|
-
validationResults.collectionExists = true;
|
|
491
|
-
resolve();
|
|
492
|
-
} else {
|
|
493
|
-
reject(new Error('No contract code at address'));
|
|
494
|
-
}
|
|
495
|
-
} catch (e) {
|
|
496
|
-
reject(e);
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
req.on('error', reject);
|
|
502
|
-
req.on('timeout', () => {
|
|
503
|
-
req.destroy();
|
|
504
|
-
reject(new Error('RPC timeout'));
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
req.write(postData);
|
|
508
|
-
req.end();
|
|
509
|
-
});
|
|
510
|
-
} catch (e) {
|
|
511
|
-
validationResults.collectionExists = false;
|
|
512
|
-
}
|
|
513
|
-
} else {
|
|
514
|
-
validationResults.collectionExists = true; // No specific collection, OK
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// 7. Check API connectivity
|
|
518
|
-
spinner.text = `Step ${currentStep}/${steps + 1}: ๐งช DRYRUN - Testing API endpoint connectivity...`;
|
|
519
|
-
try {
|
|
520
|
-
await new Promise((resolve, reject) => {
|
|
521
|
-
const apiUrl = new URL('https://genobank.app/api_bioip/');
|
|
522
|
-
const options = {
|
|
523
|
-
hostname: apiUrl.hostname,
|
|
524
|
-
port: apiUrl.port || 443,
|
|
525
|
-
path: apiUrl.pathname,
|
|
526
|
-
method: 'GET',
|
|
527
|
-
timeout: 5000
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const req = https.request(options, (res) => {
|
|
531
|
-
validationResults.apiConnection = (res.statusCode === 200 || res.statusCode === 404);
|
|
532
|
-
resolve();
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
req.on('error', () => {
|
|
536
|
-
validationResults.apiConnection = false;
|
|
537
|
-
resolve(); // Don't reject, just mark as failed
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
req.on('timeout', () => {
|
|
541
|
-
req.destroy();
|
|
542
|
-
validationResults.apiConnection = false;
|
|
543
|
-
resolve();
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
req.end();
|
|
547
|
-
});
|
|
548
|
-
} catch (e) {
|
|
549
|
-
validationResults.apiConnection = false;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
spinner.succeed(`Step ${currentStep}/${steps + 1}: โ Infrastructure validation complete`);
|
|
553
|
-
|
|
554
|
-
} catch (error) {
|
|
555
|
-
spinner.fail(`Step ${currentStep}/${steps + 1}: Infrastructure validation failed`);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// Display validation results
|
|
559
|
-
console.log('\n');
|
|
560
|
-
const imageUrl = (0, collections_1.getDefaultImageForCategory)(detectedCategory);
|
|
561
|
-
const licenseType = (0, licenses_1.getLicenseType)(options.license || 'non-commercial');
|
|
562
|
-
const licenseDisplayName = getLicenseDisplayName(options.license || 'non-commercial');
|
|
563
|
-
|
|
564
|
-
// Build full preview for dryrun
|
|
565
|
-
const preview = buildMetadataPreview({
|
|
566
|
-
fileName,
|
|
567
|
-
fileSize,
|
|
568
|
-
title: aiTitle,
|
|
569
|
-
description: aiDescription || `${detectedCategory} dataset`,
|
|
570
|
-
category: detectedCategory,
|
|
571
|
-
fingerprint,
|
|
572
|
-
snpCount,
|
|
573
|
-
collection: collectionName,
|
|
574
|
-
collectionAddress,
|
|
575
|
-
license: licenseDisplayName,
|
|
576
|
-
licenseType,
|
|
577
|
-
imageUrl,
|
|
578
|
-
network: network.name,
|
|
579
|
-
wallet: credentials.wallet_address
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
console.log((0, boxen_1.default)(preview, {
|
|
583
|
-
padding: 1,
|
|
584
|
-
margin: 1,
|
|
585
|
-
borderStyle: 'round',
|
|
586
|
-
borderColor: 'cyan',
|
|
587
|
-
title: '๐งช DRY RUN - Metadata Preview',
|
|
588
|
-
titleAlignment: 'center'
|
|
589
|
-
}));
|
|
590
|
-
|
|
591
|
-
// Display infrastructure validation results
|
|
592
|
-
console.log('\n');
|
|
593
|
-
const allValid = Object.values(validationResults).every(v => v === true);
|
|
594
|
-
const validationColor = allValid ? 'green' : 'yellow';
|
|
595
|
-
|
|
596
|
-
const statusIcon = (valid) => valid ? chalk_1.default.green('โ
') : chalk_1.default.red('โ');
|
|
597
|
-
|
|
598
|
-
const infrastructureStatus =
|
|
599
|
-
chalk_1.default.bold.white('๐ง Infrastructure Validation Results\n\n') +
|
|
600
|
-
`${statusIcon(validationResults.awsCredentials)} AWS Credentials: ${validationResults.awsCredentials ? chalk_1.default.green('Valid') : chalk_1.default.red('Invalid')}\n` +
|
|
601
|
-
`${statusIcon(validationResults.s3Bucket)} S3 Bucket Access: ${validationResults.s3Bucket ? chalk_1.default.green('test.vault.genoverse.io exists') : chalk_1.default.red('Bucket not found')}\n` +
|
|
602
|
-
`${statusIcon(validationResults.s3Access)} S3 Path Validation: ${validationResults.s3Access ? chalk_1.default.green('Path structure valid') : chalk_1.default.red('Invalid path')}\n` +
|
|
603
|
-
`${statusIcon(validationResults.walletValid)} Wallet Address: ${validationResults.walletValid ? chalk_1.default.green('Valid format') : chalk_1.default.red('Invalid format')}\n` +
|
|
604
|
-
`${statusIcon(validationResults.rpcConnection)} Story Protocol RPC: ${validationResults.rpcConnection ? chalk_1.default.green('Connected') : chalk_1.default.red('Connection failed')}\n` +
|
|
605
|
-
`${statusIcon(validationResults.collectionExists)} Collection On-Chain: ${validationResults.collectionExists ? chalk_1.default.green('Verified') : chalk_1.default.red('Not found')}\n` +
|
|
606
|
-
`${statusIcon(validationResults.apiConnection)} API Endpoint: ${validationResults.apiConnection ? chalk_1.default.green('Accessible') : chalk_1.default.red('Not accessible')}\n\n` +
|
|
607
|
-
(allValid
|
|
608
|
-
? chalk_1.default.green.bold('โ
All infrastructure checks passed - Ready to tokenize!')
|
|
609
|
-
: chalk_1.default.yellow.bold('โ ๏ธ Some infrastructure checks failed - Fix issues before tokenizing'));
|
|
610
|
-
|
|
611
|
-
console.log((0, boxen_1.default)(infrastructureStatus, {
|
|
612
|
-
padding: 1,
|
|
613
|
-
margin: 1,
|
|
614
|
-
borderStyle: 'round',
|
|
615
|
-
borderColor: validationColor,
|
|
616
|
-
title: '๐ง Infrastructure Status',
|
|
617
|
-
titleAlignment: 'center'
|
|
618
|
-
}));
|
|
619
|
-
|
|
620
|
-
console.log('\n');
|
|
621
|
-
console.log((0, boxen_1.default)(chalk_1.default.cyan.bold('๐งช DRY RUN MODE COMPLETE\n\n') +
|
|
622
|
-
chalk_1.default.white('All validation and AI classification steps completed!\n\n') +
|
|
623
|
-
chalk_1.default.gray('โ
File validated and fingerprinted\n') +
|
|
624
|
-
chalk_1.default.gray('โ
AI metadata generated by Claude Haiku\n') +
|
|
625
|
-
chalk_1.default.gray('โ
Collection and license configured\n') +
|
|
626
|
-
chalk_1.default.gray(`${allValid ? 'โ
' : 'โ ๏ธ '} Infrastructure validation ${allValid ? 'passed' : 'has issues'}\n\n`) +
|
|
627
|
-
chalk_1.default.yellow('โธ๏ธ Tokenization paused before data upload and blockchain minting\n\n') +
|
|
628
|
-
chalk_1.default.white('To proceed with actual tokenization, run without --dryrun flag:\n\n') +
|
|
629
|
-
chalk_1.default.cyan(`biofs tokenize "${absolutePath}" --network ${networkName} --license ${options.license || 'non-commercial'}`), {
|
|
630
|
-
padding: 1,
|
|
631
|
-
margin: 1,
|
|
632
|
-
borderStyle: 'double',
|
|
633
|
-
borderColor: 'cyan',
|
|
634
|
-
title: '๐งช Dry Run Complete',
|
|
635
|
-
titleAlignment: 'center'
|
|
636
|
-
}));
|
|
637
|
-
console.log('\n');
|
|
638
|
-
return; // Exit without tokenizing
|
|
639
|
-
}
|
|
640
|
-
|
|
641
286
|
// Step 5: Upload to GenoBank with Web3 signature authentication
|
|
642
287
|
spinner = (0, ora_1.default)(`Step ${currentStep}/${steps}: ๐ค Uploading to secure GenoBank vault with Web3 authentication...`).start();
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
const bucket = networkName === 'mainnet' ? 'vault.genoverse.io' : 'test.vault.genoverse.io';
|
|
671
|
-
const registrationId = `bioip_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
672
|
-
s3Path = `biowallet/${credentials.wallet_address}/bioip/${registrationId}/${fileName}`;
|
|
673
|
-
|
|
674
|
-
// Upload to S3 with progress
|
|
675
|
-
const fileBuffer = await (0, promises_1.readFile)(absolutePath);
|
|
676
|
-
await s3.upload({
|
|
677
|
-
Bucket: bucket,
|
|
678
|
-
Key: s3Path,
|
|
679
|
-
Body: fileBuffer
|
|
680
|
-
}).on('httpUploadProgress', (progress) => {
|
|
681
|
-
const percentCompleted = Math.round((progress.loaded * 100) / progress.total);
|
|
682
|
-
const progressBar = 'โ'.repeat(Math.floor(percentCompleted / 5)) + 'โ'.repeat(20 - Math.floor(percentCompleted / 5));
|
|
683
|
-
spinner.text = `Step ${currentStep}/${steps}: ๐ค Uploading to S3 ${(0, format_1.formatFileSize)(progress.loaded)}/${(0, format_1.formatFileSize)(progress.total)} ${progressBar} ${percentCompleted}%`;
|
|
684
|
-
}).promise();
|
|
685
|
-
|
|
686
|
-
spinner.text = `Step ${currentStep}/${steps}: ๐ค S3 upload complete, registering on blockchain...`;
|
|
687
|
-
|
|
688
|
-
// Register with API using s3_path parameter (bypasses CloudFlare)
|
|
689
|
-
const formDataS3 = new form_data_1.default();
|
|
690
|
-
formDataS3.append('user_signature', credentials.user_signature);
|
|
691
|
-
formDataS3.append('s3_path', s3Path);
|
|
692
|
-
formDataS3.append('title', aiTitle);
|
|
693
|
-
formDataS3.append('description', aiDescription || `${detectedCategory} dataset`);
|
|
694
|
-
formDataS3.append('license_type', (0, licenses_1.getLicenseType)(options.license || 'non-commercial'));
|
|
695
|
-
formDataS3.append('fingerprint', fingerprint);
|
|
696
|
-
formDataS3.append('file_category', detectedCategory);
|
|
697
|
-
formDataS3.append('collection_address', collectionAddress);
|
|
698
|
-
formDataS3.append('image_url', (0, collections_1.getDefaultImageForCategory)(detectedCategory));
|
|
699
|
-
formDataS3.append('network', networkName);
|
|
700
|
-
|
|
701
|
-
response = await axios_1.default.post(`${API_BASE}/register_bioip`, formDataS3, {
|
|
702
|
-
headers: {
|
|
703
|
-
...formDataS3.getHeaders()
|
|
288
|
+
// Read file
|
|
289
|
+
const fileBuffer = await (0, promises_1.readFile)(absolutePath);
|
|
290
|
+
// Prepare form data with file upload
|
|
291
|
+
const formData = new form_data_1.default();
|
|
292
|
+
formData.append('user_signature', credentials.user_signature);
|
|
293
|
+
formData.append('file', fileBuffer, fileName);
|
|
294
|
+
formData.append('title', aiTitle);
|
|
295
|
+
formData.append('description', aiDescription || `${detectedCategory} dataset`);
|
|
296
|
+
formData.append('license_type', (0, licenses_1.getLicenseType)(options.license || 'non-commercial'));
|
|
297
|
+
formData.append('fingerprint', fingerprint);
|
|
298
|
+
formData.append('file_category', detectedCategory);
|
|
299
|
+
formData.append('collection_address', collectionAddress);
|
|
300
|
+
formData.append('image_url', (0, collections_1.getDefaultImageForCategory)(detectedCategory));
|
|
301
|
+
formData.append('network', networkName);
|
|
302
|
+
// Submit to API
|
|
303
|
+
const response = await axios_1.default.post(`${API_BASE}/register_bioip`, formData, {
|
|
304
|
+
headers: {
|
|
305
|
+
...formData.getHeaders()
|
|
306
|
+
},
|
|
307
|
+
maxBodyLength: Infinity,
|
|
308
|
+
maxContentLength: Infinity,
|
|
309
|
+
onUploadProgress: (progressEvent) => {
|
|
310
|
+
if (progressEvent.total) {
|
|
311
|
+
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
312
|
+
const progressBar = 'โ'.repeat(Math.floor(percentCompleted / 5)) + 'โ'.repeat(20 - Math.floor(percentCompleted / 5));
|
|
313
|
+
spinner.text = `Step ${currentStep}/${steps}: ๐ค Uploading ${(0, format_1.formatFileSize)(progressEvent.loaded)}/${(0, format_1.formatFileSize)(progressEvent.total)} ${progressBar} ${percentCompleted}%`;
|
|
704
314
|
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
// Small file: Use standard upload through CloudFlare
|
|
708
|
-
const fileBuffer = await (0, promises_1.readFile)(absolutePath);
|
|
709
|
-
const formData = new form_data_1.default();
|
|
710
|
-
formData.append('user_signature', credentials.user_signature);
|
|
711
|
-
formData.append('file', fileBuffer, fileName);
|
|
712
|
-
formData.append('title', aiTitle);
|
|
713
|
-
formData.append('description', aiDescription || `${detectedCategory} dataset`);
|
|
714
|
-
formData.append('license_type', (0, licenses_1.getLicenseType)(options.license || 'non-commercial'));
|
|
715
|
-
formData.append('fingerprint', fingerprint);
|
|
716
|
-
formData.append('file_category', detectedCategory);
|
|
717
|
-
formData.append('collection_address', collectionAddress);
|
|
718
|
-
formData.append('image_url', (0, collections_1.getDefaultImageForCategory)(detectedCategory));
|
|
719
|
-
formData.append('network', networkName);
|
|
720
|
-
|
|
721
|
-
response = await axios_1.default.post(`${API_BASE}/register_bioip`, formData, {
|
|
722
|
-
headers: {
|
|
723
|
-
...formData.getHeaders()
|
|
724
|
-
},
|
|
725
|
-
maxBodyLength: Infinity,
|
|
726
|
-
maxContentLength: Infinity,
|
|
727
|
-
onUploadProgress: (progressEvent) => {
|
|
728
|
-
if (progressEvent.total) {
|
|
729
|
-
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
730
|
-
const progressBar = 'โ'.repeat(Math.floor(percentCompleted / 5)) + 'โ'.repeat(20 - Math.floor(percentCompleted / 5));
|
|
731
|
-
spinner.text = `Step ${currentStep}/${steps}: ๐ค Uploading ${(0, format_1.formatFileSize)(progressEvent.loaded)}/${(0, format_1.formatFileSize)(progressEvent.total)} ${progressBar} ${percentCompleted}%`;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
|
|
315
|
+
}
|
|
316
|
+
});
|
|
737
317
|
spinner.succeed(`Step ${currentStep}/${steps}: โ Uploaded to encrypted S3 vault & registered in MongoDB`);
|
|
738
318
|
currentStep++;
|
|
739
319
|
// Debug: Log the response structure
|
|
@@ -843,12 +423,7 @@ function detectFileCategory(fileName, fileExt) {
|
|
|
843
423
|
'.gff': 'annotation',
|
|
844
424
|
'.gtf': 'annotation',
|
|
845
425
|
'.dcm': 'medical_imaging',
|
|
846
|
-
'.dicom': 'medical_imaging'
|
|
847
|
-
'.mov': 'medical_video',
|
|
848
|
-
'.mp4': 'medical_video',
|
|
849
|
-
'.webm': 'medical_video',
|
|
850
|
-
'.avi': 'medical_video',
|
|
851
|
-
'.mkv': 'medical_video'
|
|
426
|
+
'.dicom': 'medical_imaging'
|
|
852
427
|
};
|
|
853
428
|
// Check compound extensions first
|
|
854
429
|
for (const [ext, category] of Object.entries(extMap)) {
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
// ===== LOAD ENVIRONMENT VARIABLES FROM .ENV FILES =====
|
|
5
|
-
// This runs BEFORE any other code to ensure S3 credentials are available
|
|
6
|
-
const dotenv = require('dotenv');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
|
|
10
|
-
// Try loading .env from multiple locations (in order of priority)
|
|
11
|
-
const possibleEnvPaths = [
|
|
12
|
-
path.join(process.cwd(), '.env'), // Current directory
|
|
13
|
-
path.join(__dirname, '..', '.env'), // Parent directory
|
|
14
|
-
path.join(__dirname, '..', '..', '.env'), // Two levels up
|
|
15
|
-
path.join(require('os').homedir(), '.biofs', '.env') // User home directory
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
for (const envPath of possibleEnvPaths) {
|
|
19
|
-
if (fs.existsSync(envPath)) {
|
|
20
|
-
dotenv.config({ path: envPath });
|
|
21
|
-
if (process.env.DEBUG === '1') {
|
|
22
|
-
console.log(`[DEBUG] Loaded .env from: ${envPath}`);
|
|
23
|
-
}
|
|
24
|
-
break; // Use first found .env
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// ===== END ENVIRONMENT LOADING =====
|
|
28
|
-
|
|
29
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
5
|
};
|
|
@@ -56,8 +30,8 @@ const program = new commander_1.Command();
|
|
|
56
30
|
// Set up the CLI
|
|
57
31
|
program
|
|
58
32
|
.name('biofs')
|
|
59
|
-
.description('BioFS by GenoBank.io - BioNFT-Gated S3 CLI for genomic data
|
|
60
|
-
.version('1.
|
|
33
|
+
.description('BioFS by GenoBank.io - BioNFT-Gated S3 CLI for genomic data')
|
|
34
|
+
.version('1.4.2')
|
|
61
35
|
.option('--debug', 'Enable debug output')
|
|
62
36
|
.hook('preAction', (thisCommand) => {
|
|
63
37
|
// Set global debug flag if --debug is passed
|
|
@@ -73,6 +47,8 @@ program
|
|
|
73
47
|
.option('--port <number>', 'Callback server port', parseInt)
|
|
74
48
|
.option('--no-browser', "Don't auto-open browser")
|
|
75
49
|
.option('--timeout <seconds>', 'Auth timeout in seconds', parseInt)
|
|
50
|
+
.option('--wallet <address>', 'Wallet address for direct authentication')
|
|
51
|
+
.option('--signature <signature>', 'Signature for direct authentication')
|
|
76
52
|
.action(async (options) => {
|
|
77
53
|
try {
|
|
78
54
|
await (0, login_1.loginCommand)(options);
|
|
@@ -193,7 +169,6 @@ program
|
|
|
193
169
|
.option('--collection <address>', 'Manual collection address override')
|
|
194
170
|
.option('--network <network>', 'Story Protocol network: mainnet, testnet', 'mainnet')
|
|
195
171
|
.option('--no-ai', 'Skip AI classification')
|
|
196
|
-
.option('--dryrun', 'Test validation and preview metadata without tokenizing')
|
|
197
172
|
.option('--quiet', 'No interactive prompts')
|
|
198
173
|
.option('--yes', 'Auto-confirm all prompts')
|
|
199
174
|
.action(async (file, options) => {
|
|
@@ -396,9 +371,8 @@ program
|
|
|
396
371
|
// Show welcome message if no command
|
|
397
372
|
if (process.argv.length === 2) {
|
|
398
373
|
console.log(chalk_1.default.cyan('\nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ'));
|
|
399
|
-
console.log(chalk_1.default.cyan('โ BioFS CLI v1.
|
|
374
|
+
console.log(chalk_1.default.cyan('โ BioFS CLI v1.4.2 โ'));
|
|
400
375
|
console.log(chalk_1.default.cyan('โ BioNFT-Gated S3 CLI โ'));
|
|
401
|
-
console.log(chalk_1.default.cyan('โ + Medical Video Support โ'));
|
|
402
376
|
console.log(chalk_1.default.cyan('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n'));
|
|
403
377
|
console.log('Available commands:');
|
|
404
378
|
console.log(` ${chalk_1.default.green('login')} - Authenticate with Web3 wallet`);
|
|
@@ -438,7 +412,6 @@ process.on('unhandledRejection', (error) => {
|
|
|
438
412
|
});
|
|
439
413
|
process.on('SIGINT', () => {
|
|
440
414
|
console.log('\n\nInterrupted. Goodbye!');
|
|
441
|
-
|
|
442
|
-
setTimeout(() => process.exit(0), 100);
|
|
415
|
+
process.exit(0);
|
|
443
416
|
});
|
|
444
417
|
//# sourceMappingURL=index.js.map
|