passkit-wallet 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -139,6 +139,98 @@ function WalletButtons({ pkpassUrl, googleSaveUrl }) {
139
139
  }
140
140
  ```
141
141
 
142
+ ## Handlers (Web Service Protocol)
143
+
144
+ The `handlers` module implements Apple's web service protocol so you don't have to. Provide a "store" object with async callbacks for your DB, and get back plain `{ status, headers, body }` handler functions you can wire into any framework.
145
+
146
+ ### Apple Pass Handlers
147
+
148
+ ```typescript
149
+ import { createApplePassHandlers } from 'passkit-wallet/handlers'
150
+
151
+ const handlers = createApplePassHandlers({
152
+ authenticationToken: 'your-auth-token',
153
+ store: {
154
+ getPass: async (serialNumber) => {
155
+ const pass = await db.findPass(serialNumber)
156
+ return pass ? { updatedAt: pass.updatedAt } : null
157
+ },
158
+ registerDevice: async (deviceLibId, pushToken, serialNumber) => {
159
+ const existed = await db.upsertRegistration(deviceLibId, pushToken, serialNumber)
160
+ return existed ? 'already_registered' : 'created'
161
+ },
162
+ unregisterDevice: async (deviceLibId, serialNumber) => {
163
+ await db.deleteRegistration(deviceLibId, serialNumber)
164
+ },
165
+ getRegistrations: async (passTypeId, deviceLibId, updatedSince) => {
166
+ return db.findRegistrations(passTypeId, deviceLibId, updatedSince)
167
+ },
168
+ getPassData: async (serialNumber) => {
169
+ return db.getPassFields(serialNumber)
170
+ },
171
+ },
172
+ buildPass: async (passData) => {
173
+ // Use your template to build the .pkpass buffer
174
+ const template = await apple.loadPassTemplate()
175
+ const pass = template.createPass()
176
+ // ... set fields from passData
177
+ return pass.getAsBuffer()
178
+ },
179
+ onLog: (logs) => console.log('Apple Wallet logs:', logs),
180
+ })
181
+
182
+ // Wire into any framework (Express example):
183
+ app.post('/v1/devices/:did/registrations/:ptid/:sn', async (req, res) => {
184
+ const result = await handlers.registerDevice({
185
+ deviceLibraryIdentifier: req.params.did,
186
+ passTypeIdentifier: req.params.ptid,
187
+ serialNumber: req.params.sn,
188
+ pushToken: req.body.pushToken,
189
+ authorization: req.headers.authorization,
190
+ })
191
+ res.status(result.status).json(result.body)
192
+ })
193
+ ```
194
+
195
+ ### Apple Order Handlers
196
+
197
+ ```typescript
198
+ import { createAppleOrderHandlers } from 'passkit-wallet/handlers'
199
+
200
+ const orderHandlers = createAppleOrderHandlers({
201
+ authenticationToken: 'your-order-auth-token',
202
+ store: {
203
+ getOrder: async (orderIdentifier) => {
204
+ const order = await db.findOrder(orderIdentifier)
205
+ return order ? { updatedAt: order.updatedAt } : null
206
+ },
207
+ registerDevice: async (deviceId, pushToken, orderIdentifier) => {
208
+ const existed = await db.upsertOrderRegistration(deviceId, pushToken, orderIdentifier)
209
+ return existed ? 'already_registered' : 'created'
210
+ },
211
+ unregisterDevice: async (deviceId, orderIdentifier) => {
212
+ await db.deleteOrderRegistration(deviceId, orderIdentifier)
213
+ },
214
+ getRegistrations: async (orderTypeId, deviceId, modifiedSince) => {
215
+ return db.findOrderRegistrations(orderTypeId, deviceId, modifiedSince)
216
+ },
217
+ },
218
+ buildOrder: async (orderIdentifier) => {
219
+ // Build and sign the .order buffer
220
+ const orderBody = apple.mountOrderInstance({ /* ... */ })
221
+ return apple.generateOrder(orderBody)
222
+ },
223
+ })
224
+ ```
225
+
226
+ ### Handler Methods
227
+
228
+ **Pass handlers:** `registerDevice`, `unregisterDevice`, `getSerialNumbers`, `getLatestPass`, `log`
229
+
230
+ **Order handlers:** `registerDevice`, `unregisterDevice`, `getOrderIdentifiers`, `getLatestOrder`, `log`
231
+
232
+ All handlers return `{ status: number, headers?: Record<string, string>, body?: unknown }`.
233
+
142
234
  ## Apple Certificate Setup
143
235
 
144
236
  1. Create a Pass Type ID and Order Type ID in the [Apple Developer Portal](https://developer.apple.com/account/resources/identifiers/list/passTypeId).
@@ -180,6 +272,11 @@ function WalletButtons({ pkpassUrl, googleSaveUrl }) {
180
272
  - `getClass` / `createClass` / `updateClass` / `updateObject` — CRUD operations on wallet classes and objects.
181
273
  - `sendObjectMessage(client, type, resourceId, message)` — attach a message to a wallet object.
182
274
 
275
+ ### Handlers
276
+
277
+ - `createApplePassHandlers(config)` — returns handler functions for Apple Pass web service endpoints.
278
+ - `createAppleOrderHandlers(config)` — returns handler functions for Apple Order web service endpoints.
279
+
183
280
  ### React
184
281
 
185
282
  - `<AddToAppleWallet url={string} />` — Apple Wallet badge link.
@@ -0,0 +1,39 @@
1
+ import type { HandlerResponse, AppleOrderHandlersConfig, AppleOrderDeviceRequest, AppleOrderIdentifiersRequest, AppleOrderLatestRequest, AppleLogRequest } from "./types.js";
2
+ /**
3
+ * Create framework-agnostic handler functions for the Apple Order web service
4
+ * protocol. Each handler accepts a plain request object and returns a plain
5
+ * `{ status, headers, body }` response.
6
+ */
7
+ export declare const createAppleOrderHandlers: (config: AppleOrderHandlersConfig) => {
8
+ /**
9
+ * `POST /v1/devices/:did/registrations/:otid/:oid`
10
+ *
11
+ * Register a device to receive push notifications for an order.
12
+ */
13
+ registerDevice(req: AppleOrderDeviceRequest): Promise<HandlerResponse>;
14
+ /**
15
+ * `DELETE /v1/devices/:did/registrations/:otid/:oid`
16
+ *
17
+ * Unregister a device from an order.
18
+ */
19
+ unregisterDevice(req: AppleOrderDeviceRequest): Promise<HandlerResponse>;
20
+ /**
21
+ * `GET /v1/devices/:did/registrations/:otid`
22
+ *
23
+ * Return order identifiers registered to a device.
24
+ */
25
+ getOrderIdentifiers(req: AppleOrderIdentifiersRequest): Promise<HandlerResponse>;
26
+ /**
27
+ * `GET /v1/orders/:otid/:oid`
28
+ *
29
+ * Return the latest version of an order as a signed `.order` buffer.
30
+ */
31
+ getLatestOrder(req: AppleOrderLatestRequest): Promise<HandlerResponse>;
32
+ /**
33
+ * `POST /v1/log`
34
+ *
35
+ * Accept log messages from Apple Wallet.
36
+ */
37
+ log(req: AppleLogRequest): Promise<HandlerResponse>;
38
+ };
39
+ //# sourceMappingURL=apple-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-order.d.ts","sourceRoot":"","sources":["../../src/handlers/apple-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,eAAe,EAChB,MAAM,YAAY,CAAA;AAWnB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,wBAAwB;IAIrE;;;;OAIG;wBACuB,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuB5E;;;;OAIG;0BACyB,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa9E;;;;OAIG;6BAC4B,4BAA4B,GAAG,OAAO,CAAC,eAAe,CAAC;IA0BtF;;;;OAIG;wBACuB,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC;IAsB5E;;;;OAIG;aACY,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAO5D,CAAA"}
@@ -0,0 +1,102 @@
1
+ function validateAuth(authorization, expectedToken) {
2
+ if (!authorization)
3
+ return false;
4
+ const token = authorization.replace(/^AppleOrder\s+/i, "").trim();
5
+ return token === expectedToken;
6
+ }
7
+ /**
8
+ * Create framework-agnostic handler functions for the Apple Order web service
9
+ * protocol. Each handler accepts a plain request object and returns a plain
10
+ * `{ status, headers, body }` response.
11
+ */
12
+ export const createAppleOrderHandlers = (config) => {
13
+ const { authenticationToken, store } = config;
14
+ return {
15
+ /**
16
+ * `POST /v1/devices/:did/registrations/:otid/:oid`
17
+ *
18
+ * Register a device to receive push notifications for an order.
19
+ */
20
+ async registerDevice(req) {
21
+ if (!validateAuth(req.authorization, authenticationToken)) {
22
+ return { status: 401 };
23
+ }
24
+ if (!req.pushToken) {
25
+ return { status: 400, body: { message: "pushToken is required" } };
26
+ }
27
+ const order = await store.getOrder(req.orderIdentifier);
28
+ if (!order) {
29
+ return { status: 404 };
30
+ }
31
+ const result = await store.registerDevice(req.deviceIdentifier, req.pushToken, req.orderIdentifier);
32
+ return { status: result === "created" ? 201 : 200 };
33
+ },
34
+ /**
35
+ * `DELETE /v1/devices/:did/registrations/:otid/:oid`
36
+ *
37
+ * Unregister a device from an order.
38
+ */
39
+ async unregisterDevice(req) {
40
+ if (!validateAuth(req.authorization, authenticationToken)) {
41
+ return { status: 401 };
42
+ }
43
+ await store.unregisterDevice(req.deviceIdentifier, req.orderIdentifier);
44
+ return { status: 200 };
45
+ },
46
+ /**
47
+ * `GET /v1/devices/:did/registrations/:otid`
48
+ *
49
+ * Return order identifiers registered to a device.
50
+ */
51
+ async getOrderIdentifiers(req) {
52
+ const registrations = await store.getRegistrations(req.orderTypeIdentifier, req.deviceIdentifier, req.ordersModifiedSince);
53
+ if (registrations.length === 0) {
54
+ return { status: 204 };
55
+ }
56
+ const sorted = registrations.sort((a, b) => a.updatedAt.getTime() - b.updatedAt.getTime());
57
+ const lastModified = sorted[sorted.length - 1].updatedAt.toISOString();
58
+ return {
59
+ status: 200,
60
+ body: {
61
+ orderIdentifiers: sorted.map((r) => r.orderIdentifier),
62
+ lastModified,
63
+ },
64
+ };
65
+ },
66
+ /**
67
+ * `GET /v1/orders/:otid/:oid`
68
+ *
69
+ * Return the latest version of an order as a signed `.order` buffer.
70
+ */
71
+ async getLatestOrder(req) {
72
+ if (!validateAuth(req.authorization, authenticationToken)) {
73
+ return { status: 401 };
74
+ }
75
+ const order = await store.getOrder(req.orderIdentifier);
76
+ if (!order) {
77
+ return { status: 404 };
78
+ }
79
+ const orderBuffer = await config.buildOrder(req.orderIdentifier);
80
+ return {
81
+ status: 200,
82
+ headers: {
83
+ "Content-Type": "application/vnd.apple.order",
84
+ "Content-Disposition": `attachment; filename="${req.orderIdentifier}.order"`,
85
+ },
86
+ body: orderBuffer,
87
+ };
88
+ },
89
+ /**
90
+ * `POST /v1/log`
91
+ *
92
+ * Accept log messages from Apple Wallet.
93
+ */
94
+ async log(req) {
95
+ if (config.onLog) {
96
+ await config.onLog(req.logs);
97
+ }
98
+ return { status: 200 };
99
+ },
100
+ };
101
+ };
102
+ //# sourceMappingURL=apple-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-order.js","sourceRoot":"","sources":["../../src/handlers/apple-order.ts"],"names":[],"mappings":"AASA,SAAS,YAAY,CACnB,aAAiC,EACjC,aAAqB;IAErB,IAAI,CAAC,aAAa;QAAE,OAAO,KAAK,CAAA;IAChC,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACjE,OAAO,KAAK,KAAK,aAAa,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAgC,EAAE,EAAE;IAC3E,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAE7C,OAAO;QACL;;;;WAIG;QACH,KAAK,CAAC,cAAc,CAAC,GAA4B;YAC/C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,mBAAmB,CAAC,EAAE,CAAC;gBAC1D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;YACxB,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;gBACnB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,EAAE,CAAA;YACpE,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;YACvD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;YACxB,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,cAAc,CACvC,GAAG,CAAC,gBAAgB,EACpB,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,eAAe,CACpB,CAAA;YAED,OAAO,EAAE,MAAM,EA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CAAC;QAED;;;;WAIG;QACH,KAAK,CAAC,cAAc,CAAC,GAA4B;YAC/C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,mBAAmB,CAAC,EAAE,CAAC;gBAC1D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;YACxB,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;YACvD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;YACxB,CAAC;YAED,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;YAEhE,OAAO;gBACL,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE;oBACP,cAAc,EAAE,6BAA6B;oBAC7C,qBAAqB,EAAE,yBAAyB,GAAG,CAAC,eAAe,SAAS;iBAC7E;gBACD,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC;QAED;;;;WAIG;QACH,KAAK,CAAC,GAAG,CAAC,GAAoB;YAC5B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;QACxB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import type { HandlerResponse, ApplePassHandlersConfig, ApplePassDeviceRequest, ApplePassSerialNumbersRequest, ApplePassLatestRequest, AppleLogRequest } from "./types.js";
2
+ /**
3
+ * Create framework-agnostic handler functions for the Apple Pass web service
4
+ * protocol. Each handler accepts a plain request object and returns a plain
5
+ * `{ status, headers, body }` response.
6
+ */
7
+ export declare const createApplePassHandlers: (config: ApplePassHandlersConfig) => {
8
+ /**
9
+ * `POST /v1/devices/:did/registrations/:ptid/:sn`
10
+ *
11
+ * Register a device to receive push notifications for a pass.
12
+ */
13
+ registerDevice(req: ApplePassDeviceRequest): Promise<HandlerResponse>;
14
+ /**
15
+ * `DELETE /v1/devices/:did/registrations/:ptid/:sn`
16
+ *
17
+ * Unregister a device from a pass.
18
+ */
19
+ unregisterDevice(req: ApplePassDeviceRequest): Promise<HandlerResponse>;
20
+ /**
21
+ * `GET /v1/devices/:did/registrations/:ptid`
22
+ *
23
+ * Return serial numbers of passes registered to a device.
24
+ */
25
+ getSerialNumbers(req: ApplePassSerialNumbersRequest): Promise<HandlerResponse>;
26
+ /**
27
+ * `GET /v1/passes/:ptid/:sn`
28
+ *
29
+ * Return the latest version of a pass as a `.pkpass` buffer.
30
+ */
31
+ getLatestPass(req: ApplePassLatestRequest): Promise<HandlerResponse>;
32
+ /**
33
+ * `POST /v1/log`
34
+ *
35
+ * Accept log messages from Apple Wallet.
36
+ */
37
+ log(req: AppleLogRequest): Promise<HandlerResponse>;
38
+ };
39
+ //# sourceMappingURL=apple-pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pass.d.ts","sourceRoot":"","sources":["../../src/handlers/apple-pass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,eAAe,EAChB,MAAM,YAAY,CAAA;AAWnB;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,uBAAuB;IAInE;;;;OAIG;wBACuB,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAuB3E;;;;OAIG;0BACyB,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa7E;;;;OAIG;0BACyB,6BAA6B,GAAG,OAAO,CAAC,eAAe,CAAC;IA0BpF;;;;OAIG;uBACsB,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC;IAsB1E;;;;OAIG;aACY,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAO5D,CAAA"}
@@ -0,0 +1,102 @@
1
+ function validateAuth(authorization, expectedToken) {
2
+ if (!authorization)
3
+ return false;
4
+ const token = authorization.replace(/^ApplePass\s+/i, "").trim();
5
+ return token === expectedToken;
6
+ }
7
+ /**
8
+ * Create framework-agnostic handler functions for the Apple Pass web service
9
+ * protocol. Each handler accepts a plain request object and returns a plain
10
+ * `{ status, headers, body }` response.
11
+ */
12
+ export const createApplePassHandlers = (config) => {
13
+ const { authenticationToken, store } = config;
14
+ return {
15
+ /**
16
+ * `POST /v1/devices/:did/registrations/:ptid/:sn`
17
+ *
18
+ * Register a device to receive push notifications for a pass.
19
+ */
20
+ async registerDevice(req) {
21
+ if (!validateAuth(req.authorization, authenticationToken)) {
22
+ return { status: 401 };
23
+ }
24
+ if (!req.pushToken) {
25
+ return { status: 400, body: { message: "pushToken is required" } };
26
+ }
27
+ const pass = await store.getPass(req.serialNumber);
28
+ if (!pass) {
29
+ return { status: 404 };
30
+ }
31
+ const result = await store.registerDevice(req.deviceLibraryIdentifier, req.pushToken, req.serialNumber);
32
+ return { status: result === "created" ? 201 : 200 };
33
+ },
34
+ /**
35
+ * `DELETE /v1/devices/:did/registrations/:ptid/:sn`
36
+ *
37
+ * Unregister a device from a pass.
38
+ */
39
+ async unregisterDevice(req) {
40
+ if (!validateAuth(req.authorization, authenticationToken)) {
41
+ return { status: 401 };
42
+ }
43
+ await store.unregisterDevice(req.deviceLibraryIdentifier, req.serialNumber);
44
+ return { status: 200 };
45
+ },
46
+ /**
47
+ * `GET /v1/devices/:did/registrations/:ptid`
48
+ *
49
+ * Return serial numbers of passes registered to a device.
50
+ */
51
+ async getSerialNumbers(req) {
52
+ const registrations = await store.getRegistrations(req.passTypeIdentifier, req.deviceLibraryIdentifier, req.passesUpdatedSince);
53
+ if (registrations.length === 0) {
54
+ return { status: 204 };
55
+ }
56
+ const sorted = registrations.sort((a, b) => a.updatedAt.getTime() - b.updatedAt.getTime());
57
+ const lastUpdated = sorted[sorted.length - 1].updatedAt.toISOString();
58
+ return {
59
+ status: 200,
60
+ body: {
61
+ serialNumbers: sorted.map((r) => r.serialNumber),
62
+ lastUpdated,
63
+ },
64
+ };
65
+ },
66
+ /**
67
+ * `GET /v1/passes/:ptid/:sn`
68
+ *
69
+ * Return the latest version of a pass as a `.pkpass` buffer.
70
+ */
71
+ async getLatestPass(req) {
72
+ if (!validateAuth(req.authorization, authenticationToken)) {
73
+ return { status: 401 };
74
+ }
75
+ const passData = await store.getPassData(req.serialNumber);
76
+ if (!passData) {
77
+ return { status: 404 };
78
+ }
79
+ const pkpassBuffer = await config.buildPass(passData);
80
+ return {
81
+ status: 200,
82
+ headers: {
83
+ "Content-Type": "application/vnd.apple.pkpass",
84
+ "Content-Disposition": `attachment; filename="${req.serialNumber}.pkpass"`,
85
+ },
86
+ body: pkpassBuffer,
87
+ };
88
+ },
89
+ /**
90
+ * `POST /v1/log`
91
+ *
92
+ * Accept log messages from Apple Wallet.
93
+ */
94
+ async log(req) {
95
+ if (config.onLog) {
96
+ await config.onLog(req.logs);
97
+ }
98
+ return { status: 200 };
99
+ },
100
+ };
101
+ };
102
+ //# sourceMappingURL=apple-pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pass.js","sourceRoot":"","sources":["../../src/handlers/apple-pass.ts"],"names":[],"mappings":"AASA,SAAS,YAAY,CACnB,aAAiC,EACjC,aAAqB;IAErB,IAAI,CAAC,aAAa;QAAE,OAAO,KAAK,CAAA;IAChC,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAChE,OAAO,KAAK,KAAK,aAAa,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAA+B,EAAE,EAAE;IACzE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAE7C,OAAO;QACL;;;;WAIG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EAAE,yBAAyB,GAAG,CAAC,YAAY,UAAU;iBAC3E;gBACD,IAAI,EAAE,YAAY;aACnB,CAAA;QACH,CAAC;QAED;;;;WAIG;QACH,KAAK,CAAC,GAAG,CAAC,GAAoB;YAC5B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;QACxB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { createApplePassHandlers } from "./apple-pass.js";
2
+ export { createAppleOrderHandlers } from "./apple-order.js";
3
+ export type { HandlerResponse, ApplePassStore, ApplePassDeviceRequest, ApplePassSerialNumbersRequest, ApplePassLatestRequest, ApplePassHandlersConfig, AppleOrderStore, AppleOrderDeviceRequest, AppleOrderIdentifiersRequest, AppleOrderLatestRequest, AppleOrderHandlersConfig, AppleLogRequest, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,YAAY,EACV,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,GAChB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { createApplePassHandlers } from "./apple-pass.js";
2
+ export { createAppleOrderHandlers } from "./apple-order.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,133 @@
1
+ /** Plain HTTP response object — framework-agnostic. */
2
+ export interface HandlerResponse {
3
+ status: number;
4
+ headers?: Record<string, string>;
5
+ body?: unknown;
6
+ }
7
+ /** Async callbacks for Apple Pass database operations. */
8
+ export interface ApplePassStore {
9
+ /** Look up a pass by serial number. Return null if not found. */
10
+ getPass(serialNumber: string): Promise<{
11
+ updatedAt: Date;
12
+ } | null>;
13
+ /**
14
+ * Register a device to receive push updates for a pass.
15
+ * Return `"created"` for new registrations or `"already_registered"` if the
16
+ * device was already registered for this pass.
17
+ */
18
+ registerDevice(deviceLibraryIdentifier: string, pushToken: string, serialNumber: string): Promise<"created" | "already_registered">;
19
+ /** Unregister a device from a pass. */
20
+ unregisterDevice(deviceLibraryIdentifier: string, serialNumber: string): Promise<void>;
21
+ /**
22
+ * Return all passes registered to a device, optionally filtered by
23
+ * modification date.
24
+ */
25
+ getRegistrations(passTypeIdentifier: string, deviceLibraryIdentifier: string, updatedSince?: string): Promise<{
26
+ serialNumber: string;
27
+ updatedAt: Date;
28
+ }[]>;
29
+ /**
30
+ * Return the data needed to build a `.pkpass` file for the given serial
31
+ * number. The shape of the returned object is up to you — the handler will
32
+ * pass it through to your `buildPass` callback.
33
+ */
34
+ getPassData(serialNumber: string): Promise<Record<string, unknown> | null>;
35
+ }
36
+ /** Request data for pass device registration / unregistration. */
37
+ export interface ApplePassDeviceRequest {
38
+ deviceLibraryIdentifier: string;
39
+ passTypeIdentifier: string;
40
+ serialNumber: string;
41
+ authorization?: string;
42
+ pushToken?: string;
43
+ }
44
+ /** Request data for fetching serial numbers. */
45
+ export interface ApplePassSerialNumbersRequest {
46
+ deviceLibraryIdentifier: string;
47
+ passTypeIdentifier: string;
48
+ passesUpdatedSince?: string;
49
+ }
50
+ /** Request data for fetching the latest pass. */
51
+ export interface ApplePassLatestRequest {
52
+ passTypeIdentifier: string;
53
+ serialNumber: string;
54
+ authorization?: string;
55
+ ifModifiedSince?: string;
56
+ }
57
+ /** Request data for the log endpoint. */
58
+ export interface AppleLogRequest {
59
+ logs: string[];
60
+ }
61
+ /** Options for `createApplePassHandlers`. */
62
+ export interface ApplePassHandlersConfig {
63
+ /** The authentication token configured in pass.json. */
64
+ authenticationToken: string;
65
+ /** Store adapter with async callbacks for DB operations. */
66
+ store: ApplePassStore;
67
+ /**
68
+ * Build a signed `.pkpass` buffer from the pass data returned by
69
+ * `store.getPassData`. This is where you call your template logic.
70
+ */
71
+ buildPass(passData: Record<string, unknown>): Promise<Buffer>;
72
+ /** Optional log callback. */
73
+ onLog?(logs: string[]): void | Promise<void>;
74
+ }
75
+ /** Async callbacks for Apple Order database operations. */
76
+ export interface AppleOrderStore {
77
+ /** Look up an order by identifier. Return null if not found. */
78
+ getOrder(orderIdentifier: string): Promise<{
79
+ updatedAt: Date;
80
+ } | null>;
81
+ /**
82
+ * Register a device to receive push updates for an order.
83
+ * Return `"created"` for new registrations or `"already_registered"` if the
84
+ * device was already registered for this order.
85
+ */
86
+ registerDevice(deviceIdentifier: string, pushToken: string, orderIdentifier: string): Promise<"created" | "already_registered">;
87
+ /** Unregister a device from an order. */
88
+ unregisterDevice(deviceIdentifier: string, orderIdentifier: string): Promise<void>;
89
+ /**
90
+ * Return all orders registered to a device, optionally filtered by
91
+ * modification date.
92
+ */
93
+ getRegistrations(orderTypeIdentifier: string, deviceIdentifier: string, modifiedSince?: string): Promise<{
94
+ orderIdentifier: string;
95
+ updatedAt: Date;
96
+ }[]>;
97
+ }
98
+ /** Request data for order device registration / unregistration. */
99
+ export interface AppleOrderDeviceRequest {
100
+ deviceIdentifier: string;
101
+ orderTypeIdentifier: string;
102
+ orderIdentifier: string;
103
+ authorization?: string;
104
+ pushToken?: string;
105
+ }
106
+ /** Request data for fetching order identifiers. */
107
+ export interface AppleOrderIdentifiersRequest {
108
+ deviceIdentifier: string;
109
+ orderTypeIdentifier: string;
110
+ ordersModifiedSince?: string;
111
+ }
112
+ /** Request data for fetching the latest order. */
113
+ export interface AppleOrderLatestRequest {
114
+ orderTypeIdentifier: string;
115
+ orderIdentifier: string;
116
+ authorization?: string;
117
+ ifModifiedSince?: string;
118
+ }
119
+ /** Options for `createAppleOrderHandlers`. */
120
+ export interface AppleOrderHandlersConfig {
121
+ /** The authentication token configured for orders. */
122
+ authenticationToken: string;
123
+ /** Store adapter with async callbacks for DB operations. */
124
+ store: AppleOrderStore;
125
+ /**
126
+ * Build a signed `.order` buffer for the given order identifier.
127
+ * This is where you call your order generation logic.
128
+ */
129
+ buildOrder(orderIdentifier: string): Promise<Buffer>;
130
+ /** Optional log callback. */
131
+ onLog?(logs: string[]): void | Promise<void>;
132
+ }
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAID,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAElE;;;;OAIG;IACH,cAAc,CACZ,uBAAuB,EAAE,MAAM,EAC/B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAA;IAE5C,uCAAuC;IACvC,gBAAgB,CACd,uBAAuB,EAAE,MAAM,EAC/B,YAAY,EAAE,MAAM,GACnB,OAAO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E,MAAM,CAAA;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,8CAA8C;AAC9C,MAAM,WAAW,wBAAwB;IACvC,sDAAsD;IACtD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,4DAA4D;IAC5D,KAAK,EAAE,eAAe,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACpD,6BAA6B;IAC7B,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export { translateOrderStatus } from "./common/types.js";
6
6
  export type { OrderStatus, CouponPassData, OrderData } from "./common/types.js";
7
7
  export type { OrderInstance, Merchant, Payment, MoneyAmount, SummaryItem, LineItem, Fulfillment, AppleCouponPassOptions, AppleOrderOptions, ApplePushOptions, } from "./apple/types.js";
8
8
  export type { GoogleReviewStatus, GoogleObjectState, GoogleClassType, GoogleObjectType, GoogleSaveType, GoogleOfferClassOptions, GoogleOfferObjectOptions, GoogleOrderClassOptions, GoogleOrderObjectOptions, } from "./google/types.js";
9
+ export { createApplePassHandlers, createAppleOrderHandlers } from "./handlers/index.js";
10
+ export type { HandlerResponse, ApplePassStore, ApplePassDeviceRequest, ApplePassSerialNumbersRequest, ApplePassLatestRequest, ApplePassHandlersConfig, AppleOrderStore, AppleOrderDeviceRequest, AppleOrderIdentifiersRequest, AppleOrderLatestRequest, AppleOrderHandlersConfig, AppleLogRequest, } from "./handlers/index.js";
9
11
  import type { ApplePassConfig, AppleOrderConfig, GoogleClientConfig } from "./common/config.js";
10
12
  /**
11
13
  * Create a configured Apple Wallet client with convenience methods.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAG/E,YAAY,EACV,aAAa,EACb,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AAGzB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,E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kB;;;;;;;;;;;;IAO/D,8CAA8C;yBAEtC,OAAO,mBAAmB,EAAE,cAAc,gBAClC,MAAM,eACP,MAAM;CAGxB,CAAA"}
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ export { loadClient, getClass, createClass, updateClass, updateObject, getSigned
6
6
  export { applePassConfigSchema, appleOrderConfigSchema, appleClientConfigSchema, googleClientConfigSchema, } from "./common/config.js";
7
7
  // ── Common Types ────────────────────────────────────────────────────────
8
8
  export { translateOrderStatus } from "./common/types.js";
9
+ // ── Handlers ─────────────────────────────────────────────────────────────
10
+ export { createApplePassHandlers, createAppleOrderHandlers } from "./handlers/index.js";
9
11
  // ── Factory helpers ─────────────────────────────────────────────────────
10
12
  import { applePassConfigSchema, appleOrderConfigSchema, googleClientConfigSchema } from "./common/config.js";
11
13
  import { loadPassTemplate as _loadPassTemplate } from "./apple/pass.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAEzB,2EAA2E;AAC3E,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAE1B,2EAA2E;AAC3E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,oBAAoB,CAAA;AAQ3B,2EAA2E;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AA8BxD,2E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AAI;gBAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;YACvD,OAAO,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE;gBAClC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,IAAI,CAAC,WAAW;aAC7B,CAAC,CAAA;QACJ,CAAC;QACD,UAAU;QACV,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAA0B,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAElC,OAAO;QACL,MAAM;QACN,MAAM,EAAE,MAAM;QACd,8CAA8C;QAC9C,YAAY,EAAE,CACZ,IAAgD,EAChD,YAAoB,EACpB,WAAmB,EACnB,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,CAAC;KAC5D,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "passkit-wallet",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Apple Wallet + Google Wallet pass generation made easy",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/dmvvilela/passkit-wallet.git"
9
+ },
10
+ "homepage": "https://github.com/dmvvilela/passkit-wallet#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/dmvvilela/passkit-wallet/issues"
13
+ },
6
14
  "type": "module",
7
15
  "main": "./dist/index.js",
8
16
  "types": "./dist/index.d.ts",
@@ -19,6 +27,10 @@
19
27
  "types": "./dist/google/index.d.ts",
20
28
  "import": "./dist/google/index.js"
21
29
  },
30
+ "./handlers": {
31
+ "types": "./dist/handlers/index.d.ts",
32
+ "import": "./dist/handlers/index.js"
33
+ },
22
34
  "./react": {
23
35
  "types": "./dist/react/index.d.ts",
24
36
  "import": "./dist/react/index.js"