@unchainedshop/ticketing 4.8.11 → 5.0.0-alpha.2
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/lib/express.d.ts +2 -2
- package/lib/express.js +25 -14
- package/lib/fastify.d.ts +1 -1
- package/lib/fastify.js +40 -24
- package/lib/index.d.ts +6 -2
- package/lib/routes.js +2 -2
- package/lib/services.js +3 -1
- package/package.json +11 -10
package/lib/express.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: (app:
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
declare const _default: (app: Express) => void;
|
|
3
3
|
export default _default;
|
package/lib/express.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import googleWalletHandler from "./mobile-tickets/google-handler-express.js";
|
|
4
|
-
import printTicketsHandler from "./pdf-tickets/print-handler-express.js";
|
|
1
|
+
import { createServerAdapter } from '@whatwg-node/server';
|
|
2
|
+
import { ticketingRoutes } from "./routes.js";
|
|
5
3
|
export default (app) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
for (const route of ticketingRoutes) {
|
|
5
|
+
const adapter = createServerAdapter(async (request, serverContext) => {
|
|
6
|
+
const context = {
|
|
7
|
+
...serverContext.unchainedContext,
|
|
8
|
+
params: serverContext.params || {},
|
|
9
|
+
};
|
|
10
|
+
return await route.handler(request, context);
|
|
11
|
+
});
|
|
12
|
+
const expressPath = route.path.replace(/\/\*$/, '/*');
|
|
13
|
+
app.use(expressPath, async (req, res) => {
|
|
14
|
+
try {
|
|
15
|
+
await adapter.handleNodeRequestAndResponse(req, res, {
|
|
16
|
+
unchainedContext: req.unchainedContext,
|
|
17
|
+
params: req.params,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
if (!res.headersSent) {
|
|
22
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
16
27
|
};
|
package/lib/fastify.d.ts
CHANGED
package/lib/fastify.js
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { createServerAdapter } from '@whatwg-node/server';
|
|
2
|
+
import { ticketingRoutes } from "./routes.js";
|
|
3
|
+
export default (fastify) => {
|
|
4
|
+
if (ticketingRoutes.length === 0)
|
|
5
|
+
return;
|
|
6
|
+
fastify.register((scope, opts, registered) => {
|
|
7
|
+
scope.removeAllContentTypeParsers();
|
|
8
|
+
scope.addContentTypeParser('*', function (request, payload, done) {
|
|
9
|
+
done(null);
|
|
10
|
+
});
|
|
11
|
+
for (const route of ticketingRoutes) {
|
|
12
|
+
const adapter = createServerAdapter(async (request, serverContext) => {
|
|
13
|
+
const context = {
|
|
14
|
+
...serverContext.unchainedContext,
|
|
15
|
+
params: serverContext.params || {},
|
|
16
|
+
};
|
|
17
|
+
return await route.handler(request, context);
|
|
18
|
+
});
|
|
19
|
+
const fastifyPath = route.path.replace(/\/\*$/, '/*');
|
|
20
|
+
scope.all(fastifyPath, async (req, reply) => {
|
|
21
|
+
try {
|
|
22
|
+
const response = await adapter.handleNodeRequestAndResponse(req.raw, reply.raw, {
|
|
23
|
+
unchainedContext: req.unchainedContext,
|
|
24
|
+
params: req.params,
|
|
25
|
+
});
|
|
26
|
+
response.headers.forEach((value, key) => {
|
|
27
|
+
reply.header(key, value);
|
|
28
|
+
});
|
|
29
|
+
reply.status(response.status);
|
|
30
|
+
reply.send(response.body || undefined);
|
|
31
|
+
return reply;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
if (!reply.sent) {
|
|
35
|
+
reply.status(500).send({ error: 'Internal Server Error' });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
registered();
|
|
25
41
|
});
|
|
26
42
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import type { UnchainedCore } from '@unchainedshop/core';
|
|
1
2
|
import { RendererTypes } from './template-registry.ts';
|
|
2
3
|
import ticketingModules, { type TicketingModule } from './module.ts';
|
|
3
|
-
import type { TicketingAPI } from './types.ts';
|
|
4
4
|
import ticketingServices, { type TicketingServices } from './services.ts';
|
|
5
|
-
export type
|
|
5
|
+
export type TicketingAPI = UnchainedCore & {
|
|
6
|
+
modules: TicketingModule;
|
|
7
|
+
services: TicketingServices;
|
|
8
|
+
};
|
|
9
|
+
export type { RendererTypes, TicketingModule, TicketingServices };
|
|
6
10
|
export { ticketingServices, ticketingModules };
|
|
7
11
|
export declare function setupPDFTickets({ renderOrderPDF }: {
|
|
8
12
|
renderOrderPDF: any;
|
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.
|
|
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.
|
|
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/lib/services.js
CHANGED
|
@@ -7,7 +7,9 @@ async function cancelTicketsForProduct(productId) {
|
|
|
7
7
|
await this.warehousing.invalidateToken(token._id);
|
|
8
8
|
await this.passes.cancelTicket(token._id);
|
|
9
9
|
}
|
|
10
|
-
await this.products.update(productId, {
|
|
10
|
+
await this.products.update(productId, {
|
|
11
|
+
$set: { 'meta.cancelled': true },
|
|
12
|
+
});
|
|
11
13
|
return tokensToCancel.length;
|
|
12
14
|
}
|
|
13
15
|
export default {
|
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": "
|
|
4
|
+
"version": "5.0.0-alpha.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@unchainedshop/api": "^
|
|
38
|
-
"@unchainedshop/core": "^
|
|
39
|
-
"@unchainedshop/core-files": "^
|
|
40
|
-
"@unchainedshop/core-warehousing": "^
|
|
41
|
-
"@unchainedshop/core-worker": "^
|
|
42
|
-
"@unchainedshop/events": "^
|
|
43
|
-
"@unchainedshop/logger": "^
|
|
44
|
-
"@unchainedshop/mongodb": "^
|
|
37
|
+
"@unchainedshop/api": "^5.0.0-alpha.1",
|
|
38
|
+
"@unchainedshop/core": "^5.0.0-alpha.1",
|
|
39
|
+
"@unchainedshop/core-files": "^5.0.0-alpha.1",
|
|
40
|
+
"@unchainedshop/core-warehousing": "^5.0.0-alpha.1",
|
|
41
|
+
"@unchainedshop/core-worker": "^5.0.0-alpha.1",
|
|
42
|
+
"@unchainedshop/events": "^5.0.0-alpha.1",
|
|
43
|
+
"@unchainedshop/logger": "^5.0.0-alpha.1",
|
|
44
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@parse/node-apn": "^
|
|
47
|
+
"@parse/node-apn": "^8.1.0",
|
|
48
48
|
"express": "5.x",
|
|
49
49
|
"fastify": ">= 5.2 < 6"
|
|
50
50
|
},
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
+
"@parse/node-apn": "^8.1.0",
|
|
63
64
|
"@types/express": "^5.0.3",
|
|
64
65
|
"@types/node": "^25.0.0",
|
|
65
66
|
"express": "^5.1.0",
|