passkit

package module
v0.0.0-...-09eb825 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 19 Imported by: 0

README

PassKit

This is a library for generating Apple Wallet PKPasses.

How to use

This library was heavily inspired by drallgood's jpasskit library which was written in Java, so the objects and functions are very similar to the ones available on jpasskit.

Define a pass

To define a pass you use the Pass struct, which represents the pass.json file. This struct is modeled as closely as possible to the json file, so adding data is straightforward:

c := passkit.NewBoardingPass(passkit.TransitTypeAir)

// Utility functions for adding fields to a pass
c.AddHeaderField(passkit.Field{
    Key: "your_head_key",
    Label: "your_displayable_head_label",
    Value:"value",
})
c.AddPrimaryFields(passkit.Field{
    Key: "your_prim_key",
    Label: "your_displayable_prim_label",
    Value:"value",
})
c.AddSecondaryFields(passkit.Field{
    Key: "your_sec_key",
    Label: "your_displayable_sec_label",
    Value:"value",
})
c.AddAuxiliaryFields(passkit.Field{
    Key: "your_aux_key",
    Label: "your_displayable_aux_label",
    Value:"value",
})
c.AddBackFields(passkit.Field{
    Key: "your_back_key",
    Label: "your_displayable_back_label",
    Value:"value",
})

boarding := time.Date(2023, 1, 1, 23, 50, 00, 00, time.UTC)

pass := passkit.Pass{
    FormatVersion:       1,
    TeamIdentifier:      "TEAMID",
    PassTypeIdentifier:  "pass.type.id",
    AuthenticationToken: "123141lkjdasj12314",
    OrganizationName:    "Your Organization",
    SerialNumber:        "1234",
    Description:         "test",
    BoardingPass:        c,
    Semantics: []passkit.SemanticTag{
        {
            AirlineCode:            "AA1234",
            TransitProvider:        "American Airlines",
            DepartureAirportCode:   "LAX",
            DepartureAirportName:   "Los Angeles International Airport",
            DepartureGate:          "28",
            DepartureTerminal:      "2",
            DestinationAirportCode: "LGA",
            DestinationAirportName: "LaGuardia Airport",
            DestinationGate:        "12",
            DestinationTerminal:    "1",
            TransitStatus:          "On Time",
            OriginalBoardingDate:   &boarding,
        },
    },
    Barcodes: []passkit.Barcode{
        {
            Format:          passkit.BarcodeFormatPDF417,
            Message:         "1312312312312312312312312312",
            MessageEncoding: "utf-8",
        },
    },
}
Templates

Passes contain additional data that has to be included in the final, signed pass, like images (icons, logos, background images) and translations. Usually, passes of the same type share images and translations. This shared information is what I call a PassTemplate, so that every generated pass of a type have the same images and whatnot.

The template contents are defined as described by the apple wallet developer documentation.

To create the pass structure you need a PassTemplate instance, either with streams (using InMemoryPassTemplate) or with files (using FolderPassTemplate).

Using files

To create the pass bundle create an instance of FolderPassTemplate using the absolute file path of the folder that contain the pass images and translations:

template := passkit.NewFolderPassTemplate("/home/user/pass")

All the files in the folder will be added to the bundled pass exactly as provided, which means they must align to the naming and location conventions described in the apple wallet developer documentation.

Using streams (In Memory)

The second approach is more flexible, having the option of loading files from data streams, or downloaded from a public URL:

template := passkit.NewInMemoryPassTemplate()

template.AddFileBytes(passkit.BundleThumbnail, bytes)
template.AddFileBytesLocalized(passkit.BundleIcon, "en", bytes)
err := template.AddFileFromURL(passkit.BundleLogo, "https://example.com/file.png")
err := template.AddFileFromURLLocalized(passkit.BundleLogo, "en", "https://example.com/file.png")
err := template.AddAllFiles("/home/user/pass")

Note: There are no checks that the contents of a provided file are valid. If a PDF file is provided, but is named icon.png, when viewing the pass on a device it probably won't work. The InMemoryPassTemplate doesn't provide any authentication for the downloads, so the URLs used must be public for the download to work as expected. The downloads use a default http.Client without any SSL configuration, so if the download is from an HTTPS site the certificate must be valid in the system where the library is running, or the download will fail with a certificate error.

