The core TypeScript/JavaScript client library and utilities for interacting with the Filosign decentralized e-signature platform. Provides high-level APIs for user registration, authentication, document signing, and secure communication.
The Platform package contains:
- Client Library: High-level API for Filosign operations
- Type Definitions: TypeScript interfaces and types
- Utilities: Helper functions for common operations
The main client for interacting with Filosign:
import { FilosignClient } from "@filosign/platform";
const client = new FilosignClient(walletClient);
await client.initialize();- Registration: Zero-knowledge registration with PIN-based encryption
- Authentication: Secure login with key regeneration
- Identity Verification: On-chain cryptographic identity management
- File Registration: Register documents for signing on-chain
- Acknowledgment: Confirm document receipt
- Signature Submission: Submit cryptographic signatures
- Status Tracking: Query document and signature states
- End-to-End Encryption: ECDH-based document encryption
- Shared Keys: Ephemeral encryption for secure file exchange
- Recipient Management: Approve trusted senders
bun add @filosign/platformimport { FilosignClient } from "@filosign/platform";
// Initialize with wallet
const client = new FilosignClient(walletClient);
await client.initialize();
// Register user (first time only)
await client.register("your-secure-pin");
// Login (subsequent sessions)
await client.login("your-secure-pin");
// Register a document for signing
const documentCid = "bafy..."; // IPFS/Filecoin CID
await client.registerDocument(documentCid, recipientAddress);
// As recipient: acknowledge document
await client.acknowledgeDocument(cidIdentifier);
// Submit signature
await client.submitSignature(cidIdentifier, signatureData);
// Encrypt document for secure transmission
const { encrypted, iv } = await client.encryptDocument(documentData, recipientAddress);
// Decrypt received document
const decrypted = await client.decryptDocument(encryptedData, iv, senderAddress);constructor(wallet: Wallet)- Create client instanceinitialize()- Setup contracts and version synchronization
isRegistered(): Promise<boolean>- Check registration statusregister(pin: string): Promise<void>- Register new user with PINlogin(pin: string): Promise<void>- Authenticate and regenerate keys
registerDocument(cid: string, recipient: Address): Promise<Hash>- Register document for signingacknowledgeDocument(cidIdentifier: string): Promise<Hash>- Acknowledge document receiptsubmitSignature(cidIdentifier: string, signatureData: SignatureData): Promise<Hash>- Submit signaturegetDocumentData(cidIdentifier: string): Promise<FileData>- Get document informationgetSignatureData(cidIdentifier: string): Promise<SignatureData>- Get signature information
encryptDocument(data: Uint8Array, recipient: Address): Promise<{encrypted: ArrayBuffer, iv: Uint8Array}>- Encrypt documentdecryptDocument(encrypted: ArrayBuffer, iv: Uint8Array, sender: Address): Promise<Uint8Array>- Decrypt document
import { computeCidIdentifier, validateSignature } from "@filosign/platform";
// Compute CID identifier from pieces
const identifier = computeCidIdentifier(pieceCidPrefix, pieceCidTail);
// Validate signature format
const isValid = validateSignature(signatureData);The platform integrates directly with Filosign smart contracts:
- FSManager: Access control and coordination
- FSFileRegistry: Document and signature management
- FSKeyRegistry: Cryptographic identity storage
Leverages WebAssembly cryptographic operations:
- Key Derivation: PIN-based encryption key generation
- ECDH Exchange: Secure key exchange for document encryption
- Signature Verification: Cryptographic signature validation
Works with decentralized storage solutions:
- IPFS: Content addressing for documents
- Filecoin: Long-term storage guarantees
- CID Management: Content identifier generation and validation
- PIN never stored on-chain or servers
- Commitment-based verification prevents PIN theft
- Encrypted seed storage with PIN-derived keys
- Encryption keys regenerated per login session
- No long-term key storage in memory
- Automatic cleanup of sensitive data
- ECDH key exchange for document encryption
- AES-GCM authenticated encryption
- Ephemeral keys for each communication
# Install dependencies
bun install
# Build library
bun run build
# Run tests
bun run test
# Generate documentation
bun run docs
# Start development server
bun run devconst client = new FilosignClient(walletClient, {
chainId: 314159, // Filecoin Calibration
contractAddresses: {
manager: "0x...",
fileRegistry: "0x...",
keyRegistry: "0x..."
}
});const client = new FilosignClient(walletClient, {
encryption: {
algorithm: "AES-GCM",
keyLength: 256,
ivLength: 12
}
});// Sender workflow
const client = new FilosignClient(senderWallet);
await client.initialize();
await client.login("sender-pin");
// Upload document to IPFS/Filecoin
const cid = await uploadToIPFS(documentData);
// Register for signing
await client.registerDocument(cid, recipientAddress);
// Recipient workflow
const recipientClient = new FilosignClient(recipientWallet);
await recipientClient.initialize();
await recipientClient.login("recipient-pin");
// Acknowledge receipt
await recipientClient.acknowledgeDocument(cidIdentifier);
// Sign document
const signatureData = await createSignature(documentData);
await recipientClient.submitSignature(cidIdentifier, signatureData);// Encrypt document for recipient
const { encrypted, iv } = await senderClient.encryptDocument(
documentData,
recipientAddress
);
// Send encrypted data + IV to recipient
// Recipient decrypts
const decrypted = await recipientClient.decryptDocument(
encrypted,
iv,
senderAddress
);try {
await client.register("weak-pin");
} catch (error) {
if (error.code === "ALREADY_REGISTERED") {
console.log("User already registered");
} else if (error.code === "INVALID_PIN") {
console.log("PIN validation failed");
}
}- Fork the repository
- Create feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit pull request
AGPL-3.0-or-later