Skip to content

Commit e02ea5f

Browse files
chore: fix linter issues (#240)
1 parent 8796ba7 commit e02ea5f

File tree

81 files changed

+3457
-3267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3457
-3267
lines changed

lib/src/boringssl/bindings/generated_bindings.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,27 @@ import 'dart:ffi' as ffi;
2525
class WebCrypto {
2626
/// Holds the symbol lookup function.
2727
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
28-
_lookup;
28+
_lookup;
2929

3030
/// The symbols are looked up in [dynamicLibrary].
3131
WebCrypto(ffi.DynamicLibrary dynamicLibrary)
32-
: _lookup = dynamicLibrary.lookup;
32+
: _lookup = dynamicLibrary.lookup;
3333

3434
/// The symbols are looked up with [lookup].
3535
WebCrypto.fromLookup(
36-
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
37-
lookup)
38-
: _lookup = lookup;
36+
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) lookup,
37+
) : _lookup = lookup;
3938

4039
/// Function to lookup BoringSSL symbols based on index in the Sym enum.
4140
/// See src/symbols.yaml for details.
42-
ffi.Pointer<ffi.Void> webcrypto_lookup_symbol(
43-
int index,
44-
) {
45-
return _webcrypto_lookup_symbol(
46-
index,
47-
);
41+
ffi.Pointer<ffi.Void> webcrypto_lookup_symbol(int index) {
42+
return _webcrypto_lookup_symbol(index);
4843
}
4944

5045
late final _webcrypto_lookup_symbolPtr =
5146
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Int32)>>(
52-
'webcrypto_lookup_symbol');
47+
'webcrypto_lookup_symbol',
48+
);
5349
late final _webcrypto_lookup_symbol = _webcrypto_lookup_symbolPtr
5450
.asFunction<ffi.Pointer<ffi.Void> Function(int)>();
5551
}

lib/src/boringssl/lookup/lookup.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final Pointer<T> Function<T extends NativeType>(String symbolName) lookup = () {
7575
}();
7676

7777
final Pointer<T> Function<T extends NativeType>(String symbolName)
78-
_cachedLookup = lookup;
78+
_cachedLookup = lookup;
7979

8080
/// Gives access to BoringSSL symbols.
8181
final BoringSsl ssl = BoringSsl.fromLookup(_cachedLookup);

