@@ -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
307300extension 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
599529extension 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
606535extension AlgorithmExtension on Algorithm {
@@ -687,33 +616,27 @@ extension on JsonWebKey {
687616
688617extension 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