diff --git a/packages/authpass_cloud_backend/lib/src/cli/smtpd_command.dart b/packages/authpass_cloud_backend/lib/src/cli/smtpd_command.dart index b180e77..c66a18a 100644 --- a/packages/authpass_cloud_backend/lib/src/cli/smtpd_command.dart +++ b/packages/authpass_cloud_backend/lib/src/cli/smtpd_command.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:authpass_cloud_backend/src/cli/serve_command.dart'; import 'package:authpass_cloud_backend/src/dao/database_access.dart'; -import 'package:authpass_cloud_backend/src/env/env.dart'; import 'package:authpass_cloud_backend/src/server.dart'; import 'package:authpass_cloud_backend/src/service/service_provider.dart'; import 'package:logging/logging.dart'; @@ -61,7 +60,7 @@ class SmtpdCommand extends BaseBackendCommand { } class SmtpBackendServer extends BackendServer { - SmtpBackendServer({required Env env, required this.config}) : super(env: env); + SmtpBackendServer({required super.env, required this.config}); final SmtpConfig config; diff --git a/packages/authpass_cloud_backend/lib/src/companyimage/besticon.dart b/packages/authpass_cloud_backend/lib/src/companyimage/besticon.dart index 34637aa..876c8fd 100644 --- a/packages/authpass_cloud_backend/lib/src/companyimage/besticon.dart +++ b/packages/authpass_cloud_backend/lib/src/companyimage/besticon.dart @@ -269,7 +269,7 @@ class BestIcon { if (decoder is IcoDecoder) { // extract the largest image and encode it to webp. final image = decoder.decodeImageLargest(bytes)!; - final pngBytes = PngEncoder().encodeImage(image); + final pngBytes = PngEncoder().encode(image); if (pngBytes.isEmpty) { _logger.severe('Unable to encode image to webp.'); } @@ -277,13 +277,13 @@ class BestIcon { return DecodedImage( image, decoder, - encodedBytes: pngBytes as Uint8List, + encodedBytes: pngBytes, encodedMimetype: 'image/png', encodedFileExtension: '.png', ); } return DecodedImage( - decoder.decodeImage(bytes), + decoder.decode(bytes), decoder, ); } @@ -412,14 +412,18 @@ class BestIcon { double _analyseImageBrightnessRatio(Image image) { final histogram = List.generate(256, (index) => 0, growable: false); var count = 0; - for (final pixel in image.data) { - final alpha = getAlpha(pixel); + final imageData = image.data; + if (imageData == null) { + throw StateError('Unable to analyze image., image.data is null.'); + } + for (final pixel in imageData) { + final alpha = pixel.a; if (alpha > 200) { continue; } - final r = getRed(pixel); - final g = getGreen(pixel); - final b = getBlue(pixel); + final r = pixel.r; + final g = pixel.g; + final b = pixel.b; count++; final brightness = (0.2126 * r + 0.7152 * g + 0.0722 * b).toInt(); histogram[brightness]++; diff --git a/packages/authpass_cloud_backend/lib/src/dao/database_access.dart b/packages/authpass_cloud_backend/lib/src/dao/database_access.dart index beddccc..e12e279 100644 --- a/packages/authpass_cloud_backend/lib/src/dao/database_access.dart +++ b/packages/authpass_cloud_backend/lib/src/dao/database_access.dart @@ -7,17 +7,15 @@ import 'package:postgres/postgres.dart'; import 'package:postgres_utils/postgres_utils.dart'; class DatabaseTransaction extends DatabaseTransactionBase { - DatabaseTransaction(PostgreSQLExecutionContext conn, AuthPassTables tables) - : super(conn, tables); + DatabaseTransaction(super.conn, super.tables); } class DatabaseAccess extends DatabaseAccessBase { DatabaseAccess({ required CryptoService cryptoService, - required DatabaseConfig config, + required super.config, }) : super( - config: config, tables: AuthPassTables(cryptoService: cryptoService), migrations: AuthPassMigrationsProvider(), ); diff --git a/packages/authpass_cloud_backend/lib/src/server.dart b/packages/authpass_cloud_backend/lib/src/server.dart index cd13980..3a708a4 100644 --- a/packages/authpass_cloud_backend/lib/src/server.dart +++ b/packages/authpass_cloud_backend/lib/src/server.dart @@ -53,7 +53,7 @@ class BackendServer { } class Server extends BackendServer { - Server({required Env env}) : super(env: env); + Server({required super.env}); Future run() async { PrintAppender.setupLogging(); diff --git a/packages/authpass_cloud_backend/lib/src/service/crypto_service.dart b/packages/authpass_cloud_backend/lib/src/service/crypto_service.dart index 1e43709..c606726 100644 --- a/packages/authpass_cloud_backend/lib/src/service/crypto_service.dart +++ b/packages/authpass_cloud_backend/lib/src/service/crypto_service.dart @@ -2,8 +2,9 @@ import 'dart:convert'; import 'dart:math'; import 'dart:typed_data'; +import 'package:uuid/data.dart'; +import 'package:uuid/rng.dart'; import 'package:uuid/uuid.dart'; -import 'package:uuid/uuid_util.dart'; enum TokenType { emailConfirm, @@ -28,8 +29,7 @@ int _tokenTypeByteLength(TokenType type) { class CryptoService { final Random _random = Random.secure(); - final Uuid _uuid = - const Uuid(options: {'grng': UuidUtil.cryptoRNG}); + final Uuid _uuid = Uuid(goptions: GlobalOptions(CryptoRNG())); // static const _ADDRESS_LENGTH = 32; // for now limit length to 10 characters, that should be more than enough. diff --git a/packages/authpass_cloud_backend/pubspec.lock b/packages/authpass_cloud_backend/pubspec.lock index 01e357a..fa6b750 100644 --- a/packages/authpass_cloud_backend/pubspec.lock +++ b/packages/authpass_cloud_backend/pubspec.lock @@ -324,10 +324,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "3.0.1" freezed: dependency: "direct dev" description: @@ -404,10 +404,10 @@ packages: dependency: "direct main" description: name: image - sha256: "8e9d133755c3e84c73288363e6343157c383a0c6c56fc51afcc5d4d7180306d6" + sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" url: "https://pub.dev" source: hosted - version: "3.3.0" + version: "4.1.4" intl: dependency: "direct overridden" description: @@ -452,10 +452,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" logging: dependency: "direct main" description: @@ -540,10 +540,10 @@ packages: dependency: "direct main" description: name: openapi_base - sha256: "99c7f3bb935e1bfd863fcbecfcd28af6a9e5937bbd5f083de4b71b3aab6a3ddf" + sha256: "6c4e72e3f8fda7eb6647e515f8623c60eb0bf498dfc034a09d84e122a121a03e" url: "https://pub.dev" source: hosted - version: "1.1.0+3" + version: "1.3.1" package_config: dependency: transitive description: @@ -742,6 +742,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: @@ -858,10 +866,10 @@ packages: dependency: "direct main" description: name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8 url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "4.3.3" vm_service: dependency: transitive description: diff --git a/packages/authpass_cloud_backend/pubspec.yaml b/packages/authpass_cloud_backend/pubspec.yaml index 4875438..2c9d05f 100644 --- a/packages/authpass_cloud_backend/pubspec.yaml +++ b/packages/authpass_cloud_backend/pubspec.yaml @@ -4,8 +4,8 @@ environment: sdk: '>=3.2.0 <4.0.0' dependencies: - meta: ^1.8.0 - uuid: ^3.0.6 + meta: ^1.11.0 + uuid: ^4.3.3 logging: ^1.2.0 logging_appenders: ^1.2.0+1 freezed_annotation: ^2.0.3 @@ -26,7 +26,7 @@ dependencies: path: ../../deps/smtpd.dart shelf: ^1.4.1 - openapi_base: ^1.1.0+3 + openapi_base: ^1.3.1 authpass_cloud_shared: path: ../authpass_cloud_shared postgres_utils: @@ -35,7 +35,7 @@ dependencies: # besticon html: ^0.15.0 dartx: ^1.1.0 - image: ^3.2.0 + image: ^4.1.4 # image: # git: # url: https://github.com/authpass/image.git @@ -47,7 +47,7 @@ dev_dependencies: build_runner: ^2.1.11 freezed: ^2.0.3+1 json_serializable: ^6.2.0 - flutter_lints: ^2.0.1 + flutter_lints: ^3.0.1 faker: ^2.1.0 dependency_overrides: diff --git a/packages/authpass_cloud_backend/test/endpoint/filecloud_endpoint_test.dart b/packages/authpass_cloud_backend/test/endpoint/filecloud_endpoint_test.dart index 29d49cf..f3dd37c 100644 --- a/packages/authpass_cloud_backend/test/endpoint/filecloud_endpoint_test.dart +++ b/packages/authpass_cloud_backend/test/endpoint/filecloud_endpoint_test.dart @@ -134,7 +134,7 @@ void main() { now = now.add(const Duration(minutes: 5)); - Future _load() async { + Future load() async { final fc = await endpoint.db.tables.fileCloud .selectFileContent(endpoint.db, fileToken: result.fileToken); if (fc == null) { @@ -148,19 +148,19 @@ void main() { } // should still be the old value. - expect((await _load()).lastAccessAt, DateTime.utc(2020, 1, 1)); - expect((await _load()).lastAccessAt, DateTime.utc(2020, 1, 1)); - expect((await _load()).lastAccessAt, DateTime.utc(2020, 1, 1)); + expect((await load()).lastAccessAt, DateTime.utc(2020, 1, 1)); + expect((await load()).lastAccessAt, DateTime.utc(2020, 1, 1)); + expect((await load()).lastAccessAt, DateTime.utc(2020, 1, 1)); expect((await stats()).countRecentlyAccessed, 0); now = now.add(const Duration(hours: 48)); expect((await stats()).countRecentlyAccessed, 0); - expect((await _load()).lastAccessAt, DateTime.utc(2020, 1, 1)); - expect((await _load()).lastAccessAt, now); + expect((await load()).lastAccessAt, DateTime.utc(2020, 1, 1)); + expect((await load()).lastAccessAt, now); expect((await stats()).countRecentlyAccessed, 1); now = now.add(const Duration(days: 2)); expect((await stats()).countRecentlyAccessed, 0); - await _load(); + await load(); expect((await stats()).countRecentlyAccessed, 1); now = now.add(const Duration(days: 2)); expect((await stats()).countRecentlyAccessed, 0);