@unchainedshop/ticketing 5.0.0-alpha.1 → 5.0.0-alpha.3

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.
@@ -25,7 +25,7 @@ const appleWalletHandler = async (req, res) => {
25
25
  return;
26
26
  }
27
27
  const { hash } = req.query;
28
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
28
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
29
29
  if (!hash || hash !== correctHash) {
30
30
  res.status(403).send('Token hash invalid for current owner');
31
31
  return;
@@ -8,7 +8,7 @@ const isAuthenticationTokenCorrect = (req, authenticationToken) => {
8
8
  const appleWalletHandler = async (req, reply) => {
9
9
  const resolvedContext = req.unchainedContext;
10
10
  const { modules } = resolvedContext;
11
- const path = req.url;
11
+ const path = '/' + (req.params['*'] || '').split('?')[0];
12
12
  logger.info(`${path} (${JSON.stringify(req.query)})`);
13
13
  if (path.startsWith('/download/')) {
14
14
  try {
@@ -27,7 +27,7 @@ const appleWalletHandler = async (req, reply) => {
27
27
  return reply.send();
28
28
  }
29
29
  const { hash } = req.query;
30
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
30
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
31
31
  if (!hash || hash !== correctHash) {
32
32
  logger.error('Token hash invalid for current owner', { tokenId });
33
33
  reply.status(403);
@@ -1,6 +1,5 @@
1
- import apn from '@parse/node-apn';
2
1
  import { Readable } from 'node:stream';
3
- export declare const pushToApplePushNotificationService: (deviceTokens: any) => Promise<apn.Responses<apn.ResponseSent, apn.ResponseFailure>>;
2
+ export declare const pushToApplePushNotificationService: (deviceTokens: any) => Promise<any>;
4
3
  export declare const buildPassBinary: (tokenSerialNumber: string, pass: {
5
4
  serialNumber: string;
6
5
  asBuffer: () => Promise<Buffer>;
@@ -1,6 +1,24 @@
1
- import apn from '@parse/node-apn';
2
1
  import { Readable } from 'node:stream';
2
+ import { createLogger } from '@unchainedshop/logger';
3
+ const logger = createLogger('unchained:apple-wallet-webservice');
4
+ let apn;
5
+ try {
6
+ const module = await import('@parse/node-apn');
7
+ apn = module.default;
8
+ }
9
+ catch (error) {
10
+ if (error?.code === 'ERR_MODULE_NOT_FOUND' &&
11
+ String(error?.message).includes('@parse/node-apn')) {
12
+ logger.warn(`optional peer npm package '@parse/node-apn' not installed, apple wallet pass update notifications will not work`);
13
+ }
14
+ else {
15
+ logger.error(`failed to load '@parse/node-apn'`, error);
16
+ }
17
+ }
3
18
  export const pushToApplePushNotificationService = async (deviceTokens) => {
19
+ if (!apn) {
20
+ throw new Error("npm dependency '@parse/node-apn' is not installed, please install it to push pass updates");
21
+ }
4
22
  const apnProvider = new apn.Provider({
5
23
  cert: process.env.PASS_CERTIFICATE_PATH,
6
24
  key: process.env.PASS_CERTIFICATE_PATH,
@@ -19,7 +19,7 @@ export const googleWalletHandler = async (req, res) => {
19
19
  res.status(404).send('Token not found');
20
20
  return;
21
21
  }
22
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
22
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
23
23
  if (!hash || hash !== correctHash) {
24
24
  res.status(403).send('Token hash invalid for current owner');
25
25
  return;
@@ -21,7 +21,7 @@ const googleWalletHandler = async (req, reply) => {
21
21
  reply.status(404);
22
22
  return reply.send('Token not found');
23
23
  }
24
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
24
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
25
25
  if (!hash || hash !== correctHash) {
26
26
  logger.error('Token hash invalid for current owner', { tokenId });
27
27
  reply.status(403);
package/lib/module.js CHANGED
@@ -9,9 +9,6 @@ const logger = createLogger('unchained:apple-wallet-webservice');
9
9
  const configurePasses = async ({ db }) => {
10
10
  const MediaObjects = await MediaObjectsCollection(db);
11
11
  const TokenSurrogates = await TokenSurrogateCollection(db);
12
- await buildDbIndexes(TokenSurrogates, [
13
- { index: { 'meta.cancelled': 1 }, options: { sparse: true } },
14
- ]);
15
12
  await buildDbIndexes(MediaObjects, [
16
13
  { index: { path: 1, 'meta.passTypeIdentifier': 1, 'meta.serialNumber': 1 } },
17
14
  {
package/lib/routes.js CHANGED
@@ -54,7 +54,7 @@ export async function googleWalletHandler(request, context) {
54
54
  }
55
55
  const url = new URL(request.url);
56
56
  const hash = url.searchParams.get('hash');
57
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
57
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
58
58
  if (!hash || hash !== correctHash) {
59
59
  return new Response(JSON.stringify({ error: 'Token hash invalid for current owner' }), {
60
60
  status: 403,
@@ -96,7 +96,7 @@ export async function appleWalletHandler(request, context) {
96
96
  });
97
97
  }
98
98
  const hash = url.searchParams.get('hash');
99
- const correctHash = await modules.warehousing.buildAccessKeyForToken(tokenId);
99
+ const correctHash = await modules.warehousing.buildAccessKeyFromToken(token);
100
100
  if (!hash || hash !== correctHash) {
101
101
  return new Response(JSON.stringify({ error: 'Token hash invalid for current owner' }), {
102
102
  status: 403,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/ticketing",
3
3
  "description": "Event ticketing extension for the Unchained Engine with PDF and wallet pass support",
4
- "version": "5.0.0-alpha.1",
4
+ "version": "5.0.0-alpha.3",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "type": "module",
@@ -44,13 +44,13 @@
44
44
  "@unchainedshop/mongodb": "^5.0.0-alpha.1"
45
45
  },
46
46
  "peerDependencies": {
47
- "@parse/node-apn": "^7.0.1",
47
+ "@parse/node-apn": "^8.1.0",
48
48
  "express": "5.x",
49
49
  "fastify": ">= 5.2 < 6"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@parse/node-apn": {
53
- "optional": false
53
+ "optional": true
54
54
  },
55
55
  "express": {
56
56
  "optional": true
@@ -60,8 +60,9 @@
60
60
  }
61
61
  },
62
62
  "devDependencies": {
63
+ "@parse/node-apn": "^8.1.0",
63
64
  "@types/express": "^5.0.3",
64
- "@types/node": "^25.0.0",
65
+ "@types/node": "^26.2.0",
65
66
  "express": "^5.1.0",
66
67
  "fastify": "^5.4.0",
67
68
  "typescript": "^5.8.3"