Skip to content

Commit

Permalink
Merge branch 'master' into 384-qr-code-from-image-file-not-recognized…
Browse files Browse the repository at this point in the history
…-otpauth-migration
  • Loading branch information
frankmer committed May 22, 2024
2 parents f9a4e48 + 6f9aa6c commit 93c71f7
Show file tree
Hide file tree
Showing 126 changed files with 2,009 additions and 2,701 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/flutter_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.16.5'
- run: "flutter upgrade"
flutter-version: '3.19.6'
- run: "flutter --version"
- run: "flutter pub get"
- run: "flutter build ios -t 'lib/mains/main_netknights.dart' --debug --flavor netknights --no-codesign"
Expand All @@ -48,14 +47,13 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17.0.7'
distribution: 'oracle'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.19.0'
- run: "flutter upgrade"
flutter-version: '3.19.6'
- run: 'flutter clean'
- run: "flutter --version"
- run: "flutter pub get"
- run: 'flutter clean'
- run: "flutter build apk -t 'lib/mains/main_netknights.dart' --debug --flavor netknights"
- run: "flutter build apk -t 'lib/mains/main_netknights.dart' --debug --flavor netknights"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,4 @@ DerivedData/
.flutter-plugins-dependencies
lib/l10n/untranslated.txt
*.jks
ios/Flutter/flutter_export_environment.sh
Binary file removed android/app/src/main/res/drawable/app_icon.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed android/app/src/netknights/res/drawable/app_icon.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion integration_test/add_tokens_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:privacyidea_authenticator/state_notifiers/completed_introduction
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/views/add_token_manually_view/add_token_manually_view.dart';
import 'package:privacyidea_authenticator/views/add_token_manually_view/add_token_manually_view_widgets/labeled_dropdown_button.dart';
Expand Down
2 changes: 1 addition & 1 deletion integration_test/copy_to_clipboard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/model/version.dart';

Expand Down
2 changes: 1 addition & 1 deletion integration_test/rename_and_delete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:privacyidea_authenticator/state_notifiers/completed_introduction
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/model/version.dart';
import 'package:privacyidea_authenticator/views/main_view/main_view_widgets/token_widgets/default_token_actions/default_delete_action.dart';
Expand Down
2 changes: 1 addition & 1 deletion integration_test/two_step_rollout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/logger.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/model/version.dart';
Expand Down
2 changes: 1 addition & 1 deletion integration_test/views_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:privacyidea_authenticator/model/states/settings_state.dart';
import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart';
import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
import 'package:privacyidea_authenticator/utils/rsa_utils.dart';
import 'package:privacyidea_authenticator/model/version.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/mains/main_netknights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import 'package:easy_dynamic_theme/easy_dynamic_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:privacyidea_authenticator/l10n/app_localizations.dart';
import 'package:privacyidea_authenticator/utils/app_customizer.dart';
import 'package:privacyidea_authenticator/utils/customization/application_customization.dart';
import 'package:privacyidea_authenticator/utils/globals.dart';
import 'package:privacyidea_authenticator/utils/logger.dart';
import 'package:privacyidea_authenticator/utils/riverpod_providers.dart';
Expand Down
9 changes: 4 additions & 5 deletions lib/model/encryption/token_encryption.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:convert';
import 'dart:io';

