https://github.com/testorg0373/t-jwt
A simple library for signing and verifying JWTs in Dart lang. Currently only supports HMAC-256.
https://github.com/testorg0373/t-jwt
dart jwt
Last synced: 6 months ago
JSON representation
A simple library for signing and verifying JWTs in Dart lang. Currently only supports HMAC-256.
- Host: GitHub
- URL: https://github.com/testorg0373/t-jwt
- Owner: TestOrg0373
- License: bsd-3-clause
- Created: 2023-03-13T13:32:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T06:32:46.000Z (over 2 years ago)
- Last Synced: 2025-03-16T04:28:00.490Z (over 1 year ago)
- Topics: dart, jwt
- Language: Dart
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Json Web Token (JWT) library for Dart
Meant for usage in our web server library but also perfectly suitable for usage independently. File issues here and see pub.dev page here.
## Limitations
- Currently only supports HS256 algorithm
- Not verified to be safe for production
- Not 100% compliant with the JWT standard yet
## Getting started
### Add dependency
```
$ dart pub add t_jwt
```
or add it manually to your `pubspec.yaml` file:
```yaml
dependencies:
t_jwt: ^replace-with-latest-version
```
### Example usage:
```dart
import 'package:t_jwt/t_jwt.dart';
void main() {
JWT jwt = JWT('your-secret-here');
Map header = {
'alg': 'HS256',
'typ': 'JWT'
};
Map payload = {
'name': 'Topography Digital',
'username': 'topography.digital',
};
DateTime expiresAt = DateTime.now().add(Duration(days: 1));
String signed = jwt.sign(header, payload, expiresAt);
bool isVerified = jwt.verify(signed);
// The token
print(signed);
// True or false depending on if the token is valid
print(isVerified);
}
```