-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from yakforward-ou/remove_callable
remove callable
- Loading branch information
Showing
58 changed files
with
207 additions
and
1,558 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
### 2.1.0 | ||
- remove delegates to avoid implicit_call_tearoffs | ||
|
||
### 2.0.3 | ||
- example link and readme update | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
import 'package:byte_token/byte_token.dart'; | ||
import 'package:crypto/crypto.dart'; | ||
|
||
/// encodes [Bytes] using [Hmac] | ||
class HmacEncoder extends BytesEncoder { | ||
const HmacEncoder(); | ||
|
||
/// takes two parameters | ||
/// first: the `input` to sign | ||
/// second the `secret key` | ||
@override | ||
Bytes call(p0, p1) => Hmac(sha256, p1).convert(p0).bytes; | ||
} | ||
Bytes hmacEncode(Bytes p0, Bytes p1) => Hmac(sha256, p1).convert(p0).bytes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
import 'package:yak_utils/yak_utils.dart'; | ||
|
||
import 'encoder.dart'; | ||
import 'extensions.dart'; | ||
import 'payload.dart'; | ||
import 'secret.dart'; | ||
import 'typedefs.dart'; | ||
|
||
/// a callable class that generates a signature [Bytes] | ||
class ByteSignature extends UnaryDelegate<Bytes, Payload> { | ||
class ByteSignature { | ||
final Secret secret; | ||
final BytesEncoder encoder; | ||
final Encode encode; | ||
|
||
/// the constructor takes a [Secret] as argument | ||
/// default encoder is [HmacEncoder] | ||
const ByteSignature( | ||
this.secret, { | ||
this.encoder = const HmacEncoder(), | ||
}); | ||
ByteSignature(this.secret, {Encode? encode}) : encode = encode ?? hmacEncode; | ||
|
||
@override | ||
Bytes call(Payload p0) { | ||
if (p0.isExpired) { | ||
throw Exception('token expired\n$p0'); | ||
} | ||
final payload = p0.toBuffer(); | ||
return encoder(payload, secret()); | ||
return encode(payload, secret()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
import 'package:yak_utils/yak_utils.dart'; | ||
|
||
typedef EncoderDelegate<T> = MultiDelegate2<T, T, T>; | ||
typedef Bytes = List<int>; | ||
typedef BytesEncoder = EncoderDelegate<Bytes>; | ||
typedef Encode = Bytes Function(Bytes, Bytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
### 2.1.0 | ||
- remove delegates to avoid implicit_call_tearoffs | ||
|
||
### 2.0.2 | ||
- example link and readme update | ||
|
||
|
Oops, something went wrong.