-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dep): update uuid dependency version range (#4194)
* chore(dep): update uuid dependency version range
- Loading branch information
Showing
7 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
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
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,19 +1,29 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'dart:math'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:uuid/uuid.dart'; | ||
import 'package:uuid/uuid_util.dart'; | ||
|
||
/// Generates a UUID (v4). | ||
/// | ||
/// If [secure] is `true`, uses a crypto-secure RNG at the cost of worse | ||
/// performance (5-100x, depending on the platform). | ||
String uuid({bool secure = false}) => const Uuid().v4( | ||
// ignore: deprecated_member_use | ||
options: !secure | ||
? null | ||
// Use the crypto-secure RNG per `package:uuid` docs: | ||
// https://github.com/Daegalus/dart-uuid/blob/d7bc930942afc752edd0fd15f8bf8234d81dfeda/example/example.dart#L21 | ||
: const <String, Object>{ | ||
'rng': UuidUtil.cryptoRNG, | ||
'rng': _cryptoRNG, | ||
'positionalArgs': [], | ||
'namedArgs': <Symbol, dynamic>{}, | ||
}, | ||
); | ||
|
||
/// Creates 16 digit cryptographically secure random number. | ||
Uint8List _cryptoRNG() { | ||
return Uint8List.fromList( | ||
List<int>.generate(16, (i) => Random.secure().nextInt(256)), | ||
); | ||
} |
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