|
| 1 | +# fula_client |
| 2 | + |
| 3 | +A Flutter SDK for [Fula](https://fx.land) decentralized storage with client-side encryption, metadata privacy, and secure file sharing. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Client-side encryption** - AES-256-GCM encryption, data never leaves your device unencrypted |
| 8 | +- **Metadata privacy** - File names and sizes are obfuscated from the server |
| 9 | +- **Secure sharing** - Share files with capability-based access tokens |
| 10 | +- **Key rotation** - Rotate encryption keys without re-uploading data |
| 11 | +- **Cross-platform** - Works on Android (FFI) and Web (WASM) |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```yaml |
| 16 | +dependencies: |
| 17 | + fula_client: ^0.1.0 |
| 18 | +``` |
| 19 | +
|
| 20 | +Or run: |
| 21 | +
|
| 22 | +```bash |
| 23 | +flutter pub add fula_client |
| 24 | +``` |
| 25 | + |
| 26 | +## Quick Start |
| 27 | + |
| 28 | +```dart |
| 29 | +import 'package:fula_client/fula_client.dart'; |
| 30 | +import 'dart:convert'; |
| 31 | +import 'dart:typed_data'; |
| 32 | +
|
| 33 | +Future<void> main() async { |
| 34 | + // Create encrypted client |
| 35 | + final config = FulaConfig( |
| 36 | + endpoint: 'http://localhost:9000', |
| 37 | + accessToken: 'your-jwt-token', |
| 38 | + ); |
| 39 | +
|
| 40 | + final encConfig = EncryptionConfig( |
| 41 | + enableMetadataPrivacy: true, |
| 42 | + obfuscationMode: ObfuscationMode.deterministic, |
| 43 | + ); |
| 44 | +
|
| 45 | + final client = await createEncryptedClient(config, encConfig); |
| 46 | +
|
| 47 | + // Upload encrypted file |
| 48 | + final data = utf8.encode('Secret document content'); |
| 49 | + await putFlat( |
| 50 | + client, |
| 51 | + 'my-bucket', |
| 52 | + '/documents/secret.txt', |
| 53 | + Uint8List.fromList(data), |
| 54 | + 'text/plain', |
| 55 | + ); |
| 56 | +
|
| 57 | + // Download and decrypt |
| 58 | + final decrypted = await getFlat(client, 'my-bucket', '/documents/secret.txt'); |
| 59 | + print('Content: ${utf8.decode(decrypted)}'); |
| 60 | +
|
| 61 | + // List files (shows original names, not obfuscated) |
| 62 | + final files = await listDecrypted(client, 'my-bucket', ListOptions()); |
| 63 | + for (final file in files) { |
| 64 | + print('${file.originalKey} - ${file.size} bytes'); |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Platform Setup |
| 70 | + |
| 71 | +### Android |
| 72 | + |
| 73 | +Add to `android/app/build.gradle`: |
| 74 | + |
| 75 | +```gradle |
| 76 | +android { |
| 77 | + defaultConfig { |
| 78 | + ndk { |
| 79 | + abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64' |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### Web |
| 86 | + |
| 87 | +Ensure your web server serves WASM files with the correct MIME type: |
| 88 | +``` |
| 89 | +application/wasm |
| 90 | +``` |
| 91 | + |
| 92 | +## API Overview |
| 93 | + |
| 94 | +### Client Creation |
| 95 | + |
| 96 | +- `createClient(config)` - Create basic client |
| 97 | +- `createEncryptedClient(config, encConfig)` - Create client with encryption |
| 98 | + |
| 99 | +### Bucket Operations |
| 100 | + |
| 101 | +- `createBucket(client, name)` - Create a bucket |
| 102 | +- `listBuckets(client)` - List all buckets |
| 103 | +- `deleteBucket(client, name)` - Delete a bucket |
| 104 | + |
| 105 | +### Object Operations |
| 106 | + |
| 107 | +- `putObject(client, bucket, key, data)` - Upload object |
| 108 | +- `getObject(client, bucket, key)` - Download object |
| 109 | +- `deleteObject(client, bucket, key)` - Delete object |
| 110 | +- `listObjects(client, bucket, options)` - List objects |
| 111 | + |
| 112 | +### Encrypted Operations |
| 113 | + |
| 114 | +- `putEncrypted(client, bucket, key, data)` - Upload with encryption |
| 115 | +- `getDecrypted(client, bucket, key)` - Download and decrypt |
| 116 | +- `listDecrypted(client, bucket, options)` - List with decrypted metadata |
| 117 | + |
| 118 | +### Flat Namespace (File System API) |
| 119 | + |
| 120 | +- `putFlat(client, bucket, path, data, contentType)` - Upload by path |
| 121 | +- `getFlat(client, bucket, path)` - Download by path |
| 122 | +- `deleteFlat(client, bucket, path)` - Delete by path |
| 123 | +- `listDirectory(client, bucket, path)` - List directory contents |
| 124 | + |
| 125 | +### Secure Sharing |
| 126 | + |
| 127 | +- `createShareToken(client, key, mode, expiry)` - Create share token |
| 128 | +- `acceptShare(tokenJson)` - Accept a share |
| 129 | +- `getWithShare(client, bucket, key, share)` - Access shared file |
| 130 | + |
| 131 | +### Key Management |
| 132 | + |
| 133 | +- `exportSecretKey(client)` - Export encryption key for backup |
| 134 | +- `createRotationManager(client)` - Create key rotation manager |
| 135 | +- `rotateBucket(client, bucket, manager)` - Rotate all keys in bucket |
| 136 | + |
| 137 | +## Documentation |
| 138 | + |
| 139 | +- [Full API Documentation](https://functionland.github.io/fula-api/) |
| 140 | +- [Flutter Integration Guide](https://github.com/functionland/fula-api/blob/main/docs/flutter-integration.md) |
| 141 | +- [Security Model](https://github.com/functionland/fula-api/blob/main/docs/THREAT_MODEL.md) |
| 142 | + |
| 143 | +## JavaScript / Web |
| 144 | + |
| 145 | +For JavaScript/TypeScript web applications, use the npm package: |
| 146 | + |
| 147 | +```bash |
| 148 | +npm install @functionland/fula-client |
| 149 | +``` |
| 150 | + |
| 151 | +## License |
| 152 | + |
| 153 | +MIT License - see [LICENSE](LICENSE) for details. |
| 154 | + |
| 155 | +## Contributing |
| 156 | + |
| 157 | +Contributions are welcome! Please see our [Contributing Guide](https://github.com/functionland/fula-api/blob/main/CONTRIBUTING.md). |
| 158 | + |
| 159 | +## Support |
| 160 | + |
| 161 | +- [GitHub Issues](https://github.com/functionland/fula-api/issues) |
| 162 | +- [Documentation](https://functionland.github.io/fula-api/) |
0 commit comments