@quatronic/sdk 0.8.0-rc.16 → 0.8.0-test.3e82420
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-TOBGX4CZ.js → chunk-5RAO3LPF.js} +9 -2
- package/dist/chunk-5RAO3LPF.js.map +1 -0
- package/dist/{chunk-G7VPNC6M.js → chunk-IFESUTF2.js} +21 -100
- package/dist/chunk-IFESUTF2.js.map +1 -0
- package/dist/{chunk-F3NHTHFO.js → chunk-NMJOF3ZM.js} +2 -2
- package/dist/{chunk-WU7N4PET.js → chunk-POZI4OKJ.js} +2 -2
- package/dist/chunk-YFZB5EW6.js +107 -0
- package/dist/chunk-YFZB5EW6.js.map +1 -0
- package/dist/cli/skills-postinstall.js +4 -3
- package/dist/cli/skills.js +4 -3
- package/dist/integrations/index.d.ts +2 -2
- package/dist/integrations/index.js +2 -2
- package/dist/next/boot/index.d.ts +1 -1
- package/dist/next/boot/index.js +4 -3
- package/dist/next/boot/index.js.map +1 -1
- package/dist/next/integrations/index.d.ts +1 -1
- package/dist/next/integrations/index.js +2 -2
- package/dist/next/security/index.js +3 -3
- package/dist/next/sentry/client.js +2 -1
- package/dist/next/sentry/client.js.map +1 -1
- package/dist/next/sentry/index.d.ts +1 -0
- package/dist/next/sentry/index.js +5 -1
- package/dist/next/sentry/index.js.map +1 -1
- package/dist/next/sentry/register.js +3 -2
- package/dist/node/boot/index.d.ts +1 -1
- package/dist/node/boot/index.js +1 -1
- package/dist/node/integrations/index.d.ts +1 -1
- package/dist/node/integrations/index.js +2 -2
- package/dist/node/sentry/index.d.ts +3 -0
- package/dist/node/sentry/index.js +7 -0
- package/dist/node/sentry/index.js.map +1 -0
- package/dist/node/sentry/register.js +2 -1
- package/dist/node/sentry/register.js.map +1 -1
- package/dist/{node-OVIG5ZYJ.js → node-YQDRNIYH.js} +2 -2
- package/dist/{types-CAwj03sM.d.ts → types-Cl7g4ego.d.ts} +7 -2
- package/package.json +5 -1
- package/skills/catalog.json +1 -0
- package/skills/qore-add-env-key/SKILL.md +57 -0
- package/skills/qore-add-integration/SKILL.next.md +13 -7
- package/skills/qore-add-integration/SKILL.node.md +13 -7
- package/skills/qore-author-skill/SKILL.md +1 -0
- package/dist/chunk-G7VPNC6M.js.map +0 -1
- package/dist/chunk-TOBGX4CZ.js.map +0 -1
- /package/dist/{chunk-F3NHTHFO.js.map → chunk-NMJOF3ZM.js.map} +0 -0
- /package/dist/{chunk-WU7N4PET.js.map → chunk-POZI4OKJ.js.map} +0 -0
- /package/dist/{node-OVIG5ZYJ.js.map → node-YQDRNIYH.js.map} +0 -0
|
@@ -14,7 +14,14 @@ var AUTH_ENV_FIELDS = {
|
|
|
14
14
|
basic: ["username", "password"],
|
|
15
15
|
oauth2_client_credentials: ["tokenUrl", "clientId", "clientSecret", "scope", "audience"]
|
|
16
16
|
};
|
|
17
|
-
var AUTH_SECRET_FIELDS = [
|
|
17
|
+
var AUTH_SECRET_FIELDS = [
|
|
18
|
+
"apiKey",
|
|
19
|
+
"token",
|
|
20
|
+
"username",
|
|
21
|
+
"password",
|
|
22
|
+
"clientId",
|
|
23
|
+
"clientSecret"
|
|
24
|
+
];
|
|
18
25
|
var RESERVED_KEY_PREFIX = "QORE_INTEGRATION_";
|
|
19
26
|
|
|
20
27
|
// src/integrations-core/env.ts
|
|
@@ -106,4 +113,4 @@ export {
|
|
|
106
113
|
loggingEnabled,
|
|
107
114
|
assertIntegrations
|
|
108
115
|
};
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
116
|
+
//# sourceMappingURL=chunk-5RAO3LPF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/integrations-core/types.ts","../src/integrations-core/env.ts","../src/integrations-core/assertIntegrations.ts"],"sourcesContent":["/**\n * How an integration authenticates. Every field except `header` and\n * `credentialsIn` names an **env key** — the SDK reads the value from the\n * environment at call time, never from the declaration — so a declaration can\n * sit in source control and carry no secret.\n */\nexport type AuthKind =\n | \"none\"\n | \"api_key_header\"\n | \"bearer_static\"\n | \"basic\"\n | \"oauth2_client_credentials\"\n\n/** What the API speaks. Informational for the portal; the client sends bytes either way. */\nexport type Protocol = \"rest\" | \"odata\" | \"soap\" | \"graphql\"\n\n/** The name of an env var, e.g. `SAP_BASE_URL`. */\nexport type EnvKey = string\n\n/**\n * A reference to an env var. The short form is required; the object form can\n * be optional and carry a default the app falls back on when the key is unset.\n */\nexport type EnvRef =\n | EnvKey\n | { key: EnvKey; optional?: boolean; default?: string | number | boolean }\n\nexport type IntegrationAuth =\n | { kind: \"none\" }\n | { kind: \"api_key_header\"; header: string; apiKey: EnvKey }\n | { kind: \"bearer_static\"; token: EnvKey }\n | { kind: \"basic\"; username: EnvKey; password: EnvKey }\n | {\n kind: \"oauth2_client_credentials\"\n tokenUrl: EnvKey\n clientId: EnvKey\n clientSecret: EnvKey\n scope?: EnvKey\n audience?: EnvKey\n /** Where the client credentials go on the token request. Default `\"header\"`. */\n credentialsIn?: \"header\" | \"body\"\n }\n\nexport interface IntegrationDefinition {\n /** Human name shown in the portal, e.g. \"SAP S/4HANA Cloud\". */\n label: string\n protocol: Protocol\n /** Env key holding the base URL for this environment. */\n baseUrl: EnvKey\n auth: IntegrationAuth\n /** Further env the app reads for this integration, by logical name. */\n config?: Record<string, EnvRef>\n}\n\nexport type IntegrationMap = Record<string, IntegrationDefinition>\n\n/**\n * Identity function that pins the literal types of the map, so an alias typo\n * at a call site is a compile error (`keyof M`) rather than a runtime\n * `not_declared`. Same shape as `definePermissions` in `auth-core`.\n */\nexport function defineIntegrations<const M extends IntegrationMap>(map: M): M {\n return map\n}\n\n/**\n * Which fields of each auth kind name an env key. Shared with the manifest\n * extractor and the portal, which derive the required-env list from a\n * declaration without evaluating app code.\n */\nexport const AUTH_ENV_FIELDS: Record<AuthKind, readonly string[]> = {\n none: [],\n api_key_header: [\"apiKey\"],\n bearer_static: [\"token\"],\n basic: [\"username\", \"password\"],\n oauth2_client_credentials: [\"tokenUrl\", \"clientId\", \"clientSecret\", \"scope\", \"audience\"],\n}\n\n/**\n * Auth fields whose env value is a secret, so the portal locks it whatever\n * `env.ts` labels it. The identifier of a login counts with its secret:\n * `username` sits with `password` and `clientId` with `clientSecret`, because\n * that is where a person looks for them and they are replaced together.\n */\nexport const AUTH_SECRET_FIELDS = [\n \"apiKey\",\n \"token\",\n \"username\",\n \"password\",\n \"clientId\",\n \"clientSecret\",\n] as const\n\n/**\n * Env keys under this prefix belong to the platform\n * (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.\n */\nexport const RESERVED_KEY_PREFIX = \"QORE_INTEGRATION_\"\n","import { normalizeAlias, type Env } from \"../connections-core/env\"\nimport {\n AUTH_ENV_FIELDS,\n RESERVED_KEY_PREFIX,\n type EnvRef,\n type IntegrationDefinition,\n} from \"./types\"\n\nexport type { Env }\n\nexport function refKey(ref: EnvRef): string {\n return typeof ref === \"string\" ? ref : ref.key\n}\n\nfunction refOptional(ref: EnvRef): boolean {\n return typeof ref !== \"string\" && (ref.optional === true || ref.default !== undefined)\n}\n\n/** The auth fields of `def` that are set, as env keys. */\nfunction authKeys(def: IntegrationDefinition): string[] {\n const auth = def.auth as unknown as Record<string, unknown>\n return AUTH_ENV_FIELDS[def.auth.kind]\n .map((field) => auth[field])\n .filter((key): key is string => typeof key === \"string\" && key !== \"\")\n}\n\n/**\n * Every env key the integration cannot run without: the base URL, every auth\n * field that is set, and every config ref that is neither optional nor\n * defaulted. Order is stable so an error message reads the same twice.\n */\nexport function requiredKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) {\n if (!refOptional(ref)) keys.push(refKey(ref))\n }\n return [...new Set(keys)]\n}\n\n/** Every env key the declaration names, required or not. */\nexport function allKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) keys.push(refKey(ref))\n return [...new Set(keys)]\n}\n\n/**\n * Read one ref from `env`, applying its default when the key is unset or\n * empty. A default comes back as declared (a number or boolean stays typed);\n * an env value is always a string.\n */\nexport function readRef(env: Env, ref: EnvRef): string | number | boolean | undefined {\n const value = env[refKey(ref)]\n if (value !== undefined && value !== \"\") return value\n return typeof ref === \"string\" ? undefined : ref.default\n}\n\n/** `QORE_INTEGRATION_<ALIAS>_LOGGING` — the one reserved key v1 reads. */\nexport function loggingKey(alias: string): string {\n return `${RESERVED_KEY_PREFIX}${normalizeAlias(alias)}_LOGGING`\n}\n\n/** Whether the per-call JSON log line is switched on for this alias (\"1\" or \"true\"). */\nexport function loggingEnabled(env: Env, alias: string): boolean {\n const value = env[loggingKey(alias)]\n return value === \"1\" || value?.toLowerCase() === \"true\"\n}\n","import { defaultEnv, type Env } from \"../connections-core/env\"\nimport { allKeys, requiredKeys } from \"./env\"\nimport { RESERVED_KEY_PREFIX, type IntegrationMap } from \"./types\"\n\nconst ENV_KEY_RE = /^[A-Z][A-Z0-9_]*$/\n\nexport interface IntegrationProblem {\n alias: string\n key: string\n /** `missing_env`: a required key is unset or empty. `reserved_key`: the declaration claims a key it may not. */\n code: \"missing_env\" | \"reserved_key\"\n message: string\n}\n\n/**\n * Report, at app startup, what is wrong with the declared integrations: a\n * required env key that is unset, or a key the declaration may not claim.\n * **It never throws.** Integrations are a visibility tool: an API key that is\n * not set (an obsolete integration, a vendor not contracted in this\n * environment) must cost the calls to that one integration — they fail with\n * `missing_env` — never the boot of the whole app. Each problem is logged as\n * one warning and returned, so a caller may act on them if it chooses.\n */\nexport function assertIntegrations(\n map: IntegrationMap,\n opts: { env?: Env; warn?: (message: string) => void } = {},\n): IntegrationProblem[] {\n const env = opts.env ?? defaultEnv()\n const warn = opts.warn ?? ((message: string) => console.warn(message))\n const problems: IntegrationProblem[] = []\n\n for (const [alias, def] of Object.entries(map)) {\n for (const key of allKeys(def)) {\n let why: string | undefined\n if (key.startsWith(RESERVED_KEY_PREFIX)) {\n why = `${RESERVED_KEY_PREFIX}* keys are reserved by the platform`\n } else if (key.startsWith(\"CONN_\")) {\n why = \"CONN_* keys belong to module connections, not integrations\"\n } else if (!ENV_KEY_RE.test(key)) {\n why = \"an env key is uppercase letters, digits and underscores\"\n }\n if (why) {\n problems.push({\n alias,\n key,\n code: \"reserved_key\",\n message: `Integration \"${alias}\" declares env key \"${key}\": ${why}`,\n })\n }\n }\n for (const key of requiredKeys(def)) {\n const value = env[key]\n if (value === undefined || value === \"\") {\n problems.push({\n alias,\n key,\n code: \"missing_env\",\n message: `Integration \"${alias}\" is missing env key \"${key}\"; calls to it will fail until it is set`,\n })\n }\n }\n }\n\n for (const p of problems) warn(`[integrations] ${p.message}`)\n return problems\n}\n"],"mappings":";;;;;;AA6DO,SAAS,mBAAmD,KAAW;AAC5E,SAAO;AACT;AAOO,IAAM,kBAAuD;AAAA,EAClE,MAAM,CAAC;AAAA,EACP,gBAAgB,CAAC,QAAQ;AAAA,EACzB,eAAe,CAAC,OAAO;AAAA,EACvB,OAAO,CAAC,YAAY,UAAU;AAAA,EAC9B,2BAA2B,CAAC,YAAY,YAAY,gBAAgB,SAAS,UAAU;AACzF;AAQO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,sBAAsB;;;ACvF5B,SAAS,OAAO,KAAqB;AAC1C,SAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AAC7C;AAEA,SAAS,YAAY,KAAsB;AACzC,SAAO,OAAO,QAAQ,aAAa,IAAI,aAAa,QAAQ,IAAI,YAAY;AAC9E;AAGA,SAAS,SAAS,KAAsC;AACtD,QAAM,OAAO,IAAI;AACjB,SAAO,gBAAgB,IAAI,KAAK,IAAI,EACjC,IAAI,CAAC,UAAU,KAAK,KAAK,CAAC,EAC1B,OAAO,CAAC,QAAuB,OAAO,QAAQ,YAAY,QAAQ,EAAE;AACzE;AAOO,SAAS,aAAa,KAAsC;AACjE,QAA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9B,WAAW,IAAI,WAAW,OAAO,GAAG;AAClC,cAAM;AAAA,MACR,WAAW,CAAC,WAAW,KAAK,GAAG,GAAG;AAChC,cAAM;AAAA,MACR;AACA,UAAI,KAAK;AACP,iBAAS,KAAK;AAAA,UACZ;AAAA,UACA;AAAA,UACA,MAAM;AAAA,UACN,SAAS,gBAAgB,KAAK,uBAAuB,GAAG,MAAM,GAAG;AAAA,QACnE,CAAC;AAAA,MACH;AAAA,IACF;AACA,eAAW,OAAO,aAAa,GAAG,GAAG;AACnC,YAAM,QAAQ,IAAI,GAAG;AACrB,UAAI,UAAU,UAAa,UAAU,IAAI;AACvC,iBAAS,KAAK;AAAA,UACZ;AAAA,UACA;AAAA,UACA,MAAM;AAAA,UACN,SAAS,gBAAgB,KAAK,yBAAyB,GAAG;AAAA,QAC5D,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,aAAW,KAAK,SAAU,MAAK,kBAAkB,EAAE,OAAO,EAAE;AAC5D,SAAO;AACT;","names":[]}
|
|
@@ -1,46 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setTelemetryHooks
|
|
3
|
-
} from "./chunk-MET4SIMB.js";
|
|
4
|
-
import {
|
|
5
|
-
makeDevSinkTransport
|
|
6
|
-
} from "./chunk-7ASQHY7O.js";
|
|
7
|
-
|
|
8
|
-
// src/sentry-core/noise.ts
|
|
9
|
-
var NOISE_EXACT = /* @__PURE__ */ new Set(["/favicon.ico", "/api/auth/me"]);
|
|
10
|
-
var RSC_QUERY_RE = /[?&]_rsc=/;
|
|
11
|
-
function isNoisePath(rawUrl, opts = {}) {
|
|
12
|
-
if (RSC_QUERY_RE.test(rawUrl)) return true;
|
|
13
|
-
const path = (rawUrl.split("?")[0] ?? "").trim();
|
|
14
|
-
if (!path) return false;
|
|
15
|
-
if (NOISE_EXACT.has(path)) return true;
|
|
16
|
-
if (path.endsWith(".map")) return true;
|
|
17
|
-
if (path.startsWith("/_next/")) return true;
|
|
18
|
-
if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true;
|
|
19
|
-
if (opts.healthPath && path === opts.healthPath) return true;
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/sentry-core/sampler.ts
|
|
24
|
-
var MUTATIONS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
25
|
-
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
26
|
-
function pathOf(ctx) {
|
|
27
|
-
const a = ctx.attributes ?? {};
|
|
28
|
-
return str(a["url.path"]) ?? str(a["http.target"]) ?? ctx.name.split(" ")[1];
|
|
29
|
-
}
|
|
30
|
-
function createTracesSampler(policy) {
|
|
31
|
-
return (ctx) => {
|
|
32
|
-
const path = pathOf(ctx);
|
|
33
|
-
if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0;
|
|
34
|
-
const a = ctx.attributes ?? {};
|
|
35
|
-
const method = (str(a["http.request.method"]) ?? str(a["http.method"]) ?? "").toUpperCase();
|
|
36
|
-
if (MUTATIONS.has(method)) return 1;
|
|
37
|
-
return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
1
|
// src/sentry-core/scrub.ts
|
|
42
2
|
var REDACTED = "\u25CF\u25CF\u25CF";
|
|
43
3
|
var EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\.[A-Z0-9-]+)*\.[A-Z]{2,}/gi;
|
|
4
|
+
var URL_USERINFO = /\b([a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi;
|
|
44
5
|
var JWT = /eyJ[\w-]+\.[\w-]+\.[\w-]+/g;
|
|
45
6
|
var AUTH_SCHEME = /\b(Bearer|Basic)\s+\S+/gi;
|
|
46
7
|
var PARAMS_TAIL = /\bparams:\s.*$/s;
|
|
@@ -61,8 +22,21 @@ var REDACT_PREFIXES = ["net.peer.", "net.sock.", "net.host.", "network.peer.", "
|
|
|
61
22
|
var DROP_SPAN_KEYS = /* @__PURE__ */ new Set(["user_agent.original", "http.user_agent", "client.address", "http.client_ip"]);
|
|
62
23
|
var DROP_SPAN_PREFIXES = ["http.request.header.", "http.response.header."];
|
|
63
24
|
var URL_SPAN_KEYS = /* @__PURE__ */ new Set(["url.full", "http.url", "url", "http.target", "url.query", "http.query"]);
|
|
25
|
+
var SECRETS = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-secret-values");
|
|
26
|
+
var secretHolder = globalThis;
|
|
27
|
+
function secretState() {
|
|
28
|
+
return secretHolder[SECRETS] ??= { values: /* @__PURE__ */ new Set(), longestFirst: [] };
|
|
29
|
+
}
|
|
30
|
+
function registerSecretValues(values) {
|
|
31
|
+
const state = secretState();
|
|
32
|
+
for (const v of values) if (typeof v === "string" && v.length >= 8) state.values.add(v);
|
|
33
|
+
state.longestFirst = [...state.values].sort((a, b) => b.length - a.length);
|
|
34
|
+
}
|
|
35
|
+
function maskSecretValues(s) {
|
|
36
|
+
return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s);
|
|
37
|
+
}
|
|
64
38
|
function redactText(s) {
|
|
65
|
-
return s.replace(PARAMS_TAIL, "params: [redacted]").replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
|
|
39
|
+
return maskSecretValues(s).replace(URL_USERINFO, `$1${REDACTED}@`).replace(PARAMS_TAIL, "params: [redacted]").replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
|
|
66
40
|
}
|
|
67
41
|
function redactQuery(query) {
|
|
68
42
|
return query.split("&").map((pair) => {
|
|
@@ -127,64 +101,11 @@ function scrubSpan(s) {
|
|
|
127
101
|
return s;
|
|
128
102
|
}
|
|
129
103
|
|
|
130
|
-
// src/sentry-core/options.ts
|
|
131
|
-
function isTty() {
|
|
132
|
-
try {
|
|
133
|
-
return typeof process !== "undefined" && process.stdout?.isTTY === true;
|
|
134
|
-
} catch {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function buildOptions(runtime, cfg) {
|
|
139
|
-
return {
|
|
140
|
-
dsn: cfg.dsn,
|
|
141
|
-
environment: cfg.environment,
|
|
142
|
-
release: cfg.release,
|
|
143
|
-
sendDefaultPii: false,
|
|
144
|
-
dataCollection: {
|
|
145
|
-
userInfo: false,
|
|
146
|
-
cookies: false,
|
|
147
|
-
httpHeaders: { request: false, response: false },
|
|
148
|
-
httpBodies: [],
|
|
149
|
-
databaseQueryData: false,
|
|
150
|
-
stackFrameVariables: false,
|
|
151
|
-
genAI: { inputs: false, outputs: false },
|
|
152
|
-
urlQueryParams: { deny: [...SECRET_PARAMS] }
|
|
153
|
-
},
|
|
154
|
-
enableLogs: true,
|
|
155
|
-
tracesSampler: createTracesSampler({
|
|
156
|
-
production: cfg.environment === "production",
|
|
157
|
-
readRate: cfg.readSampleRate,
|
|
158
|
-
healthPath: cfg.healthPath
|
|
159
|
-
}),
|
|
160
|
-
tracePropagationTargets: runtime === "browser" ? [/^\//] : cfg.connOrigins,
|
|
161
|
-
beforeSend: scrubEvent,
|
|
162
|
-
beforeSendTransaction: scrubEvent,
|
|
163
|
-
beforeSendLog: scrubLog,
|
|
164
|
-
beforeSendSpan: scrubSpan,
|
|
165
|
-
initialScope: { tags: cfg.tags },
|
|
166
|
-
...cfg.local ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? "line", color: runtime !== "browser" && isTty() }) } : {}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/sentry-core/init.ts
|
|
171
|
-
var DONE = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-initialised");
|
|
172
|
-
var holder = globalThis;
|
|
173
|
-
function initSentry(sentry, runtime, cfg, extra = {}) {
|
|
174
|
-
if (!cfg || holder[DONE]) return false;
|
|
175
|
-
holder[DONE] = true;
|
|
176
|
-
try {
|
|
177
|
-
const extras = typeof extra === "function" ? extra() : extra;
|
|
178
|
-
sentry.init({ ...extras, ...buildOptions(runtime, cfg) });
|
|
179
|
-
} catch (err) {
|
|
180
|
-
console.error("[qore] Sentry init failed", err);
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) });
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
104
|
export {
|
|
188
|
-
|
|
105
|
+
SECRET_PARAMS,
|
|
106
|
+
registerSecretValues,
|
|
107
|
+
scrubEvent,
|
|
108
|
+
scrubLog,
|
|
109
|
+
scrubSpan
|
|
189
110
|
};
|
|
190
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-IFESUTF2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry-core/scrub.ts"],"sourcesContent":["export const REDACTED = \"●●●\"\n\n// Bounded and anchored (`(?<![...])` + `{1,64}` local part, no `.` in the\n// domain-char class) so it cannot backtrack catastrophically on long runs of\n// email-charset bytes — see the fix-round-1 report for the O(n²) it replaced.\nconst EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\\.[A-Z0-9-]+)*\\.[A-Z]{2,}/gi\nconst URL_USERINFO = /\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/)[^/\\s:@]+(?::[^/\\s@]*)?@/gi\nconst JWT = /eyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+/g\nconst AUTH_SCHEME = /\\b(Bearer|Basic)\\s+\\S+/gi\nconst PARAMS_TAIL = /\\bparams:\\s.*$/s\nexport const SECRET_PARAMS: ReadonlySet<string> = new Set([\"token\", \"code\", \"state\", \"password\", \"secret\", \"key\", \"session\", \"access_token\", \"refresh_token\", \"id_token\"])\nconst SECRET_HEADERS = new Set([\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-qdc-connection-token\",\n \"x-forwarded-for\",\n \"x-real-ip\",\n \"forwarded\",\n \"user-agent\",\n])\nconst DROP_LOG_ATTRS = new Set([\"ip\", \"ip_address\", \"user_agent\", \"email\", \"user_email\", \"server.address\"])\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\nconst DROP_SPAN_KEYS = new Set([\"user_agent.original\", \"http.user_agent\", \"client.address\", \"http.client_ip\"])\nconst DROP_SPAN_PREFIXES = [\"http.request.header.\", \"http.response.header.\"]\nconst URL_SPAN_KEYS = new Set([\"url.full\", \"http.url\", \"url\", \"http.target\", \"url.query\", \"http.query\"])\n\nconst SECRETS = Symbol.for(\"@quatronic/sdk.sentry-secret-values\")\ntype SecretHolder = { [SECRETS]?: { values: Set<string>; longestFirst: string[] } }\nconst secretHolder = globalThis as SecretHolder\n\n// On globalThis because a Next app can bundle this module twice: the copy\n// serverEnv() registers into is not necessarily the one beforeSend reads.\nfunction secretState(): NonNullable<SecretHolder[typeof SECRETS]> {\n return (secretHolder[SECRETS] ??= { values: new Set(), longestFirst: [] })\n}\n\nexport function registerSecretValues(values: Iterable<unknown>): void {\n const state = secretState()\n for (const v of values) if (typeof v === \"string\" && v.length >= 8) state.values.add(v)\n state.longestFirst = [...state.values].sort((a, b) => b.length - a.length)\n}\n\nfunction maskSecretValues(s: string): string {\n return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s)\n}\n\nexport function redactText(s: string): string {\n return maskSecretValues(s)\n .replace(URL_USERINFO, `$1${REDACTED}@`)\n .replace(PARAMS_TAIL, \"params: [redacted]\")\n .replace(AUTH_SCHEME, \"$1 [redacted]\")\n .replace(JWT, \"[jwt]\")\n .replace(EMAIL, \"[email]\")\n}\n\nfunction redactQuery(query: string): string {\n return query\n .split(\"&\")\n .map((pair) => {\n const [k, v] = pair.split(\"=\", 2)\n return v !== undefined && SECRET_PARAMS.has(k!.toLowerCase()) ? `${k}=[redacted]` : pair\n })\n .join(\"&\")\n}\n\nfunction redactUrl(url: string): string {\n const i = url.indexOf(\"?\")\n return i < 0 ? url : url.slice(0, i + 1) + redactQuery(url.slice(i + 1))\n}\n\n// For values that are either a URL/path or a bare query string (no `?`).\nfunction redactUrlOrQuery(v: string): string {\n return v.includes(\"?\") ? redactUrl(v) : redactQuery(v)\n}\n\ntype Dict = Record<string, unknown>\n\nexport interface SentryEventLike {\n server_name?: string\n user?: Dict\n request?: { url?: string; query_string?: unknown; cookies?: unknown; headers?: Record<string, string>; data?: unknown }\n message?: string\n exception?: { values?: Array<{ type?: string; value?: string }> }\n breadcrumbs?: Array<{ message?: string; data?: Dict }>\n contexts?: { nextjs?: Dict } & Dict\n}\n\nexport function scrubEvent<E extends SentryEventLike>(e: E): E {\n delete e.server_name\n if (e.user) e.user = e.user.id ? { id: e.user.id } : {}\n if (e.request) {\n delete e.request.cookies\n delete e.request.data\n if (e.request.url) e.request.url = redactUrl(e.request.url)\n if (typeof e.request.query_string === \"string\") e.request.query_string = redactQuery(e.request.query_string)\n if (e.request.headers) {\n e.request.headers = Object.fromEntries(\n Object.entries(e.request.headers).filter(([k]) => !SECRET_HEADERS.has(k.toLowerCase())),\n )\n }\n }\n const nextjs = e.contexts?.nextjs\n if (typeof nextjs?.request_path === \"string\") nextjs.request_path = redactUrl(nextjs.request_path)\n if (e.message) e.message = redactText(e.message)\n for (const v of e.exception?.values ?? []) if (v.value) v.value = redactText(v.value)\n for (const b of e.breadcrumbs ?? []) {\n if (b.message) b.message = redactText(b.message)\n const d = b.data\n if (!d) continue\n for (const k of [\"url\", \"from\", \"to\"]) if (typeof d[k] === \"string\") d[k] = redactUrl(d[k])\n if (typeof d[\"http.query\"] === \"string\") d[\"http.query\"] = redactUrlOrQuery(d[\"http.query\"])\n if (Array.isArray(d.arguments)) d.arguments = d.arguments.map((a) => (typeof a === \"string\" ? redactText(a) : a))\n }\n return e\n}\n\nexport interface SentryLogLike {\n message: string\n attributes?: Dict\n}\n\nexport function scrubLog<L extends SentryLogLike>(l: L): L {\n l.message = redactText(l.message)\n if (l.attributes) {\n const out: Dict = {}\n for (const [k, v] of Object.entries(l.attributes)) {\n if (DROP_LOG_ATTRS.has(k)) continue\n out[k] = typeof v === \"string\" ? redactText(v) : v\n }\n l.attributes = out\n }\n return l\n}\n\nexport interface SentrySpanLike {\n description?: string\n data?: Dict\n}\n\nexport function scrubSpan<S extends SentrySpanLike>(s: S): S {\n // Browser page-metric spans are described by the full page URL.\n if (typeof s.description === \"string\") s.description = redactUrl(s.description)\n for (const [k, v] of Object.entries(s.data ?? {})) {\n if (DROP_SPAN_KEYS.has(k) || DROP_SPAN_PREFIXES.some((p) => k.startsWith(p))) delete s.data![k]\n else if (REDACT_KEYS.has(k) || REDACT_PREFIXES.some((p) => k.startsWith(p))) s.data![k] = REDACTED\n else if (typeof v === \"string\" && URL_SPAN_KEYS.has(k)) s.data![k] = redactUrlOrQuery(v)\n }\n return s\n}\n"],"mappings":";AAAO,IAAM,WAAW;AAKxB,IAAM,QAAQ;AACd,IAAM,eAAe;AACrB,IAAM,MAAM;AACZ,IAAM,cAAc;AACpB,IAAM,cAAc;AACb,IAAM,gBAAqC,oBAAI,IAAI,CAAC,SAAS,QAAQ,SAAS,YAAY,UAAU,OAAO,WAAW,gBAAgB,iBAAiB,UAAU,CAAC;AACzK,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,iBAAiB,oBAAI,IAAI,CAAC,MAAM,cAAc,cAAc,SAAS,cAAc,gBAAgB,CAAC;AAC1G,IAAM,cAAc,oBAAI,IAAI,CAAC,wBAAwB,SAAS,CAAC;AAC/D,IAAM,kBAAkB,CAAC,aAAa,aAAa,aAAa,iBAAiB,gBAAgB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ACzF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loggingEnabled,
|
|
3
3
|
readRef
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5RAO3LPF.js";
|
|
5
5
|
import {
|
|
6
6
|
defaultEnv
|
|
7
7
|
} from "./chunk-5XMTUPIY.js";
|
|
@@ -346,4 +346,4 @@ export {
|
|
|
346
346
|
IntegrationError,
|
|
347
347
|
createIntegrationClient
|
|
348
348
|
};
|
|
349
|
-
//# sourceMappingURL=chunk-
|
|
349
|
+
//# sourceMappingURL=chunk-NMJOF3ZM.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initSentry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YFZB5EW6.js";
|
|
4
4
|
import {
|
|
5
5
|
readSentryConfig
|
|
6
6
|
} from "./chunk-7ASQHY7O.js";
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
register,
|
|
18
18
|
onRequestError
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-POZI4OKJ.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setTelemetryHooks
|
|
3
|
+
} from "./chunk-MET4SIMB.js";
|
|
4
|
+
import {
|
|
5
|
+
makeDevSinkTransport
|
|
6
|
+
} from "./chunk-7ASQHY7O.js";
|
|
7
|
+
import {
|
|
8
|
+
SECRET_PARAMS,
|
|
9
|
+
scrubEvent,
|
|
10
|
+
scrubLog,
|
|
11
|
+
scrubSpan
|
|
12
|
+
} from "./chunk-IFESUTF2.js";
|
|
13
|
+
|
|
14
|
+
// src/sentry-core/noise.ts
|
|
15
|
+
var NOISE_EXACT = /* @__PURE__ */ new Set(["/favicon.ico", "/api/auth/me"]);
|
|
16
|
+
var RSC_QUERY_RE = /[?&]_rsc=/;
|
|
17
|
+
function isNoisePath(rawUrl, opts = {}) {
|
|
18
|
+
if (RSC_QUERY_RE.test(rawUrl)) return true;
|
|
19
|
+
const path = (rawUrl.split("?")[0] ?? "").trim();
|
|
20
|
+
if (!path) return false;
|
|
21
|
+
if (NOISE_EXACT.has(path)) return true;
|
|
22
|
+
if (path.endsWith(".map")) return true;
|
|
23
|
+
if (path.startsWith("/_next/")) return true;
|
|
24
|
+
if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true;
|
|
25
|
+
if (opts.healthPath && path === opts.healthPath) return true;
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/sentry-core/sampler.ts
|
|
30
|
+
var MUTATIONS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
31
|
+
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
32
|
+
function pathOf(ctx) {
|
|
33
|
+
const a = ctx.attributes ?? {};
|
|
34
|
+
return str(a["url.path"]) ?? str(a["http.target"]) ?? ctx.name.split(" ")[1];
|
|
35
|
+
}
|
|
36
|
+
function createTracesSampler(policy) {
|
|
37
|
+
return (ctx) => {
|
|
38
|
+
const path = pathOf(ctx);
|
|
39
|
+
if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0;
|
|
40
|
+
const a = ctx.attributes ?? {};
|
|
41
|
+
const method = (str(a["http.request.method"]) ?? str(a["http.method"]) ?? "").toUpperCase();
|
|
42
|
+
if (MUTATIONS.has(method)) return 1;
|
|
43
|
+
return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/sentry-core/options.ts
|
|
48
|
+
function isTty() {
|
|
49
|
+
try {
|
|
50
|
+
return typeof process !== "undefined" && process.stdout?.isTTY === true;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function buildOptions(runtime, cfg) {
|
|
56
|
+
return {
|
|
57
|
+
dsn: cfg.dsn,
|
|
58
|
+
environment: cfg.environment,
|
|
59
|
+
release: cfg.release,
|
|
60
|
+
sendDefaultPii: false,
|
|
61
|
+
dataCollection: {
|
|
62
|
+
userInfo: false,
|
|
63
|
+
cookies: false,
|
|
64
|
+
httpHeaders: { request: false, response: false },
|
|
65
|
+
httpBodies: [],
|
|
66
|
+
databaseQueryData: false,
|
|
67
|
+
stackFrameVariables: false,
|
|
68
|
+
genAI: { inputs: false, outputs: false },
|
|
69
|
+
urlQueryParams: { deny: [...SECRET_PARAMS] }
|
|
70
|
+
},
|
|
71
|
+
enableLogs: true,
|
|
72
|
+
tracesSampler: createTracesSampler({
|
|
73
|
+
production: cfg.environment === "production",
|
|
74
|
+
readRate: cfg.readSampleRate,
|
|
75
|
+
healthPath: cfg.healthPath
|
|
76
|
+
}),
|
|
77
|
+
tracePropagationTargets: runtime === "browser" ? [/^\//] : cfg.connOrigins,
|
|
78
|
+
beforeSend: scrubEvent,
|
|
79
|
+
beforeSendTransaction: scrubEvent,
|
|
80
|
+
beforeSendLog: scrubLog,
|
|
81
|
+
beforeSendSpan: scrubSpan,
|
|
82
|
+
initialScope: { tags: cfg.tags },
|
|
83
|
+
...cfg.local ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? "line", color: runtime !== "browser" && isTty() }) } : {}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/sentry-core/init.ts
|
|
88
|
+
var DONE = /* @__PURE__ */ Symbol.for("@quatronic/sdk.sentry-initialised");
|
|
89
|
+
var holder = globalThis;
|
|
90
|
+
function initSentry(sentry, runtime, cfg, extra = {}) {
|
|
91
|
+
if (!cfg || holder[DONE]) return false;
|
|
92
|
+
holder[DONE] = true;
|
|
93
|
+
try {
|
|
94
|
+
const extras = typeof extra === "function" ? extra() : extra;
|
|
95
|
+
sentry.init({ ...extras, ...buildOptions(runtime, cfg) });
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error("[qore] Sentry init failed", err);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) });
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
initSentry
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=chunk-YFZB5EW6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry-core/noise.ts","../src/sentry-core/sampler.ts","../src/sentry-core/options.ts","../src/sentry-core/init.ts"],"sourcesContent":["// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span: a `_rsc` query param, `/favicon.ico`, the SDK's\n// session poll, source maps, `/_next/*`, plus the caller's prefixes and health path.\n\nexport interface NoiseFilterOptions {\n healthPath?: string\n noisePrefixes?: string[]\n}\n\n// `/api/auth/me` is the SDK's own session poll (PortalProvider fires it on every\n// page mount): a heartbeat, not user activity.\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches carry a `?_rsc=` query param;\n// they look like real routes, so a path-prefix filter misses them.\nconst RSC_QUERY_RE = /[?&]_rsc=/\n\nexport function isNoisePath(rawUrl: string, opts: NoiseFilterOptions = {}): boolean {\n if (RSC_QUERY_RE.test(rawUrl)) return true\n const path = (rawUrl.split(\"?\")[0] ?? \"\").trim()\n if (!path) return false\n if (NOISE_EXACT.has(path)) return true\n if (path.endsWith(\".map\")) return true\n if (path.startsWith(\"/_next/\")) return true\n if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true\n if (opts.healthPath && path === opts.healthPath) return true\n return false\n}\n","import { isNoisePath } from \"./noise\"\n\nexport interface SamplingContextLike {\n name: string\n attributes?: Record<string, unknown>\n inheritOrSampleWith: (fallback: number) => number\n}\n\nconst MUTATIONS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"])\n\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v ? v : undefined)\n\nfunction pathOf(ctx: SamplingContextLike): string | undefined {\n const a = ctx.attributes ?? {}\n return str(a[\"url.path\"]) ?? str(a[\"http.target\"]) ?? ctx.name.split(\" \")[1]\n}\n\nexport function createTracesSampler(policy: { production: boolean; readRate: number; healthPath: string }) {\n return (ctx: SamplingContextLike): number => {\n const path = pathOf(ctx)\n if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0\n const a = ctx.attributes ?? {}\n const method = (str(a[\"http.request.method\"]) ?? str(a[\"http.method\"]) ?? \"\").toUpperCase()\n if (MUTATIONS.has(method)) return 1\n return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1)\n }\n}\n","import { makeDevSinkTransport } from \"./dev-sink\"\nimport type { SentryConfig } from \"./env\"\nimport { createTracesSampler, type SamplingContextLike } from \"./sampler\"\nimport { SECRET_PARAMS, scrubEvent, scrubLog, scrubSpan } from \"./scrub\"\n\nexport type Runtime = \"node\" | \"edge\" | \"browser\"\n\n// Structural copy of @sentry/core's DataCollection (10.75+): stop PII at collection,\n// the scrubbers stay as the backstop. Older 10.x ignores the unknown option.\nexport interface QoreDataCollection {\n userInfo: false\n cookies: false\n httpHeaders: { request: false; response: false }\n httpBodies: []\n databaseQueryData: false\n stackFrameVariables: false\n genAI: { inputs: false; outputs: false }\n urlQueryParams: { deny: string[] }\n}\n\nexport interface QoreSentryOptions {\n dsn: string\n environment: string\n release?: string\n sendDefaultPii: false\n dataCollection: QoreDataCollection\n enableLogs: true\n tracesSampler: (ctx: SamplingContextLike) => number\n tracePropagationTargets: Array<string | RegExp>\n beforeSend: typeof scrubEvent\n beforeSendTransaction: typeof scrubEvent\n beforeSendLog: typeof scrubLog\n beforeSendSpan: typeof scrubSpan\n initialScope: { tags: Record<string, string> }\n transport?: ReturnType<typeof makeDevSinkTransport>\n}\n\nfunction isTty(): boolean {\n try {\n return typeof process !== \"undefined\" && process.stdout?.isTTY === true\n } catch {\n return false\n }\n}\n\nexport function buildOptions(runtime: Runtime, cfg: SentryConfig): QoreSentryOptions {\n return {\n dsn: cfg.dsn,\n environment: cfg.environment,\n release: cfg.release,\n sendDefaultPii: false,\n dataCollection: {\n userInfo: false,\n cookies: false,\n httpHeaders: { request: false, response: false },\n httpBodies: [],\n databaseQueryData: false,\n stackFrameVariables: false,\n genAI: { inputs: false, outputs: false },\n urlQueryParams: { deny: [...SECRET_PARAMS] },\n },\n enableLogs: true,\n tracesSampler: createTracesSampler({\n production: cfg.environment === \"production\",\n readRate: cfg.readSampleRate,\n healthPath: cfg.healthPath,\n }),\n tracePropagationTargets: runtime === \"browser\" ? [/^\\//] : cfg.connOrigins,\n beforeSend: scrubEvent,\n beforeSendTransaction: scrubEvent,\n beforeSendLog: scrubLog,\n beforeSendSpan: scrubSpan,\n initialScope: { tags: cfg.tags },\n ...(cfg.local\n ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? \"line\", color: runtime !== \"browser\" && isTty() }) }\n : {}),\n }\n}\n","import { setTelemetryHooks } from \"../telemetry-hooks\"\nimport type { SentryConfig } from \"./env\"\nimport { buildOptions, type Runtime } from \"./options\"\n\nexport interface SentryLike {\n init(options: object): unknown\n logger: Record<\"debug\" | \"info\" | \"warn\" | \"error\", (msg: string, attrs?: Record<string, string | number | boolean>) => void>\n setUser(user: { id: string } | null): void\n}\n\nconst DONE = Symbol.for(\"@quatronic/sdk.sentry-initialised\")\ntype Holder = { [DONE]?: boolean }\nconst holder = globalThis as Holder\n\n// A factory `extra` runs only once the guard passes, inside the try: integrations\n// such as Replay throw when constructed twice.\nexport function initSentry(\n sentry: SentryLike,\n runtime: Runtime,\n cfg: SentryConfig | null,\n extra: object | (() => object) = {},\n): boolean {\n if (!cfg || holder[DONE]) return false\n holder[DONE] = true\n try {\n const extras = typeof extra === \"function\" ? extra() : extra\n sentry.init({ ...extras, ...buildOptions(runtime, cfg) })\n } catch (err) {\n console.error(\"[qore] Sentry init failed\", err)\n return false\n }\n setTelemetryHooks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,SAAS,WACd,QACA,SACA,KACA,QAAiC,CAAC,GACzB;AACT,MAAI,CAAC,OAAO,OAAO,IAAI,EAAG,QAAO;AACjC,SAAO,IAAI,IAAI;AACf,MAAI;AACF,UAAM,SAAS,OAAO,UAAU,aAAa,MAAM,IAAI;AACvD,WAAO,KAAK,EAAE,GAAG,QAAQ,GAAG,aAAa,SAAS,GAAG,EAAE,CAAC;AAAA,EAC1D,SAAS,KAAK;AACZ,YAAQ,MAAM,6BAA6B,GAAG;AAC9C,WAAO;AAAA,EACT;AACA,oBAAkB,EAAE,KAAK,OAAO,QAAQ,SAAS,CAAC,MAAM,OAAO,QAAQ,CAAC,EAAE,CAAC;AAC3E,SAAO;AACT;","names":[]}
|
|
@@ -163,9 +163,10 @@ extension file.
|
|
|
163
163
|
|
|
164
164
|
## Contract skills
|
|
165
165
|
|
|
166
|
-
\`qore-add-
|
|
167
|
-
\`qore-observability\` and \`qore-use-database\`
|
|
168
|
-
the
|
|
166
|
+
\`qore-add-env-key\`, \`qore-add-integration\`, \`qore-add-connection\`,
|
|
167
|
+
\`qore-use-permissions\`, \`qore-observability\` and \`qore-use-database\`
|
|
168
|
+
produce code the portal reads: the Secrets tab, the Integrations tab,
|
|
169
|
+
connections, roles, Monitoring, the local database. An
|
|
169
170
|
extension may add to them but not relax them, and turning one off does not turn
|
|
170
171
|
off the SDK's lint rules that check the same things.
|
|
171
172
|
|
package/dist/cli/skills.js
CHANGED
|
@@ -162,9 +162,10 @@ extension file.
|
|
|
162
162
|
|
|
163
163
|
## Contract skills
|
|
164
164
|
|
|
165
|
-
\`qore-add-
|
|
166
|
-
\`qore-observability\` and \`qore-use-database\`
|
|
167
|
-
the
|
|
165
|
+
\`qore-add-env-key\`, \`qore-add-integration\`, \`qore-add-connection\`,
|
|
166
|
+
\`qore-use-permissions\`, \`qore-observability\` and \`qore-use-database\`
|
|
167
|
+
produce code the portal reads: the Secrets tab, the Integrations tab,
|
|
168
|
+
connections, roles, Monitoring, the local database. An
|
|
168
169
|
extension may add to them but not relax them, and turning one off does not turn
|
|
169
170
|
off the SDK's lint rules that check the same things.
|
|
170
171
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IntegrationMap, a as IntegrationDefinition, E as EnvRef } from '../types-
|
|
2
|
-
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, e as IntegrationAuth, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../types-
|
|
1
|
+
import { I as IntegrationMap, a as IntegrationDefinition, E as EnvRef } from '../types-Cl7g4ego.js';
|
|
2
|
+
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, e as IntegrationAuth, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../types-Cl7g4ego.js';
|
|
3
3
|
import { E as Env } from '../env-R-bci5RU.js';
|
|
4
4
|
|
|
5
5
|
interface IntegrationProblem {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IntegrationError,
|
|
7
7
|
OAUTH_REFRESH_SKEW_MS,
|
|
8
8
|
createIntegrationClient
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NMJOF3ZM.js";
|
|
10
10
|
import {
|
|
11
11
|
AUTH_ENV_FIELDS,
|
|
12
12
|
AUTH_SECRET_FIELDS,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
loggingKey,
|
|
19
19
|
readRef,
|
|
20
20
|
requiredKeys
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-5RAO3LPF.js";
|
|
22
22
|
import {
|
|
23
23
|
PLATFORM_MANAGED_HOSTS,
|
|
24
24
|
isPlatformManagedHost
|
package/dist/next/boot/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-POZI4OKJ.js";
|
|
5
|
+
import "../../chunk-YFZB5EW6.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
|
|
9
10
|
// src/next/boot/index.ts
|
|
10
11
|
async function qoreRegister(node) {
|
|
11
12
|
await register();
|
|
12
13
|
if (process.env.NEXT_RUNTIME === "nodejs" && node) {
|
|
13
|
-
const { bootNode } = await import("../../node-
|
|
14
|
+
const { bootNode } = await import("../../node-YQDRNIYH.js");
|
|
14
15
|
await bootNode(node);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/boot/index.ts"],"sourcesContent":["// The body of a Next app's `src/instrumentation.ts`. The app passes what only\n// it can name (its env, migrations, seed); the platform's own boot steps live\n// here, so a new one reaches every app as an SDK release.\n//\n// export async function register() {\n// await qoreRegister(process.env.NEXT_RUNTIME === \"nodejs\" ? { ...loaders } : undefined)\n// // the app's own boot code, after migrations\n// }\n//\n// The ternary in the app file, and the `if` below, are what keep the Node-only\n// loaders out of the edge bundle: Next replaces NEXT_RUNTIME at build time and\n// the bundler drops the dead branch with its imports.\nimport { register as registerSentry } from \"../sentry/register\"\nimport type { NodeBoot } from \"./types\"\n\nexport { onRequestError } from \"../sentry/register\"\nexport type { NodeBoot } from \"./types\"\n\nexport async function qoreRegister(node?: NodeBoot): Promise<void> {\n await registerSentry()\n if (process.env.NEXT_RUNTIME === \"nodejs\" && node) {\n const { bootNode } = await import(\"./node\")\n await bootNode(node)\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/boot/index.ts"],"sourcesContent":["// The body of a Next app's `src/instrumentation.ts`. The app passes what only\n// it can name (its env, migrations, seed); the platform's own boot steps live\n// here, so a new one reaches every app as an SDK release.\n//\n// export async function register() {\n// await qoreRegister(process.env.NEXT_RUNTIME === \"nodejs\" ? { ...loaders } : undefined)\n// // the app's own boot code, after migrations\n// }\n//\n// The ternary in the app file, and the `if` below, are what keep the Node-only\n// loaders out of the edge bundle: Next replaces NEXT_RUNTIME at build time and\n// the bundler drops the dead branch with its imports.\nimport { register as registerSentry } from \"../sentry/register\"\nimport type { NodeBoot } from \"./types\"\n\nexport { onRequestError } from \"../sentry/register\"\nexport type { NodeBoot } from \"./types\"\n\nexport async function qoreRegister(node?: NodeBoot): Promise<void> {\n await registerSentry()\n if (process.env.NEXT_RUNTIME === \"nodejs\" && node) {\n const { bootNode } = await import(\"./node\")\n await bootNode(node)\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,eAAsB,aAAa,MAAgC;AACjE,QAAM,SAAe;AACrB,MAAI,QAAQ,IAAI,iBAAiB,YAAY,MAAM;AACjD,UAAM,EAAE,SAAS,IAAI,MAAM,OAAO,wBAAQ;AAC1C,UAAM,SAAS,IAAI;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, E as EnvRef, e as IntegrationAuth, a as IntegrationDefinition, I as IntegrationMap, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../../types-
|
|
1
|
+
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, E as EnvRef, e as IntegrationAuth, a as IntegrationDefinition, I as IntegrationMap, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../../types-Cl7g4ego.js';
|
|
2
2
|
export { DEFAULT_INTEGRATION_TIMEOUT_MS, INTEGRATION_ALIAS_ATTR, INTEGRATION_SPAN_TYPE, INTEGRATION_SPAN_TYPE_ATTR, IntegrationClient, IntegrationConfig, IntegrationError, IntegrationErrorCode, IntegrationHandle, IntegrationProblem, IntegrationRequest, OAUTH_REFRESH_SKEW_MS, PLATFORM_MANAGED_HOSTS, ParamValue, allKeys, assertIntegrations, createIntegrationClient, isPlatformManagedHost, loggingEnabled, loggingKey, readRef, requiredKeys } from '../../integrations/index.js';
|
|
3
3
|
import '../../env-R-bci5RU.js';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IntegrationError,
|
|
7
7
|
OAUTH_REFRESH_SKEW_MS,
|
|
8
8
|
createIntegrationClient
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NMJOF3ZM.js";
|
|
10
10
|
import {
|
|
11
11
|
AUTH_ENV_FIELDS,
|
|
12
12
|
AUTH_SECRET_FIELDS,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
loggingKey,
|
|
19
19
|
readRef,
|
|
20
20
|
requiredKeys
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-5RAO3LPF.js";
|
|
22
22
|
import {
|
|
23
23
|
PLATFORM_MANAGED_HOSTS,
|
|
24
24
|
isPlatformManagedHost
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
STATIC_SECURITY_HEADERS
|
|
3
|
+
} from "../../chunk-2HE2D4SY.js";
|
|
1
4
|
import {
|
|
2
5
|
proxyMatcher
|
|
3
6
|
} from "../../chunk-X6D3TBNS.js";
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
readCspReport
|
|
8
11
|
} from "../../chunk-P7HNHLW7.js";
|
|
9
12
|
import "../../chunk-FUPTRHT7.js";
|
|
10
|
-
import {
|
|
11
|
-
STATIC_SECURITY_HEADERS
|
|
12
|
-
} from "../../chunk-2HE2D4SY.js";
|
|
13
13
|
|
|
14
14
|
// src/next/security/index.ts
|
|
15
15
|
import { NextResponse as NextResponse2 } from "next/server";
|
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
} from "../../chunk-DYOSRJH3.js";
|
|
4
4
|
import {
|
|
5
5
|
initSentry
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-YFZB5EW6.js";
|
|
7
7
|
import "../../chunk-MET4SIMB.js";
|
|
8
8
|
import "../../chunk-7ASQHY7O.js";
|
|
9
|
+
import "../../chunk-IFESUTF2.js";
|
|
9
10
|
|
|
10
11
|
// src/next/sentry/client.ts
|
|
11
12
|
import * as Sentry from "@sentry/nextjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: 0,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: 0,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":";;;;;;;;;;;AAAA,YAAY,YAAY;AAMxB,IAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EAAM,eAAe;AAAA,EAAM,eAAe;AAAA,EAAM,OAAO,CAAC,sBAAsB;AAC7F;AAIO,SAAS,YAAY,KAAe,QAAgC;AACzE,QAAM,MAAM,kBAAkB,GAAG;AAEjC,SAAO;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAW;AAAA,IAAK,MACxC,KAAK,QACD,CAAC,IACD;AAAA,MACE,cAAc,CAAC,OAAO,kBAAkB,cAAc,CAAC;AAAA,MACvD,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,IAC5B;AAAA,EACN;AACF;AAEA,IAAI,OAAO,aAAa,YAAa,aAAY,UAAU,MAAM;AAE1D,IAAM,0BAAiC;","names":[]}
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
readSentryConfig
|
|
7
7
|
} from "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import {
|
|
9
|
+
registerSecretValues
|
|
10
|
+
} from "../../chunk-IFESUTF2.js";
|
|
8
11
|
|
|
9
12
|
// src/next/sentry/index.tsx
|
|
10
13
|
import { connection } from "next/server";
|
|
@@ -23,6 +26,7 @@ async function QdcSentryRuntimeConfig() {
|
|
|
23
26
|
);
|
|
24
27
|
}
|
|
25
28
|
export {
|
|
26
|
-
QdcSentryRuntimeConfig
|
|
29
|
+
QdcSentryRuntimeConfig,
|
|
30
|
+
registerSecretValues
|
|
27
31
|
};
|
|
28
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/sentry/index.tsx"],"sourcesContent":["import { connection } from \"next/server\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { RUNTIME_CONFIG_ID, serializeRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// Env is read per request: a prerendered layout would bake in the build's (empty) env.\nexport async function QdcSentryRuntimeConfig() {\n await connection()\n const cfg = readSentryConfig(process.env, { frontend: true })\n if (!cfg) return null\n return (\n <script\n id={RUNTIME_CONFIG_ID}\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: serializeRuntimeConfig(cfg) }}\n />\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/next/sentry/index.tsx"],"sourcesContent":["import { connection } from \"next/server\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { RUNTIME_CONFIG_ID, serializeRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// Env is read per request: a prerendered layout would bake in the build's (empty) env.\nexport async function QdcSentryRuntimeConfig() {\n await connection()\n const cfg = readSentryConfig(process.env, { frontend: true })\n if (!cfg) return null\n return (\n <script\n id={RUNTIME_CONFIG_ID}\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: serializeRuntimeConfig(cfg) }}\n />\n )\n}\n\nexport { registerSecretValues } from \"../../sentry-core/scrub\"\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAUvB;AALJ,eAAsB,yBAAyB;AAC7C,QAAM,WAAW;AACjB,QAAM,MAAM,iBAAiB,QAAQ,KAAK,EAAE,UAAU,KAAK,CAAC;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ,MAAK;AAAA,MACL,yBAAyB,EAAE,QAAQ,uBAAuB,GAAG,EAAE;AAAA;AAAA,EACjE;AAEJ;","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-POZI4OKJ.js";
|
|
5
|
+
import "../../chunk-YFZB5EW6.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
export {
|
|
9
10
|
onRequestError,
|
|
10
11
|
register
|
package/dist/node/boot/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, E as EnvRef, e as IntegrationAuth, a as IntegrationDefinition, I as IntegrationMap, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../../types-
|
|
1
|
+
export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, E as EnvRef, e as IntegrationAuth, a as IntegrationDefinition, I as IntegrationMap, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../../types-Cl7g4ego.js';
|
|
2
2
|
export { DEFAULT_INTEGRATION_TIMEOUT_MS, INTEGRATION_ALIAS_ATTR, INTEGRATION_SPAN_TYPE, INTEGRATION_SPAN_TYPE_ATTR, IntegrationClient, IntegrationConfig, IntegrationError, IntegrationErrorCode, IntegrationHandle, IntegrationProblem, IntegrationRequest, OAUTH_REFRESH_SKEW_MS, PLATFORM_MANAGED_HOSTS, ParamValue, allKeys, assertIntegrations, createIntegrationClient, isPlatformManagedHost, loggingEnabled, loggingKey, readRef, requiredKeys } from '../../integrations/index.js';
|
|
3
3
|
import '../../env-R-bci5RU.js';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IntegrationError,
|
|
7
7
|
OAUTH_REFRESH_SKEW_MS,
|
|
8
8
|
createIntegrationClient
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NMJOF3ZM.js";
|
|
10
10
|
import {
|
|
11
11
|
AUTH_ENV_FIELDS,
|
|
12
12
|
AUTH_SECRET_FIELDS,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
loggingKey,
|
|
19
19
|
readRef,
|
|
20
20
|
requiredKeys
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-5RAO3LPF.js";
|
|
22
22
|
import {
|
|
23
23
|
PLATFORM_MANAGED_HOSTS,
|
|
24
24
|
isPlatformManagedHost
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initSentry
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-YFZB5EW6.js";
|
|
4
4
|
import "../../chunk-MET4SIMB.js";
|
|
5
5
|
import {
|
|
6
6
|
readSentryConfig
|
|
7
7
|
} from "../../chunk-7ASQHY7O.js";
|
|
8
|
+
import "../../chunk-IFESUTF2.js";
|
|
8
9
|
|
|
9
10
|
// src/node/sentry/register.ts
|
|
10
11
|
import * as Sentry from "@sentry/node";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/node/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\ninitSentry(Sentry, \"node\", readSentryConfig(process.env, { frontend: false }))\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/node/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\ninitSentry(Sentry, \"node\", readSentryConfig(process.env, { frontend: false }))\n"],"mappings":";;;;;;;;;;AAAA,YAAY,YAAY;AAIxB,WAAW,QAAQ,QAAQ,iBAAiB,QAAQ,KAAK,EAAE,UAAU,MAAM,CAAC,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertIntegrations
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5RAO3LPF.js";
|
|
4
4
|
import "./chunk-5XMTUPIY.js";
|
|
5
5
|
|
|
6
6
|
// src/next/boot/node.ts
|
|
@@ -30,4 +30,4 @@ async function bootNode(boot) {
|
|
|
30
30
|
export {
|
|
31
31
|
bootNode
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=node-
|
|
33
|
+
//# sourceMappingURL=node-YQDRNIYH.js.map
|
|
@@ -64,8 +64,13 @@ declare function defineIntegrations<const M extends IntegrationMap>(map: M): M;
|
|
|
64
64
|
* declaration without evaluating app code.
|
|
65
65
|
*/
|
|
66
66
|
declare const AUTH_ENV_FIELDS: Record<AuthKind, readonly string[]>;
|
|
67
|
-
/**
|
|
68
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Auth fields whose env value is a secret, so the portal locks it whatever
|
|
69
|
+
* `env.ts` labels it. The identifier of a login counts with its secret:
|
|
70
|
+
* `username` sits with `password` and `clientId` with `clientSecret`, because
|
|
71
|
+
* that is where a person looks for them and they are replaced together.
|
|
72
|
+
*/
|
|
73
|
+
declare const AUTH_SECRET_FIELDS: readonly ["apiKey", "token", "username", "password", "clientId", "clientSecret"];
|
|
69
74
|
/**
|
|
70
75
|
* Env keys under this prefix belong to the platform
|
|
71
76
|
* (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatronic/sdk",
|
|
3
|
-
"version": "0.8.0-
|
|
3
|
+
"version": "0.8.0-test.3e82420",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"types": "./dist/next/sentry/client.d.ts",
|
|
49
49
|
"import": "./dist/next/sentry/client.js"
|
|
50
50
|
},
|
|
51
|
+
"./node/sentry": {
|
|
52
|
+
"types": "./dist/node/sentry/index.d.ts",
|
|
53
|
+
"import": "./dist/node/sentry/index.js"
|
|
54
|
+
},
|
|
51
55
|
"./node/sentry/register": {
|
|
52
56
|
"types": "./dist/node/sentry/register.d.ts",
|
|
53
57
|
"import": "./dist/node/sentry/register.js"
|
package/skills/catalog.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
{"name": "qore-add-api-route", "kind": "convenience", "requires": ["runtime=next"], "legacyNames": ["quatronic-add-api-route"]},
|
|
4
4
|
{"name": "qore-add-connection", "kind": "contract", "legacyNames": ["quatronic-add-connection"]},
|
|
5
5
|
{"name": "qore-add-db-table", "kind": "convenience", "requires": ["runtime=next", "db"], "legacyNames": ["quatronic-add-db-table"]},
|
|
6
|
+
{"name": "qore-add-env-key", "kind": "contract"},
|
|
6
7
|
{"name": "qore-add-feature", "kind": "convenience", "requires": ["runtime=next"], "legacyNames": ["quatronic-add-feature"]},
|
|
7
8
|
{"name": "qore-add-integration", "kind": "contract", "legacyNames": ["quatronic-add-integration"]},
|
|
8
9
|
{"name": "qore-add-page", "kind": "convenience", "requires": ["runtime=next"], "legacyNames": ["quatronic-add-page"]},
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qore-add-env-key
|
|
3
|
+
description: Add an env key to src/config/env.ts and decide whether it is a secret or configuration (`.meta({ kind: "config" })`). Use whenever this app reads a new environment variable, or when a key shows up under the wrong heading in the portal.
|
|
4
|
+
allowed-tools: Edit, Read
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Add an env key
|
|
8
|
+
|
|
9
|
+
`src/config/env.ts` is the one list of env this app reads. The manifest
|
|
10
|
+
extractor reads it on every deploy and sends the portal each key's **name**
|
|
11
|
+
(never its value), whether it is optional, and whether it is labelled
|
|
12
|
+
configuration. Values are set per environment in the portal's Secrets tab.
|
|
13
|
+
|
|
14
|
+
## 1. Declare it
|
|
15
|
+
|
|
16
|
+
Add the key to the zod server schema, and to `.env.example` with a blank value
|
|
17
|
+
(never a real one). A required key that is unset fails the env parse, so make a
|
|
18
|
+
key required only when the app cannot work without it; otherwise add
|
|
19
|
+
`.optional()`.
|
|
20
|
+
|
|
21
|
+
## 2. Secret or configuration?
|
|
22
|
+
|
|
23
|
+
Every key is a **secret** unless you label it configuration:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
SAP_BASE_URL: z.string().url().meta({ kind: "config" }),
|
|
27
|
+
SAP_CLIENT_ID: z.string().min(1),
|
|
28
|
+
SAP_CLIENT_SECRET: z.string().min(1),
|
|
29
|
+
SAP_COMPANY_CODE: z.string().min(1).meta({ kind: "config" }),
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The label decides two things in the portal: where a person looks for the key
|
|
33
|
+
(Secrets or Configuration), and whether it is governed as a secret (age,
|
|
34
|
+
rotation reminders, findings). So judge a key by what it belongs to, not only
|
|
35
|
+
by what leaking it would cost.
|
|
36
|
+
|
|
37
|
+
- **Secret:** everything that belongs to a login. That is the secret itself
|
|
38
|
+
**and** the identifier paired with it: client id + client secret, username +
|
|
39
|
+
password, key id + key. It also covers any value with a credential embedded in
|
|
40
|
+
it (a database URL with a password, a webhook URL carrying a token). These are
|
|
41
|
+
looked up together, aged together and replaced together, so a client id
|
|
42
|
+
labelled config ends up on a different screen from its secret.
|
|
43
|
+
- **Configuration** (`.meta({ kind: "config" })`): everything that says *where*
|
|
44
|
+
or *how* to call something. That includes URLs, hosts, ports, paths, realm /
|
|
45
|
+
tenant / company codes, timeouts, retries, feature flags, public keys and
|
|
46
|
+
certificates, and anything shipped to the browser.
|
|
47
|
+
- **In doubt:** ask the user. Do not pick a side yourself.
|
|
48
|
+
|
|
49
|
+
A key with more than one environment counts as configuration only when every
|
|
50
|
+
environment's `env.ts` labels it so. An integration's credential fields
|
|
51
|
+
(`apiKey`, `token`, `username`, `password`, `clientId`, `clientSecret`; see
|
|
52
|
+
/qore-add-integration) are always shown as secrets on the Integrations tab,
|
|
53
|
+
whatever the label says, so never label one of them config.
|
|
54
|
+
|
|
55
|
+
## Don't
|
|
56
|
+
|
|
57
|
+
- **Don't** put a real value in `.env.example`, in code, or in a log line.
|
|
@@ -90,14 +90,19 @@ the app cannot do its job without that integration; otherwise mark it
|
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
92
|
// inside serverSchema = z.object({ ... })
|
|
93
|
-
SAP_BASE_URL: z.string().url(),
|
|
94
|
-
SAP_TOKEN_URL: z.string().url(),
|
|
93
|
+
SAP_BASE_URL: z.string().url().meta({ kind: "config" }),
|
|
94
|
+
SAP_TOKEN_URL: z.string().url().meta({ kind: "config" }),
|
|
95
95
|
SAP_CLIENT_ID: z.string().min(1),
|
|
96
96
|
SAP_CLIENT_SECRET: z.string().min(1),
|
|
97
|
-
SAP_COMPANY_CODE: z.string().min(1),
|
|
98
|
-
SAP_TIMEOUT_MS: z.coerce.number().optional(),
|
|
97
|
+
SAP_COMPANY_CODE: z.string().min(1).meta({ kind: "config" }),
|
|
98
|
+
SAP_TIMEOUT_MS: z.coerce.number().optional().meta({ kind: "config" }),
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
URLs, codes and timeouts are configuration, so they carry
|
|
102
|
+
`.meta({ kind: "config" })`. The client id stays unlabelled, a secret beside
|
|
103
|
+
the client secret, because it belongs to the same login. /qore-add-env-key has
|
|
104
|
+
the rule; in doubt, ask the user.
|
|
105
|
+
|
|
101
106
|
Add the same keys to `.env.example` with a blank value (never a real one), so
|
|
102
107
|
a colleague's `pnpm bootstrap` knows what to ask the portal for. Then set the
|
|
103
108
|
values per environment in the portal's Secrets tab; the Integrations tab shows
|
|
@@ -197,9 +202,10 @@ per call (`qore.integration.call`: alias, method, template, status, duration).
|
|
|
197
202
|
declaration; the client refuses `http(s)://…` paths (`absolute_url`), which is
|
|
198
203
|
what keeps a path parameter from redirecting a call to another host.
|
|
199
204
|
- **Don't put a credential in `config`, in `.env.example`, or in a log line.**
|
|
200
|
-
`apiKey` / `token` / `
|
|
201
|
-
SDK never logs them and neither should you. A
|
|
202
|
-
error carry no secret, so reporting one is safe;
|
|
205
|
+
`apiKey` / `token` / `username` / `password` / `clientId` / `clientSecret`
|
|
206
|
+
are the secret fields; the SDK never logs them and neither should you. A
|
|
207
|
+
failed call's span and error carry no secret, so reporting one is safe;
|
|
208
|
+
whether to report it at all
|
|
203
209
|
follows /qore-observability (unexpected: let it throw; expected: no capture).
|
|
204
210
|
- **Don't bypass `env.ts`.** Reading `process.env.SAP_BASE_URL` directly skips
|
|
205
211
|
validation and leaves `qore env pull` unaware of the key.
|
|
@@ -90,14 +90,19 @@ the service cannot do its job without that integration; otherwise mark it
|
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
92
|
// inside `const schema = z.object({ ... })`
|
|
93
|
-
SAP_BASE_URL: z.string().url(),
|
|
94
|
-
SAP_TOKEN_URL: z.string().url(),
|
|
93
|
+
SAP_BASE_URL: z.string().url().meta({ kind: "config" }),
|
|
94
|
+
SAP_TOKEN_URL: z.string().url().meta({ kind: "config" }),
|
|
95
95
|
SAP_CLIENT_ID: z.string().min(1),
|
|
96
96
|
SAP_CLIENT_SECRET: z.string().min(1),
|
|
97
|
-
SAP_COMPANY_CODE: z.string().min(1),
|
|
98
|
-
SAP_TIMEOUT_MS: z.coerce.number().optional(),
|
|
97
|
+
SAP_COMPANY_CODE: z.string().min(1).meta({ kind: "config" }),
|
|
98
|
+
SAP_TIMEOUT_MS: z.coerce.number().optional().meta({ kind: "config" }),
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
URLs, codes and timeouts are configuration, so they carry
|
|
102
|
+
`.meta({ kind: "config" })`. The client id stays unlabelled, a secret beside
|
|
103
|
+
the client secret, because it belongs to the same login. /qore-add-env-key has
|
|
104
|
+
the rule; in doubt, ask the user.
|
|
105
|
+
|
|
101
106
|
Add the same keys to `.env.example` with a blank value (never a real one), so
|
|
102
107
|
a colleague's `pnpm bootstrap` knows what to ask the portal for. Then set the
|
|
103
108
|
values per environment in the portal's Secrets tab; the Integrations tab shows
|
|
@@ -197,9 +202,10 @@ per call (`qore.integration.call`: alias, method, template, status, duration).
|
|
|
197
202
|
declaration; the client refuses `http(s)://…` paths (`absolute_url`), which is
|
|
198
203
|
what keeps a path parameter from redirecting a call to another host.
|
|
199
204
|
- **Don't put a credential in `config`, in `.env.example`, or in a log line.**
|
|
200
|
-
`apiKey` / `token` / `
|
|
201
|
-
SDK never logs them and neither should you. A
|
|
202
|
-
error carry no secret, so reporting one is safe;
|
|
205
|
+
`apiKey` / `token` / `username` / `password` / `clientId` / `clientSecret`
|
|
206
|
+
are the secret fields; the SDK never logs them and neither should you. A
|
|
207
|
+
failed call's span and error carry no secret, so reporting one is safe;
|
|
208
|
+
whether to report it at all
|
|
203
209
|
follows /qore-observability (unexpected: let it throw; expected: no capture).
|
|
204
210
|
- **Don't bypass `env.ts`.** Reading `process.env.SAP_BASE_URL` directly skips
|
|
205
211
|
validation and leaves `qore env pull` unaware of the key.
|
|
@@ -40,6 +40,7 @@ Code written with these skills is read by the portal:
|
|
|
40
40
|
|
|
41
41
|
| Skill | What the portal reads |
|
|
42
42
|
|---|---|
|
|
43
|
+
| `qore-add-env-key` | The Secrets tab: which keys are secrets, which configuration |
|
|
43
44
|
| `qore-add-integration` | The Integrations tab |
|
|
44
45
|
| `qore-add-connection` | Connection wiring |
|
|
45
46
|
| `qore-use-permissions` | Roles on the Access page |
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sentry-core/noise.ts","../src/sentry-core/sampler.ts","../src/sentry-core/scrub.ts","../src/sentry-core/options.ts","../src/sentry-core/init.ts"],"sourcesContent":["// Pure predicate deciding whether an HTTP request is infrastructural noise that\n// should never become a span: a `_rsc` query param, `/favicon.ico`, the SDK's\n// session poll, source maps, `/_next/*`, plus the caller's prefixes and health path.\n\nexport interface NoiseFilterOptions {\n healthPath?: string\n noisePrefixes?: string[]\n}\n\n// `/api/auth/me` is the SDK's own session poll (PortalProvider fires it on every\n// page mount): a heartbeat, not user activity.\nconst NOISE_EXACT = new Set([\"/favicon.ico\", \"/api/auth/me\"])\n\n// React Server Components navigations/prefetches carry a `?_rsc=` query param;\n// they look like real routes, so a path-prefix filter misses them.\nconst RSC_QUERY_RE = /[?&]_rsc=/\n\nexport function isNoisePath(rawUrl: string, opts: NoiseFilterOptions = {}): boolean {\n if (RSC_QUERY_RE.test(rawUrl)) return true\n const path = (rawUrl.split(\"?\")[0] ?? \"\").trim()\n if (!path) return false\n if (NOISE_EXACT.has(path)) return true\n if (path.endsWith(\".map\")) return true\n if (path.startsWith(\"/_next/\")) return true\n if ((opts.noisePrefixes ?? []).some((p) => path.startsWith(p))) return true\n if (opts.healthPath && path === opts.healthPath) return true\n return false\n}\n","import { isNoisePath } from \"./noise\"\n\nexport interface SamplingContextLike {\n name: string\n attributes?: Record<string, unknown>\n inheritOrSampleWith: (fallback: number) => number\n}\n\nconst MUTATIONS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"])\n\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v ? v : undefined)\n\nfunction pathOf(ctx: SamplingContextLike): string | undefined {\n const a = ctx.attributes ?? {}\n return str(a[\"url.path\"]) ?? str(a[\"http.target\"]) ?? ctx.name.split(\" \")[1]\n}\n\nexport function createTracesSampler(policy: { production: boolean; readRate: number; healthPath: string }) {\n return (ctx: SamplingContextLike): number => {\n const path = pathOf(ctx)\n if (path && isNoisePath(path, { healthPath: policy.healthPath })) return 0\n const a = ctx.attributes ?? {}\n const method = (str(a[\"http.request.method\"]) ?? str(a[\"http.method\"]) ?? \"\").toUpperCase()\n if (MUTATIONS.has(method)) return 1\n return ctx.inheritOrSampleWith(policy.production ? policy.readRate : 1)\n }\n}\n","export const REDACTED = \"●●●\"\n\n// Bounded and anchored (`(?<![...])` + `{1,64}` local part, no `.` in the\n// domain-char class) so it cannot backtrack catastrophically on long runs of\n// email-charset bytes — see the fix-round-1 report for the O(n²) it replaced.\nconst EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\\.[A-Z0-9-]+)*\\.[A-Z]{2,}/gi\nconst JWT = /eyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+/g\nconst AUTH_SCHEME = /\\b(Bearer|Basic)\\s+\\S+/gi\nconst PARAMS_TAIL = /\\bparams:\\s.*$/s\nexport const SECRET_PARAMS: ReadonlySet<string> = new Set([\"token\", \"code\", \"state\", \"password\", \"secret\", \"key\", \"session\", \"access_token\", \"refresh_token\", \"id_token\"])\nconst SECRET_HEADERS = new Set([\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-qdc-connection-token\",\n \"x-forwarded-for\",\n \"x-real-ip\",\n \"forwarded\",\n \"user-agent\",\n])\nconst DROP_LOG_ATTRS = new Set([\"ip\", \"ip_address\", \"user_agent\", \"email\", \"user_email\", \"server.address\"])\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\nconst DROP_SPAN_KEYS = new Set([\"user_agent.original\", \"http.user_agent\", \"client.address\", \"http.client_ip\"])\nconst DROP_SPAN_PREFIXES = [\"http.request.header.\", \"http.response.header.\"]\nconst URL_SPAN_KEYS = new Set([\"url.full\", \"http.url\", \"url\", \"http.target\", \"url.query\", \"http.query\"])\n\nexport function redactText(s: string): string {\n return s\n .replace(PARAMS_TAIL, \"params: [redacted]\")\n .replace(AUTH_SCHEME, \"$1 [redacted]\")\n .replace(JWT, \"[jwt]\")\n .replace(EMAIL, \"[email]\")\n}\n\nfunction redactQuery(query: string): string {\n return query\n .split(\"&\")\n .map((pair) => {\n const [k, v] = pair.split(\"=\", 2)\n return v !== undefined && SECRET_PARAMS.has(k!.toLowerCase()) ? `${k}=[redacted]` : pair\n })\n .join(\"&\")\n}\n\nfunction redactUrl(url: string): string {\n const i = url.indexOf(\"?\")\n return i < 0 ? url : url.slice(0, i + 1) + redactQuery(url.slice(i + 1))\n}\n\n// For values that are either a URL/path or a bare query string (no `?`).\nfunction redactUrlOrQuery(v: string): string {\n return v.includes(\"?\") ? redactUrl(v) : redactQuery(v)\n}\n\ntype Dict = Record<string, unknown>\n\nexport interface SentryEventLike {\n server_name?: string\n user?: Dict\n request?: { url?: string; query_string?: unknown; cookies?: unknown; headers?: Record<string, string>; data?: unknown }\n message?: string\n exception?: { values?: Array<{ type?: string; value?: string }> }\n breadcrumbs?: Array<{ message?: string; data?: Dict }>\n contexts?: { nextjs?: Dict } & Dict\n}\n\nexport function scrubEvent<E extends SentryEventLike>(e: E): E {\n delete e.server_name\n if (e.user) e.user = e.user.id ? { id: e.user.id } : {}\n if (e.request) {\n delete e.request.cookies\n delete e.request.data\n if (e.request.url) e.request.url = redactUrl(e.request.url)\n if (typeof e.request.query_string === \"string\") e.request.query_string = redactQuery(e.request.query_string)\n if (e.request.headers) {\n e.request.headers = Object.fromEntries(\n Object.entries(e.request.headers).filter(([k]) => !SECRET_HEADERS.has(k.toLowerCase())),\n )\n }\n }\n const nextjs = e.contexts?.nextjs\n if (typeof nextjs?.request_path === \"string\") nextjs.request_path = redactUrl(nextjs.request_path)\n if (e.message) e.message = redactText(e.message)\n for (const v of e.exception?.values ?? []) if (v.value) v.value = redactText(v.value)\n for (const b of e.breadcrumbs ?? []) {\n if (b.message) b.message = redactText(b.message)\n const d = b.data\n if (!d) continue\n for (const k of [\"url\", \"from\", \"to\"]) if (typeof d[k] === \"string\") d[k] = redactUrl(d[k])\n if (typeof d[\"http.query\"] === \"string\") d[\"http.query\"] = redactUrlOrQuery(d[\"http.query\"])\n if (Array.isArray(d.arguments)) d.arguments = d.arguments.map((a) => (typeof a === \"string\" ? redactText(a) : a))\n }\n return e\n}\n\nexport interface SentryLogLike {\n message: string\n attributes?: Dict\n}\n\nexport function scrubLog<L extends SentryLogLike>(l: L): L {\n l.message = redactText(l.message)\n if (l.attributes) {\n const out: Dict = {}\n for (const [k, v] of Object.entries(l.attributes)) {\n if (DROP_LOG_ATTRS.has(k)) continue\n out[k] = typeof v === \"string\" ? redactText(v) : v\n }\n l.attributes = out\n }\n return l\n}\n\nexport interface SentrySpanLike {\n description?: string\n data?: Dict\n}\n\nexport function scrubSpan<S extends SentrySpanLike>(s: S): S {\n // Browser page-metric spans are described by the full page URL.\n if (typeof s.description === \"string\") s.description = redactUrl(s.description)\n for (const [k, v] of Object.entries(s.data ?? {})) {\n if (DROP_SPAN_KEYS.has(k) || DROP_SPAN_PREFIXES.some((p) => k.startsWith(p))) delete s.data![k]\n else if (REDACT_KEYS.has(k) || REDACT_PREFIXES.some((p) => k.startsWith(p))) s.data![k] = REDACTED\n else if (typeof v === \"string\" && URL_SPAN_KEYS.has(k)) s.data![k] = redactUrlOrQuery(v)\n }\n return s\n}\n","import { makeDevSinkTransport } from \"./dev-sink\"\nimport type { SentryConfig } from \"./env\"\nimport { createTracesSampler, type SamplingContextLike } from \"./sampler\"\nimport { SECRET_PARAMS, scrubEvent, scrubLog, scrubSpan } from \"./scrub\"\n\nexport type Runtime = \"node\" | \"edge\" | \"browser\"\n\n// Structural copy of @sentry/core's DataCollection (10.75+): stop PII at collection,\n// the scrubbers stay as the backstop. Older 10.x ignores the unknown option.\nexport interface QoreDataCollection {\n userInfo: false\n cookies: false\n httpHeaders: { request: false; response: false }\n httpBodies: []\n databaseQueryData: false\n stackFrameVariables: false\n genAI: { inputs: false; outputs: false }\n urlQueryParams: { deny: string[] }\n}\n\nexport interface QoreSentryOptions {\n dsn: string\n environment: string\n release?: string\n sendDefaultPii: false\n dataCollection: QoreDataCollection\n enableLogs: true\n tracesSampler: (ctx: SamplingContextLike) => number\n tracePropagationTargets: Array<string | RegExp>\n beforeSend: typeof scrubEvent\n beforeSendTransaction: typeof scrubEvent\n beforeSendLog: typeof scrubLog\n beforeSendSpan: typeof scrubSpan\n initialScope: { tags: Record<string, string> }\n transport?: ReturnType<typeof makeDevSinkTransport>\n}\n\nfunction isTty(): boolean {\n try {\n return typeof process !== \"undefined\" && process.stdout?.isTTY === true\n } catch {\n return false\n }\n}\n\nexport function buildOptions(runtime: Runtime, cfg: SentryConfig): QoreSentryOptions {\n return {\n dsn: cfg.dsn,\n environment: cfg.environment,\n release: cfg.release,\n sendDefaultPii: false,\n dataCollection: {\n userInfo: false,\n cookies: false,\n httpHeaders: { request: false, response: false },\n httpBodies: [],\n databaseQueryData: false,\n stackFrameVariables: false,\n genAI: { inputs: false, outputs: false },\n urlQueryParams: { deny: [...SECRET_PARAMS] },\n },\n enableLogs: true,\n tracesSampler: createTracesSampler({\n production: cfg.environment === \"production\",\n readRate: cfg.readSampleRate,\n healthPath: cfg.healthPath,\n }),\n tracePropagationTargets: runtime === \"browser\" ? [/^\\//] : cfg.connOrigins,\n beforeSend: scrubEvent,\n beforeSendTransaction: scrubEvent,\n beforeSendLog: scrubLog,\n beforeSendSpan: scrubSpan,\n initialScope: { tags: cfg.tags },\n ...(cfg.local\n ? { transport: makeDevSinkTransport({ traces: cfg.devTraces ?? \"line\", color: runtime !== \"browser\" && isTty() }) }\n : {}),\n }\n}\n","import { setTelemetryHooks } from \"../telemetry-hooks\"\nimport type { SentryConfig } from \"./env\"\nimport { buildOptions, type Runtime } from \"./options\"\n\nexport interface SentryLike {\n init(options: object): unknown\n logger: Record<\"debug\" | \"info\" | \"warn\" | \"error\", (msg: string, attrs?: Record<string, string | number | boolean>) => void>\n setUser(user: { id: string } | null): void\n}\n\nconst DONE = Symbol.for(\"@quatronic/sdk.sentry-initialised\")\ntype Holder = { [DONE]?: boolean }\nconst holder = globalThis as Holder\n\n// A factory `extra` runs only once the guard passes, inside the try: integrations\n// such as Replay throw when constructed twice.\nexport function initSentry(\n sentry: SentryLike,\n runtime: Runtime,\n cfg: SentryConfig | null,\n extra: object | (() => object) = {},\n): boolean {\n if (!cfg || holder[DONE]) return false\n holder[DONE] = true\n try {\n const extras = typeof extra === \"function\" ? extra() : extra\n sentry.init({ ...extras, ...buildOptions(runtime, cfg) })\n } catch (err) {\n console.error(\"[qore] Sentry init failed\", err)\n return false\n }\n setTelemetryHooks({ log: sentry.logger, setUser: (u) => sentry.setUser(u) })\n return true\n}\n\nexport function resetSentryInitForTests(): void {\n delete holder[DONE]\n}\n"],"mappings":";;;;;;;;AAWA,IAAM,cAAc,oBAAI,IAAI,CAAC,gBAAgB,cAAc,CAAC;AAI5D,IAAM,eAAe;AAEd,SAAS,YAAY,QAAgB,OAA2B,CAAC,GAAY;AAClF,MAAI,aAAa,KAAK,MAAM,EAAG,QAAO;AACtC,QAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,CAAC,KAAK,IAAI,KAAK;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,YAAY,IAAI,IAAI,EAAG,QAAO;AAClC,MAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAClC,MAAI,KAAK,WAAW,SAAS,EAAG,QAAO;AACvC,OAAK,KAAK,iBAAiB,CAAC,GAAG,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,EAAG,QAAO;AACvE,MAAI,KAAK,cAAc,SAAS,KAAK,WAAY,QAAO;AACxD,SAAO;AACT;;;ACnBA,IAAM,YAAY,oBAAI,IAAI,CAAC,QAAQ,OAAO,SAAS,QAAQ,CAAC;AAE5D,IAAM,MAAM,CAAC,MAAoC,OAAO,MAAM,YAAY,IAAI,IAAI;AAElF,SAAS,OAAO,KAA8C;AAC5D,QAAM,IAAI,IAAI,cAAc,CAAC;AAC7B,SAAO,IAAI,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,aAAa,CAAC,KAAK,IAAI,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AA,IAChB,cAAc,EAAE,MAAM,IAAI,KAAK;AAAA,IAC/B,GAAI,IAAI,QACJ,EAAE,WAAW,qBAAqB,EAAE,QAAQ,IAAI,aAAa,QAAQ,OAAO,YAAY,aAAa,MAAM,EAAE,CAAC,EAAE,IAChH,CAAC;AAAA,EACP;AACF;;;ACnEA,IAAM,OAAO,uBAAO,IAAI,mCAAmC;AAE3D,IAAM,SAAS;AAIR,SAAS,WACd,QACA,SACA,KACA,QAAiC,CAAC,GACzB;AACT,MAAI,CAAC,OAAO,OAAO,IAAI,EAAG,QAAO;AACjC,SAAO,IAAI,IAAI;AACf,MAAI;AACF,UAAM,SAAS,OAAO,UAAU,aAAa,MAAM,IAAI;AACvD,WAAO,KAAK,EAAE,GAAG,QAAQ,GAAG,aAAa,SAAS,GAAG,EAAE,CAAC;AAAA,EAC1D,SAAS,KAAK;AACZ,YAAQ,MAAM,6BAA6B,GAAG;AAC9C,WAAO;AAAA,EACT;AACA,oBAAkB,EAAE,KAAK,OAAO,QAAQ,SAAS,CAAC,MAAM,OAAO,QAAQ,CAAC,EAAE,CAAC;AAC3E,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/integrations-core/types.ts","../src/integrations-core/env.ts","../src/integrations-core/assertIntegrations.ts"],"sourcesContent":["/**\n * How an integration authenticates. Every field except `header` and\n * `credentialsIn` names an **env key** — the SDK reads the value from the\n * environment at call time, never from the declaration — so a declaration can\n * sit in source control and carry no secret.\n */\nexport type AuthKind =\n | \"none\"\n | \"api_key_header\"\n | \"bearer_static\"\n | \"basic\"\n | \"oauth2_client_credentials\"\n\n/** What the API speaks. Informational for the portal; the client sends bytes either way. */\nexport type Protocol = \"rest\" | \"odata\" | \"soap\" | \"graphql\"\n\n/** The name of an env var, e.g. `SAP_BASE_URL`. */\nexport type EnvKey = string\n\n/**\n * A reference to an env var. The short form is required; the object form can\n * be optional and carry a default the app falls back on when the key is unset.\n */\nexport type EnvRef =\n | EnvKey\n | { key: EnvKey; optional?: boolean; default?: string | number | boolean }\n\nexport type IntegrationAuth =\n | { kind: \"none\" }\n | { kind: \"api_key_header\"; header: string; apiKey: EnvKey }\n | { kind: \"bearer_static\"; token: EnvKey }\n | { kind: \"basic\"; username: EnvKey; password: EnvKey }\n | {\n kind: \"oauth2_client_credentials\"\n tokenUrl: EnvKey\n clientId: EnvKey\n clientSecret: EnvKey\n scope?: EnvKey\n audience?: EnvKey\n /** Where the client credentials go on the token request. Default `\"header\"`. */\n credentialsIn?: \"header\" | \"body\"\n }\n\nexport interface IntegrationDefinition {\n /** Human name shown in the portal, e.g. \"SAP S/4HANA Cloud\". */\n label: string\n protocol: Protocol\n /** Env key holding the base URL for this environment. */\n baseUrl: EnvKey\n auth: IntegrationAuth\n /** Further env the app reads for this integration, by logical name. */\n config?: Record<string, EnvRef>\n}\n\nexport type IntegrationMap = Record<string, IntegrationDefinition>\n\n/**\n * Identity function that pins the literal types of the map, so an alias typo\n * at a call site is a compile error (`keyof M`) rather than a runtime\n * `not_declared`. Same shape as `definePermissions` in `auth-core`.\n */\nexport function defineIntegrations<const M extends IntegrationMap>(map: M): M {\n return map\n}\n\n/**\n * Which fields of each auth kind name an env key. Shared with the manifest\n * extractor and the portal, which derive the required-env list from a\n * declaration without evaluating app code.\n */\nexport const AUTH_ENV_FIELDS: Record<AuthKind, readonly string[]> = {\n none: [],\n api_key_header: [\"apiKey\"],\n bearer_static: [\"token\"],\n basic: [\"username\", \"password\"],\n oauth2_client_credentials: [\"tokenUrl\", \"clientId\", \"clientSecret\", \"scope\", \"audience\"],\n}\n\n/** Auth fields whose env value is a secret, so the portal masks it. */\nexport const AUTH_SECRET_FIELDS = [\"apiKey\", \"token\", \"password\", \"clientSecret\"] as const\n\n/**\n * Env keys under this prefix belong to the platform\n * (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.\n */\nexport const RESERVED_KEY_PREFIX = \"QORE_INTEGRATION_\"\n","import { normalizeAlias, type Env } from \"../connections-core/env\"\nimport {\n AUTH_ENV_FIELDS,\n RESERVED_KEY_PREFIX,\n type EnvRef,\n type IntegrationDefinition,\n} from \"./types\"\n\nexport type { Env }\n\nexport function refKey(ref: EnvRef): string {\n return typeof ref === \"string\" ? ref : ref.key\n}\n\nfunction refOptional(ref: EnvRef): boolean {\n return typeof ref !== \"string\" && (ref.optional === true || ref.default !== undefined)\n}\n\n/** The auth fields of `def` that are set, as env keys. */\nfunction authKeys(def: IntegrationDefinition): string[] {\n const auth = def.auth as unknown as Record<string, unknown>\n return AUTH_ENV_FIELDS[def.auth.kind]\n .map((field) => auth[field])\n .filter((key): key is string => typeof key === \"string\" && key !== \"\")\n}\n\n/**\n * Every env key the integration cannot run without: the base URL, every auth\n * field that is set, and every config ref that is neither optional nor\n * defaulted. Order is stable so an error message reads the same twice.\n */\nexport function requiredKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) {\n if (!refOptional(ref)) keys.push(refKey(ref))\n }\n return [...new Set(keys)]\n}\n\n/** Every env key the declaration names, required or not. */\nexport function allKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) keys.push(refKey(ref))\n return [...new Set(keys)]\n}\n\n/**\n * Read one ref from `env`, applying its default when the key is unset or\n * empty. A default comes back as declared (a number or boolean stays typed);\n * an env value is always a string.\n */\nexport function readRef(env: Env, ref: EnvRef): string | number | boolean | undefined {\n const value = env[refKey(ref)]\n if (value !== undefined && value !== \"\") return value\n return typeof ref === \"string\" ? undefined : ref.default\n}\n\n/** `QORE_INTEGRATION_<ALIAS>_LOGGING` — the one reserved key v1 reads. */\nexport function loggingKey(alias: string): string {\n return `${RESERVED_KEY_PREFIX}${normalizeAlias(alias)}_LOGGING`\n}\n\n/** Whether the per-call JSON log line is switched on for this alias (\"1\" or \"true\"). */\nexport function loggingEnabled(env: Env, alias: string): boolean {\n const value = env[loggingKey(alias)]\n return value === \"1\" || value?.toLowerCase() === \"true\"\n}\n","import { defaultEnv, type Env } from \"../connections-core/env\"\nimport { allKeys, requiredKeys } from \"./env\"\nimport { RESERVED_KEY_PREFIX, type IntegrationMap } from \"./types\"\n\nconst ENV_KEY_RE = /^[A-Z][A-Z0-9_]*$/\n\nexport interface IntegrationProblem {\n alias: string\n key: string\n /** `missing_env`: a required key is unset or empty. `reserved_key`: the declaration claims a key it may not. */\n code: \"missing_env\" | \"reserved_key\"\n message: string\n}\n\n/**\n * Report, at app startup, what is wrong with the declared integrations: a\n * required env key that is unset, or a key the declaration may not claim.\n * **It never throws.** Integrations are a visibility tool: an API key that is\n * not set (an obsolete integration, a vendor not contracted in this\n * environment) must cost the calls to that one integration — they fail with\n * `missing_env` — never the boot of the whole app. Each problem is logged as\n * one warning and returned, so a caller may act on them if it chooses.\n */\nexport function assertIntegrations(\n map: IntegrationMap,\n opts: { env?: Env; warn?: (message: string) => void } = {},\n): IntegrationProblem[] {\n const env = opts.env ?? defaultEnv()\n const warn = opts.warn ?? ((message: string) => console.warn(message))\n const problems: IntegrationProblem[] = []\n\n for (const [alias, def] of Object.entries(map)) {\n for (const key of allKeys(def)) {\n let why: string | undefined\n if (key.startsWith(RESERVED_KEY_PREFIX)) {\n why = `${RESERVED_KEY_PREFIX}* keys are reserved by the platform`\n } else if (key.startsWith(\"CONN_\")) {\n why = \"CONN_* keys belong to module connections, not integrations\"\n } else if (!ENV_KEY_RE.test(key)) {\n why = \"an env key is uppercase letters, digits and underscores\"\n }\n if (why) {\n problems.push({\n alias,\n key,\n code: \"reserved_key\",\n message: `Integration \"${alias}\" declares env key \"${key}\": ${why}`,\n })\n }\n }\n for (const key of requiredKeys(def)) {\n const value = env[key]\n if (value === undefined || value === \"\") {\n problems.push({\n alias,\n key,\n code: \"missing_env\",\n message: `Integration \"${alias}\" is missing env key \"${key}\"; calls to it will fail until it is set`,\n })\n }\n }\n }\n\n for (const p of problems) warn(`[integrations] ${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