Signing and zipping a pass

As all passes need to be signed when bundled we need to use a Signer instance. There are two types of signer:

  • FileBasedSigner: creates a temp folder to store the signed pass file contents.
  • MemoryBasedSigner: keeps the signed pass file contents in memory.

To use any of the Signer instances you need to provide an instance of SigningInformation. SigningInformation defines the certificates used to generate the signature file bundled with every pass. There are two ways to obtain an instance. Either by
reading the certificates from the filesystem, or from already loaded bytes in memory:

// Using the certificate files from your filesystem
signInfo, err := passkit.LoadSigningInformationFromFiles("/home/user/pass_cert.p12", "pass_cert_password", "/home/user/AppleWWDRCA.cer")
// Using the bytes from the certificates, loaded from a database or vault, for example.
signInfo, err := passkit.LoadSigningInformationFromBytes(passCertBytes, "pass_cert_password", wwdrcaBytes)

Important: The provided certificates must be encoded in DER form. If the files are encoded as PEM the signature generation will fail. Errors will also be returned if the certificates are invalid (expired, not x509 certs, etc).

Bundling the pass

Finally, to create the signed pass bundle you use the Pass, Signer, SigningInformation, and PassTemplate instances created previously, like so:

signer := passkit.NewMemoryBasedSigner()
signInfo, err := passkit.LoadSigningInformationFromFiles("/home/user/pass_cert.p12", "pass_cert_password", "/home/user/AppleWWDRCA.cer")
if err != nil {
    panic(err)
}

z, err := signer.CreateSignedAndZippedPassArchive(&pass, template, signInfo)
if err != nil {
    panic(err)
}

err = os.WriteFile("/home/user/pass.pkpass", z, 0644)
if err != nil {
    panic(err)
}

After this step the pass bundle is ready to be distributed as you see fit.

Contributing

Right now I'm not really working on a project where this library is being actively used, so any bugs are hard for me to detect and fix. That's why this project is open to contributions. Just make a Pull Request with fixes or any other feature request, and I will probably accept them and merge them (I will at least look at your code before approving anything).

Documentation

Index

Constants

