@arcote.tech/arc-host 0.3.0 → 0.3.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/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -3737
- package/dist/index.js.map +6 -8
- package/dist/src/arc-host.d.ts +6 -0
- package/dist/src/arc-host.d.ts.map +1 -1
- package/dist/src/context-handler.d.ts.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/index.ts +0 -3
- package/package.json +2 -2
- package/src/arc-host.ts +177 -6
- package/src/context-handler.ts +11 -1
- package/src/index.ts +0 -3
- package/dist/sqliteAdapter.d.ts +0 -3
- package/dist/sqliteAdapter.d.ts.map +0 -1
- package/sqliteAdapter.ts +0 -7
package/dist/src/arc-host.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class ArcHost {
|
|
|
51
51
|
private handleHttpCommand;
|
|
52
52
|
/**
|
|
53
53
|
* Handle HTTP query request
|
|
54
|
+
* Uses view.queryContext() to apply protections consistently with liveQuery
|
|
54
55
|
*/
|
|
55
56
|
private handleHttpQuery;
|
|
56
57
|
/**
|
|
@@ -61,6 +62,11 @@ export declare class ArcHost {
|
|
|
61
62
|
* Handle HTTP event sync request
|
|
62
63
|
*/
|
|
63
64
|
private handleHttpEventSync;
|
|
65
|
+
/**
|
|
66
|
+
* Handle HTTP route request
|
|
67
|
+
* Matches path against registered routes and executes handler
|
|
68
|
+
*/
|
|
69
|
+
private handleHttpRoute;
|
|
64
70
|
/**
|
|
65
71
|
* Stop the server
|
|
66
72
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arc-host.d.ts","sourceRoot":"","sources":["../../src/arc-host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arc-host.d.ts","sourceRoot":"","sources":["../../src/arc-host.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aA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bf;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,GAAG,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,EACF,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,GAAG,IAAI,GACzB,OAAO,CAAC,aAAa,EAAE,CAAC;IA2C3B;;OAEG;IACG,cAAc,CAClB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,KAAK,EAAE,YAAY,GAAG,IAAI,GACzB,OAAO,CAAC,aAAa,EAAE,CAAC;IA8C3B;;OAEG;IACH,QAAQ,IAAI,KAAK,CAAC,aAAa,CAAC;IAIhC;;OAEG;IACH,cAAc,IAAI,iBAAiB;IAInC;;OAEG;IACH,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAI/C;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;CAG5C"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export { ConnectionManager } from "./connection-manager";
|
|
|
3
3
|
export { ContextHandler } from "./context-handler";
|
|
4
4
|
export type { ArcHostConfig, ClientToHostMessage, ConnectedClient, HostToClientMessage, SyncableEvent, TokenPayload, } from "./types";
|
|
5
5
|
export { canTokenEmitEvent, canTokenReceiveEvent, filterEventsForToken, } from "./event-auth";
|
|
6
|
-
export { sqliteAdapterFactory } from "../sqliteAdapter";
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Re-export everything from src
|
|
2
2
|
export * from "./src";
|
|
3
3
|
|
|
4
|
-
// Legacy export for backwards compatibility
|
|
5
|
-
export { sqliteAdapterFactory } from "./sqliteAdapter";
|
|
6
|
-
|
|
7
4
|
// Helper function to start host
|
|
8
5
|
import type { ArcContextAny, DBAdapterFactory } from "@arcote.tech/arc";
|
|
9
6
|
import { ArcHost } from "./src/arc-host";
|
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.3.
|
|
7
|
+
"version": "0.3.2",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@arcote.tech/arc-adapter-db-sqlite": "
|
|
11
|
+
"@arcote.tech/arc-adapter-db-sqlite": "^0.3.0",
|
|
12
12
|
"jsonwebtoken": "^9.0.2"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
package/src/arc-host.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ArcRouteAny } from "@arcote.tech/arc";
|
|
1
2
|
import { liveQuery } from "@arcote.tech/arc";
|
|
2
3
|
import type { Server, ServerWebSocket } from "bun";
|
|
3
4
|
import jwt from "jsonwebtoken";
|
|
@@ -335,7 +336,13 @@ export class ArcHost {
|
|
|
335
336
|
|
|
336
337
|
// HTTP query endpoint: POST /query/:viewName
|
|
337
338
|
if (url.pathname.startsWith("/query/") && req.method === "POST") {
|
|
338
|
-
return self.handleHttpQuery(
|
|
339
|
+
return self.handleHttpQuery(
|
|
340
|
+
req,
|
|
341
|
+
url,
|
|
342
|
+
tokenPayload,
|
|
343
|
+
corsHeaders,
|
|
344
|
+
token,
|
|
345
|
+
);
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
// SSE stream endpoint: GET /stream/:viewName
|
|
@@ -354,6 +361,17 @@ export class ArcHost {
|
|
|
354
361
|
return self.handleHttpEventSync(req, tokenPayload, corsHeaders);
|
|
355
362
|
}
|
|
356
363
|
|
|
364
|
+
// Route endpoints: /route/*
|
|
365
|
+
if (url.pathname.startsWith("/route/")) {
|
|
366
|
+
return self.handleHttpRoute(
|
|
367
|
+
req,
|
|
368
|
+
url,
|
|
369
|
+
tokenPayload,
|
|
370
|
+
corsHeaders,
|
|
371
|
+
token,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
357
375
|
return new Response("Not Found", { status: 404, headers: corsHeaders });
|
|
358
376
|
},
|
|
359
377
|
|
|
@@ -427,6 +445,10 @@ export class ArcHost {
|
|
|
427
445
|
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
428
446
|
});
|
|
429
447
|
} catch (error) {
|
|
448
|
+
console.error(`[ARC HTTP] Command '${commandName}' error:`, error);
|
|
449
|
+
if (error instanceof Error && error.stack) {
|
|
450
|
+
console.error(`[ARC HTTP] Stack trace:`, error.stack);
|
|
451
|
+
}
|
|
430
452
|
return new Response(JSON.stringify({ error: (error as Error).message }), {
|
|
431
453
|
status: 500,
|
|
432
454
|
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
@@ -436,12 +458,14 @@ export class ArcHost {
|
|
|
436
458
|
|
|
437
459
|
/**
|
|
438
460
|
* Handle HTTP query request
|
|
461
|
+
* Uses view.queryContext() to apply protections consistently with liveQuery
|
|
439
462
|
*/
|
|
440
463
|
private async handleHttpQuery(
|
|
441
464
|
req: Request,
|
|
442
465
|
url: URL,
|
|
443
|
-
|
|
466
|
+
_token: TokenPayload | null,
|
|
444
467
|
corsHeaders: Record<string, string>,
|
|
468
|
+
rawToken: string | null,
|
|
445
469
|
): Promise<Response> {
|
|
446
470
|
const viewName = url.pathname.split("/query/")[1];
|
|
447
471
|
if (!viewName) {
|
|
@@ -453,11 +477,29 @@ export class ArcHost {
|
|
|
453
477
|
|
|
454
478
|
try {
|
|
455
479
|
const params = await req.json();
|
|
456
|
-
const dataStorage = this.contextHandler.getDataStorage();
|
|
457
|
-
const tx = await dataStorage.getReadTransaction();
|
|
458
|
-
const result = await tx.find(viewName, params);
|
|
459
480
|
|
|
460
|
-
//
|
|
481
|
+
// Get view element
|
|
482
|
+
const viewElement = this.contextHandler
|
|
483
|
+
.getModel()
|
|
484
|
+
.context.get(viewName) as any;
|
|
485
|
+
|
|
486
|
+
if (!viewElement || !viewElement.queryContext) {
|
|
487
|
+
return new Response(JSON.stringify({ error: "View not found" }), {
|
|
488
|
+
status: 404,
|
|
489
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Set auth token so view.queryContext() can apply protections
|
|
494
|
+
this.contextHandler.setAuthToken(rawToken);
|
|
495
|
+
|
|
496
|
+
// Use view's queryContext which applies protections automatically
|
|
497
|
+
const model = this.contextHandler.getModel();
|
|
498
|
+
const adapters = model.getAdapters();
|
|
499
|
+
const queryCtx = viewElement.queryContext(adapters);
|
|
500
|
+
|
|
501
|
+
// Execute query through view's queryContext (protections applied)
|
|
502
|
+
const result = await queryCtx.find(params);
|
|
461
503
|
|
|
462
504
|
return new Response(JSON.stringify(result), {
|
|
463
505
|
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
@@ -631,6 +673,135 @@ export class ArcHost {
|
|
|
631
673
|
}
|
|
632
674
|
}
|
|
633
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Handle HTTP route request
|
|
678
|
+
* Matches path against registered routes and executes handler
|
|
679
|
+
*/
|
|
680
|
+
private async handleHttpRoute(
|
|
681
|
+
req: Request,
|
|
682
|
+
url: URL,
|
|
683
|
+
tokenPayload: TokenPayload | null,
|
|
684
|
+
corsHeaders: Record<string, string>,
|
|
685
|
+
rawToken: string | null,
|
|
686
|
+
): Promise<Response> {
|
|
687
|
+
const method = req.method as "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
688
|
+
|
|
689
|
+
// Find matching route in context
|
|
690
|
+
const context = this.contextHandler.getModel().context;
|
|
691
|
+
let matchedRoute: ArcRouteAny | null = null;
|
|
692
|
+
let routeParams: Record<string, string> = {};
|
|
693
|
+
|
|
694
|
+
for (const element of context.elements) {
|
|
695
|
+
// Check if element is a route (has matchesPath method)
|
|
696
|
+
if (element && typeof (element as any).matchesPath === "function") {
|
|
697
|
+
const route = element as ArcRouteAny;
|
|
698
|
+
const match = route.matchesPath(url.pathname);
|
|
699
|
+
if (match.matches) {
|
|
700
|
+
matchedRoute = route;
|
|
701
|
+
routeParams = match.params;
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (!matchedRoute) {
|
|
708
|
+
return new Response(JSON.stringify({ error: "Route not found" }), {
|
|
709
|
+
status: 404,
|
|
710
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// Get handler for this method
|
|
715
|
+
const handler = matchedRoute.getHandler(method);
|
|
716
|
+
if (!handler) {
|
|
717
|
+
return new Response(
|
|
718
|
+
JSON.stringify({ error: `Method ${method} not allowed` }),
|
|
719
|
+
{
|
|
720
|
+
status: 405,
|
|
721
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
722
|
+
},
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Check protection
|
|
727
|
+
if (!matchedRoute.isPublic && matchedRoute.hasProtections) {
|
|
728
|
+
if (!tokenPayload) {
|
|
729
|
+
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
|
730
|
+
status: 401,
|
|
731
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// Set auth token for protection check
|
|
736
|
+
this.contextHandler.setAuthToken(rawToken);
|
|
737
|
+
|
|
738
|
+
// Check if token type matches any protection
|
|
739
|
+
let isAuthorized = false;
|
|
740
|
+
for (const protection of matchedRoute.protections) {
|
|
741
|
+
if (protection.token.name === tokenPayload.tokenType) {
|
|
742
|
+
// Create a mock token instance for the check
|
|
743
|
+
const mockTokenInstance = {
|
|
744
|
+
params: tokenPayload.params,
|
|
745
|
+
getTokenDefinition: () => protection.token,
|
|
746
|
+
};
|
|
747
|
+
const allowed = await protection.check(mockTokenInstance as any);
|
|
748
|
+
if (allowed) {
|
|
749
|
+
isAuthorized = true;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (!isAuthorized) {
|
|
756
|
+
return new Response(JSON.stringify({ error: "Forbidden" }), {
|
|
757
|
+
status: 403,
|
|
758
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
} else if (!matchedRoute.isPublic && !matchedRoute.hasProtections) {
|
|
762
|
+
// Route is not public and has no protections - require any valid token
|
|
763
|
+
if (!tokenPayload) {
|
|
764
|
+
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
|
765
|
+
status: 401,
|
|
766
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Build route context
|
|
772
|
+
this.contextHandler.setAuthToken(rawToken);
|
|
773
|
+
const model = this.contextHandler.getModel();
|
|
774
|
+
const adapters = model.getAdapters();
|
|
775
|
+
|
|
776
|
+
const authParams = tokenPayload
|
|
777
|
+
? { params: tokenPayload.params, tokenName: tokenPayload.tokenType }
|
|
778
|
+
: undefined;
|
|
779
|
+
|
|
780
|
+
const routeContext = matchedRoute.buildContext(adapters, authParams);
|
|
781
|
+
|
|
782
|
+
try {
|
|
783
|
+
// Execute handler
|
|
784
|
+
const response = await handler(routeContext, req, routeParams, url);
|
|
785
|
+
|
|
786
|
+
// Add CORS headers to response
|
|
787
|
+
const newHeaders = new Headers(response.headers);
|
|
788
|
+
for (const [key, value] of Object.entries(corsHeaders)) {
|
|
789
|
+
newHeaders.set(key, value);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return new Response(response.body, {
|
|
793
|
+
status: response.status,
|
|
794
|
+
statusText: response.statusText,
|
|
795
|
+
headers: newHeaders,
|
|
796
|
+
});
|
|
797
|
+
} catch (error) {
|
|
798
|
+
return new Response(JSON.stringify({ error: (error as Error).message }), {
|
|
799
|
+
status: 500,
|
|
800
|
+
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
634
805
|
/**
|
|
635
806
|
* Stop the server
|
|
636
807
|
*/
|
package/src/context-handler.ts
CHANGED
|
@@ -78,7 +78,17 @@ export class ContextHandler {
|
|
|
78
78
|
|
|
79
79
|
// TODO: Check command protection with token
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
try {
|
|
82
|
+
return await command(params);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(`[ARC] Command '${commandName}' failed:`);
|
|
85
|
+
console.error(`[ARC] Params:`, JSON.stringify(params, null, 2));
|
|
86
|
+
console.error(`[ARC] Error:`, error);
|
|
87
|
+
if (error instanceof Error) {
|
|
88
|
+
console.error(`[ARC] Stack:`, error.stack);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
/**
|
package/src/index.ts
CHANGED
package/dist/sqliteAdapter.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqliteAdapter.d.ts","sourceRoot":"","sources":["../sqliteAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,gBAErD,CAAC"}
|
package/sqliteAdapter.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DBAdapterFactory } from "@arcote.tech/arc";
|
|
2
|
-
// @ts-ignore - external package without types
|
|
3
|
-
import { createBunSQLiteAdapterFactory } from "@arcote.tech/arc-adapter-db-sqlite";
|
|
4
|
-
|
|
5
|
-
export const sqliteAdapterFactory = (dbName: string): DBAdapterFactory => {
|
|
6
|
-
return createBunSQLiteAdapterFactory(dbName);
|
|
7
|
-
};
|