Skip to content

Commit a5be8de

Browse files
authored
chore(aws_common): Crypto-secure UUID (#1573)
1 parent a49b339 commit a5be8de

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

packages/aws_common/lib/aws_common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ export 'src/util/equatable.dart';
3434
export 'src/util/json.dart';
3535
export 'src/util/print.dart';
3636
export 'src/util/serializable.dart';
37+
export 'src/util/uuid.dart';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import 'package:uuid/uuid.dart';
16+
import 'package:uuid/uuid_util.dart';
17+
18+
/// Generates a crypto-secure UUID (v4).
19+
String uuid() => const Uuid().v4(
20+
// Use the crypto-secure RNG per `package:uuid` docs:
21+
// https://github.com/Daegalus/dart-uuid/blob/d7bc930942afc752edd0fd15f8bf8234d81dfeda/example/example.dart#L21
22+
options: const <String, Object>{
23+
'rng': UuidUtil.cryptoRNG,
24+
},
25+
);

packages/aws_common/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
collection: ^1.15.0
1313
http: ^0.13.4
1414
meta: ^1.7.0
15+
uuid: 3.0.6
1516

1617
dev_dependencies:
1718
amplify_lints: ^1.0.0

0 commit comments

Comments
 (0)