@c9up/ream 0.1.17 → 0.1.18
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/rpc/RpcProvider.d.ts +8 -0
- package/dist/rpc/RpcProvider.d.ts.map +1 -1
- package/dist/rpc/RpcProvider.js +9 -2
- package/dist/rpc/RpcProvider.js.map +1 -1
- package/events.win32-x64-msvc.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/rpc/RpcProvider.ts +16 -2
|
@@ -24,6 +24,14 @@ export interface RpcProviderOptions {
|
|
|
24
24
|
export interface RpcConfig {
|
|
25
25
|
/** HTTP path the JSON-RPC endpoint is mounted at. Default `/rpc`. */
|
|
26
26
|
path?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Guards applied to the `/rpc` route itself (e.g. `['jwt']`), so warden
|
|
29
|
+
* authenticates the endpoint at the edge and populates `ctx.auth` for every
|
|
30
|
+
* call — which per-method `.guard()` / `authorizeRpc()` then read. Without
|
|
31
|
+
* this, the inline-mounted route carries no guard metadata, so warden treats
|
|
32
|
+
* it as public and never populates `ctx.auth` (every guarded method 401s).
|
|
33
|
+
*/
|
|
34
|
+
guards?: string[];
|
|
27
35
|
}
|
|
28
36
|
export declare class RpcProvider extends Provider {
|
|
29
37
|
readonly rpc: RpcRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProvider.d.ts","sourceRoot":"","sources":["../../src/rpc/RpcProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"RpcProvider.d.ts","sourceRoot":"","sources":["../../src/rpc/RpcProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,qBAAa,WAAY,SAAQ,QAAQ;IACvC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAA;gBAEX,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,kBAAuB;IAKpD,QAAQ,IAAI,IAAI;IAgBV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAarC;AAMD,eAAe,WAAW,CAAA"}
|
package/dist/rpc/RpcProvider.js
CHANGED
|
@@ -36,11 +36,18 @@ export class RpcProvider extends Provider {
|
|
|
36
36
|
container.singleton('rpc', () => this.rpc);
|
|
37
37
|
}
|
|
38
38
|
async boot() {
|
|
39
|
-
const
|
|
39
|
+
const config = this.app.config.get('rpc');
|
|
40
|
+
const path = config?.path ?? '/rpc';
|
|
40
41
|
const router = this.app.container.make('router');
|
|
41
42
|
// RpcRouter.handle() reads the registered methods at request time, so the
|
|
42
43
|
// mount can happen before apps finish registering methods.
|
|
43
|
-
router.post(path, (ctx) => this.rpc.handle(ctx));
|
|
44
|
+
const route = router.post(path, (ctx) => this.rpc.handle(ctx));
|
|
45
|
+
// Apply route-level guards (e.g. ['jwt']) so warden authenticates the
|
|
46
|
+
// endpoint at the edge and populates ctx.auth — the inline route has no
|
|
47
|
+
// decorator metadata otherwise.
|
|
48
|
+
const guards = config?.guards ?? [];
|
|
49
|
+
if (guards.length > 0)
|
|
50
|
+
route.guard(...guards);
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
// Also expose as the default export so reamrc's provider loader can do
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProvider.js","sourceRoot":"","sources":["../../src/rpc/RpcProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"RpcProvider.js","sourceRoot":"","sources":["../../src/rpc/RpcProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAoB1C,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAC9B,GAAG,CAAW;IAEvB,YAAY,GAAe,EAAE,UAA8B,EAAE;QAC3D,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,SAAS,EAAE,CAAA;IAC9C,CAAC;IAEQ,QAAQ;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAA;QACpC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,GAAG;gBAAE,OAAM,CAAC,4BAA4B;YAC9E,MAAM,IAAI,SAAS,CACjB,iCAAiC,EACjC,gEAAgE,EAChE;gBACE,IAAI,EAAE,kGAAkG;aACzG,CACF,CAAA;QACH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QAChC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC5C,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAY,KAAK,CAAC,CAAA;QACpD,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,MAAM,CAAA;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAS,QAAQ,CAAC,CAAA;QACxD,0EAA0E;QAC1E,2DAA2D;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;QAC3E,sEAAsE;QACtE,wEAAwE;QACxE,gCAAgC;QAChC,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,EAAE,CAAA;QACnC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF;AAED,uEAAuE;AACvE,+EAA+E;AAC/E,gFAAgF;AAChF,4BAA4B;AAC5B,eAAe,WAAW,CAAA"}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
package/src/rpc/RpcProvider.ts
CHANGED
|
@@ -30,6 +30,14 @@ export interface RpcProviderOptions {
|
|
|
30
30
|
export interface RpcConfig {
|
|
31
31
|
/** HTTP path the JSON-RPC endpoint is mounted at. Default `/rpc`. */
|
|
32
32
|
path?: string
|
|
33
|
+
/**
|
|
34
|
+
* Guards applied to the `/rpc` route itself (e.g. `['jwt']`), so warden
|
|
35
|
+
* authenticates the endpoint at the edge and populates `ctx.auth` for every
|
|
36
|
+
* call — which per-method `.guard()` / `authorizeRpc()` then read. Without
|
|
37
|
+
* this, the inline-mounted route carries no guard metadata, so warden treats
|
|
38
|
+
* it as public and never populates `ctx.auth` (every guarded method 401s).
|
|
39
|
+
*/
|
|
40
|
+
guards?: string[]
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
export class RpcProvider extends Provider {
|
|
@@ -57,11 +65,17 @@ export class RpcProvider extends Provider {
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
override async boot(): Promise<void> {
|
|
60
|
-
const
|
|
68
|
+
const config = this.app.config.get<RpcConfig>('rpc')
|
|
69
|
+
const path = config?.path ?? '/rpc'
|
|
61
70
|
const router = this.app.container.make<Router>('router')
|
|
62
71
|
// RpcRouter.handle() reads the registered methods at request time, so the
|
|
63
72
|
// mount can happen before apps finish registering methods.
|
|
64
|
-
router.post(path, (ctx: HttpContext) => this.rpc.handle(ctx))
|
|
73
|
+
const route = router.post(path, (ctx: HttpContext) => this.rpc.handle(ctx))
|
|
74
|
+
// Apply route-level guards (e.g. ['jwt']) so warden authenticates the
|
|
75
|
+
// endpoint at the edge and populates ctx.auth — the inline route has no
|
|
76
|
+
// decorator metadata otherwise.
|
|
77
|
+
const guards = config?.guards ?? []
|
|
78
|
+
if (guards.length > 0) route.guard(...guards)
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
|