@dcid/sdk
v0.1.2
Published
DCID SDK - Decentralized identity, verifiable credentials, and zero-knowledge proofs for web, extensions, and mobile
Maintainers
Readme
DCID SDK
Official TypeScript SDK for DCID - Decentralized identity, verifiable credentials, and zero-knowledge proofs.
Features
- 🔐 Decentralized Identity (DID) - self-sovereign identity
- ✅ Verifiable Credentials - Issue, store, and verify credentials
- 🔒 Zero-Knowledge Proofs - Privacy-preserving verification
- 🔑 Secure Key Management - HSM-backed key storage
- 📦 IPFS Backup - Encrypted credential backup and recovery
- 🌐 Cross-Platform - Works in browser, extensions, and mobile
- 📊 Analytics - Optional privacy-respecting analytics
- ⚡ Real-time Updates - WebSocket support for MTP credentials
Installation
npm install @dcid/sdkQuick Start
import { DCIDClient } from '@dcid/sdk';
// Initialize the SDK
const client = new DCIDClient({
appId: 'your-app-id',
config: {
appId: 'your-signing-app-id',
appIdEncryption: 'your-encryption-app-id',
env: 'prod',
},
apiUrl: 'your-backend-url',
});
await client.initialize();
// Authenticate with OTP
await client.auth.initiateSignIn('[email protected]');
const tokens = await client.auth.confirmCode('[email protected]', '123456');
await client.auth.login(tokens.accessToken, tokens.refreshToken);
// Check auth state
console.log('Authenticated:', client.auth.isAuthenticated());Platform Support
The SDK automatically detects the runtime environment and adapts:
- Web - Uses localStorage + IndexedDB
- Browser Extension - Uses chrome.storage + message passing
- Mobile (React Native) - Uses AsyncStorage + Keychain
Architecture
The SDK is modular and tree-shakeable:
- Core - Configuration and main client
- Storage - Cross-platform storage adapters
- HTTP - API client with automatic token refresh
- Auth - OTP authentication and token management
- Identity - DID creation, credentials, proofs
- Analytics - Privacy-respecting event tracking with session & consent management
Development
# Install dependencies
npm install
# Build
npm run build
# Test
npm test
# Test with coverage
npm run test:coverage
# Type check
npm run typecheckProject Structure
dcid-sdk/
├── src/
│ ├── core/ # Core SDK (DCIDClient, config, types)
│ ├── platform/ # Platform adapters (web, extension, mobile)
│ ├── auth/ # Authentication module
│ ├── identity/ # Identity & credentials (DID, VC, ZKP)
│ ├── analytics/ # Analytics with SessionManager & ConsentManager
│ ├── http/ # HTTP client with token refresh
│ ├── storage/ # Storage adapters
│ └── utils/ # Utilities (crypto, logger, errors)
├── tests/ # 88 tests passing
├── examples/ # See dcid-sdk-examples repo
└── docs/ # Platform-specific guides
├── WEBAPP_GUIDE.md # Web app integration
├── EXTENSION_GUIDE.md # Browser extension integration
└── MOBILE_GUIDE.md # React Native integration🔧 Technical Highlights
- Identity: DCID integration, HSM-backed keys, DID creation, VC issuance/verification, ZKP generation
- Analytics: GDPR/CCPA-compliant consent management, session tracking with auto-timeout, privacy-preserving metrics
- Architecture: Platform-agnostic, tree-shakeable modules, full TypeScript coverage
- Testing: Comprehensive mocks for identity SDK, storage adapters, crypto providers
Platform Guides
Comprehensive integration guides for each platform:
- Please Note Web application integrations are for testing and NON-PRODUCTION use.
- We recommend Browser Extensions or Mobile Apps only
- Web Applications - React, Vue, Svelte, vanilla JS
- Browser Extensions - Chrome, Firefox (Manifest V3)
- Mobile Apps - React Native (iOS & Android)
Each guide includes:
- Platform-specific setup and configuration
- Complete authentication flow examples
- Identity & credential management
- Platform-specific features (QR scanning, biometrics, deep linking)
- Troubleshooting and best practices
Examples
For complete working examples, see the dcid-sdk-examples repository:
- Web application integration
- Browser extension integration
- React Native mobile app integration
