From d2f311c388cda7843bfbde7f832b1f23d54a6dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Uek=C3=B6tter?= Date: Sun, 4 Aug 2024 20:37:51 +0200 Subject: [PATCH] wip --- passkit/lib/src/pkpass/pkpass.dart | 22 +++++++++++++++++----- passkit/lib/src/signature_writer.dart | 0 passkit/pubspec.yaml | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) delete mode 100644 passkit/lib/src/signature_writer.dart diff --git a/passkit/lib/src/pkpass/pkpass.dart b/passkit/lib/src/pkpass/pkpass.dart index 13396da..ed65534 100644 --- a/passkit/lib/src/pkpass/pkpass.dart +++ b/passkit/lib/src/pkpass/pkpass.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:archive/archive.dart'; import 'package:crypto/crypto.dart'; +import 'package:meta/meta.dart'; import 'package:passkit/src/pkpass/exceptions.dart'; import 'package:passkit/src/pkpass/pass_data.dart'; import 'package:passkit/src/pkpass/pass_type.dart'; @@ -130,7 +131,8 @@ class PkPass { // TODO(ueman): Provide an async method for this. static List passesFromBytes( final List bytes, { - bool skipVerification = false, + bool skipChecksumVerification = false, + bool skipSignatureVerification = false, }) { if (bytes.isEmpty) { throw EmptyBytesException(); @@ -143,7 +145,8 @@ class PkPass { .map( (file) => fromBytes( file.content as List, - skipChecksumVerification: skipVerification, + skipChecksumVerification: skipChecksumVerification, + skipSignatureVerification: skipSignatureVerification, ), ) .toList(); @@ -233,10 +236,15 @@ class PkPass { /// When written to disk, the file should have an ending of `.pkpass`. /// /// Remarks: - /// - There's no support for a signature + /// - There's no support for signature, which means pass created by this + /// can't be added to the Apple wallet + /// - There's no support for verifying that the signature matches the PkPass /// - There's no support for localization /// - There's no support for personalization - List? write() { + /// - Image sizes aren't checked, which means it's possible to create passes + /// that look odd and wrong in Apple wallet or [passkit_ui](https://pub.dev/packages/passkit_ui) + @experimental + Uint8List? write() { final archive = Archive(); final encoder = JsonEncoder.withIndent(' '); @@ -274,7 +282,11 @@ class PkPass { ); archive.addFile(manifestFile); - return ZipEncoder().encode(archive); + final pkpass = ZipEncoder().encode(archive); + if (pkpass == null) { + return null; + } + return Uint8List.fromList(pkpass); } } diff --git a/passkit/lib/src/signature_writer.dart b/passkit/lib/src/signature_writer.dart deleted file mode 100644 index e69de29..0000000 diff --git a/passkit/pubspec.yaml b/passkit/pubspec.yaml index 2673b22..8eaea55 100644 --- a/passkit/pubspec.yaml +++ b/passkit/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: http_parser: ^4.0.0 intl: ^0.19.0 json_annotation: ^4.9.0 + meta: any pkcs7: ^1.0.3 dev_dependencies: