UNPKG

@kurrent/opentelemetry

Version:

KurrentDB NodeJS Client SDK interceptors for tracing with OpenTelemetry

32 lines 1.23 kB
"use strict"; /* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", { value: true }); exports.describeAuth = void 0; exports.hasConvertGrpcEventMethod = hasConvertGrpcEventMethod; exports.isJSONEventData = isJSONEventData; const kurrentdb_client_1 = require("@kurrent/kurrentdb-client"); function hasConvertGrpcEventMethod(obj // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type ) { return typeof obj.convertGrpcEvent === "function"; } function isJSONEventData(event) { return event.contentType === "application/json"; } /** * Derive the auth-related span attributes from the per-call credentials and * whether a {@link CredentialsProvider} is configured. Narrows the credential * shape once so `username` is only ever set alongside `kind: "basic"`. */ const describeAuth = (credentials, hasProvider) => { if ((0, kurrentdb_client_1.isBasicCredentials)(credentials)) { return { kind: "basic", username: credentials.username }; } if (credentials) return { kind: "bearer" }; if (hasProvider) return { kind: "provider" }; return {}; }; exports.describeAuth = describeAuth; //# sourceMappingURL=utils.js.map