Skip to main content

A frustration-free compression tool for PKPass archives.

Project description

airpress

PyPI version PyPI version Build Status

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

airpress-1.0.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

airpress-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file airpress-1.0.0.tar.gz.

File metadata

  • Download URL: airpress-1.0.0.tar.gz
  • Upload date:
  • Size: 7.9 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

Hashes for airpress-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f6b1bbc00e215415d124ccd8fa7db7c78c0bce1e947d01e276b9374e51ecfecf
MD5 2e104593b32f76a147dd6be1deec2042
BLAKE2b-256 604b772ccbc385070ec57f5d6c3af529717489cfe561524155ed7c1f22c5793e

See more details on using hashes here.

File details

Details for the file airpress-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: airpress-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 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

Hashes for airpress-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7b5a207f4e62c1f02cefcb71465ea065f3762e88100edb36a57e07657170a96
MD5 e564aff48223dfa00b895f1e219d767c
BLAKE2b-256 d14a660c31cb5c5ca5c3e73c7ca4dda37345579f942d76589a4618c67b759856

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page