View Source
const (
	TextAlignmentLeft    TextAlignment = "PKTextAlignmentLeft"
	TextAlignmentCenter  TextAlignment = "PKTextAlignmentCenter"
	TextAlignmentRight   TextAlignment = "PKTextAlignmentRight"
	TextAlignmentNatural TextAlignment = "PKTextAlignmentNatural"

	BarcodeFormatQR      BarcodeFormat = "PKBarcodeFormatQR"
	BarcodeFormatPDF417  BarcodeFormat = "PKBarcodeFormatPDF417"
	BarcodeFormatAztec   BarcodeFormat = "PKBarcodeFormatAztec"
	BarcodeFormatCode128 BarcodeFormat = "PKBarcodeFormatCode128"

	DataDetectorTypePhoneNumber   DataDetectorType = "PKDataDetectorTypePhoneNumber"
	DataDetectorTypeLink          DataDetectorType = "PKDataDetectorTypeLink"
	DataDetectorTypeAddress       DataDetectorType = "PKDataDetectorTypeAddress"
	DataDetectorTypeCalendarEvent DataDetectorType = "PKDataDetectorTypeCalendarEvent"

	DateStyleNone   DateStyle = "PKDateStyleNone"
	DateStyleShort  DateStyle = "PKDateStyleShort"
	DateStyleMedium DateStyle = "PKDateStyleMedium"
	DateStyleLong   DateStyle = "PKDateStyleLong"
	DateStyleFull   DateStyle = "PKDateStyleFull"

	NumberStyleDecimal    NumberStyle = "PKNumberStyleDecimal"
	NumberStylePercent    NumberStyle = "PKNumberStylePercent"
	NumberStyleScientific NumberStyle = "PKNumberStyleScientific"
	NumberStyleSpellOut   NumberStyle = "PKNumberStyleSpellOut"

	PassPersonalizationFieldName         PassPersonalizationField = "PKPassPersonalizationFieldName"
	PassPersonalizationFieldPostalCode   PassPersonalizationField = "PKPassPersonalizationFieldPostalCode"
	PassPersonalizationFieldEmailAddress PassPersonalizationField = "PKPassPersonalizationFieldEmailAddress"
	PassPersonalizationFieldPhoneNumber  PassPersonalizationField = "PKPassPersonalizationFieldPhoneNumber"

	TransitTypeAir     TransitType = "PKTransitTypeAir"
	TransitTypeBoat    TransitType = "PKTransitTypeBoat"
	TransitTypeBus     TransitType = "PKTransitTypeBus"
	TransitTypeGeneric TransitType = "PKTransitTypeGeneric"
	TransitTypeTrain   TransitType = "PKTransitTypeTrain"

	EventTypeGeneric         EventType = "PKEventTypeGeneric"
	EventTypeLivePerformance EventType = "PKEventTypeLivePerformance"
	EventTypeMovie           EventType = "PKEventTypeMovie"
	EventTypeSports          EventType = "PKEventTypeSports"
	EventTypeConference      EventType = "PKEventTypeConference"
	EventTypeConvention      EventType = "PKEventTypeConvention"
	EventTypeWorkshop        EventType = "PKEventTypeWorkshop"
	EventTypeSocialGathering EventType = "PKEventTypeSocialGathering"
)
View Source
const (
	BundleIconRetinaHD                = "icon@3x.png"
	BundleIconRetina                  = "icon@2x.png"
	BundleIcon                        = "icon.png"
	BundleLogoRetinaHD                = "logo@3x.png"
	BundleLogoRetina                  = "logo@2x.png"
	BundleThumbnailRetinaHD           = "thumbnail@3x.png"
	BundleThumbnailRetina             = "thumbnail@2x.png"
	BundleThumbnail                   = "thumbnail.png"
	BundleStripRetinaHD               = "strip@3x.png"
	BundleStripRetina                 = "strip@2x.png"
	BundleStrip                       = "strip.png"
	BundleBackgroundRetinaHD          = "background@3x.png"
	BundleBackgroundRetina            = "background@2x.png"
	BundleBackground                  = "background.png"
	BundleFooterRetinaHD              = "footer@3x.png"
	BundleFooterRetina                = "footer@2x.png"
	BundleFooter                      = "footer.png"
	BundlePersonalizationLogoRetinaHD = "personalizationLogo@3x.png"
	BundlePersonalizationLogoRetina   = "personalizationLogo@2x.png"
)

Variables

Functions

This section is empty.

Types

type Barcode

type Barcode struct {
	Format          BarcodeFormat `json:"format,omitempty"`
	AltText         string        `json:"altText,omitempty"`
	Message         string        `json:"message,omitempty"`
	MessageEncoding string        `json:"messageEncoding,omitempty"`
}

Barcode Representation of https://developer.apple.com/documentation/walletpasses/pass/barcodes

func (*Barcode) GetValidationErrors

func (b *Barcode) GetValidationErrors() []string

func (*Barcode) IsValid

func (b *Barcode) IsValid() bool

type BarcodeFormat

type BarcodeFormat string

type Beacon

type Beacon struct {
	Major         int    `json:"major,omitempty"`
	Minor         int    `json:"minor,omitempty"`
	ProximityUUID string `json:"proximityUUID,omitempty"`
	RelevantText  string `json:"relevantText,omitempty"`
}

Beacon Representation of https://developer.apple.com/documentation/walletpasses/pass/beacons

func (*Beacon) GetValidationErrors

func (b *Beacon) GetValidationErrors() []string

func (*Beacon) IsValid

func (b *Beacon) IsValid() bool

type BoardingPass

type BoardingPass struct {
	*GenericPass
	TransitType TransitType `json:"transitType,omitempty"`
}

BoardingPass Representation of https://developer.apple.com/documentation/walletpasses/pass/boardingpass

func NewBoardingPass

func NewBoardingPass(transitType TransitType) *BoardingPass

func (*BoardingPass) GetValidationErrors

func (b *BoardingPass) GetValidationErrors() []string

func (*BoardingPass) IsValid

