File tree 2 files changed +10
-7
lines changed
examples/flutter_firebase_login/packages/authentication_repository/lib/src
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
import 'dart:async' ;
2
2
3
3
import 'package:authentication_repository/authentication_repository.dart' ;
4
- import 'package:authentication_repository/src/crypto .dart' ;
4
+ import 'package:authentication_repository/src/crypto_api .dart' ;
5
5
import 'package:cache/cache.dart' ;
6
6
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
7
7
import 'package:google_sign_in/google_sign_in.dart' ;
@@ -31,15 +31,17 @@ class AuthenticationRepository {
31
31
AuthenticationRepository ({
32
32
CacheClient ? cache,
33
33
firebase_auth.FirebaseAuth ? firebaseAuth,
34
- GoogleSignIn ? googleSignIn
34
+ GoogleSignIn ? googleSignIn,
35
+ CryptoApi ? cryptoApi
35
36
}) : _cache = cache ?? CacheClient (),
36
37
_firebaseAuth = firebaseAuth ?? firebase_auth.FirebaseAuth .instance,
37
- _googleSignIn = googleSignIn ?? GoogleSignIn .standard ()
38
+ _googleSignIn = googleSignIn ?? GoogleSignIn .standard (),
39
+ _crypto = cryptoApi ?? CryptoApi ()
38
40
39
41
final CacheClient _cache;
40
42
final firebase_auth.FirebaseAuth _firebaseAuth;
41
43
final GoogleSignIn _googleSignIn;
42
- final Crypto _crypto = Crypto () ;
44
+ final Crypto _crypto;
43
45
44
46
/// User cache key.
45
47
/// Should only be used for testing purposes.
Original file line number Diff line number Diff line change @@ -3,13 +3,14 @@ import 'dart:convert';
3
3
4
4
import 'package:crypto/crypto.dart' ;
5
5
6
- class Crypto {
6
+ class CryptoApi {
7
+
8
+ static const charset =
9
+ '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._' ;
7
10
8
11
/// Generates a cryptographically secure random nonce, to be included in a
9
12
/// credential request.
10
13
String generateNonce ([int length = 32 ]) {
11
- const charset =
12
- '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._' ;
13
14
var random = Random .secure ();
14
15
return List .generate (length, (_) => charset[random.nextInt (charset.length)])
15
16
.join ();
You can’t perform that action at this time.
0 commit comments