trusted_time_service 1.0.0 copy "trusted_time_service: ^1.0.0" to clipboard
trusted_time_service: ^1.0.0 copied to clipboard

A tamper-resistant trusted time service for Flutter and Dart apps.

Trusted Time Service #

A tamper-resistant trusted time service for Flutter and Dart apps.

This package provides a secure and reliable time source that does not depend on the device clock, making it ideal for security-sensitive use cases like OTP expiry, payments, token validation, and anti-cheat systems.


โœจ Features #

  • Fetches trusted UTC time from HTTPS servers
  • Anchors to native monotonic uptime via FFI
  • Calculates trusted current time without relying on device clock
  • Supports custom timezone offsets
  • Manual trusted anchor injection for server-provided time
  • Safe fallback to system time if initialization fails
  • Ready-to-use on Android and iOS
  • Secure and tamper-resistant design

๐Ÿ“ฆ Installation #

Add this to your pubspec.yaml:

dependencies:
  trusted_time_service: latest

Then run:

flutter pub get

๐Ÿ”ง Platform Setup #

This package uses native uptime through FFI and is ready to use out of the box.

Android #

โœ… Fully supported. No additional setup required.

iOS #

โœ… Fully supported. No additional setup required.

Simply add the package and start using it.


๐Ÿงช Basic Usage #

Initialize once at app startup #

import 'package:trusted_time_service/trusted_time_service.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await TrustedTimeService().initialize(
    defaultOffsetHours: 6, // Example timezone
  );

  runApp(const MyApp());
}

Get trusted current time #

final now = TrustedTimeService().now();
print(now);

Get trusted UTC #

final utc = TrustedTimeService().nowUtc();

Provide custom offset #

final local = TrustedTimeService().now(
  offsetHours: 6,
);

๐Ÿงช Advanced Usage #

Use server-provided trusted time #

If you already have a trusted time source (for example, your own backend or secure server), you can directly use that time as the anchor instead of calling the default HTTPS provider.

await TrustedTimeService().initialize(
  trustedAnchorUtc: serverTime,
);

Reset trusted time #

TrustedTimeService().reset();

Useful when:

  • User logs out
  • Security refresh is needed

๐Ÿ“Š Comparison #

Feature System Time Trusted Time
Tamper resistant โŒ โœ…
Timezone safe โŒ โœ…
Monotonic โŒ โœ…
Secure โŒ โœ…

๐ŸŒŸ Contributors #

We appreciate everyone who contributes to making this package better โค๏ธ

ishafiul


๐Ÿค Welcome to Contribute #

We warmly welcome developers from all experience levels to contribute โค๏ธ

You can help by:

  • Fixing bugs
  • Improving performance
  • Adding features
  • Writing documentation
  • Creating examples
  • Improving platform support

Even small contributions make a big difference.

If you are new to open source, this is a great project to start!


๐Ÿ“ฌ Support #

If you find this package useful:

  • โญ Star the repository
  • Share it with the community
  • Open issues for suggestions

๐Ÿ“„ License #

MIT License

0
likes
150
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A tamper-resistant trusted time service for Flutter and Dart apps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on trusted_time_service

Packages that implement trusted_time_service