func (b *BoardingPass) IsValid() bool

type Coupon

type Coupon struct {
	*GenericPass
}

Coupon Representation of https://developer.apple.com/documentation/walletpasses/pass/coupon

func NewCoupon

func NewCoupon() *Coupon

type DataDetectorType

type DataDetectorType string

type DateStyle

type DateStyle string

type EventTicket

type EventTicket struct {
	*GenericPass
}

EventTicket Representation of https://developer.apple.com/documentation/walletpasses/pass/eventticket

func NewEventTicket

func NewEventTicket() *EventTicket

type EventType

type EventType string

type Field

type Field struct {
	Key               string             `json:"key,omitempty"`
	Label             string             `json:"label,omitempty"`
	Value             interface{}        `json:"value,omitempty"`
	AttributedValue   interface{}        `json:"attributedValue,omitempty"`
	ChangeMessage     string             `json:"changeMessage,omitempty"`
	TextAlignment     TextAlignment      `json:"textAlignment,omitempty"`
	DataDetectorTypes []DataDetectorType `json:"dataDetectorTypes,omitempty"`
	CurrencyCode      string             `json:"currencyCode,omitempty"`
	NumberStyle       NumberStyle        `json:"numberStyle,omitempty"`
	DateStyle         DateStyle          `json:"dateStyle,omitempty"`
	TimeStyle         DateStyle          `json:"timeStyle,omitempty"`
	IsRelative        bool               `json:"isRelative,omitempty"`
	IgnoreTimeZone    bool               `json:"ignoresTimeZone,omitempty"`
	Semantics         *SemanticTag       `json:"semantics,omitempty"`
	Row               int                `json:"row,omitempty"`
}

Field Representation of https://developer.apple.com/documentation/walletpasses/passfieldcontent

func (*Field) GetValidationErrors

func (f *Field) GetValidationErrors() []string

func (*Field) IsValid

func (f *Field) IsValid() bool

type FolderPassTemplate

type FolderPassTemplate struct {
	// contains filtered or unexported fields
}

func NewFolderPassTemplate

func NewFolderPassTemplate(templateDir string) *FolderPassTemplate

func (*FolderPassTemplate) GetAllFiles

func (f *FolderPassTemplate) GetAllFiles() (map[string][]byte, error)

func (*FolderPassTemplate) ProvisionPassAtDirectory

func (f *FolderPassTemplate) ProvisionPassAtDirectory(tmpDirPath string) error

type GenericPass

type GenericPass struct {
	HeaderFields    []Field `json:"headerFields,omitempty"`
	PrimaryFields   []Field `json:"primaryFields,omitempty"`
	SecondaryFields []Field `json:"secondaryFields,omitempty"`
	AuxiliaryFields []Field `json:"auxiliaryFields,omitempty"`
	BackFields      []Field `json:"backFields,omitempty"`
}

GenericPass Representation of https://developer.apple.com/documentation/walletpasses/pass/generic

func NewGenericPass

func NewGenericPass() *GenericPass

func (*GenericPass) AddAuxiliaryFields

func (gp *GenericPass) AddAuxiliaryFields(field Field)

func (*GenericPass) AddBackFields

func (gp *GenericPass) AddBackFields(field Field)

func (*GenericPass) AddHeaderField

func (gp *GenericPass) AddHeaderField(field Field)

func (*GenericPass) AddPrimaryFields

func (gp *GenericPass) AddPrimaryFields(field Field)

func (*GenericPass) AddSecondaryFields

func (gp *GenericPass) AddSecondaryFields(field Field)

func (*GenericPass) GetValidationErrors

func (gp *GenericPass) GetValidationErrors() []string

func (*GenericPass) IsValid

func (gp *GenericPass) IsValid() bool

type InMemoryPassTemplate

type InMemoryPassTemplate struct {
	// contains filtered or unexported fields
}

func NewInMemoryPassTemplate

func NewInMemoryPassTemplate() *InMemoryPassTemplate

func (*InMemoryPassTemplate) AddAllFiles

func (m *InMemoryPassTemplate) AddAllFiles(directoryWithFilesToAdd string) error

func (*InMemoryPassTemplate) AddFileBytes