import '../../processors/scheme_processors/token_import_scheme_processors/privacyidea_authenticator_qr_processor.dart';
import '../tokens/token.dart';
Expand All @@ -23,16 +22,16 @@ class TokenEncryption {
static Uri generateQrCodeUri({required Token token}) {
final tokenJson = token.toJson();
final encoded = json.encode(tokenJson);
final zip = gzip.encode(utf8.encode(encoded));
final base64 = base64Url.encode(zip);
final bytes = utf8.encode(encoded);
final base64 = base64Url.encode(bytes);
final uri = Uri.parse('${PrivacyIDEAAuthenticatorQrProcessor.scheme}://${PrivacyIDEAAuthenticatorQrProcessor.host}?data=$base64');
return uri;
}

static Token fromQrCodeUri(Uri uri) {
final base64String = uri.queryParameters['data'];
final zip = base64Url.decode(base64String!);
final jsonString = utf8.decode(gzip.decode(zip));
final bytes = base64Url.decode(base64String!);
final jsonString = utf8.decode(bytes);
final tokenJson = json.decode(jsonString) as Map<String, dynamic>;
return Token.fromJson(tokenJson);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/model/states/introduction_state.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/introduction_extension.dart';

import '../enums/introduction.dart';
import '../extensions/enums/introduction_extension.dart';

part 'introduction_state.g.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/model/token_import/token_import_source.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:privacyidea_authenticator/l10n/app_localizations.dart';

import '../../l10n/app_localizations.dart';
import '../../processors/mixins/token_import_processor.dart';
import '../enums/token_import_type.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/model/token_import/token_origin_data.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:json_annotation/json_annotation.dart';

import '../version.dart';
import '../enums/token_origin_source_type.dart';
import '../version.dart';

part 'token_origin_data.g.dart';

Expand Down
10 changes: 5 additions & 5 deletions lib/model/tokens/day_password_token.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/algorithms_extension.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/encodings_extension.dart';
import 'package:privacyidea_authenticator/utils/errors.dart';
import 'package:uuid/uuid.dart';

import '../../utils/errors.dart';
import '../../utils/identifiers.dart';
import '../enums/algorithms.dart';
import '../enums/day_password_token_view_mode.dart';
import '../enums/encodings.dart';
import '../enums/token_types.dart';
import '../extensions/enums/algorithms_extension.dart';
import '../extensions/enums/encodings_extension.dart';
import '../token_import/token_origin_data.dart';
import 'otp_token.dart';
import 'token.dart';
Expand Down Expand Up @@ -131,15 +131,15 @@ class DayPasswordToken extends OTPToken {
name: URI_SECRET,
);
}
if (uriMap[URI_PERIOD] < 1) {
if (uriMap[URI_PERIOD] != null && uriMap[URI_PERIOD] < 1) {
throw LocalizedArgumentError(
localizedMessage: (localizations, value, parameter) => localizations.invalidValueForParameter(value, parameter),
unlocalizedMessage: 'Period must be greater than 0',
invalidValue: uriMap[URI_PERIOD],
name: URI_PERIOD,
);
}
if (uriMap[URI_DIGITS] < 1) {
if (uriMap[URI_DIGITS] != null && uriMap[URI_DIGITS] < 1) {
throw LocalizedArgumentError(
localizedMessage: (localizations, value, parameter) => localizations.invalidValueForParameter(value, parameter),
unlocalizedMessage: 'Digits must be greater than 0',
Expand Down
4 changes: 2 additions & 2 deletions lib/model/tokens/hotp_token.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/algorithms_extension.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/encodings_extension.dart';
import 'package:uuid/uuid.dart';

import '../../utils/identifiers.dart';
import '../enums/algorithms.dart';
import '../enums/encodings.dart';
import '../enums/token_types.dart';
import '../extensions/enums/algorithms_extension.dart';
import '../extensions/enums/encodings_extension.dart';
import '../token_import/token_origin_data.dart';
import 'otp_token.dart';
import 'token.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/model/tokens/steam_token.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:base32/base32.dart';
import 'package:crypto/crypto.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/encodings_extension.dart';
import 'package:privacyidea_authenticator/utils/errors.dart';
import 'package:uuid/uuid.dart';

import '../../utils/errors.dart';
import '../../utils/identifiers.dart';
import '../enums/algorithms.dart';
import '../enums/encodings.dart';
import '../enums/token_types.dart';
import '../extensions/enums/encodings_extension.dart';
import '../extensions/int_extension.dart';
import '../token_import/token_origin_data.dart';
import 'token.dart';
Expand Down
13 changes: 7 additions & 6 deletions lib/model/tokens/totp_token.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/algorithms_extension.dart';
import 'package:privacyidea_authenticator/model/extensions/enums/encodings_extension.dart';
import 'package:uuid/uuid.dart';

import '../../utils/identifiers.dart';
import '../../utils/logger.dart';
import '../enums/algorithms.dart';
import '../enums/encodings.dart';
import '../enums/token_types.dart';
import '../extensions/enums/algorithms_extension.dart';
import '../extensions/enums/encodings_extension.dart';
import '../token_import/token_origin_data.dart';
import 'otp_token.dart';
import 'token.dart';
Expand All @@ -29,16 +29,17 @@ class TOTPToken extends OTPToken {
}

final int period;

@override
String get otpValue => algorithm.generateTOTPCodeString(
String otpFromTime(DateTime time) => algorithm.generateTOTPCodeString(
secret: secret,
time: DateTime.now(),
time: time,
length: digits,
interval: Duration(seconds: period),
isGoogle: true,
);

@override
String get otpValue => otpFromTime(DateTime.now());

TOTPToken({
required int period,
required super.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:privacyidea_authenticator/model/extensions/enums/token_origin_source_type.dart';

import '../../../model/enums/token_origin_source_type.dart';
import '../../../model/extensions/enums/token_origin_source_type.dart';
import '../../../model/processor_result.dart';
import '../../../model/tokens/token.dart';
import '../../../utils/token_import_origins.dart';
Expand Down
Loading

0 comments on commit 93c71f7

Please sign in to comment.