A frustration-free compression tool for PKPass archives.
Project description
airpress
Compression tool for PKPass archives.
AirPress does compression in runtime memory without creating temporary files or directories, which is handy for server-side implementation.
Installation
From PyPI:
pip install airpress
Quickstart
from airpress import PKPass
# PKPass compressor operates on `bytes` objects as input/output
p = PKPass(
('icon.png', bytes(...)),
('logo.png', bytes(...)),
('pass.json', bytes(...)),
...
)
p.sign(cert=bytes(...), key=bytes(...), password=bytes(...)) # `password` argument is optional
_ = bytes(p) # Creates `bytes` object containing signed and compressed `.pkpass` archive
In most cases you're likely to return pkpass as http response and bytes object is exactly what you need.
It's up to you how to handle .pkpass archive from this point.
PKPass will raise human-readable errors in case something is
wrong with pass package you're trying to sign and compress.
Prepare Pass Type ID certificate
If you don't have your pass type certificate, follow this guide to create one.
Export your developer certificate as .p12 file and convert it into a pair of cert and key .pem files:
openssl pkcs12 -in "Certificates.p12" -clcerts -nokeys -out certificate.pem
openssl pkcs12 -in "Certificates.p12" -nocerts -out key.pem
You will be asked for an export password (or export phrase), you may leave it blank or provide a passphrase. It's this value that you later should supply to PKPass compressor (or leave blank).
Example
This example shows how to read locally stored assets as bytes objects, compress pkpass archive
and save it to script's parent directory.
import os
from airpress import PKPass
icon = open(os.path.join(os.path.dirname(__file__), '...your_path_to/icon.png'), 'rb').read()
icon_2x = open(os.path.join(os.path.dirname(__file__), '...your_path_to/icon@2x.png'), 'rb').read()
logo = open(os.path.join(os.path.dirname(__file__), '...your_path_to/logo.png'), 'rb').read()
logo_2x = open(os.path.join(os.path.dirname(__file__), '...your_path_to/logo@2x.png'), 'rb').read()
# It is more likely that you'll be dumping python dictionary into json file, but as an example `pass.json` is a file
pass_json = open(os.path.join(os.path.dirname(__file__), '...your_path_to/pass.json'), 'rb').read()
key = open(os.path.join(os.path.dirname(__file__), '...your_path_to/key.pem'), 'rb').read()
cert = open(os.path.join(os.path.dirname(__file__), '...your_path_to/certificate.pem'), 'rb').read()
password = bytes('your_password_123', 'utf8')
p = PKPass(
('icon.png', icon),
('icon@2x.png', icon_2x),
('logo.png', logo),
('logo@2x.png', logo_2x),
('pass.json', pass_json),
)
p.sign(cert=cert, key=key, password=password)
with open('pass.pkpass', 'wb') as file:
file.write(bytes(p))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airpress-0.0.2.tar.gz.
File metadata
- Download URL: airpress-0.0.2.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a471fb6a015e8d3739d2f62a2b208f8348ea59e98d2e4b4acefc50e92d968d6f
|
|
| MD5 |
e82c54caa200cf01ead6bb7249d68ae8
|
|
| BLAKE2b-256 |
73c945bcc53dd0ed75ed926714acfc694a564dc5572827643430f244249e0dc1
|
File details
Details for the file airpress-0.0.2-py3-none-any.whl.
File metadata
- Download URL: airpress-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98eba5ac9742c295baf4af927af20a4e838c94f0b717d36348475e523b7fe89b
|
|
| MD5 |
ef7daed217838210174a5b32ba147100
|
|
| BLAKE2b-256 |
cae0336130b0c758cd3ca4af4afd4ab592e936a9fd264efe52f03e9a1c8f34ba
|