ueman / passkit Goto Github PK
View Code? Open in Web Editor NEWVarious Dart & Flutter packages to work with Apple's PassKit
Various Dart & Flutter packages to work with Apple's PassKit
When the web service URL of the pass contains a path, it will currently get overriden.
This seems incorrect to me and I think we should fix it.
However, the spec doesn't mention any specific behavior, so the current implementation could be correct.
See
passkit/passkit_ui/lib/src/widgets/transit_type_widget.dart
Lines 20 to 24 in d3ff006
Right now, the only icon used is the plane icon, but we need
Ideally there's a CC0 SVG that can be used via
to create a Custom Painter out of it.
Umbrella issue to collect various app feature ideas:
.pkpasses
bundles.order
filesPkPass bundles are essentially a zip (but with a pkpasses file extension) which contains up to 10 pkpass files.
https://developer.apple.com/documentation/walletpasses/distributing_and_updating_a_pass#3793284
The passes seem like they have an aspect ratio of something around of 3 (width) to 4 (height) (310 to 400).
We need to figure out how to properly size the passes so that they're always following this aspect ratio while still having a good a11y.
To create the manifest file, recursively list the files in the package (except the manifest file and signature), calculate the SHA-1 hash of the contents of those files, and store the data in a dictionary. The keys are relative paths to the file from the pass package. The values are the SHA-1 hash (hex encoded) of the data at that path. Write this dictionary to the file manifest.json at the top level of the pass package.
To create the signature file, make a PKCS #7
detached signature of the manifest file, using the private key associated with your signing certificate. Include the WWDR intermediate certificate as part of the signature. You can download this certificate from Apple’s website. Write the signature to the file signature at the top level of the pass package. Include the date and time that the pass was signed using the S/MIME signing-time attribute.
pointycastle
and pkcs7
to sign the pass in pure Dart codeThe WWDR certificate can be downloaded from here.
When updating a pass via the HTTP client, we should check whether the pass is signed with the same certificate to check for its authenticity. This method should also be exposed, so that updates from other sources (downloads etc) can do the same check.
The text of the back fields is run through data detectors for URLs and phone numbers, which appear as live links. Users can tap the URL to launch it in Safari and can tap phone numbers to dial them. Text on the back of the card can include line breaks, escaped in the JSON file as \n.
This is currently unsupported in passkit_ui
.
Maybe something like flutter_linkify
can solve this problem.
Synchronous parsing of the PkPass files can lead to skipped frames when this lib is used in Flutter. Provide an option to parse them on a background isolate
For reference: ThemeExtension.
Text can be localized, but images can be localized too.
PkPass docs for localizations (text and images):
Docs for .strings
file format description:
.strings
files are UTF-16 not UTF-8, so the files have to be read like this StackOverflow post suggests. This issue dart-lang/convert#30 contains some hints too.
There are various approaches to parsing a .strings
file:
petiteparser
Personally, I would like to see a custom parser based on petiteparser
with all the bells and whistles, but I think using a RegEx at first should be sufficient.
The API could look like one of the following examples:
class PkPass {
String getTranslated(String key, Locale locale) { ... }
}
// and then you can use it something like this:
PkPass pass = ...;
pass.getTranslated(pass.pass.description, locale);
With intl
pass.pass.description;
// provide a localized getter that makes use of Intl.defaultLocale or is alternatively set somehow
pass.pass.descriptionLocalized;
This paragraph is only relevant for passkit_UI
Language fallback rules (should be applied on a per field basis):
de_DE
)
de
instead of de_DE
)
PlatformDispatcher.locales
(while skipping already tried languages)
de_DE
), then without (just de
)Formatted values like dates, numbers, etc are always localized to the users' current language (as described here)
The default localized value should be https://api.dart.dev/stable/3.4.4/dart-io/Platform/localeName.html on dart:io and whatever browser equivalent there is. On Flutter it should use the Localization.of().locale as default.
https://main-api.flutter.dev/flutter/material/CarouselView-class.html
The currently relevant passes are selected based on the location and date.
It would be nice if it's possible to create PkPass
files with a WYSIWYG editor.
Depends on #11
Currently, a PkPass files checksums is not verified. This functionally should be added. I also would like an option to optionally skip checksum verification.
I guess this can easily be done by using package:crypto
, for signature verification, look into pointycastle and pkcs7
Docs: https://developer.apple.com/documentation/walletpasses/building_a_pass#3732525
Right now, the pull request verification doesn't get triggered when the title changes and the job has to be manually restarted. That's quite annoying and should be fixed
When a PkPass file is updated, the system is supposed to show a change message notification/hint (depending on whether it was updated in background/foreground).
This is done by comparing the fields of the old and updated pass.
Those fields with a change message should be returned with a properly formatted change message. Otherwise, a generic message should be returned.
An open question is whether those fields support localization, but I would assume so.
We could provide an API that looks something like this:
class PkPass {
List<String> getChangeMessages(PkPass oldPass, String locale) {
// ...
}
}
final changeMessages = newPass.getChangeMessages(oldPass, 'de_DE');
Passes show an icon in the lower right corner if they're NFC enabled. The passkit_ui
package should show it too. Ideally, it can be toggled though, since it still has to be enabled by the consuming application.
For documentation, see the following links:
Tasks:
Individual check marks can be done in separate PRs
By adding JsonKey annotations, we ensure that deserialization is less prone to break due to refactorings. Additionally, we're able to give properties names that are idiomatic to Dart.
It probably also makes it easier to migrate to macros when the time comes.
Docs:
The event example PkPass from the Apple Docs should look like the following image:
Docs:
Reference images |
---|
This pass file example.zip (change file extension back to pkpass) should look like the following screenshot
If there are purely presentational widgets with no added functionality, they should be migrated to be a golden test.
Worth checking package:alchemist.
General docs: https://developer.apple.com/documentation/walletpasses/adding_a_web_service_to_update_passes
Is there a test server that implements all of these thingies? Otherwise, I'm not sure how to properly end-to-end test this.
Something along the lines of
String getFormatted(String locale) {
if(numberstyle != null) {
// return formatted number
}
if(datestyle != null) {
// return formatted date
}
// and so on
}
Create a package, which implements the backend interface for the various services mentioned in #9
There are multiple popular Dart web frameworks:
shelf
and dart_frog
are somewhat compatible, so it may make sense to choose shelf
as a target.
The push notification format is described here https://stackoverflow.com/a/15878404 and a sample implementation can be found here https://github.com/drallgood/jpasskit
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.