@olane/o-server 0.8.13 → 0.8.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,QAAQ,EACT,MAAM,0CAA0C,CAAC;AAElD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE,QAAQ,CAAC;SACjB;KACF;CACF;AAED,wBAAgB,cAAc,CAAC,YAAY,EAAE,oBAAoB,SAC5C,OAAO,OAAO,QAAQ,QAAQ,YAAY,mBAe9D"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,QAAQ,EACT,MAAM,0CAA0C,CAAC;AAElD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE,QAAQ,CAAC;SACjB;KACF;CACF;AAED,wBAAgB,cAAc,CAAC,YAAY,EAAE,oBAAoB,IACjD,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,mBAe9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-auth.d.ts","sourceRoot":"","sources":["../../../src/middleware/jwt-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,GAAG,MAAM,cAAc,CAAC;AAI/B;;GAEG;AACH,MA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AAE,WAAW,GAAG,QAAQ,CAAC;IAE/B,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qFAAqF;IACrF,UAAU,CAAC,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;IAE7B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,GAAG,CAAC,EAAE,UAAU,CAAC;SAClB;KACF;CACF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,IA4CrC,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,mBAyG9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"o-server.d.ts","sourceRoot":"","sources":["../../src/o-server.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,cAAc,EACf,MAAM,yCAAyC,CAAC;AAiBjD,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAoW5D"}
1
+ {"version":3,"file":"o-server.d.ts","sourceRoot":"","sources":["../../src/o-server.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,cAAc,EACf,MAAM,yCAAyC,CAAC;AAuBjD,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CA4W5D"}
@@ -4,7 +4,8 @@ import { errorHandler } from './middleware/error-handler.js';
4
4
  import { authMiddleware } from './middleware/auth.js';
5
5
  import { createJwtMiddleware } from './middleware/jwt-auth.js';
6
6
  import { ServerLogger } from './utils/logger.js';
7
- import { oAddress, oRequestContext } from '@olane/o-core';
7
+ import { oAddress, oRequestContext, } from '@olane/o-core';
8
+ import { randomUUID } from 'crypto';
8
9
  import { validateAddress, validateMethod, sanitizeParams, validateRequest, useRequestSchema, streamRequestSchema, } from './validation/index.js';
9
10
  export function oServer(config) {
10
11
  const { node, port = 3000, basePath = '/api/v1', cors: corsConfig, authenticate, jwtAuth, debug = false, } = config;
@@ -20,9 +21,7 @@ export function oServer(config) {
20
21
  return undefined;
21
22
  // Extract raw token from Authorization header
22
23
  const authHeader = req.headers.authorization;
23
- const token = authHeader?.startsWith('Bearer ')
24
- ? authHeader.slice(7)
25
- : '';
24
+ const token = authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : '';
26
25
  return {
27
26
  token,
28
27
  claims: req.jwt,
@@ -35,23 +34,23 @@ export function oServer(config) {
35
34
  function stripClientAuth(params) {
36
35
  if (!params || typeof params !== 'object')
37
36
  return params;
38
- const { _auth, ...rest } = params;
37
+ const { _auth, _trace, ...rest } = params;
39
38
  return rest;
40
39
  }
41
40
  /**
42
- * Deep-strip _auth from response data before sending to HTTP client.
43
- * Prevents leaking tokens in response payloads.
41
+ * Deep-strip internal fields (_auth, _trace) from response data before
42
+ * sending to HTTP client. Prevents leaking tokens and trace metadata.
44
43
  */
45
- function stripAuthFromResponse(obj) {
44
+ function stripInternalFields(obj) {
46
45
  if (obj === null || obj === undefined || typeof obj !== 'object')
47
46
  return obj;
48
47
  if (Array.isArray(obj))
49
- return obj.map(stripAuthFromResponse);
48
+ return obj.map(stripInternalFields);
50
49
  const result = {};
51
50
  for (const key of Object.keys(obj)) {
52
- if (key === '_auth')
51
+ if (key === '_auth' || key === '_trace')
53
52
  continue;
54
- result[key] = stripAuthFromResponse(obj[key]);
53
+ result[key] = stripInternalFields(obj[key]);
55
54
  }
56
55
  return result;
57
56
  }
@@ -109,13 +108,15 @@ export function oServer(config) {
109
108
  : sanitizedParams;
110
109
  logger.debugLog(`Calling use with address ${addressStr}, method: ${method}`);
111
110
  const address = new oAddress(addressStr);
112
- // Wrap in request context for AsyncLocalStorage propagation
113
- const result = await (auth
114
- ? oRequestContext.run({ auth }, () => node.use(address, { method, params: finalParams, id }))
115
- : node.use(address, { method, params: finalParams, id }));
111
+ // Generate a short request ID for tracing across the call chain
112
+ const requestId = randomUUID().replace(/-/g, '').substring(0, 8);
113
+ const store = { requestId };
114
+ if (auth)
115
+ store.auth = auth;
116
+ const result = await oRequestContext.run(store, () => node.use(address, { method, params: finalParams, id }));
116
117
  const response = {
117
118
  success: true,
118
- data: stripAuthFromResponse(result.result),
119
+ data: stripInternalFields(result.result),
119
120
  };
120
121
  res.json(response);
121
122
  }
@@ -147,13 +148,15 @@ export function oServer(config) {
147
148
  : sanitizedParams;
148
149
  logger.debugLog(`Calling method ${method} on ${addressParam} with params:`, sanitizedParams);
149
150
  const address = new oAddress(addressStr);
150
- // Wrap in request context for AsyncLocalStorage propagation
151
- const result = await (auth
152
- ? oRequestContext.run({ auth }, () => node.use(address, { method, params: finalParams }))
153
- : node.use(address, { method, params: finalParams }));
151
+ // Generate a short request ID for tracing across the call chain
152
+ const requestId = randomUUID().replace(/-/g, '').substring(0, 8);
153
+ const store = { requestId };
154
+ if (auth)
155
+ store.auth = auth;
156
+ const result = await oRequestContext.run(store, () => node.use(address, { method: method, params: finalParams }));
154
157
  const response = {
155
158
  success: true,
156
- data: stripAuthFromResponse(result.result),
159
+ data: stripInternalFields(result.result),
157
160
  };
158
161
  res.json(response);
159
162
  }
@@ -187,15 +190,18 @@ export function oServer(config) {
187
190
  res.setHeader('Cache-Control', 'no-cache');
188
191
  res.setHeader('Connection', 'keep-alive');
189
192
  const address = new oAddress(addressStr);
193
+ // Generate a short request ID for tracing across the call chain
194
+ const requestId = randomUUID().replace(/-/g, '').substring(0, 8);
195
+ const store = { requestId };
196
+ if (auth)
197
+ store.auth = auth;
190
198
  try {
191
199
  // TODO: Implement actual streaming support when available
192
200
  // For now, execute and return result
193
- const result = await (auth
194
- ? oRequestContext.run({ auth }, () => node.use(address, { method, params: finalParams }))
195
- : node.use(address, { method, params: finalParams }));
201
+ const result = await oRequestContext.run(store, () => node.use(address, { method, params: finalParams }));
196
202
  res.write(`data: ${JSON.stringify({
197
203
  type: 'complete',
198
- result: stripAuthFromResponse(result.result),
204
+ result: stripInternalFields(result.result),
199
205
  })}\n\n`);
200
206
  res.end();
201
207
  }
@@ -8,17 +8,7 @@ export declare const useRequestSchema: z.ZodObject<{
8
8
  method: z.ZodString;
9
9
  params: z.ZodOptional<z.ZodAny>;
10
10
  id: z.ZodOptional<z.ZodString>;
11
- }, "strip", z.ZodTypeAny, {
12
- address: string;
13
- method: string;
14
- params?: any;
15
- id?: string | undefined;
16
- }, {
17
- address: string;
18
- method: string;
19
- params?: any;
20
- id?: string | undefined;
21
- }>;
11
+ }, z.core.$strip>;
22
12
  /**
23
13
  * Schema for POST /:address/:method endpoint
24
14
  * This endpoint accepts any body as params
@@ -32,15 +22,7 @@ export declare const streamRequestSchema: z.ZodObject<{
32
22
  address: z.ZodString;
33
23
  method: z.ZodString;
34
24
  params: z.ZodOptional<z.ZodAny>;
35
- }, "strip", z.ZodTypeAny, {
36
- address: string;
37
- method: string;
38
- params?: any;
39
- }, {
40
- address: string;
41
- method: string;
42
- params?: any;
43
- }>;
25
+ }, z.core.$strip>;
44
26
  /**
45
27
  * Validates request data against a Zod schema
46
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request-validator.d.ts","sourceRoot":"","sources":["../../../src/validation/request-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAqB3E"}
1
+ {"version":3,"file":"request-validator.d.ts","sourceRoot":"","sources":["../../../src/validation/request-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;iBAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAqB3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-server",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -34,40 +34,40 @@
34
34
  "license": "(MIT OR Apache-2.0)",
35
35
  "description": "HTTP server entrypoint for Olane OS nodes - exposes node's 'use' functionality via REST API",
36
36
  "devDependencies": {
37
- "@eslint/eslintrc": "^3.3.1",
38
- "@eslint/js": "^9.29.0",
39
- "@tsconfig/node20": "^20.1.6",
40
- "@types/cors": "^2.8.17",
41
- "@types/express": "^4.17.21",
37
+ "@eslint/eslintrc": "^3.3.4",
38
+ "@eslint/js": "^10.0.1",
39
+ "@tsconfig/node20": "^20.1.9",
40
+ "@types/cors": "^2.8.19",
41
+ "@types/express": "^5.0.6",
42
42
  "@types/jest": "^30.0.0",
43
43
  "@types/jsonwebtoken": "^9.0.10",
44
44
  "@types/mocha": "^10.0.10",
45
- "@types/node": "^20.14.0",
45
+ "@types/node": "^25.3.0",
46
46
  "@types/supertest": "^6.0.3",
47
- "@typescript-eslint/eslint-plugin": "^8.34.1",
48
- "@typescript-eslint/parser": "^8.34.1",
49
- "aegir": "^47.0.21",
50
- "eslint": "^9.29.0",
51
- "eslint-config-prettier": "^10.1.6",
52
- "eslint-plugin-prettier": "^5.5.0",
53
- "globals": "^16.2.0",
54
- "jest": "^30.0.0",
55
- "prettier": "^3.5.3",
47
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
48
+ "@typescript-eslint/parser": "^8.56.1",
49
+ "aegir": "^47.0.26",
50
+ "eslint": "^10.0.2",
51
+ "eslint-config-prettier": "^10.1.8",
52
+ "eslint-plugin-prettier": "^5.5.5",
53
+ "globals": "^17.3.0",
54
+ "jest": "^30.2.0",
55
+ "prettier": "^3.8.1",
56
56
  "supertest": "^7.2.2",
57
- "ts-jest": "^29.4.0",
57
+ "ts-jest": "^29.4.6",
58
58
  "ts-node": "^10.9.2",
59
59
  "tsconfig-paths": "^4.2.0",
60
- "tsx": "^4.20.3",
61
- "typescript": "5.4.5"
60
+ "tsx": "^4.21.0",
61
+ "typescript": "5.9.3"
62
62
  },
63
63
  "dependencies": {
64
- "@olane/o-core": "0.8.13",
65
- "cors": "^2.8.5",
66
- "debug": "^4.4.1",
67
- "dotenv": "^16.5.0",
68
- "express": "^4.21.2",
64
+ "@olane/o-core": "0.8.15",
65
+ "cors": "^2.8.6",
66
+ "debug": "^4.4.3",
67
+ "dotenv": "^17.3.1",
68
+ "express": "^5.2.1",
69
69
  "jsonwebtoken": "^9.0.3",
70
- "zod": "^3.25.76"
70
+ "zod": "^4.3.6"
71
71
  },
72
- "gitHead": "23c3e99e1dfe069697b4df483ef93c3e0b2902f7"
72
+ "gitHead": "e68ec122eedbca326b2f0bb5c0df7ed33de0af1b"
73
73
  }