Skip to content

Commit

Permalink
fix: Use jsArray and dartArray
Browse files Browse the repository at this point in the history
  • Loading branch information
koji-1009 committed Dec 6, 2024
1 parent d27cadf commit aeeb3cc
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions lib/src/crypto_subtle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,40 +348,46 @@ TypedData getRandomValues(TypedData array) {
//
// See also: https://github.com/dart-lang/sdk/issues/59651
if (array is Uint8List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else if (array is Uint16List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else if (array is Uint32List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else if (array is Int8List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else if (array is Int16List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else if (array is Int32List) {
final values = array.toJS;
window.crypto.getRandomValues(values);
if (array != values.toDart) {
array.setAll(0, values.toDart);
final jsArray = array.toJS;
window.crypto.getRandomValues(jsArray);
final dartArray = jsArray.toDart;
if (array != dartArray) {
array.setAll(0, dartArray);
}
} else {
throw UnsupportedError('Unsupported TypedData type ${array.runtimeType}');
Expand Down

0 comments on commit aeeb3cc

Please sign in to comment.