func (m *InMemoryPassTemplate) AddFileBytes(name string, data []byte)

func (*InMemoryPassTemplate) AddFileBytesLocalized

func (m *InMemoryPassTemplate) AddFileBytesLocalized(name, locale string, data []byte)

func (*InMemoryPassTemplate) AddFileFromURL

func (m *InMemoryPassTemplate) AddFileFromURL(name string, u url.URL) error

func (*InMemoryPassTemplate) AddFileFromURLLocalized

func (m *InMemoryPassTemplate) AddFileFromURLLocalized(name, locale string, u url.URL) error

func (*InMemoryPassTemplate) GetAllFiles

func (m *InMemoryPassTemplate) GetAllFiles() (map[string][]byte, error)

func (*InMemoryPassTemplate) ProvisionPassAtDirectory

func (m *InMemoryPassTemplate) ProvisionPassAtDirectory(tmpDirPath string) error

type Location

type Location struct {
	Latitude     float64 `json:"latitude,omitempty"`
	Longitude    float64 `json:"longitude,omitempty"`
	Altitude     float64 `json:"altitude,omitempty"`
	RelevantText string  `json:"relevantText,omitempty"`
}

Location Representation of https://developer.apple.com/documentation/walletpasses/pass/locations

func (*Location) GetValidationErrors

func (l *Location) GetValidationErrors() []string

func (*Location) IsValid

func (l *Location) IsValid() bool

type NFC

type NFC struct {
	Message                string `json:"message,omitempty"`
	EncryptionPublicKey    string `json:"encryptionPublicKey,omitempty"`
	RequiresAuthentication bool   `json:"requiresAuthentication,omitempty"`
}

NFC Representation of https://developer.apple.com/documentation/walletpasses/pass/nfc

type NumberStyle

type NumberStyle string

type PWAssociatedApp

type PWAssociatedApp struct {
	Title        string
	IdGooglePlay string
	IdAmazon     string
}

func (*PWAssociatedApp) GetValidationErrors

func (a *PWAssociatedApp) GetValidationErrors() []string

func (*PWAssociatedApp) IsValid

func (a *PWAssociatedApp) IsValid() bool

type Pass

type Pass struct {
	FormatVersion              int                    `json:"formatVersion,omitempty"`
	SerialNumber               string                 `json:"serialNumber,omitempty"`
	PassTypeIdentifier         string                 `json:"passTypeIdentifier,omitempty"`
	WebServiceURL              string                 `json:"webServiceURL,omitempty"`
	AuthenticationToken        string                 `json:"authenticationToken,omitempty"`
	Description                string                 `json:"description,omitempty"`
	TeamIdentifier             string                 `json:"teamIdentifier,omitempty"`
	OrganizationName           string                 `json:"organizationName,omitempty"`
	LogoText                   string                 `json:"logoText,omitempty"`
	ForegroundColor            string                 `json:"foregroundColor,omitempty"`
	BackgroundColor            string                 `json:"backgroundColor,omitempty"`
	LabelColor                 string                 `json:"labelColor,omitempty"`
	GroupingIdentifier         string                 `json:"groupingIdentifier,omitempty"`
	Beacons                    []Beacon               `json:"beacons,omitempty"`
	Locations                  []Location             `json:"locations,omitempty"`
	Barcodes                   []Barcode              `json:"barcodes,omitempty"`
	EventTicket                *EventTicket           `json:"eventTicket,omitempty"`
	Coupon                     *Coupon                `json:"coupon,omitempty"`
	StoreCard                  *StoreCard             `json:"storeCard,omitempty"`
	BoardingPass               *BoardingPass          `json:"boardingPass,omitempty"`
	Generic                    *GenericPass           `json:"generic,omitempty"`
	AppLaunchURL               string                 `json:"appLaunchURL,omitempty"`
	AssociatedStoreIdentifiers []int64                `json:"associatedStoreIdentifiers,omitempty"`
	UserInfo                   map[string]interface{} `json:"userInfo,omitempty"`
	MaxDistance                int64                  `json:"maxDistance,omitempty"`
	RelevantDate               *time.Time             `json:"relevantDate,omitempty"`
	ExpirationDate             *time.Time             `json:"expirationDate,omitempty"`
	Voided                     bool                   `json:"voided,omitempty"`
	Nfc                        *NFC                   `json:"nfc,omitempty"`
	SharingProhibited          bool                   `json:"sharingProhibited,omitempty"`
	Semantics                  *SemanticTag           `json:"semantics,omitempty"`
	// contains filtered or unexported fields
}

