mirror of
https://github.com/jonasroussel/dart_jsonwebtoken.git
synced 2025-08-06 13:51:08 +08:00
removing unreachable chips
This commit is contained in:
41
README.md
41
README.md
@ -1,9 +1,6 @@
|
|||||||
# JSON Web Token (JWT)
|
# JSON Web Token (JWT)
|
||||||
|
|
||||||
[](https://pub.dev/packages/dart_jsonwebtoken)
|
[](https://pub.dev/packages/dart_jsonwebtoken)
|
||||||
[](https://pub.dev/packages/dart_jsonwebtoken/score)
|
|
||||||
[](https://pub.dev/packages/dart_jsonwebtoken/score)
|
|
||||||
[](https://pub.dev/packages/dart_jsonwebtoken/score)
|
|
||||||
|
|
||||||
A dart implementation of the famous javascript library `jsonwebtoken`.
|
A dart implementation of the famous javascript library `jsonwebtoken`.
|
||||||
|
|
||||||
@ -25,20 +22,20 @@ import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
|||||||
// Create a json web token
|
// Create a json web token
|
||||||
// Pass the payload to be sent in the form of a map
|
// Pass the payload to be sent in the form of a map
|
||||||
final jwt = JWT(
|
final jwt = JWT(
|
||||||
|
|
||||||
// Payload
|
// Payload
|
||||||
{
|
{
|
||||||
'id': 123,
|
'id': 123,
|
||||||
|
|
||||||
'server': {
|
'server': {
|
||||||
'id': '3e4fc296',
|
'id': '3e4fc296',
|
||||||
'loc': 'euw-2',
|
'loc': 'euw-2',
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
issuer: 'https://github.com/jonasroussel/dart_jsonwebtoken',
|
issuer: 'https://github.com/jonasroussel/dart_jsonwebtoken',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sign it (default with HS256 algorithm)
|
// Sign it (default with HS256 algorithm)
|
||||||
@ -55,29 +52,29 @@ try {
|
|||||||
final jwt = JWT.verify(token, SecretKey('secret passphrase'));
|
final jwt = JWT.verify(token, SecretKey('secret passphrase'));
|
||||||
|
|
||||||
print('Payload: ${jwt.payload}');
|
print('Payload: ${jwt.payload}');
|
||||||
|
|
||||||
} on JWTExpiredError {
|
} on JWTExpiredError {
|
||||||
|
|
||||||
print('jwt expired');
|
print('jwt expired');
|
||||||
|
|
||||||
} on JWTError catch (ex) {
|
} on JWTError catch (ex) {
|
||||||
|
|
||||||
print(ex.message); // ex: invalid signature
|
print(ex.message); // ex: invalid signature
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Supported Algorithms
|
### Supported Algorithms
|
||||||
|
|
||||||
| JWT Algorithms | Digital Signature or MAC Algorithm |
|
| JWT Algorithms | Digital Signature or MAC Algorithm |
|
||||||
| ------------ | ---------------------------------------------------- |
|
| -------------- | ---------------------------------------------------- |
|
||||||
| HS256 | HMAC using SHA-256 hash algorithm |
|
| HS256 | HMAC using SHA-256 hash algorithm |
|
||||||
| HS384 | HMAC using SHA-384 hash algorithm |
|
| HS384 | HMAC using SHA-384 hash algorithm |
|
||||||
| HS512 | HMAC using SHA-512 hash algorithm |
|
| HS512 | HMAC using SHA-512 hash algorithm |
|
||||||
| RS256 | RSASSA-PKCS1-v1_5 using SHA-256 hash algorithm |
|
| RS256 | RSASSA-PKCS1-v1_5 using SHA-256 hash algorithm |
|
||||||
| RS384 | RSASSA-PKCS1-v1_5 using SHA-384 hash algorithm |
|
| RS384 | RSASSA-PKCS1-v1_5 using SHA-384 hash algorithm |
|
||||||
| RS512 | RSASSA-PKCS1-v1_5 using SHA-512 hash algorithm |
|
| RS512 | RSASSA-PKCS1-v1_5 using SHA-512 hash algorithm |
|
||||||
| ES256 | ECDSA using P-256 curve and SHA-256 hash algorithm |
|
| ES256 | ECDSA using P-256 curve and SHA-256 hash algorithm |
|
||||||
| ES384 | ECDSA using P-384 curve and SHA-384 hash algorithm |
|
| ES384 | ECDSA using P-384 curve and SHA-384 hash algorithm |
|
||||||
| ES512 | ECDSA using P-521 curve and SHA-512 hash algorithm |
|
| ES512 | ECDSA using P-521 curve and SHA-512 hash algorithm |
|
||||||
| EdDSA | EdDSA using ed25519 curve and SHA-512 hash algorithm |
|
| EdDSA | EdDSA using ed25519 curve and SHA-512 hash algorithm |
|
||||||
|
Reference in New Issue
Block a user