pkpass

package module
v0.0.0-...-bcd8b42 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 10 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(passDir, password string, cert io.Reader) (io.Reader, error)

New will create a new Apple pass given the directory of companion files, the password needed to open the certificate, and the certificate. You should read the returned reader into a file, this file is your Apple pass and can be opened from iOS and macOS devices.

Types

This section is empty.

Jump to

Keyboard shortcuts

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