Pass Representation of https://developer.apple.com/documentation/walletpasses/pass

func (*Pass) GetValidationErrors

func (p *Pass) GetValidationErrors() []string

func (*Pass) IsValid

func (p *Pass) IsValid() bool

func (*Pass) SetBackgroundColorHex

func (p *Pass) SetBackgroundColorHex(hex string) error

func (*Pass) SetBackgroundColorRGB

func (p *Pass) SetBackgroundColorRGB(r, g, b uint8) error

func (*Pass) SetForegroundColorHex

func (p *Pass) SetForegroundColorHex(hex string) error

func (*Pass) SetForegroundColorRGB

func (p *Pass) SetForegroundColorRGB(r, g, b uint8) error

func (*Pass) SetLabelColorHex

func (p *Pass) SetLabelColorHex(hex string) error

func (*Pass) SetLabelColorRGB

func (p *Pass) SetLabelColorRGB(r, g, b uint8) error

type PassPersonalizationField

type PassPersonalizationField string

type PassTemplate

type PassTemplate interface {
	ProvisionPassAtDirectory(tmpDirPath string) error
	GetAllFiles() (map[string][]byte, error)
}

type Personalization

type Personalization struct {
	RequiredPersonalizationFields []PassPersonalizationField `json:"requiredPersonalizationFields"`
	Description                   string                     `json:"description"`
	TermsAndConditions            string                     `json:"termsAndConditions"`
}

Personalization Representation of https://developer.apple.com/documentation/walletpasses/personalize

func (*Personalization) GetValidationErrors

func (pz *Personalization) GetValidationErrors() []string

func (*Personalization) IsValid

func (pz *Personalization) IsValid() bool

type SemanticTag

