Toolkit documentation - alexandercerutti/passkit-webservice-toolkit GitHub Wiki

This package exposes a set of endpoint definitions and Typescript types to let you build your integration. They are organized below per Apple Service.

How are composed the endpoint definitions

Each entry point exposes an endpoint definition. Thanks to the magic of Typescript, the properties of the definition will show the exact values 🪄 🌈.

So, anytime, you can mouse-hover the constants and see all the details of the endpoint.

type EntrypointDefinition = {
    method: "POST";
    path: "/v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber";
    params: ["deviceLibraryIdentifier", "passTypeIdentifier", "serialNumber"];
    toString(): "POST /v1/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber";
}

Entry points

This package is studied to be compatible with both CJS and ESM. It exposes the following entry points in package.json:

{
	".": {
		"import": "./lib/esm/index.js",
		"require": "./lib/cjs/index.js"
	},
	"./v1": {
		"import": "./lib/esm/services/v1/index.js",
		"require": "./lib/cjs/services/v1/index.js"
	},
	"./v1/*": {
		"import": "./lib/esm/services/v1/*",
		"require": "./lib/cjs/services/v1/*"
	}
}

Therefore it could be used in the following ways:

import { v1 } from "passkit-webservice-toolkit";
import { ... } from "passkit-webservice-toolkit/v1";
import { LogEndpoint } from "passkit-webservice-toolkit/v1/log.js";

const { v1 } = require("passkit-webservice-toolkit");
const { ... } = require("passkit-webservice-toolkit/v1");
const { LogEndpoint } = require("passkit-webservice-toolkit/v1/log.js");

Services

Register

Documentation: https://developer.apple.com/documentation/walletpasses/register_a_pass_for_update_notifications

Entrypoint: passkit-webservice-toolkit/v1/register.js.

Exports:

Name Kind Description
RegisterEndpoint EntrypointDefinition -
RegisterParams type Type shortcut to
(typeof RegisterEndpoint)["params"]
PushToken interface The request body from Apple. See docs for more.

Unregister

Documentation: https://developer.apple.com/documentation/walletpasses/unregister_a_pass_for_update_notifications

Entrypoint: passkit-webservice-toolkit/v1/unregister.js.

Exports:

Name Kind Description
UnregisterEndpoint EntrypointDefinition -
UnregisterParams type Type shortcut to
(typeof UnregisterEndpoint)["params"]

Update

Documentation: https://developer.apple.com/documentation/walletpasses/send_an_updated_pass

Entrypoint: passkit-webservice-toolkit/v1/update.js.

Exports:

Name Kind Description
UpdateEndpoint EntrypointDefinition -
UpdateParams type Type shortcut to
(typeof UpdateEndpoint)["params"]

List

Documentation: https://developer.apple.com/documentation/walletpasses/get_the_list_of_updatable_passes

Entrypoint: passkit-webservice-toolkit/v1/list.js.

Description:

Will be called only after the server signals Apple of updates via APNS.

Exports:

Name Kind Description
ListEndpoint EntrypointDefinition -
ListParams type Type shortcut to
(typeof ListEndpoint)["params"]
SerialNumbers interface The response body to send back to Apple. See docs for more.

Log

Documentation: https://developer.apple.com/documentation/walletpasses/log_a_message

Entrypoint: passkit-webservice-toolkit/v1/log.js.

Exports:

Name Kind Description
ListEndpoint EntrypointDefinition -
ListParams type Type shortcut to
(typeof LogEndpoint)["params"]
LogEntries interface The request body defined by Apple. See docs for more.

Utilities

passkit-webservice-toolkit also exposes some utilities that could be helpful to perform some kind of validation.

Authorization

Entrypoint: passkit-webservice-toolkit/v1/utils/auth.js

isAuthorizationSchemeValid

declare function isAuthorizationSchemeValid(authorizationString: string): boolean;

Description:

Will perform light validation on the Authorization schema, by checking if it is ApplePass and returning the right boolean.


getAuthorizationToken

declare function getAuthorizationToken(authorizationString: string): string;

Description:

Will extract the token from the Authorization header you provide. Performs a light validation on the Authorization Schema.

Throws if the schema is not ApplePass.

⚠️ **GitHub.com Fallback** ⚠️