diff --git a/README.md b/README.md index 210539d8..993e9737 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/a ## Examples and Documentation -Visit the [documentation](https://angel3-docs.dukefirehawk.com/) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel. +Visit the [documentation](https://angel3-docs.dukefirehawk.com/) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel3 framework. Examples and complete projects can be found [here](https://github.com/dukefirehawk/angel3-examples). diff --git a/packages/auth/lib/src/plugin.dart b/packages/auth/lib/src/plugin.dart index 329ca764..35aa769b 100644 --- a/packages/auth/lib/src/plugin.dart +++ b/packages/auth/lib/src/plugin.dart @@ -108,8 +108,13 @@ class AngelAuth { 'An `AngelAuth` plug-in was called without its `deserializer` being set. All authentication will fail.'); } */ - + if (app.container == null) { + log.severe('Angel.container is null.'); + throw StateError( + 'Angel.container is null. All authentication will fail.'); + } var appContainer = app.container!; + appContainer.registerSingleton(this); if (runtimeType != AngelAuth) { appContainer.registerSingleton(this, as: AngelAuth); @@ -132,14 +137,14 @@ class AngelAuth { } }); - appContainer.registerLazySingleton>((container) async { + appContainer.registerLazySingleton>((container) async { var result = await container.makeAsync<_AuthResult>(); - return result!.user; + return result?.user; }); - appContainer.registerLazySingleton>((container) async { + appContainer.registerLazySingleton>((container) async { var result = await container.makeAsync<_AuthResult>(); - return result!.token; + return result?.token; }); } @@ -151,7 +156,13 @@ class AngelAuth { } void _apply( - RequestContext req, ResponseContext? res, AuthToken token, User user) { + RequestContext req, ResponseContext res, AuthToken token, User user) { + if (req.container == null) { + log.severe('RequestContext.container is null.'); + throw StateError( + 'RequestContext.container is not set. All authentication will fail.'); + } + var reqContainer = req.container!; if (!reqContainer.has()) { reqContainer.registerSingleton(user); @@ -162,7 +173,7 @@ class AngelAuth { } if (allowCookie) { - _addProtectedCookie(res!, 'token', token.serialize(_hs256)); + _addProtectedCookie(res, 'token', token.serialize(_hs256)); } } @@ -188,7 +199,7 @@ class AngelAuth { /// } /// ``` @deprecated - Future decodeJwt(RequestContext req, ResponseContext res) async { + Future decodeJwtOld(RequestContext req, ResponseContext res) async { if (req.method == 'POST' && req.path == reviveTokenEndpoint) { return await reviveJwt(req, res); } else { @@ -231,18 +242,23 @@ class AngelAuth { /// Retrieves a JWT from a request, if any was sent at all. String? getJwt(RequestContext req) { if (req.headers?.value('Authorization') != null) { - final authHeader = req.headers!.value('Authorization')!; - - // Allow Basic auth to fall through - if (_rgxBearer.hasMatch(authHeader)) { - return authHeader.replaceAll(_rgxBearer, '').trim(); + final authHeader = req.headers?.value('Authorization'); + if (authHeader != null) { + // Allow Basic auth to fall through + if (_rgxBearer.hasMatch(authHeader)) { + return authHeader.replaceAll(_rgxBearer, '').trim(); + } } + + log.info('RequestContext.headers is null'); } else if (allowCookie && req.cookies.any((cookie) => cookie.name == 'token')) { return req.cookies.firstWhere((cookie) => cookie.name == 'token').value; - } else if (allowTokenInQuery && - req.uri?.queryParameters['token'] is String) { - return req.uri!.queryParameters['token']?.toString(); + } else if (allowTokenInQuery) { + //&& req.uri?.queryParameters['token'] is String) { + if (req.uri != null) { + return req.uri?.queryParameters['token']?.toString(); + } } return null; diff --git a/packages/auth/pubspec.yaml b/packages/auth/pubspec.yaml index 4a761a56..a3391bb7 100644 --- a/packages/auth/pubspec.yaml +++ b/packages/auth/pubspec.yaml @@ -19,9 +19,4 @@ dev_dependencies: logging: ^1.0.0 pedantic: ^1.11.0 test: ^1.17.4 -#dependency_overrides: -# angel3_framework: -# path: ../framework -# angel3_container: -# path: ../container/angel_container \ No newline at end of file diff --git a/packages/markdown/CHANGELOG.md b/packages/markdown/CHANGELOG.md index 9050f883..6b1ca845 100644 --- a/packages/markdown/CHANGELOG.md +++ b/packages/markdown/CHANGELOG.md @@ -1,8 +1,12 @@ # Change Log -## 3.0.0 +## 4.0.0 * Migrated to support Dart SDK 2.12.x NNBD + +## 3.0.0 + +* Migrated to support Dart SDK 2.12.x non NNBD ## 2.0.0 diff --git a/packages/markdown/README.md b/packages/markdown/README.md index 4fb3a08b..b0f13029 100644 --- a/packages/markdown/README.md +++ b/packages/markdown/README.md @@ -1,6 +1,6 @@ # Angel3 Markdown -[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_markdown) +[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_markdown) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) diff --git a/packages/markdown/lib/angel3_markdown.dart b/packages/markdown/lib/angel3_markdown.dart index 82b78b3c..b95114e7 100644 --- a/packages/markdown/lib/angel3_markdown.dart +++ b/packages/markdown/lib/angel3_markdown.dart @@ -16,28 +16,28 @@ final RegExp _braces = RegExp(r'@?{{(((\\})|([^}]))+)}}'); /// and returns a String, or a `Future`. AngelConfigurer markdown( Directory viewsDirectory, { - String extension, - ExtensionSet extensionSet, - FutureOr Function(String content, Map locals) + String? extension, + ExtensionSet? extensionSet, + FutureOr Function(String content, Map locals)? template, }) { extension ??= '.md'; extensionSet ??= ExtensionSet.gitHubWeb; return (Angel app) async { - app.viewGenerator = (String name, [Map locals]) async { + app.viewGenerator = (String name, [Map? locals]) async { var file = viewsDirectory.childFile( - viewsDirectory.fileSystem.path.setExtension(name, extension)); + viewsDirectory.fileSystem.path.setExtension(name, extension!)); var contents = await file.readAsString(); contents = contents.replaceAllMapped(_braces, (m) { - var text = m[0]; + var text = m[0]!; if (text.startsWith('@')) { // Raw braces return text.substring(1); } else { - var expr = m[1]; + var expr = m[1]!; var split = expr.split('.'); var root = split[0]; @@ -46,7 +46,7 @@ AngelConfigurer markdown( 'Expected a local named "$root", but none was provided. Expression text: "$text"'); } - return _resolveDotNotation(split, locals[root]).toString(); + return _resolveDotNotation(split, locals![root]).toString(); } }); diff --git a/packages/markdown/pubspec.yaml b/packages/markdown/pubspec.yaml index e2820efd..96e728e7 100644 --- a/packages/markdown/pubspec.yaml +++ b/packages/markdown/pubspec.yaml @@ -1,9 +1,9 @@ name: angel3_markdown -version: 3.0.0 +version: 4.0.0 description: Angel3 Markdown view generator. Write static sites, with no build step. homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/markdown environment: - sdk: ">=2.10.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: angel3_framework: ^4.0.0 file: ^6.1.2 diff --git a/packages/pretty_logging/README.md b/packages/pretty_logging/README.md index 79f3dde8..b695f8cc 100644 --- a/packages/pretty_logging/README.md +++ b/packages/pretty_logging/README.md @@ -1,4 +1,5 @@ -# angel3_pretty_logging +# Angel3 Petty Logging + [![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_pretty_logging) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) @@ -7,7 +8,8 @@ Standalone helper for colorful logging output, using pkg:io AnsiCode. -# Installation +## Installation + In your `pubspec.yaml`: ```yaml @@ -15,15 +17,15 @@ dependencies: angel3_pretty_logging: ^3.0.0 ``` -# Usage +## Usage + Basic usage is very simple: ```dart myLogger.onRecord.listen(prettyLog); ``` -However, you can conditionally pass logic to omit printing an -error, provide colors, or to provide a custom print function: +However, you can conditionally pass logic to omit printing an error, provide colors, or to provide a custom print function: ```dart var pretty = prettyLog(