type SemanticTag struct {
	AirlineCode                    string                           `json:"airlineCode,omitempty"`
	ArtistIds                      []string                         `json:"artistIDs,omitempty"`
	AwayTeamAbbreviation           string                           `json:"awayTeamAbbreviation,omitempty"`
	AwayTeamLocation               string                           `json:"awayTeamLocation,omitempty"`
	AwayTeamName                   string                           `json:"awayTeamName,omitempty"`
	Balance                        *SemanticTagCurrencyAmount       `json:"currency,omitempty"`
	BoardingGroup                  string                           `json:"boardingGroup,omitempty"`
	BoardingSequenceNumber         string                           `json:"boardingSequenceNumber,omitempty"`
	CarNumber                      string                           `json:"carNumber,omitempty"`
	ConfirmationNumber             string                           `json:"confirmationNumber,omitempty"`
	CurrentArrivalDate             *time.Time                       `json:"currentArrivalDate,omitempty"`
	CurrentBoardingDate            *time.Time                       `json:"currentBoardingDate,omitempty"`
	CurrentDepartureDate           *time.Time                       `json:"currentDepartureDate,omitempty"`
	DepartureAirportCode           string                           `json:"departureAirportCode,omitempty"`
	DepartureAirportName           string                           `json:"departureAirportName,omitempty"`
	DepartureGate                  string                           `json:"departureGate,omitempty"`
	DepartureLocation              *SemanticTagLocation             `json:"departureLocation,omitempty"`
	DepartureLocationDescription   string                           `json:"departureLocationDescription,omitempty"`
	DeparturePlatform              string                           `json:"departurePlatform,omitempty"`
	DepartureStationName           string                           `json:"departureStationName,omitempty"`
	DepartureTerminal              string                           `json:"departureTerminal,omitempty"`
	DestinationAirportCode         string                           `json:"destinationAirportCode,omitempty"`
	DestinationAirportName         string                           `json:"destinationAirportName,omitempty"`
	DestinationGate                string                           `json:"destinationGate,omitempty"`
	DestinationLocation            *SemanticTagLocation             `json:"destinationLocation,omitempty"`
	DestinationLocationDescription string                           `json:"destinationLocationDescription,omitempty"`
	DestinationPlatform            string                           `json:"destinationPlatform,omitempty"`
	DestinationStationName         string                           `json:"destinationStationName,omitempty"`
	DestinationTerminal            string                           `json:"destinationTerminal,omitempty"`
	Duration                       *uint64                          `json:"duration,omitempty"`
	EventEndDate                   *time.Time                       `json:"eventEndDate,omitempty"`
	EventName                      string                           `json:"eventName,omitempty"`
	EventStartDate                 *time.Time                       `json:"eventStartDate,omitempty"`
	EventType                      EventType                        `json:"eventType,omitempty"`
	FlightCode                     string                           `json:"flightCode,omitempty"`
	FlightNumber                   string                           `json:"flightNumber,omitempty"`
	Genre                          string                           `json:"genre,omitempty"`
	HomeTeamAbbreviation           string                           `json:"homeTeamAbbreviation,omitempty"`
	HomeTeamLocation               string                           `json:"homeTeamLocation,omitempty"`
	HomeTeamName                   string                           `json:"homeTeamName,omitempty"`
	LeagueAbbreviation             string                           `json:"leagueAbbreviation,omitempty"`
	LeagueName                     string                           `json:"leagueName,omitempty"`
	MembershipProgramName          string                           `json:"membershipProgramName,omitempty"`
	MembershipProgramNumber        string                           `json:"membershipProgramNumber,omitempty"`
	OriginalArrivalDate            *time.Time                       `json:"originalArrivalDate,omitempty"`
	OriginalBoardingDate           *time.Time                       `json:"originalBoardingDate,omitempty"`
	OriginalDepartureDate          *time.Time                       `json:"originalDepartureDate,omitempty"`
	PassengerName                  *SemanticTagPersonNameComponents `json:"passengerName,omitempty"`
	PerformerNames                 string                           `json:"performerNames,omitempty"`
	PriorityStatus                 string                           `json:"priorityStatus,omitempty"`
	Seats                          []SemanticTagSeat                `json:"seats,omitempty"`
	SecurityScreening              string                           `json:"securityScreening,omitempty"`
	SilenceRequested               bool                             `json:"silenceRequested,omitempty"`
	SportName                      string                           `json:"sportName,omitempty"`
	TotalPrice                     *SemanticTagCurrencyAmount       `json:"totalPrice,omitempty"`
	TransitProvider                string                           `json:"transitProvider,omitempty"`
	TransitStatus                  string                           `json:"transitStatus,omitempty"`
	TransitStatusReason            string                           `json:"transitStatusReason,omitempty"`
	VehicleName                    string                           `json:"vehicleName,omitempty"`
	VehicleNumber                  string                           `json:"vehicleNumber,omitempty"`
	VehicleType                    string                           `json:"vehicleType,omitempty"`
	VenueEntrance                  string                           `json:"venueEntrance,omitempty"`
	VenueLocation                  *SemanticTagLocation             `json:"venueLocation,omitempty"`
	VenueName                      string                           `json:"venueName,omitempty"`
	VenuePhoneNumber               string                           `json:"venuePhoneNumber,omitempty"`
	VenueRoom                      string                           `json:"venueRoom,omitempty"`
	WifiAccess                     *SemanticTagWifiNetwork          `json:"wifiAccess,omitempty"`
}

SemanticTag Representation of https://developer.apple.com/documentation/walletpasses/semantictags

func (*SemanticTag) GetValidationErrors

func (s *SemanticTag) GetValidationErrors() []string

func (*SemanticTag) IsValid

func (s *SemanticTag) IsValid() bool

type SemanticTagCurrencyAmount

type SemanticTagCurrencyAmount struct {
	Amount       string `json:"amount"`
	CurrencyCode string `json:"currencyCode"`
}

SemanticTagCurrencyAmount Representation of https://developer.apple.com/documentation/walletpasses/semantictagtype/currencyamount

func (*SemanticTagCurrencyAmount) GetValidationErrors

