Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
AStA
Digitaler 3G-Nachweis
Commits
d6ecab29
Commit
d6ecab29
authored
Jan 25, 2022
by
Leon Tappe
🔥
Browse files
add encryption to verification responses as well
parent
e6a042e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
verification/lib/verification_bloc.dart
View file @
d6ecab29
...
@@ -69,15 +69,26 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> {
...
@@ -69,15 +69,26 @@ class VerificationBloc extends Bloc<VerificationEvent, VerificationState> {
}
}
if
((
response
?.
verified
??
false
)
&&
!(
response
?.
hasError
??
false
))
{
if
((
response
?.
verified
??
false
)
&&
!(
response
?.
hasError
??
false
))
{
_verification
=
response
;
_verification
=
response
;
await
_verificationStore
!.
writeAsString
(
json
.
encode
(
_verification
!.
toMap
));
final
iv
=
IV
.
fromLength
(
16
);
await
_verificationStore
!.
writeAsString
(
iv
.
base64
+
_encrypter
!.
encrypt
(
json
.
encode
(
_verification
!.
toMap
),
iv:
iv
).
base64
);
yield
VerificationState
.
verified
;
yield
VerificationState
.
verified
;
}
else
if
(((((
await
Connectivity
().
checkConnectivity
())
==
ConnectivityResult
.
none
)
||
}
else
if
(((((
await
Connectivity
().
checkConnectivity
())
==
ConnectivityResult
.
none
)
||
((
response
?.
hasError
??
false
)
&&
((
response
?.
hasError
??
false
)
&&
response
!.
error
==
VerificationErrorType
.
server
))
&&
response
!.
error
==
VerificationErrorType
.
server
))
&&
(
_verificationStore
?.
existsSync
()
??
false
)))
{
(
_verificationStore
?.
existsSync
()
??
false
)))
{
// get verification from local storage
// get verification from local storage
final
loaded
=
String
rawVerification
;
VerificationResponse
.
fromMap
(
json
.
decode
(
await
_verificationStore
!.
readAsString
()));
final
storeData
=
await
_verificationStore
!.
readAsString
();
final
iv
=
IV
.
fromBase64
(
storeData
.
substring
(
0
,
24
));
final
encrypted
=
Encrypted
.
fromBase64
(
storeData
.
substring
(
24
));
try
{
rawVerification
=
_encrypter
!.
decrypt
(
encrypted
,
iv:
iv
);
}
catch
(
e
)
{
yield
VerificationState
.
unverified
;
return
;
}
final
loaded
=
VerificationResponse
.
fromMap
(
json
.
decode
(
rawVerification
));
if
(
loaded
.
timestamp
.
isAfter
(
DateTime
.
now
().
subtract
(
const
Duration
(
minutes:
30
))))
{
if
(
loaded
.
timestamp
.
isAfter
(
DateTime
.
now
().
subtract
(
const
Duration
(
minutes:
30
))))
{
_verification
=
loaded
;
_verification
=
loaded
;
yield
VerificationState
.
verified
;
yield
VerificationState
.
verified
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment