stellarium-ts 0.10.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/routes.js +9 -9
  2. package/package.json +1 -1
package/dist/routes.js CHANGED
@@ -69,6 +69,15 @@ const routes = async (fastify, options) => {
69
69
  // Start Run Routes
70
70
  fastify.post('/run', async (request, reply) => {
71
71
  const runRequest = request.body;
72
+ // Check that the API Key matches the env variable
73
+ const authorizationHeader = request.headers['authorization'];
74
+ if (!authorizationHeader) {
75
+ return reply.status(401).send({ error: 'Authorization header is required' });
76
+ }
77
+ const apiKey = authorizationHeader.split(' ')[1];
78
+ if (apiKey !== process.env.API_KEY) {
79
+ return reply.status(401).send({ error: 'Invalid API Key' });
80
+ }
72
81
  try {
73
82
  const script = parseScript(runRequest.source);
74
83
  if (script.declaration.kind !== 'request') {
@@ -88,15 +97,6 @@ const routes = async (fastify, options) => {
88
97
  fastify.post('/run/resource', async (request, reply) => {
89
98
  const resourceRequest = request.body;
90
99
  const paymentVoucher = resourceRequest.paymentVoucher;
91
- // Check that the API Key matches the env variable
92
- const authorizationHeader = request.headers['authorization'];
93
- if (!authorizationHeader) {
94
- return reply.status(401).send({ error: 'Authorization header is required' });
95
- }
96
- const apiKey = authorizationHeader.split(' ')[1];
97
- if (apiKey !== process.env.API_KEY) {
98
- return reply.status(401).send({ error: 'Invalid API Key' });
99
- }
100
100
  if (paymentVoucher) {
101
101
  const isValid = verifyData(paymentVoucherPayload(paymentVoucher, resourceRequest.resourcePath, resourceRequest.resourceName, resourceRequest.parameters), paymentVoucher.publicKey, paymentVoucher.signature);
102
102
  if (!isValid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellarium-ts",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "A Stellarium Node in TypeScript.",
5
5
  "homepage": "https://github.com/qualletio/stellarium-ts#readme",
6
6
  "bugs": {