@neat.is/core 0.10.3 → 0.10.4
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/{chunk-DLQNMU3R.js → chunk-2OQVIBZZ.js} +59 -22
- package/dist/chunk-2OQVIBZZ.js.map +1 -0
- package/dist/{chunk-M7CGATVC.js → chunk-EFBWQIKG.js} +12 -2
- package/dist/chunk-EFBWQIKG.js.map +1 -0
- package/dist/{chunk-5SJHA5ZH.js → chunk-LXQCL4MP.js} +2 -2
- package/dist/{chunk-LNIVRE4L.js → chunk-TUGYIRUT.js} +51 -2
- package/dist/{chunk-LNIVRE4L.js.map → chunk-TUGYIRUT.js.map} +1 -1
- package/dist/cli.cjs +58 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +114 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +4 -4
- package/dist/neatd.cjs +114 -20
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +3 -3
- package/dist/{otel-grpc-CU73Y5WT.js → otel-grpc-B7ABHLV7.js} +3 -3
- package/dist/server.cjs +62 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +7 -4
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-DLQNMU3R.js.map +0 -1
- package/dist/chunk-M7CGATVC.js.map +0 -1
- /package/dist/{chunk-5SJHA5ZH.js.map → chunk-LXQCL4MP.js.map} +0 -0
- /package/dist/{otel-grpc-CU73Y5WT.js.map → otel-grpc-B7ABHLV7.js.map} +0 -0
package/dist/neatd.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
reconcileDaemonRecordSync,
|
|
4
4
|
startDaemon
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2OQVIBZZ.js";
|
|
6
6
|
import {
|
|
7
7
|
listProjects,
|
|
8
8
|
registryPath
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TUGYIRUT.js";
|
|
10
10
|
import {
|
|
11
11
|
BindAuthorityError,
|
|
12
12
|
__require
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-EFBWQIKG.js";
|
|
14
14
|
|
|
15
15
|
// src/neatd.ts
|
|
16
16
|
import { promises as fs } from "fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reshapeGrpcRequest,
|
|
3
3
|
startOtelGrpcReceiver
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-LXQCL4MP.js";
|
|
5
|
+
import "./chunk-EFBWQIKG.js";
|
|
6
6
|
export {
|
|
7
7
|
reshapeGrpcRequest,
|
|
8
8
|
startOtelGrpcReceiver
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=otel-grpc-
|
|
10
|
+
//# sourceMappingURL=otel-grpc-B7ABHLV7.js.map
|
package/dist/server.cjs
CHANGED
|
@@ -49,6 +49,10 @@ function assertBindAuthority(host, token) {
|
|
|
49
49
|
if (isLoopbackHost2(host)) return;
|
|
50
50
|
throw new BindAuthorityError(host);
|
|
51
51
|
}
|
|
52
|
+
function isBearerDelegated(req) {
|
|
53
|
+
const config = req.routeOptions?.config;
|
|
54
|
+
return config?.bearerDelegated === true;
|
|
55
|
+
}
|
|
52
56
|
function mountBearerAuth(app, opts) {
|
|
53
57
|
if (!opts.token || opts.token.length === 0) return;
|
|
54
58
|
if (opts.trustProxy) return;
|
|
@@ -64,6 +68,10 @@ function mountBearerAuth(app, opts) {
|
|
|
64
68
|
done();
|
|
65
69
|
return;
|
|
66
70
|
}
|
|
71
|
+
if (isBearerDelegated(req)) {
|
|
72
|
+
done();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
67
75
|
if (publicRead && PUBLIC_READ_METHODS.has(req.method)) {
|
|
68
76
|
done();
|
|
69
77
|
return;
|
|
@@ -97,7 +105,7 @@ function readAuthEnv(env = process.env) {
|
|
|
97
105
|
publicRead: parseBoolEnv(env.NEAT_PUBLIC_READ)
|
|
98
106
|
};
|
|
99
107
|
}
|
|
100
|
-
var import_node_crypto, LOOPBACK_HOSTS, BindAuthorityError, PUBLIC_READ_METHODS, DEFAULT_UNAUTH_PATHS, PROJECT_SCOPED_UNAUTH_PATTERN;
|
|
108
|
+
var import_node_crypto, LOOPBACK_HOSTS, BindAuthorityError, PUBLIC_READ_METHODS, DEFAULT_UNAUTH_PATHS, PROJECT_SCOPED_UNAUTH_PATTERN, BEARER_DELEGATED;
|
|
101
109
|
var init_auth = __esm({
|
|
102
110
|
"src/auth.ts"() {
|
|
103
111
|
"use strict";
|
|
@@ -127,6 +135,7 @@ var init_auth = __esm({
|
|
|
127
135
|
PROJECT_SCOPED_UNAUTH_PATTERN = new RegExp(
|
|
128
136
|
`^/projects/[^/]+/(?:${DEFAULT_UNAUTH_PATHS.map((p) => p.slice(1)).join("|")})$`
|
|
129
137
|
);
|
|
138
|
+
BEARER_DELEGATED = { bearerDelegated: true };
|
|
130
139
|
}
|
|
131
140
|
});
|
|
132
141
|
|
|
@@ -23093,6 +23102,19 @@ function registerRoutes(scope, ctx) {
|
|
|
23093
23102
|
});
|
|
23094
23103
|
}
|
|
23095
23104
|
});
|
|
23105
|
+
scope.post("/repo-sync", async (req, reply) => {
|
|
23106
|
+
const proj = resolveProject(registry, req, reply, ctx.bootstrap, ctx.singleProject);
|
|
23107
|
+
if (!proj) return;
|
|
23108
|
+
const syncNow = ctx.repoSync?.(proj.name);
|
|
23109
|
+
if (!syncNow) {
|
|
23110
|
+
return reply.code(404).send({
|
|
23111
|
+
error: "repo-sync is not running for this project",
|
|
23112
|
+
project: proj.name,
|
|
23113
|
+
hint: "Only a hosted daemon syncs bound repos. On a local daemon, POST /graph/scan re-extracts the project path."
|
|
23114
|
+
});
|
|
23115
|
+
}
|
|
23116
|
+
return reply.code(202).send({ project: proj.name, ...syncNow() });
|
|
23117
|
+
});
|
|
23096
23118
|
scope.post("/graph/scan", async (req, reply) => {
|
|
23097
23119
|
const proj = resolveProject(registry, req, reply, ctx.bootstrap, ctx.singleProject);
|
|
23098
23120
|
if (!proj) return;
|
|
@@ -23340,6 +23362,39 @@ function registerRoutes(scope, ctx) {
|
|
|
23340
23362
|
}
|
|
23341
23363
|
});
|
|
23342
23364
|
}
|
|
23365
|
+
var OTLP_BODY_LIMIT = 16 * 1024 * 1024;
|
|
23366
|
+
function otlpOnRest(getReceiver) {
|
|
23367
|
+
return async function plugin(scope) {
|
|
23368
|
+
scope.removeAllContentTypeParsers();
|
|
23369
|
+
scope.addContentTypeParser(
|
|
23370
|
+
"*",
|
|
23371
|
+
{ parseAs: "buffer", bodyLimit: OTLP_BODY_LIMIT },
|
|
23372
|
+
(_req, body, done) => done(null, body)
|
|
23373
|
+
);
|
|
23374
|
+
const relay = async (req, reply) => {
|
|
23375
|
+
const receiver = getReceiver();
|
|
23376
|
+
if (!receiver) {
|
|
23377
|
+
return reply.code(503).header("retry-after", "1").send({ error: "OTLP receiver is starting" });
|
|
23378
|
+
}
|
|
23379
|
+
const headers = { ...req.headers };
|
|
23380
|
+
delete headers["content-length"];
|
|
23381
|
+
delete headers["transfer-encoding"];
|
|
23382
|
+
delete headers.connection;
|
|
23383
|
+
const res = await receiver.inject({
|
|
23384
|
+
method: "POST",
|
|
23385
|
+
url: req.url,
|
|
23386
|
+
headers,
|
|
23387
|
+
payload: req.body
|
|
23388
|
+
});
|
|
23389
|
+
const contentType = res.headers["content-type"];
|
|
23390
|
+
if (contentType !== void 0) void reply.header("content-type", contentType);
|
|
23391
|
+
return reply.code(res.statusCode).send(res.rawPayload);
|
|
23392
|
+
};
|
|
23393
|
+
const route = { config: BEARER_DELEGATED, bodyLimit: OTLP_BODY_LIMIT };
|
|
23394
|
+
scope.post("/v1/traces", route, relay);
|
|
23395
|
+
scope.post("/projects/:project/v1/traces", route, relay);
|
|
23396
|
+
};
|
|
23397
|
+
}
|
|
23343
23398
|
async function buildApi(opts) {
|
|
23344
23399
|
const app = (0, import_fastify2.default)({ logger: false, routerOptions: { maxParamLength: 1024 } });
|
|
23345
23400
|
await app.register(import_cors.default, { origin: true });
|
|
@@ -23358,6 +23413,7 @@ async function buildApi(opts) {
|
|
|
23358
23413
|
authProxy: trustProxy === true,
|
|
23359
23414
|
requiresAuth
|
|
23360
23415
|
}));
|
|
23416
|
+
if (opts.otlpReceiver) await app.register(otlpOnRest(opts.otlpReceiver));
|
|
23361
23417
|
const startedAt = opts.startedAt ?? Date.now();
|
|
23362
23418
|
const registry = buildLegacyRegistry(opts);
|
|
23363
23419
|
const legacyErrorsExplicit = !opts.projects && opts.errorsPath !== void 0;
|
|
@@ -23388,6 +23444,7 @@ async function buildApi(opts) {
|
|
|
23388
23444
|
bootstrap: opts.bootstrap,
|
|
23389
23445
|
singleProject: opts.singleProject?.name,
|
|
23390
23446
|
connectorsHome: opts.connectorsHome,
|
|
23447
|
+
repoSync: opts.repoSync,
|
|
23391
23448
|
runPoll: opts.runPoll ?? runConnectorPoll
|
|
23392
23449
|
};
|
|
23393
23450
|
app.get("/health", async () => {
|
|
@@ -23885,11 +23942,13 @@ async function main() {
|
|
|
23885
23942
|
const otelPort = Number(process.env.OTEL_PORT ?? 4318);
|
|
23886
23943
|
const auth = readAuthEnv();
|
|
23887
23944
|
assertBindAuthority(host, auth.authToken);
|
|
23945
|
+
let otelReceiver;
|
|
23888
23946
|
const app = await buildApi({
|
|
23889
23947
|
projects: registry,
|
|
23890
23948
|
authToken: auth.authToken,
|
|
23891
23949
|
trustProxy: auth.trustProxy,
|
|
23892
|
-
publicRead: auth.publicRead
|
|
23950
|
+
publicRead: auth.publicRead,
|
|
23951
|
+
otlpReceiver: () => otelReceiver
|
|
23893
23952
|
});
|
|
23894
23953
|
await app.listen({ port, host });
|
|
23895
23954
|
console.log(`neat-core listening on http://${host}:${port}`);
|
|
@@ -23906,6 +23965,7 @@ async function main() {
|
|
|
23906
23965
|
authToken: auth.otelToken,
|
|
23907
23966
|
trustProxy: auth.trustProxy
|
|
23908
23967
|
});
|
|
23968
|
+
otelReceiver = otelApp;
|
|
23909
23969
|
await otelApp.listen({ port: otelPort, host });
|
|
23910
23970
|
console.log(`neat-core OTLP receiver on http://${host}:${otelPort}/v1/traces`);
|
|
23911
23971
|
if (process.env.NEAT_OTLP_GRPC === "true") {
|