@osfactory/otel-hook 0.13.2 → 0.14.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.
- package/README.md +43 -0
- package/dist/{adapter-DyCb7y1N.d.ts → adapter-D5R8lhfl.d.ts} +1 -1
- package/dist/cli.js +427 -37
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +30 -4
- package/dist/config.js +161 -9
- package/dist/config.js.map +1 -1
- package/dist/{destinations-C4sSKjDO.d.ts → destinations-2KrcRslo.d.ts} +92 -2
- package/dist/{export-destinations-BjRXDots.d.ts → export-destinations-DvoH4QOe.d.ts} +101 -9
- package/dist/{hook-CKLpgrYP.d.ts → hook-DVK8Don-.d.ts} +4 -4
- package/dist/index.d.ts +10 -10
- package/dist/index.js +424 -36
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +3 -3
- package/dist/integration.d.ts +7 -7
- package/dist/integration.js +376 -34
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{payload-DLK7QaBB.d.ts → payload-D4r71EL-.d.ts} +1 -1
- package/dist/privacy.d.ts +2 -2
- package/dist/privacy.js +42 -1
- package/dist/privacy.js.map +1 -1
- package/dist/providers.d.ts +8 -8
- package/dist/{registry-DM-4YvIA.d.ts → registry-DOJh9mzB.d.ts} +2 -2
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +128 -2
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-CD61uW99.d.ts → schema-oRsbo7WO.d.ts} +45 -0
- package/dist/{service-CbI9CObT.d.ts → service-DySC7KQM.d.ts} +6 -1
- package/dist/telemetry.d.ts +5 -4
- package/dist/telemetry.js +285 -15
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +128 -2
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { O as OtelHookConfig, k as OtelHookConfigPatch } from './schema-
|
|
1
|
+
import { O as OtelHookConfig, k as OtelHookConfigPatch } from './schema-oRsbo7WO.js';
|
|
2
2
|
import { b as CanonicalEvent } from './events-fcomX6d5.js';
|
|
3
3
|
import { I as IdentityClaim, d as InvocationIdentity, S as SourceProvenance } from './identity-BrVBs901.js';
|
|
4
|
-
import { P as PrivacyService } from './service-
|
|
5
|
-
import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-
|
|
6
|
-
import { P as ProviderRegistry } from './registry-
|
|
4
|
+
import { P as PrivacyService } from './service-DySC7KQM.js';
|
|
5
|
+
import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-D5R8lhfl.js';
|
|
6
|
+
import { P as ProviderRegistry } from './registry-DOJh9mzB.js';
|
|
7
7
|
import { I as IdGenerator, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-DhpSDIkp.js';
|
|
8
8
|
import { c as RecordingTelemetrySink, I as InMemoryStateStore, F as FixedClock, R as RecordingLogger } from './memory-B3r6sZtC.js';
|
|
9
9
|
export { e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, j as createRecordingLogger, k as createRecordingTelemetrySink } from './memory-B3r6sZtC.js';
|
|
10
|
-
import { O as OtelHook } from './hook-
|
|
10
|
+
import { O as OtelHook } from './hook-DVK8Don-.js';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { a as ContentDisclosure, b as ContentFact } from './content-M9xIKG7h.js';
|
|
13
13
|
import './primitives-CJ8-rn-f.js';
|
package/dist/testing.js
CHANGED
|
@@ -153,6 +153,59 @@ var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
|
153
153
|
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
// src/config/repository-key.ts
|
|
157
|
+
var MAX_REPOSITORY_REFERENCE_LENGTH = 2048;
|
|
158
|
+
var SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
159
|
+
var SCP_LIKE_PATTERN = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)(.+)$/;
|
|
160
|
+
var trimTrailingSlashes = (value) => {
|
|
161
|
+
let end = value.length;
|
|
162
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
|
|
163
|
+
return value.slice(0, end);
|
|
164
|
+
};
|
|
165
|
+
var keyOf = (host, pathname) => {
|
|
166
|
+
const withoutSlashes = trimTrailingSlashes(pathname);
|
|
167
|
+
const cleanedPath = trimTrailingSlashes(
|
|
168
|
+
withoutSlashes.toLowerCase().endsWith(".git") ? withoutSlashes.slice(0, -4) : withoutSlashes
|
|
169
|
+
);
|
|
170
|
+
if (host.length === 0 || cleanedPath.length === 0 || cleanedPath === "/") {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
const withSlash = cleanedPath.startsWith("/") ? cleanedPath : `/${cleanedPath}`;
|
|
174
|
+
return `${host}${withSlash}`.toLowerCase();
|
|
175
|
+
};
|
|
176
|
+
var normalizeRepositoryKey = (reference) => {
|
|
177
|
+
const trimmed = reference.trim();
|
|
178
|
+
if (trimmed.length === 0 || trimmed.length > MAX_REPOSITORY_REFERENCE_LENGTH) {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
if (SCHEME_PATTERN.test(trimmed)) {
|
|
182
|
+
let url;
|
|
183
|
+
try {
|
|
184
|
+
url = new URL(trimmed);
|
|
185
|
+
} catch {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
if (url.protocol === "file:") {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
return keyOf(url.hostname, url.pathname);
|
|
192
|
+
}
|
|
193
|
+
if (trimmed.startsWith("/") || trimmed.startsWith(".") || trimmed.includes("\\")) {
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
const scp = SCP_LIKE_PATTERN.exec(trimmed);
|
|
197
|
+
if (scp !== null && !trimmed.split(":")[0]?.includes("/")) {
|
|
198
|
+
const [, host, pathPart] = scp;
|
|
199
|
+
return host === void 0 || pathPart === void 0 ? void 0 : keyOf(host, pathPart);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const url = new URL(`https://${trimmed}`);
|
|
203
|
+
return keyOf(url.hostname, url.pathname);
|
|
204
|
+
} catch {
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
156
209
|
// src/config/destinations.ts
|
|
157
210
|
var DEFAULT_DESTINATION_NAME = "default";
|
|
158
211
|
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
@@ -171,6 +224,30 @@ var headerValueSchema = z3.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
|
171
224
|
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
172
225
|
);
|
|
173
226
|
var endpointSchema = z3.string().url().max(2048);
|
|
227
|
+
var MAX_DESTINATION_SCOPES = 64;
|
|
228
|
+
var MAX_SCOPE_REPOSITORIES = 256;
|
|
229
|
+
var ALL_REPOSITORIES = "*";
|
|
230
|
+
var repositoryReferenceSchema = z3.string().min(1).max(MAX_REPOSITORY_REFERENCE_LENGTH).refine(
|
|
231
|
+
(value) => normalizeRepositoryKey(value) !== void 0,
|
|
232
|
+
"not a repository URL: use https://host/owner/repo, git@host:owner/repo.git, or host/owner/repo"
|
|
233
|
+
);
|
|
234
|
+
var destinationScopeSchema = z3.strictObject({
|
|
235
|
+
/**
|
|
236
|
+
* Repository URLs (any spelling of the remote; compared by host and path,
|
|
237
|
+
* case-insensitively, without `.git`), or `"*"` for every record that names
|
|
238
|
+
* a repository. A record that names none never matches a scope.
|
|
239
|
+
*/
|
|
240
|
+
repositories: z3.union([
|
|
241
|
+
z3.literal(ALL_REPOSITORIES),
|
|
242
|
+
z3.array(repositoryReferenceSchema).min(1).max(MAX_SCOPE_REPOSITORIES).readonly()
|
|
243
|
+
]),
|
|
244
|
+
/** Signals sent for these repositories. Default: every signal the destination takes. */
|
|
245
|
+
signals: z3.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
246
|
+
/** Content disclosure for these repositories, never above `privacy.contentMode`. Default: unchanged. */
|
|
247
|
+
contentMode: contentModeSchema.optional(),
|
|
248
|
+
/** False leaves `session.id` off metric data points for these repositories. Default true. */
|
|
249
|
+
includeSessionId: z3.boolean().optional()
|
|
250
|
+
});
|
|
174
251
|
var exportDestinationSchema = z3.strictObject({
|
|
175
252
|
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
176
253
|
name: z3.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
@@ -204,7 +281,15 @@ var exportDestinationSchema = z3.strictObject({
|
|
|
204
281
|
* opt-in for content-bearing records leaving the host. `metrics` is never on by
|
|
205
282
|
* default: a destination receives hook-derived metrics only when it lists them.
|
|
206
283
|
*/
|
|
207
|
-
signals: z3.array(exportSignalSchema).min(1).max(3).readonly().optional()
|
|
284
|
+
signals: z3.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
285
|
+
/**
|
|
286
|
+
* Per-repository filter. Absent: every record goes to this destination, as
|
|
287
|
+
* before scopes existed. Present: a record goes only when its repository
|
|
288
|
+
* (`vcs.repository.url.full`) matches a scope — the first matching scope
|
|
289
|
+
* decides its signals, content mode, and session id — and a record that
|
|
290
|
+
* names no repository is not sent here at all.
|
|
291
|
+
*/
|
|
292
|
+
scopes: z3.array(destinationScopeSchema).min(1).max(MAX_DESTINATION_SCOPES).readonly().optional()
|
|
208
293
|
}).refine(
|
|
209
294
|
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0 || destination.metricsEndpoint !== void 0,
|
|
210
295
|
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint / metricsEndpoint"
|
|
@@ -726,6 +811,23 @@ var EMPTY_EXTENSIONS = Object.freeze({});
|
|
|
726
811
|
var emptyExtensions = () => ({});
|
|
727
812
|
|
|
728
813
|
// src/privacy/service.ts
|
|
814
|
+
var DISCLOSURE_RANK = Object.freeze({
|
|
815
|
+
omitted: 0,
|
|
816
|
+
masked: 1,
|
|
817
|
+
redacted: 2,
|
|
818
|
+
raw: 3
|
|
819
|
+
});
|
|
820
|
+
var WHITESPACE = /\s/u;
|
|
821
|
+
var withoutTrailingToken = (text) => {
|
|
822
|
+
let end = text.length;
|
|
823
|
+
while (end > 0) {
|
|
824
|
+
const low = text.charCodeAt(end - 1);
|
|
825
|
+
const width = end >= 2 && low >= 56320 && low <= 57343 ? 2 : 1;
|
|
826
|
+
if (WHITESPACE.test(text.slice(end - width, end))) break;
|
|
827
|
+
end -= width;
|
|
828
|
+
}
|
|
829
|
+
return text.slice(0, end);
|
|
830
|
+
};
|
|
729
831
|
var compilePatterns = (sources, flags) => {
|
|
730
832
|
const compiled = [];
|
|
731
833
|
for (const source of sources) {
|
|
@@ -1063,7 +1165,31 @@ var createPrivacyService = (policyInput) => {
|
|
|
1063
1165
|
flattenToAttributes,
|
|
1064
1166
|
sanitizeAttributes,
|
|
1065
1167
|
sanitizeExtensions,
|
|
1066
|
-
boundString
|
|
1168
|
+
boundString,
|
|
1169
|
+
restrictContent: (fact, mode) => {
|
|
1170
|
+
const target = CONTENT_MODE_DISCLOSURE[mode];
|
|
1171
|
+
if (fact.text === void 0 || DISCLOSURE_RANK[fact.disclosure] <= DISCLOSURE_RANK[target]) {
|
|
1172
|
+
return fact;
|
|
1173
|
+
}
|
|
1174
|
+
const { text, ...rest } = fact;
|
|
1175
|
+
switch (target) {
|
|
1176
|
+
case "omitted":
|
|
1177
|
+
return { ...rest, disclosure: "omitted", truncated: false };
|
|
1178
|
+
case "masked":
|
|
1179
|
+
return { ...rest, disclosure: "masked", text: maskText(text) };
|
|
1180
|
+
case "redacted": {
|
|
1181
|
+
const redacted = redactSecretSpans(fact.truncated ? withoutTrailingToken(text) : text);
|
|
1182
|
+
return {
|
|
1183
|
+
...rest,
|
|
1184
|
+
disclosure: "redacted",
|
|
1185
|
+
text: redacted.text,
|
|
1186
|
+
secretsRedacted: fact.secretsRedacted + redacted.count
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
case "raw":
|
|
1190
|
+
return fact;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1067
1193
|
};
|
|
1068
1194
|
};
|
|
1069
1195
|
|