coffrify 0.9.0 copy "coffrify: ^0.9.0" to clipboard
coffrify: ^0.9.0 copied to clipboard

Official Dart SDK for Coffrify, encrypted file transfer infrastructure: transfers, webhooks, API keys, audit, vaults and 30+ resources. Pure Dart, no Flutter dependency.

example/lib/main.dart

// Coffrify Dart SDK — minimal CLI example.
//
// Demonstrates:
//   - Bootstrapping the Coffrify client
//   - Creating a transfer
//   - Verifying an inbound webhook signature with the test helper

import 'package:coffrify/coffrify.dart';
import 'package:coffrify/testing.dart';

Future<void> main() async {
  const apiKey = String.fromEnvironment(
    'COFFRIFY_API_KEY',
    defaultValue: 'cof_test_replace_me',
  );

  final client = Coffrify(
    apiKey: apiKey,
    configuration: CoffrifyConfiguration(
      apiKey: apiKey,
      timeout: const Duration(seconds: 20),
      retryPolicy: const ExponentialBackoff(maxAttempts: 3),
    ),
  );

  print('Creating transfer...');
  try {
    final result = await client.transfers.create(
      const [
        TransferFileInput(
          name: 'hello.txt',
          size: 11,
          mimeType: 'text/plain',
        ),
      ],
      options: const CreateTransferOptions(
        expiresInHours: 24,
        maxDownloads: 5,
        transferTitle: 'SDK demo',
      ),
    );
    print('Transfer created: ${result.transfer.shortCode}');
    print('Upload URL: ${result.uploadUrls.first.url}');
  } on CoffrifyApiException catch (e) {
    print('Coffrify error ${e.status}: ${e.message}');
  }

  print('\nVerifying a test webhook...');
  const secret = 'whsec_1234567890abcdef';
  final signed = signPayloadTest(
    secret: secret,
    body: {
      'id': 'evt_demo',
      'type': 'ping',
      'created_at': DateTime.now().toUtc().toIso8601String(),
      'workspace_id': 'ws_demo',
      'data': {'source': 'manual'},
    },
  );
  final verification = await verifyWebhook(
    secret: secret,
    body: signed.body,
    headers: signed.headers,
  );
  if (verification.valid) {
    print('Webhook OK - event type: ${verification.event!.type}');
  } else {
    print('Webhook rejected: ${verification.failure!.name}');
  }
}
0
likes
160
points
77
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Official Dart SDK for Coffrify, encrypted file transfer infrastructure: transfers, webhooks, API keys, audit, vaults and 30+ resources. Pure Dart, no Flutter dependency.

Homepage
Repository (GitHub)
View/report issues

Topics

#coffrify #file-transfer #webhooks #encryption #sdk

License

MIT (license)

Dependencies

crypto, http, meta

More

Packages that depend on coffrify