Skip to content
Merged

dart #60

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/src/dpop/dpop_signer_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ Future<String> signRs256(
String signingInput,
String privateKeyPem,
String publicExponent,
) async =>
signRs256Sync(signingInput, privateKeyPem);
) async => signRs256Sync(signingInput, privateKeyPem);
6 changes: 4 additions & 2 deletions lib/src/dpop/dpop_signer_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ Future<String> signRs256(
String privateKeyPem,
String publicExponent,
) async {
final key =
await (_keys[privateKeyPem] ??= _importKey(privateKeyPem, publicExponent));
final key = await (_keys[privateKeyPem] ??= _importKey(
privateKeyPem,
publicExponent,
));
final signature = await web.window.crypto.subtle
.sign(_algorithm, key, Uint8List.fromList(utf8.encode(signingInput)).toJS)
.toDart;
Expand Down
10 changes: 8 additions & 2 deletions test/dpop_token_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ void main() {
);

// RS256 is deterministic: same key and input, same signature.
expect(await signRs256(input, _pem), signRs256Sync(input, _pem));
expect(
await signRs256(input, _pem, _jwk['e'] as String),
signRs256Sync(input, _pem),
);
// And again, from the cached key.
expect(await signRs256(input, _pem), signRs256Sync(input, _pem));
expect(
await signRs256(input, _pem, _jwk['e'] as String),
signRs256Sync(input, _pem),
);
});
}

Expand Down
Loading