pkpass

package module
v0.1.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

pkpass-go

Summary

This package will generate a signed Apple Wallet Pass given your companion files, and your Apple issued Pass Type Certificate.

For instructions on how to obtain these certifcates for your account, please see this tutorial.

example coupon

Currently, we depend on openssl. When running in production, I recommend installing this in your Docker container.

Usage

// Open your certifcate via a file, string reader, etc.
cert, err := os.Open("Certificates.p12")
if err != nil {
    panic(err)
}
defer cert.Close()
    
// Pass the directory containing your companiion files, the password you need
// to open your certificate, and the actual certificate to the New func.
r, err := pkpass.New("Coupon.pass", "", cert)
if err != nil {
    panic(err)
}

// The reader contains your freshly minted .pkpass file, just write it out so you can
// use it.
f, err := os.Create("Coupon.pkpass")
if err != nil {
    t.Fatal(err)
}
defer f.Close()

// Copy the reader into an actual file so that you can open it.
_, err = io.Copy(f, r)
if err != nil {
    panic(err)
}

Certificates

When you log into your Apple Developer account, you should create a Pass Type ID. This type id will be what goes into your pass.json file, and will be what the certificate will be attached to. You should name this using the reverse domain convention.

pass.com.example.mypass

Once you have created a Pass Type ID, click edit. Follow the instructions to create and download your certificate. Likely, your certificate will be placced into Keychain Access from there, you can export it, and use it with this package.

It is important that you update your pass.json file prior to creating the pass. You will need to substitute the passTypeIdentifier and teamIdentifier for their actual values.

License

Copyright © 2018 Trevor Hutto

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(storageFolder, passFolder, passID, password string, cert io.Reader) (io.Reader, error)

New creates a new Apple pass using a temporary directory for intermediate files. It ensures that temporary files are cleaned up after the pass is generated. Parameters:

  • storageFolder: the root storage folder containing wwdr, template folder, and private_key.p12.
  • passID: an identifier for the pass (used for reading content from passDir).
  • password: the password for unlocking the .p12 certificate.
  • cert: an io.Reader providing the .p12 certificate data.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL