Skip to main content

A frustration-free compression tool for PKPass archives.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Neo-Airpress

PyPI version PyPI version Build Status

AirPress lets you create, sign and zip PKPass archives for Apple Wallet in runtime memory without a need for temporary files or directories.

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. PKPass will raise human-readable errors in case something is wrong with pass package you're trying to sign and compress.

Manage assets in pass package

Accessing PKPass assets that are already added to pass package is as easy as working with dictionary.

Retrieve asset:

icon = p['icon.png']

It can also be used as alternative to add/update asset:

p['icon.png'] = bytes(...)

Remove asset from pass package:

del p['logo.png']

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 with local files

In case you'd like to play around with locally stored files, or your server keeps assets in the same file storage as source code, this example shows you 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


# Create empty pass package
p = PKPass()

# Add locally stored assets
for filename in os.listdir('your_dir_with_assets'):
    with open(os.path.join(os.path.dirname(__file__), 'your_dir_with_assets', filename), 'rb') as file:
        data = file.read()
        # Add each individual asset to pass package
        p.add_to_pass_package((filename, data))

# Add locally stored credentials
with open(
        os.path.join(os.path.dirname(__file__), 'your_dir_with_credentials/key.pem'), 'rb'
) as key, open(
    os.path.join(os.path.dirname(__file__), 'your_dir_with_credentials/certificate.pem'), 'rb'
) as cert:
    # Add credentials to pass package 
    p.key = key.read()
    p.cert = cert.read()
    p.password = bytes('passpass', 'utf8')

# As we've added credentials to pass package earlier we don't need to supply them to `.sign()`
# This is an alternative to calling .sign() method with credentials as arguments. 
p.sign()
 
# Create pkpass file with pass data 
with open('your_dir_for_output/data.pkpass', 'wb') as file:
    file.write(bytes(p))

Hope you find this package useful! I'd love to hear your feedback and suggestions for this tiny library as there's always room for improvement.

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

neo_airpress-1.0.5.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neo_airpress-1.0.5-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file neo_airpress-1.0.5.tar.gz.

File metadata

  • Download URL: neo_airpress-1.0.5.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for neo_airpress-1.0.5.tar.gz
Algorithm Hash digest
SHA256 3268bccd9b38b8fe53a6c06601354daf7f9f5906f8e89af64284626ff4edc7da
MD5 a8ba5d804e9783c8b62b5948018cd9c2
BLAKE2b-256 79e6f3ce2df18e58588e5235058b2a693833ededa0fc401b4d14499a3716b2c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for neo_airpress-1.0.5.tar.gz:

Publisher: publish.yml on jontyms/neo-airpress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file neo_airpress-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: neo_airpress-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for neo_airpress-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b7dc5f9563a77d67ce719e3ed976ad754a94c6ee011ae4ef18f16e00157d1757
MD5 39d44b0e8ac6db03d3d56e85dd4bb05e
BLAKE2b-256 0cdb9951c7892aa4aa1accf624ef83e4f2380ed901b67bdaf824b39e8f755ee5

See more details on using hashes here.

Provenance

The following attestation bundles were made for neo_airpress-1.0.5-py3-none-any.whl:

Publisher: publish.yml on jontyms/neo-airpress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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