GenoBank.io

DNA Kit Activation System - Complete Guide

Table of Contents

  1. Overview
  2. System Architecture
  3. Magic URL System
  4. Passkey Authentication
  5. Implementation Details
  6. API Endpoints
  7. Security
  8. Testing Guide
  9. Troubleshooting

Overview

The GenoBank DNA Kit Activation system allows users to activate their DNA collection kits and mint BioNFTsβ„’ on Story Protocol. The system supports two activation methods:

  1. Magic URL Activation: Pre-registered kits shipped with secure activation URLs
  2. Open Registration: Any DNA kit can be activated using passkey authentication

Key Features

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     β”‚     β”‚                     β”‚     β”‚                     β”‚
β”‚   Laboratory/Lab    │────▢│   GenoBank API     │────▢│  Story Protocol    β”‚
β”‚                     β”‚     β”‚                     β”‚     β”‚                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                           β”‚                           β”‚
         β”‚ 1. Create                 β”‚ 3. Validate              β”‚ 4. Mint
         β”‚    Magic Link             β”‚    & Store               β”‚    BioNFT
         β”‚                           β”‚                           β”‚
         β–Ό                           β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     β”‚     β”‚                     β”‚     β”‚                     β”‚
β”‚   DNA Kit with     │────▢│  Activation Page    │────▢│     BioNFTβ„’        β”‚
β”‚   Magic URL        β”‚     β”‚  (Passkey Auth)     β”‚     β”‚                     β”‚
β”‚                     β”‚     β”‚                     β”‚     β”‚                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                           β”‚
         β”‚ 2. User Clicks           β”‚ 
         β”‚    Magic URL             β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Magic URL System

How Magic URLs Work

  1. Laboratory Creates Magic Link
    POST https://genobank.app/create_magic_link
       
    // Request
    {
      signature: "0x...", // Lab's Web3 signature
      data: {
        "prefix": "100",
        "biosampleId": "55052008714049",
        "physicalId": "10055052008714049", 
        "packageHashCode": "2xuE-AXCa-Z3D-tQb",
        "domain": "https://genobank.io"
      }
    }
       
    // Response
    {
      "url": "https://genobank.io/activate/?biosampleId=55052008714049&laboratoryId=39&physicalId=10055052008714049#67d6516e1229eee318e5032776377b639f1c2ee2fe93531164bf5706d56fdcf1"
    }
    
  2. URL Structure
    https://genobank.io/activate/?
      biosampleId=55052008714049&        // Kit serial number
      laboratoryId=39&                   // Lab/Permittee ID  
      physicalId=10055052008714049       // Physical kit ID
      #67d6516e1229eee3...               // HMAC-SHA256 secret
    
  3. Secret Generation
    # Server-side HMAC generation
    secret = hmac.new(
        BIOSAMPLE_ACTIVATION_SECRET.encode('utf-8'),
        str(biosampleId).encode(),
        digestmod='sha256'
    ).hexdigest()
    

Biosample Activation Records

Pre-registered kits appear in the activation registry:

GET https://genobank.app/biosample_activations

// Response
{
  "data": [{
    "serial": 55052008714049,
    "permitteeSerial": "39",
    "physicalId": "10055052008714049",
    "createdAt": "2025-03-12 18:45:08.580000",
    "manufacturer": "DNA Genotek"
  }]
}

Passkey Authentication

Privy Integration

The system uses Privy for passkey authentication:

// Configuration
const privy = new Privy({
    appId: 'cmc5jn5sh01wel10ng0x5atlt',
    config: {
        loginMethods: ['passkey', 'email', 'google', 'apple'],
        appearance: {
            theme: 'light',
            accentColor: '#667eea'
        }
    }
});

Authentication Flow

  1. User clicks β€œContinue with Passkey”
  2. Device prompts for biometric (Face ID, Touch ID, or Windows Hello)
  3. Privy creates embedded wallet
  4. Signs GenoBank message: β€œI want to proceed”
  5. Verifies with GenoBank API: /recover?signature={sig}

Implementation Details

Frontend Files

  1. /activate/passkey-activation.html
    • 4-step activation flow UI
    • Responsive design
    • Progress indicators
  2. /activate/passkey-activate.js
    • Privy SDK integration
    • Magic URL detection
    • Barcode scanning (ZXing library)
    • API communication

Key JavaScript Functions

// Check for magic URL on page load
function checkMagicLinkActivation() {
    const urlParams = new URLSearchParams(window.location.search);
    const biosampleId = urlParams.get('biosampleId');
    const laboratoryId = urlParams.get('laboratoryId');
    const physicalId = urlParams.get('physicalId');
    const secret = window.location.hash.substring(1);
    
    if (biosampleId && secret) {
        window.magicLinkData = {
            biosampleId,
            laboratoryId,
            physicalId,
            secret
        };
    }
}

// Authenticate with passkey
async function authenticateWithPrivy() {
    const user = await privy.login();
    const wallet = await privy.getEmbeddedWallet();
    const signature = await wallet.signMessage("I want to proceed");
    // Store credentials
    localStorage.setItem('user_sign', signature);
    localStorage.setItem('user_address', wallet.address);
}

