stellarium-ts 0.8.0 → 0.10.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.
|
@@ -42,7 +42,12 @@ export declare class CombinationResourceInvoker implements ResourceInvoker {
|
|
|
42
42
|
* @param parameters - The parameters to pass to the function
|
|
43
43
|
* @returns The return value of the function
|
|
44
44
|
*/
|
|
45
|
-
invoke(resource: Resource, functionName: string, parameters: ResourceFunctionCallParameter[]): Promise<
|
|
45
|
+
invoke(resource: Resource, functionName: string, parameters: ResourceFunctionCallParameter[]): Promise<{
|
|
46
|
+
value: any;
|
|
47
|
+
error: {
|
|
48
|
+
message: string;
|
|
49
|
+
} | null;
|
|
50
|
+
}>;
|
|
46
51
|
createPaymentVoucher(recipientAddress: string, amount: number, resourcePath: string, resourceName: string, parameters: ResourceFunctionCallParameter[]): PaymentVoucher;
|
|
47
52
|
}
|
|
48
53
|
//# sourceMappingURL=invoker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/resource/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/resource/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,EAC1C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,6BAA6B,EAAE;;;;;;;;;;EAI9C;AAED,qBAAa,0BAA2B,YAAW,eAAe;IAElD,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAAsB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAU,OAAO,CAAC,QAAQ,CAAC,UAAU;IAAhL,YAA6B,kBAAkB,EAAE,kBAAkB,EAAmB,iBAAiB,EAAE,MAAM,EAAmB,SAAS,EAAE,MAAM,EAAmB,UAAU,EAAE,MAAM,EAAI;IAC5L;;;;;;;;;;OAUG;IACG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAA;KAAC,CAAC,CAmD7J;IAED,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,6BAA6B,EAAE,GAAG,cAAc,CAOtK;CACJ"}
|
package/dist/resource/invoker.js
CHANGED
|
@@ -63,17 +63,18 @@ export class CombinationResourceInvoker {
|
|
|
63
63
|
},
|
|
64
64
|
});
|
|
65
65
|
if (!result.ok) {
|
|
66
|
-
|
|
66
|
+
return { value: null, error: { message: `Failed to invoke ${resource.name}.${functionName}: ${result.statusText}` } };
|
|
67
67
|
}
|
|
68
68
|
const data = await result.json();
|
|
69
|
-
return data.
|
|
69
|
+
return { value: data.value, error: data.error };
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
72
|
const fn = resource.functions.find(f => f.name === functionName);
|
|
73
73
|
if (!fn) {
|
|
74
|
-
|
|
74
|
+
return { value: null, error: { message: `Function ${functionName} not found in resource ${resource.name}` } };
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
const result = await fn.exec(parameters);
|
|
77
|
+
return { value: result, error: null };
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
createPaymentVoucher(recipientAddress, amount, resourcePath, resourceName, parameters) {
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAKlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,UAAU,YAAY;IAClB,OAAO,EAAE,OAAO,CAAC;CACpB;AA+BD;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,kBAAkB,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAKlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,UAAU,YAAY;IAClB,OAAO,EAAE,OAAO,CAAC;CACpB;AA+BD;;;;GAIG;AACH,QAAA,MAAM,MAAM,EAAE,kBAAkB,CAAC,YAAY,CAmJ5C,CAAC;eAGa,MAAM"}
|
package/dist/routes.js
CHANGED
|
@@ -88,6 +88,15 @@ const routes = async (fastify, options) => {
|
|
|
88
88
|
fastify.post('/run/resource', async (request, reply) => {
|
|
89
89
|
const resourceRequest = request.body;
|
|
90
90
|
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
|
+
}
|
|
91
100
|
if (paymentVoucher) {
|
|
92
101
|
const isValid = verifyData(paymentVoucherPayload(paymentVoucher, resourceRequest.resourcePath, resourceRequest.resourceName, resourceRequest.parameters), paymentVoucher.publicKey, paymentVoucher.signature);
|
|
93
102
|
if (!isValid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stellarium-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A Stellarium Node in TypeScript.",
|
|
5
5
|
"homepage": "https://github.com/qualletio/stellarium-ts#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"dotenv": "^18.0.5",
|
|
46
46
|
"fastify": "^5.12.5",
|
|
47
|
-
"requestscript": "
|
|
47
|
+
"requestscript": "1.1.0",
|
|
48
48
|
"sqlite": "^5.1.1",
|
|
49
49
|
"sqlite3": "^6.0.1"
|
|
50
50
|
},
|