@genobank/biofs 2.1.11 → 2.3.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.
@@ -0,0 +1,396 @@
1
+ # LabNFT + BioFS Integration Complete
2
+
3
+ ## Overview
4
+
5
+ GenoBank's lab registration system is now fully integrated with BioFS-CLI and all related services. Labs are registered via unified API, minted as LabNFTs on Sequentia blockchain, and recognized across the entire GenoBank ecosystem.
6
+
7
+ ## Architecture
8
+
9
+ ### Components Integrated
10
+
11
+ 1. **LabNFT Smart Contract** (Sequentia L1)
12
+ - Contract: `0x24f42752F491540e305384A5C947911649C910CF`
13
+ - Chain ID: `15132025`
14
+ - Network: Sequentia Mainnet (`http://52.90.163.112:8545`)
15
+
16
+ 2. **GenoBank API** (`/register_lab` endpoint)
17
+ - URL: `https://genobank.app/register_lab`
18
+ - Generates custodial wallets or accepts user wallets
19
+ - Mints LabNFTs automatically
20
+ - Stores in MongoDB `labs` collection
21
+
22
+ 3. **BioFS-CLI v2.2.0**
23
+ - New module: `/src/lib/sequentia/LabNFT.ts`
24
+ - Commands: `biofs admin register-lab`, `biofs admin verify-lab`
25
+ - Integrated with Sequentia Protocol SDK
26
+
27
+ 4. **Lab Management Service**
28
+ - Service: `libs/service/lab_management_service.py`
29
+ - Method: `register_lab_with_nft()`
30
+ - DAO: `libs/dao/labnft_dao.py`
31
+
32
+ ## New Features
33
+
34
+ ### 1. Unified Lab Registration
35
+
36
+ **Via BioFS-CLI:**
37
+ ```bash
38
+ # Register with custodial wallet generation
39
+ biofs admin register-lab https://novogene.com --yes
40
+
41
+ # Register with custom details
42
+ biofs admin register-lab https://example.edu \
43
+ --name "Example Genomics Lab" \
44
+ --email contact@example.edu \
45
+ --specialization "cancer genomics" \
46
+ --location "Boston, MA" \
47
+ --lab-type RESEARCHER
48
+ ```
49
+
50
+ **Via API:**
51
+ ```bash
52
+ curl -X POST https://genobank.app/register_lab \
53
+ -H "Content-Type: application/json" \
54
+ -d '{
55
+ "name": "Test Lab",
56
+ "lab_type": "LAB",
57
+ "specialization": "WGS",
58
+ "location": "Boston, MA",
59
+ "website": "https://test-lab.com",
60
+ "email": "contact@test-lab.com",
61
+ "mint_nft": true
62
+ }'
63
+ ```
64
+
65
+ ### 2. Lab Verification
66
+
67
+ **Check LabNFT ownership and status:**
68
+ ```bash
69
+ biofs admin verify-lab 0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07
70
+ ```
71
+
72
+ **Output:**
73
+ ```
74
+ ✅ Lab Verified!
75
+
76
+ LabNFT Details:
77
+ Serial: #43
78
+ Contract: 0x24f42752F491540e305384A5C947911649C910CF
79
+ Owner: 0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07
80
+
81
+ Lab Information:
82
+ Name: Novogene
83
+ Type: Lab
84
+ Specialization: Genomic sequencing and bioinformatics
85
+ Location: United States
86
+ Website: https://novogene.com
87
+ Email: contact@novogene.com
88
+
89
+ Access Control:
90
+ Access Level: Research Only
91
+ GA4GH Level: None
92
+ Verified: ✅ Yes
93
+ Active: ✅ Yes
94
+
95
+ GDPR Consent:
96
+ Biodata Consent: 0xbe8ee34d...
97
+ Commercial Consent: 0x2d3543df...
98
+ ```
99
+
100
+ ### 3. File Sharing with LabNFT Verification
101
+
102
+ **BioFS will automatically verify LabNFT ownership when sharing files:**
103
+
104
+ ```bash
105
+ # Share file with lab (LabNFT verified automatically)
106
+ biofs share patient001.vcf \
107
+ --lab 0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07 \
108
+ --license non-commercial
109
+ ```
110
+
111
+ **Backend verification flow:**
112
+ 1. Check if recipient wallet has LabNFT
113
+ 2. Verify LabNFT is active and verified
114
+ 3. Check GDPR consent hashes
115
+ 4. Grant access if all checks pass
116
+
117
+ ## MongoDB Collections
118
+
119
+ ### Unified `labs` Collection
120
+
121
+ Replaces fragmented `lab_wallets`, `permittees`, and `researchers` collections:
122
+
123
+ ```javascript
124
+ {
125
+ "_id": ObjectId("..."),
126
+ "name": "Novogene",
127
+ "owner_wallet": "0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07",
128
+ "wallet_type": "custodial_generated", // or "user_provided"
129
+ "wallet_private_key": "...", // Only for custodial wallets
130
+ "wallet_mnemonic": "...", // Only for custodial wallets
131
+ "wallet_claimed": false,
132
+ "lab_type": "LAB", // LAB, RESEARCHER, or INSTITUTION
133
+ "specialization": "Genomic sequencing",
134
+ "location": "United States",
135
+ "website": "https://www.novogene.com",
136
+ "email": "contact@novogene.com",
137
+ "verified": true,
138
+ "sequentia": {
139
+ "registered": true,
140
+ "labnft_token_id": 43,
141
+ "tx_hash": "0xabc123...",
142
+ "block_number": 12345,
143
+ "contract": "0x24f42752F491540e305384A5C947911649C910CF"
144
+ },
145
+ "gdpr_consent": {
146
+ "biodata_consent_hash": "0xbe8ee34d...",
147
+ "commercial_consent_hash": "0x2d3543df...",
148
+ "consent_date": ISODate("2025-11-11T...")
149
+ },
150
+ "created_at": ISODate("2025-11-11T..."),
151
+ "updated_at": ISODate("2025-11-11T...")
152
+ }
153
+ ```
154
+
155
+ ## BioFS-CLI Integration
156
+
157
+ ### New LabNFT Module
158
+
159
+ **File:** `/home/ubuntu/biofs-cli/src/lib/sequentia/LabNFT.ts`
160
+
161
+ **Key Features:**
162
+ - Full LabNFT contract integration
163
+ - EIP-55 checksummed addresses
164
+ - GDPR consent hash generation
165
+ - Lab type and access level enums
166
+ - GA4GH compliance levels
167
+
168
+ **Usage:**
169
+ ```typescript
170
+ import { LabNFT, LabType, AccessLevel } from '@genobank/biofs';
171
+
172
+ // Initialize client
173
+ const labNFT = new LabNFT(executorPrivateKey);
174
+
175
+ // Check registration
176
+ const isRegistered = await labNFT.isLabRegistered(wallet);
177
+
178
+ // Get lab info
179
+ const labInfo = await labNFT.getLabByWallet(wallet);
180
+
181
+ // Mint new LabNFT
182
+ const result = await labNFT.mintLab({
183
+ owner: wallet,
184
+ labType: LabType.LAB,
185
+ name: "Test Lab",
186
+ specialization: "Genomics",
187
+ location: "Boston, MA",
188
+ website: "https://test.com",
189
+ email: "contact@test.com",
190
+ accessLevel: AccessLevel.RESEARCH_ONLY
191
+ });
192
+ ```
193
+
194
+ ## API Integration
195
+
196
+ ### Unified `/register_lab` Endpoint
197
+
198
+ **Location:** `/home/ubuntu/Genobank_APIs/production_api/run/runweb.py`
199
+
200
+ **Request:**
201
+ ```json
202
+ {
203
+ "name": "Lab Name",
204
+ "lab_type": "LAB|RESEARCHER|INSTITUTION",
205
+ "specialization": "genomics",
206
+ "location": "New York, NY",
207
+ "website": "https://example.com",
208
+ "email": "contact@example.com",
209
+ "wallet_address": "0x..." // optional
210
+ "mint_nft": true
211
+ }
212
+ ```
213
+
214
+ **Response:**
215
+ ```json
216
+ {
217
+ "status": "Success",
218
+ "status_details": {
219
+ "message": "Lab registered successfully",
220
+ "data": {
221
+ "lab_id": "673cf34f79d8b5f2c9f20c91",
222
+ "wallet_address": "0x44232e3c104BBd6c6de6C34567e1dB4af2104807",
223
+ "wallet_type": "custodial_generated",
224
+ "private_key": "...",
225
+ "mnemonic": "word1 word2 ...",
226
+ "labnft": {
227
+ "serial": 34,
228
+ "tx_hash": "0x1ebfa931...",
229
+ "block_number": 12345,
230
+ "contract": "0x24f42752F491540e305384A5C947911649C910CF"
231
+ }
232
+ }
233
+ }
234
+ }
235
+ ```
236
+
237
+ ## Migration Summary
238
+
239
+ ### Before (Fragmented System)
240
+
241
+ - **Collections:** `lab_wallets`, `permittees`, `researchers`
242
+ - **Registration:** Manual via multiple endpoints
243
+ - **No blockchain verification**
244
+ - **No unified access control**
245
+
246
+ ### After (Unified System)
247
+
248
+ - **Collection:** Single `labs` collection
249
+ - **Registration:** Unified `/register_lab` API
250
+ - **LabNFT minting:** Automatic on registration
251
+ - **Access control:** LabNFT-based verification
252
+ - **CLI support:** `biofs admin register-lab`, `biofs admin verify-lab`
253
+
254
+ ### Migration Stats
255
+
256
+ - **Total labs:** 63
257
+ - **Labs with LabNFTs:** 63 (100%)
258
+ - **Custodial wallets:** 28
259
+ - **User-provided wallets:** 35
260
+ - **LabNFT serials:** #1 - #61 (plus test labs #60-61)
261
+
262
+ ## Security Features
263
+
264
+ ### 1. GDPR Compliance
265
+
266
+ - **Biodata consent hash:** Stored on-chain
267
+ - **Commercial consent hash:** Separate tracking
268
+ - **Consent revocation:** Supported via ConsentManager module
269
+
270
+ ### 2. Access Control
271
+
272
+ - **Four access levels:**
273
+ - Research Only (0)
274
+ - Clinical Non-Critical (1)
275
+ - Clinical Critical (2)
276
+ - Commercial (3)
277
+
278
+ - **GA4GH compliance levels:**
279
+ - None (0)
280
+ - Basic (1)
281
+ - Lite (2)
282
+ - Full (3)
283
+
284
+ ### 3. Wallet Security
285
+
286
+ - **Custodial wallets:** Private keys encrypted in MongoDB
287
+ - **EIP-55 checksumming:** Address validation
288
+ - **Claim workflow:** Labs can claim custodial wallets via email
289
+
290
+ ## File Sharing Integration
291
+
292
+ ### Current Implementation
293
+
294
+ File sharing currently uses wallet-based verification:
295
+
296
+ ```python
297
+ # runweb.py:4668
298
+ def share_file(self, signature, data):
299
+ user = self.user_service.get_user_from_token(signature)
300
+ saved = self.shared_service.share_file(user, data)
301
+ return saved
302
+ ```
303
+
304
+ ### Future Enhancement (Planned)
305
+
306
+ Add LabNFT verification layer:
307
+
308
+ ```python
309
+ def share_file(self, signature, data):
310
+ user = self.user_service.get_user_from_token(signature)
311
+
312
+ # Verify recipient has LabNFT
313
+ recipient_wallet = data['permittee']
314
+ if not self.labnft_dao.is_wallet_registered(recipient_wallet):
315
+ raise ValueError("Recipient does not have LabNFT")
316
+
317
+ # Verify LabNFT is active and verified
318
+ lab_info = self.labnft_dao.get_lab_by_wallet(recipient_wallet)
319
+ if not lab_info or not lab_info['verified'] or not lab_info['active']:
320
+ raise ValueError("Recipient lab not verified")
321
+
322
+ saved = self.shared_service.share_file(user, data)
323
+ return saved
324
+ ```
325
+
326
+ ## Testing
327
+
328
+ ### Test Lab Registration
329
+
330
+ ```bash
331
+ # Via CLI
332
+ biofs admin register-lab https://novogene.com --yes
333
+
334
+ # Via API
335
+ curl -X POST https://genobank.app/register_lab \
336
+ -H "Content-Type: application/json" \
337
+ -d '{"name": "Test Lab", "lab_type": "LAB", "mint_nft": true}'
338
+ ```
339
+
340
+ ### Verify Registration
341
+
342
+ ```bash
343
+ # Check on-chain
344
+ biofs admin verify-lab 0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07
345
+
346
+ # Check in MongoDB
347
+ mongosh "mongodb+srv://..." --eval "db.labs.findOne({owner_wallet: '0x9346be6aD3384EB36c172F8B2bB4b7C9d8afFc07'})"
348
+ ```
349
+
350
+ ## Version History
351
+
352
+ - **v2.2.0** (2025-11-12): LabNFT integration complete
353
+ - Added `LabNFT.ts` module
354
+ - Updated `register-lab` to use unified API
355
+ - Added `verify-lab` command
356
+ - Integrated with Sequentia Protocol SDK
357
+
358
+ - **v2.1.11** (Previous): Pre-LabNFT integration
359
+ - Manual lab registration
360
+ - BioPIL DAO placeholder
361
+
362
+ ## Next Steps
363
+
364
+ 1. **Implement LabNFT verification in file sharing endpoints**
365
+ - Add LabNFT checks to `share_file()`
366
+ - Add LabNFT checks to `approve_biosample_request()`
367
+ - Add LabNFT checks to `deliver_raw_data_from_root()`
368
+
369
+ 2. **Add lab claiming workflow**
370
+ - Email verification for custodial wallets
371
+ - Wallet claiming via GenoBank dashboard
372
+ - Private key transfer mechanism
373
+
374
+ 3. **Enhance BioFS-CLI**
375
+ - `biofs lab list` - List all registered labs
376
+ - `biofs lab update` - Update lab information
377
+ - `biofs lab claim` - Claim custodial wallet
378
+
379
+ 4. **Admin Dashboard Integration**
380
+ - View all LabNFTs at `https://admin.genobank.io`
381
+ - Approve/verify labs
382
+ - Monitor LabNFT activity
383
+
384
+ ## Support
385
+
386
+ - **Documentation:** This file
387
+ - **API Reference:** `/production_api/API-ENDPOINTS-FUNCTION-MANUAL.md`
388
+ - **BioFS-CLI Help:** `biofs admin register-lab --help`
389
+ - **Issues:** https://github.com/Genobank/biofs-cli/issues
390
+ - **Email:** support@genobank.io
391
+
392
+ ---
393
+
394
+ **Implementation Date:** November 12, 2025
395
+ **Author:** GenoBank.io Development Team
396
+ **Version:** BioFS-CLI v2.2.0 + Production API v2025.11
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Admin Commands Index
3
+ *
4
+ * Admin operations for BioFS including lab registration and verification
5
+ *
6
+ * @author GenoBank.io
7
+ */
8
+ import { Command } from 'commander';
9
+ /**
10
+ * Create the admin command group
11
+ */
12
+ export declare function createAdminCommand(): Command;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAS5C"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Admin Commands Index
4
+ *
5
+ * Admin operations for BioFS including lab registration and verification
6
+ *
7
+ * @author GenoBank.io
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.createAdminCommand = createAdminCommand;
11
+ const commander_1 = require("commander");
12
+ const register_lab_1 = require("./register-lab");
13
+ const verify_lab_1 = require("./verify-lab");
14
+ /**
15
+ * Create the admin command group
16
+ */
17
+ function createAdminCommand() {
18
+ const admin = new commander_1.Command('admin')
19
+ .description('Admin operations (requires admin privileges)');
20
+ // Add subcommands
21
+ admin.addCommand((0, register_lab_1.createRegisterLabCommand)());
22
+ admin.addCommand((0, verify_lab_1.createVerifyLabCommand)());
23
+ return admin;
24
+ }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/admin/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AASH,gDASC;AAhBD,yCAAoC;AACpC,iDAA0D;AAC1D,6CAAsD;AAEtD;;GAEG;AACH,SAAgB,kBAAkB;IAChC,MAAM,KAAK,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;SAC/B,WAAW,CAAC,8CAA8C,CAAC,CAAC;IAE/D,kBAAkB;IAClB,KAAK,CAAC,UAAU,CAAC,IAAA,uCAAwB,GAAE,CAAC,CAAC;IAC7C,KAAK,CAAC,UAAU,CAAC,IAAA,mCAAsB,GAAE,CAAC,CAAC;IAE3C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Admin Register Lab Command - Sequentia Network (v2.0)
3
+ *
4
+ * Onboards new research labs by calling GenoBank's unified /register_lab API:
5
+ * 1. Extracts lab info from website
6
+ * 2. Generates custodial wallet (or accepts user wallet)
7
+ * 3. Stores in MongoDB 'labs' collection
8
+ * 4. Mints LabNFT on Sequentia blockchain
9
+ *
10
+ * This command now delegates to the GenoBank API for consistency
11
+ * across all registration channels (CLI, web interface, admin dashboard).
12
+ *
13
+ * @author GenoBank.io - BioFS CLI Team
14
+ * @version 2.0 - Unified API Integration
15
+ */
16
+ import { Command } from 'commander';
17
+ interface RegisterLabOptions {
18
+ name?: string;
19
+ email?: string;
20
+ specialization?: string;
21
+ location?: string;
22
+ wallet?: string;
23
+ labType?: string;
24
+ autoApprove?: boolean;
25
+ yes?: boolean;
26
+ }
27
+ /**
28
+ * Main registration function
29
+ */
30
+ export declare function registerLab(websiteUrl: string, options: RegisterLabOptions): Promise<void>;
31
+ /**
32
+ * Create the register-lab command
33
+ */
34
+ export declare function createRegisterLabCommand(): Command;
35
+ export {};
36
+ //# sourceMappingURL=register-lab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-lab.d.ts","sourceRoot":"","sources":["../../../src/commands/admin/register-lab.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAwDD;;GAEG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAwHf;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAelD"}