// Activate kit
async function activateKit() {
    if (window.magicLinkData) {
        // Use existing /claim endpoint
        const tokenId = generateTokenId(biosampleId, walletAddress);
        await fetch(`/claim/${tokenId}`, {
            method: 'POST',
            body: JSON.stringify({
                secret: window.magicLinkData.secret,
                physicalId: window.magicLinkData.physicalId,
                laboratoryId: window.magicLinkData.laboratoryId
            })
        });
    } else {
        // Use new activation endpoint
        await fetch(`/api_activation/`, {
            method: 'POST',
            body: JSON.stringify({
                user_signature: userSignature,
                barcode: currentBarcode,
                manufacturer: detectManufacturer(currentBarcode).name
            })
        });
    }
}

Backend Integration

The system leverages existing GenoBank infrastructure:

# /production_api/plugins/activation/api_activate_kit.py

class ApiActivateKit:
    def __init__(self):
        self.signature_service = SignatureService()
        self.biosample_service = BiosampleService()
        self.biosample_dao = BiosampleDAO()
        self.story_protocol = StoryIpManagerDAO()
        
    @cherrypy.expose
    def index(self):
        # 1. Verify signature
        wallet = self.signature_service.recover_from_signature(user_signature)
        
        # 2. Create biosample record
        biosample_data = {
            "serial": barcode,
            "owner": wallet,
            "manufacturer": manufacturer,
            "status": "ACTIVE"
        }
        
        # 3. Mint BioNFT on Story Protocol
        mint_result = self.story_protocol.mint_and_register_ip({
            "collection_address": self.biosample_collection,
            "recipient": wallet,
            "metadata_uri": metadata_uri
        })
        
        # 4. Save to database
        self.biosample_dao.create(biosample_data)

API Endpoints

POST /create_magic_link
Headers: Content-Type: application/json
Body: {
  "signature": "0x...",
  "data": {
    "biosampleId": "55052008714049",
    "physicalId": "10055052008714049",
    "domain": "https://genobank.io"
  }
}

2. Claim Kit (With Magic URL)

POST /claim/{tokenId}
Headers: Content-Type: application/json
Body: {
  "secret": "67d6516e1229eee3...",
  "physicalId": "10055052008714049",
  "laboratoryId": "39"
}

3. Activate Kit (Open Registration)

POST /api_activation/
Headers: Content-Type: application/json
Body: {
  "user_signature": "0x...",
  "barcode": "55052008714049",
  "manufacturer": "DNA Genotek"
}

4. Verify Signature

GET /recover?signature={signature}
Response: {
  "wallet_address": "0x...",
  "user": {...}
}

5. Check Activations

GET /biosample_activations?serial={serial}
Response: {
  "data": [{
    "serial": 55052008714049,
    "permitteeSerial": "39",
    "physicalId": "10055052008714049"
  }]
}

Security

Authentication Security

Magic URL Security

Kit Activation Security

Testing Guide

1. Test Magic URL Activation

# Visit with magic URL
https://genobank.io/activate/passkey-activation.html?biosampleId=55052008714049&laboratoryId=39&physicalId=10055052008714049#secret

# Should:
- Pre-fill barcode field
- Detect magic link
- Use /claim endpoint

2. Test Open Registration

# Visit directly
https://genobank.io/activate/passkey-activation.html

# Should:
- Show empty barcode field
- Accept any valid barcode
- Use /api_activation endpoint

3. Test Barcode Formats

// Valid formats
41221040804049  // DNA Genotek (412 prefix)
42221040804049  // Spectrum DNA (422 prefix)
43221040804049  // Mawi DNA (432 prefix)
55052008714049  // GenoBank Standard (550 prefix)

4. Test Authentication Methods

Troubleshooting

Common Issues

  1. β€œBiosample Activation Not Found”
    • Kit not pre-registered
    • Use open registration flow instead
  2. β€œInvalid signature”
    • Expired Web3 signature
    • Re-authenticate with Privy
  3. β€œKit already activated”
    • Check /biosamples?serial={serial}
    • Kit may be claimed by another user
  4. Camera not working
    • Check browser permissions
    • Use manual barcode entry
  5. Passkey not available
    • Device doesn’t support WebAuthn
    • Falls back to email/social login

Debug Mode

Enable console logging:

// In browser console
localStorage.setItem('debug', 'true');

// Check stored data
console.log('Magic Link Data:', window.magicLinkData);
console.log('User Wallet:', localStorage.getItem('user_address'));
console.log('User Signature:', localStorage.getItem('user_sign'));

Error Handling

All errors display user-friendly messages:

function showError(message) {
    const errorEl = document.getElementById('error-message');
    errorEl.textContent = message;
    errorEl.style.display = 'block';
    setTimeout(() => errorEl.style.display = 'none', 5000);
}

Kit Manufacturer Support

Detected by barcode prefix (first 3 digits):

Prefix Manufacturer Kit Type
412 DNA Genotek Saliva Collection
422 Spectrum DNA Saliva Collection
432 Mawi DNA Saliva Collection
442 Norgen Biotek Saliva Collection
452 Zymo Research Saliva Collection
550 GenoBank Standard Standard Kit

Future Enhancements

  1. QR Code Support
    • Scan QR codes instead of barcodes
    • Embed magic URL in QR
  2. Bulk Activation
    • Activate multiple kits at once
    • CSV upload for labs
  3. Mobile App
    • Native iOS/Android apps
    • Better camera integration
  4. Analytics
    • Track activation success rates
    • Monitor authentication methods
    • Geographic distribution
  5. Enhanced Security
    • 2FA for high-value kits
    • Geofencing for region-locked kits
    • Fraud detection

Support

For technical support:

License

This implementation is part of the GenoBank platform and subject to GenoBank’s terms of service.