lib/src/boringssl/lookup/utils.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ String get libraryFileName {
4242
///
4343
/// Returns `null` if it could not be found.
4444
Pointer<T> Function<T extends NativeType>(String symbolName)?
45-
lookupLibraryInDotDartTool() {
45+
lookupLibraryInDotDartTool() {
4646
final dotDartTool = _findDotDartTool();
4747
if (dotDartTool == null) {
4848
return null;
@@ -78,8 +78,9 @@ Uri? _findDotDartTool() {
7878

7979
// Traverse up until we see a `.dart_tool/package_config.json` file.
8080
do {
81-
if (File.fromUri(root.resolve('.dart_tool/package_config.json'))
82-
.existsSync()) {
81+
if (File.fromUri(
82+
root.resolve('.dart_tool/package_config.json'),
83+
).existsSync()) {
8384
return root.resolve('.dart_tool/');
8485
}
8586
} while (root != (root = root.resolve('..')));
@@ -90,8 +91,9 @@ Uri? _findDotDartTool() {
9091

9192
// Traverse up until we see a `.dart_tool/package_config.json` file.
9293
do {
93-
if (File.fromUri(root.resolve('.dart_tool/package_config.json'))
94-
.existsSync()) {
94+
if (File.fromUri(
95+
root.resolve('.dart_tool/package_config.json'),
96+
).existsSync()) {
9597
return root.resolve('.dart_tool/');
9698
}
9799
} while (root != (root = root.resolve('..')));

lib/src/crypto_subtle.dart

Lines changed: 58 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ extension type JSSubtleCrypto(JSObject _) implements JSObject {
101101
);
102102

103103
/// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
104-
external JSPromise<JSArrayBuffer> digest(
105-
String algorithm,
106-
JSTypedArray data,
107-
);
104+
external JSPromise<JSArrayBuffer> digest(String algorithm, JSTypedArray data);
108105

109106
/// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
110107
external JSPromise<JSArrayBuffer> deriveBits(
@@ -151,10 +148,7 @@ extension type JSSubtleCrypto(JSObject _) implements JSObject {
151148

152149
/// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey
153150
@JS('exportKey')
154-
external JSPromise<JSArrayBuffer> exportKey(
155-
String format,
156-
JSCryptoKey key,
157-
);
151+
external JSPromise<JSArrayBuffer> exportKey(String format, JSCryptoKey key);
158152

159153
/// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey
160154
@JS('exportKey')
@@ -283,25 +277,24 @@ class Algorithm {
283277
TypedData? salt,
284278
TypedData? info,
285279
int? iterations,
286-
}) =>
287-
Algorithm(
288-
name: this.name ?? name,
289-
modulusLength: this.modulusLength ?? modulusLength,
290-
publicExponent: this.publicExponent ?? publicExponent,
291-
hash: this.hash ?? hash,
292-
saltLength: this.saltLength ?? saltLength,
293-
label: this.label ?? label,
294-
namedCurve: this.namedCurve ?? namedCurve,
295-
public: this.public ?? public,
296-
counter: this.counter ?? counter,
297-
length: this.length ?? length,
298-
iv: this.iv ?? iv,
299-
additionalData: this.additionalData ?? additionalData,
300-
tagLength: this.tagLength ?? tagLength,
301-
salt: this.salt ?? salt,
302-
info: this.info ?? info,
303-
iterations: this.iterations ?? iterations,
304-
);
280+
}) => Algorithm(
281+
name: this.name ?? name,
282+
modulusLength: this.modulusLength ?? modulusLength,
283+
publicExponent: this.publicExponent ?? publicExponent,
284+
hash: this.hash ?? hash,
285+
saltLength: this.saltLength ?? saltLength,
286+
label: this.label ?? label,
287+
namedCurve: this.namedCurve ?? namedCurve,
288+
public: this.public ?? public,
289+
counter: this.counter ?? counter,
290+
length: this.length ?? length,
291+
iv: this.iv ?? iv,
292+
additionalData: this.additionalData ?? additionalData,
293+
tagLength: this.tagLength ?? tagLength,
294+
salt: this.salt ?? salt,
295+
info: this.info ?? info,
296+
iterations: this.iterations ?? iterations,
297+
);
305298
}
306299

307300
extension type JSJsonWebKey(JSObject _) implements JSObject {
@@ -390,11 +383,7 @@ TypedData getRandomValues(TypedData array) {
390383
array.setAll(0, dartArray);
391384
}
392385
} else {
393-
throw ArgumentError.value(
394-
array,
395-
'array',
396-
'Unsupported TypedData type',
397-
);
386+
throw ArgumentError.value(array, 'array', 'Unsupported TypedData type');
398387
}
399388

400389
return array;
@@ -406,11 +395,7 @@ Future<ByteBuffer> decrypt(
406395
Uint8List data,
407396
) async {
408397
final value = await window.crypto.subtle
409-
.decrypt(
410-
algorithm.toJS,
411-
key,
412-
data.toJS,
413-
)
398+
.decrypt(algorithm.toJS, key, data.toJS)
414399
.toDart;
415400

416401
return value.toDart;
@@ -422,40 +407,20 @@ Future<ByteBuffer> encrypt(
422407
Uint8List data,
423408
) async {
424409
final value = await window.crypto.subtle
425-
.encrypt(
426-
algorithm.toJS,
427-
key,
428-
data.toJS,
429-
)
410+
.encrypt(algorithm.toJS, key, data.toJS)
430411
.toDart;
431412

432413
return value.toDart;
433414
}
434415

435-
Future<ByteBuffer> exportKey(
436-
String format,
437-
JSCryptoKey key,
438-
) async {
439-
final value = await window.crypto.subtle
440-
.exportKey(
441-
format,
442-
key,
443-
)
444-
.toDart;
416+
Future<ByteBuffer> exportKey(String format, JSCryptoKey key) async {
417+
final value = await window.crypto.subtle.exportKey(format, key).toDart;
445418

446419
return value.toDart;
447420
}
448421

449-
Future<JsonWebKey> exportJsonWebKey(
450-
String format,
451-
JSCryptoKey key,
452-
) async {
453-
final value = await window.crypto.subtle
454-
.exportJsonWebKey(
455-
format,
456-
key,
457-
)
458-
.toDart;
422+
Future<JsonWebKey> exportJsonWebKey(String format, JSCryptoKey key) async {
423+
final value = await window.crypto.subtle.exportJsonWebKey(format, key).toDart;
459424

460425
return value.toDart;
461426
}
@@ -466,11 +431,7 @@ Future<JSCryptoKey> generateKey(
466431
List<String> usages,
467432
) async {
468433
final value = await window.crypto.subtle
469-
.generateCryptoKey(
470-
algorithm.toJS,
471-
extractable,
472-
usages.toJS,
473-
)
434+
.generateCryptoKey(algorithm.toJS, extractable, usages.toJS)
474435
.toDart;
475436

476437
return value;
@@ -482,26 +443,14 @@ Future<JSCryptoKeyPair> generateKeyPair(
482443
List<String> usages,
483444
) async {
484445
final value = await window.crypto.subtle
485-
.generateCryptoKeyPair(
486-
algorithm.toJS,
487-
extractable,
488-
usages.toJS,
489-
)
446+
.generateCryptoKeyPair(algorithm.toJS, extractable, usages.toJS)
490447
.toDart;
491448

492449
return value;
493450
}
494451

495-
Future<ByteBuffer> digest(
496-
String algorithm,
497-
Uint8List data,
498-
) async {
499-
final value = await window.crypto.subtle
500-
.digest(
501-
algorithm,
502-
data.toJS,
503-
)
504-
.toDart;
452+
Future<ByteBuffer> digest(String algorithm, Uint8List data) async {
453+
final value = await window.crypto.subtle.digest(algorithm, data.toJS).toDart;
505454

506455
return value.toDart;
507456
}
@@ -514,13 +463,7 @@ Future<JSCryptoKey> importKey(
514463
List<String> usages,
515464
) async {
516465
final value = await window.crypto.subtle
517-
.importKey(
518-
format,
519-
keyData.toJS,
520-
algorithm.toJS,
521-
extractable,
522-
usages.toJS,
523-
)
466+
.importKey(format, keyData.toJS, algorithm.toJS, extractable, usages.toJS)
524467
.toDart;
525468

526469
return value;
@@ -552,11 +495,7 @@ Future<ByteBuffer> sign(
552495
Uint8List data,
553496
) async {
554497
final value = await window.crypto.subtle
555-
.sign(
556-
algorithm.toJS,
557-
key,
558-
data.toJS,
559-
)
498+
.sign(algorithm.toJS, key, data.toJS)
560499
.toDart;
561500

562501
return value.toDart;
@@ -569,12 +508,7 @@ Future<bool> verify(
569508
Uint8List data,
570509
) async {
571510
final value = await window.crypto.subtle
572-
.verify(
573-
algorithm.toJS,
574-
key,
575-
signature.toJS,
576-
data.toJS,
577-
)
511+
.verify(algorithm.toJS, key, signature.toJS, data.toJS)
578512
.toDart;
579513

580514
return value.toDart;
@@ -586,21 +520,16 @@ Future<ByteBuffer> deriveBits(
586520
int length,
587521
) async {
588522
final value = await window.crypto.subtle
589-
.deriveBits(
590-
algorithm.toJS,
591-
key,
592-
length,
593-
)
523+
.deriveBits(algorithm.toJS, key, length)
594524
.toDart;
595525

596526
return value.toDart;
597527
}
598528

599529
extension ListExtension on List<String> {
600530
@visibleForTesting
601-
JSArray<JSString> get toJS => <JSString>[
602-
for (final value in this) value.toJS,
603-
].toJS;
531+
JSArray<JSString> get toJS =>
532+
<JSString>[for (final value in this) value.toJS].toJS;
604533
}
605534

606535
extension AlgorithmExtension on Algorithm {
@@ -687,33 +616,27 @@ extension on JsonWebKey {
687616

688617
extension on JSJsonWebKey {
689618
JsonWebKey get toDart => JsonWebKey(
690-
kty: kty,
691-
use: use,
692-
key_ops: keyOps?.toDart.map((e) => e.toDart).toList(),
693-
alg: alg,
694-
ext: ext,
695-
crv: crv,
696-
x: x,
697-
y: y,
698-
d: d,
699-
n: n,
700-
e: e,
701-
p: p,
702-
q: q,
703-
dp: dp,
704-
dq: dq,
705-
qi: qi,
706-
oth: oth?.toDart
707-
.map(
708-
(e) => RsaOtherPrimesInfo(
709-
r: e.r,
710-
d: e.d,
711-
t: e.t,
712-
),
713-
)
714-
.toList(),
715-
k: k,
716-
);
619+
kty: kty,
620+
use: use,
621+
key_ops: keyOps?.toDart.map((e) => e.toDart).toList(),
622+
alg: alg,
623+
ext: ext,
624+
crv: crv,
625+
x: x,
626+
y: y,
627+
d: d,
628+
n: n,
629+
e: e,
630+
p: p,
631+
q: q,
632+
dp: dp,
633+
dq: dq,
634+
qi: qi,
635+
oth: oth?.toDart
636+
.map((e) => RsaOtherPrimesInfo(r: e.r, d: e.d, t: e.t))
637+
.toList(),
638+
k: k,
639+
);
717640
}
718641

719642
// TODO: crypto.subtle.unwrapKey

0 commit comments

Comments
 (0)