func (s *SemanticTagCurrencyAmount) GetValidationErrors() []string

func (*SemanticTagCurrencyAmount) IsValid

func (s *SemanticTagCurrencyAmount) IsValid() bool

type SemanticTagLocation

type SemanticTagLocation struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

SemanticTagLocation Representation of https://developer.apple.com/documentation/walletpasses/semantictagtype/location

func (*SemanticTagLocation) GetValidationErrors

func (l *SemanticTagLocation) GetValidationErrors() []string

func (*SemanticTagLocation) IsValid

func (l *SemanticTagLocation) IsValid() bool

type SemanticTagPersonNameComponents

type SemanticTagPersonNameComponents struct {
	FamilyName             string `json:"familyName,omitempty"`
	GivenName              string `json:"givenName,omitempty"`
	MiddleName             string `json:"middleName,omitempty"`
	NamePrefix             string `json:"namePrefix,omitempty"`
	NameSuffix             string `json:"nameSuffix,omitempty"`
	Nickname               string `json:"nickname,omitempty"`
	PhoneticRepresentation string `json:"phoneticRepresentation,omitempty"`
}

SemanticTagPersonNameComponents Representation of https://developer.apple.com/documentation/walletpasses/semantictagtype/personnamecomponents

func (*SemanticTagPersonNameComponents) GetValidationErrors

func (l *SemanticTagPersonNameComponents) GetValidationErrors() []string

func (*SemanticTagPersonNameComponents) IsValid

type SemanticTagSeat

type SemanticTagSeat struct {
	SeatDescription string `json:"seatDescription,omitempty"`
	SeatIdentifier  string `json:"seatIdentifier,omitempty"`
	SeatNumber      string `json:"seatNumber,omitempty"`
	SeatRow         string `json:"seatRow,omitempty"`
	SeatSection     string `json:"seatSection,omitempty"`
	SeatType        string `json:"seatType,omitempty"`
}

SemanticTagSeat Representation of https://developer.apple.com/documentation/walletpasses/semantictagtype/seat

func (*SemanticTagSeat) GetValidationErrors

func (l *SemanticTagSeat) GetValidationErrors() []string

func (*SemanticTagSeat) IsValid

func (l *SemanticTagSeat) IsValid() bool

type SemanticTagWifiNetwork

type SemanticTagWifiNetwork struct {
	SSID     string `json:"ssid"`
	Password string `json:"password"`
}

func (*SemanticTagWifiNetwork) GetValidationErrors

func (w *SemanticTagWifiNetwork) GetValidationErrors() []string

func (*SemanticTagWifiNetwork) IsValid

func (w *SemanticTagWifiNetwork) IsValid() bool

type Signer

type Signer interface {
	CreateSignedAndZippedPassArchive(p *Pass, t PassTemplate, i *SigningInformation) ([]byte, error)
	CreateSignedAndZippedPersonalizedPassArchive(p *Pass, pz *Personalization, t PassTemplate, i *SigningInformation) ([]byte, error)
	SignManifestFile(manifestJson []byte, i *SigningInformation) ([]byte, error)
}

func NewFileBasedSigner

func NewFileBasedSigner() Signer

func NewMemoryBasedSigner

func NewMemoryBasedSigner() Signer

type SigningInformation

type SigningInformation struct {
	// contains filtered or unexported fields
}

func LoadSigningInformationFromBytes

func LoadSigningInformationFromBytes(pkcs12KeyStoreFile []byte, keyStorePassword string, appleWWDRCAFile []byte) (*SigningInformation, error)

func LoadSigningInformationFromFiles

func LoadSigningInformationFromFiles(pkcs12KeyStoreFilePath, keyStorePassword, appleWWDRCAFilePath string) (*SigningInformation, error)

type StoreCard

type StoreCard struct {
	*GenericPass
}

StoreCard Representation of https://developer.apple.com/documentation/walletpasses/pass/storecard

func NewStoreCard

func NewStoreCard() *StoreCard

type TextAlignment

type TextAlignment string

type TransitType

type TransitType string

type Validateable

type Validateable interface {
	IsValid() bool
	GetValidationErrors() []string
}

Jump to

Keyboard shortcuts

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