Skip to content

Commit

Permalink
update dependencies, fixed warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoul committed Jan 30, 2024
1 parent 276cb76 commit 92f87b2
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down
20 changes: 12 additions & 8 deletions packages/authpass_cloud_backend/lib/src/companyimage/besticon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,21 @@ 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.');
}

return DecodedImage(
image,
decoder,
encodedBytes: pngBytes as Uint8List,
encodedBytes: pngBytes,
encodedMimetype: 'image/png',
encodedFileExtension: '.png',
);
}
return DecodedImage(
decoder.decodeImage(bytes),
decoder.decode(bytes),
decoder,
);
}
Expand Down Expand Up @@ -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]++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import 'package:postgres/postgres.dart';
import 'package:postgres_utils/postgres_utils.dart';

class DatabaseTransaction extends DatabaseTransactionBase<AuthPassTables> {
DatabaseTransaction(PostgreSQLExecutionContext conn, AuthPassTables tables)
: super(conn, tables);
DatabaseTransaction(super.conn, super.tables);
}

class DatabaseAccess
extends DatabaseAccessBase<DatabaseTransaction, AuthPassTables> {
DatabaseAccess({
required CryptoService cryptoService,
required DatabaseConfig config,
required super.config,
}) : super(
config: config,
tables: AuthPassTables(cryptoService: cryptoService),
migrations: AuthPassMigrationsProvider(),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/authpass_cloud_backend/lib/src/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class BackendServer {
}

class Server extends BackendServer {
Server({required Env env}) : super(env: env);
Server({required super.env});

Future<void> run() async {
PrintAppender.setupLogging();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,8 +29,7 @@ int _tokenTypeByteLength(TokenType type) {

class CryptoService {
final Random _random = Random.secure();
final Uuid _uuid =
const Uuid(options: <String, dynamic>{'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.
Expand Down
28 changes: 18 additions & 10 deletions packages/authpass_cloud_backend/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions packages/authpass_cloud_backend/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void main() {

now = now.add(const Duration(minutes: 5));

Future<FileContent> _load() async {
Future<FileContent> load() async {
final fc = await endpoint.db.tables.fileCloud
.selectFileContent(endpoint.db, fileToken: result.fileToken);
if (fc == null) {
Expand All @@ -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);
Expand Down

0 comments on commit 92f87b2

Please sign in to comment.