flare-redact 1.8.0 → 1.9.1

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/init.js CHANGED
@@ -1,43 +1,68 @@
1
1
  /**
2
2
  * `flare-redact init`: read the project's package.json, pick the integrations
3
3
  * that fit, and print the lines to paste. `--ci` also writes a GitHub workflow
4
- * that scans every pull request. It never edits source files: the output is a
4
+ * that scans every pull request, and `--hook` a git pre-commit hook that scans
5
+ * the lines each commit adds. It never edits source files: the output is a
5
6
  * plan the developer applies, so nothing changes behind their back.
6
7
  */
7
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
8
- import { dirname, join, relative } from 'node:path';
8
+ import { execFileSync } from 'node:child_process';
9
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
10
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
11
  const LLM = 'llm';
10
12
  const LOGS = 'logs';
13
+ const GDPR = 'gdpr';
14
+ /** The Sentry SDKs whose `init` takes the hooks, in the order they are checked. */
15
+ const SENTRY_SDKS = [
16
+ '@sentry/nextjs', '@sentry/node', '@sentry/nestjs', '@sentry/bun', '@sentry/deno',
17
+ '@sentry/aws-serverless', '@sentry/google-cloud-serverless', '@sentry/cloudflare',
18
+ '@sentry/sveltekit', '@sentry/nuxt', '@sentry/remix', '@sentry/astro',
19
+ '@sentry/react', '@sentry/vue', '@sentry/angular', '@sentry/svelte', '@sentry/solid',
20
+ '@sentry/browser', '@sentry/react-native', '@sentry/electron',
21
+ ];
22
+ /** The major version a range like `^11.2.0` or `>=10 <12` starts at, if it names one. */
23
+ const major = (range) => {
24
+ const found = /^[^\d]*(\d+)/.exec(range);
25
+ return found ? Number(found[1]) : undefined;
26
+ };
11
27
  /** One recipe per supported library, in the order they are printed. */
12
28
  const RECIPES = [
13
29
  {
14
- dep: 'openai',
30
+ deps: ['openai'],
15
31
  title: 'OpenAI: prompts are redacted before they leave, replies are restored',
16
- code: `import OpenAI from 'openai';
32
+ code: () => `import OpenAI from 'openai';
17
33
  import { wrapOpenAI } from 'flare-redact/llm';
18
34
 
19
35
  const openai = wrapOpenAI(new OpenAI(), { preset: '${LLM}' });`,
20
36
  },
21
37
  {
22
- dep: '@anthropic-ai/sdk',
38
+ deps: ['@anthropic-ai/sdk'],
23
39
  title: 'Anthropic: prompts are redacted before they leave, replies are restored',
24
- code: `import Anthropic from '@anthropic-ai/sdk';
40
+ code: () => `import Anthropic from '@anthropic-ai/sdk';
25
41
  import { wrapAnthropic } from 'flare-redact/llm';
26
42
 
27
43
  const anthropic = wrapAnthropic(new Anthropic(), { preset: '${LLM}' });`,
28
44
  },
29
45
  {
30
- dep: 'pino',
46
+ deps: SENTRY_SDKS,
47
+ title: 'Sentry: events, breadcrumbs, spans and logs are redacted before they are sent',
48
+ // Sentry 11 streams spans and warns about a beforeSendTransaction hook.
49
+ code: (dep, range) => `import * as Sentry from '${dep}';
50
+ import { sentryRedact } from 'flare-redact/sentry';
51
+
52
+ Sentry.init({ dsn: process.env.SENTRY_DSN, ...sentryRedact({ preset: '${GDPR}' }${(major(range) ?? 0) >= 11 ? ", { traceLifecycle: 'stream' }" : ''}) });`,
53
+ },
54
+ {
55
+ deps: ['pino'],
31
56
  title: 'pino: every log line is redacted',
32
- code: `import pino from 'pino';
57
+ code: () => `import pino from 'pino';
33
58
  import { pinoRedact } from 'flare-redact/pino';
34
59
 
35
60
  const log = pino(pinoRedact({ preset: '${LOGS}' }));`,
36
61
  },
37
62
  {
38
- dep: 'winston',
63
+ deps: ['winston'],
39
64
  title: 'winston: every log field is redacted',
40
- code: `import winston from 'winston';
65
+ code: () => `import winston from 'winston';
41
66
  import { winstonRedact } from 'flare-redact/winston';
42
67
 
43
68
  const log = winston.createLogger({
@@ -46,9 +71,9 @@ const log = winston.createLogger({
46
71
  });`,
47
72
  },
48
73
  {
49
- dep: 'express',
74
+ deps: ['express'],
50
75
  title: 'Express: log a safe copy of each request',
51
- code: `import { httpRedactor } from 'flare-redact/http';
76
+ code: () => `import { httpRedactor } from 'flare-redact/http';
52
77
 
53
78
  app.use(httpRedactor({ preset: '${LOGS}' }));
54
79
  app.use((req, _res, next) => { console.log(req.redacted()); next(); });`,
@@ -56,7 +81,10 @@ app.use((req, _res, next) => { console.log(req.redacted()); next(); });`,
56
81
  ];
57
82
  const CONSOLE_STEP = {
58
83
  title: 'console: redact everything printed with console.*',
59
- code: `import { wrapConsole } from 'flare-redact';
84
+ code: `// With no code change, start the app with:
85
+ // FLARE_REDACT_PRESET=${LOGS} node --import flare-redact/register app.js
86
+ // or call this once, before anything logs:
87
+ import { wrapConsole } from 'flare-redact';
60
88
 
61
89
  wrapConsole({ preset: '${LOGS}' });`,
62
90
  };
@@ -64,11 +92,10 @@ wrapConsole({ preset: '${LOGS}' });`,
64
92
  export function planInit(pkg) {
65
93
  const deps = { ...pkg?.devDependencies, ...pkg?.dependencies };
66
94
  const has = (name) => Object.prototype.hasOwnProperty.call(deps, name);
67
- const steps = RECIPES.filter((recipe) => has(recipe.dep)).map((recipe) => ({
68
- found: recipe.dep,
69
- title: recipe.title,
70
- code: recipe.code,
71
- }));
95
+ const steps = RECIPES.flatMap((recipe) => {
96
+ const dep = recipe.deps.find(has);
97
+ return dep ? [{ found: dep, title: recipe.title, code: recipe.code(dep, String(deps[dep] ?? '')) }] : [];
98
+ });
72
99
  // No logger found: console is the logger.
73
100
  if (!steps.some((step) => step.found === 'pino' || step.found === 'winston'))
74
101
  steps.push(CONSOLE_STEP);
@@ -92,7 +119,7 @@ export function renderInit(plan, source) {
92
119
  out.push('', `${++n}. Install`, indent('npm install flare-redact'));
93
120
  for (const step of plan.steps)
94
121
  out.push('', `${++n}. ${step.title}`, indent(step.code));
95
- out.push('', 'Presets: logs (defaults + phone numbers), llm (all personal data, names and', 'addresses in prose), gdpr (llm + network and device IDs), strict (everything).', '', 'Check the project now: npx flare-redact --scan .', 'Scan every pull request: npx flare-redact init --ci', '');
122
+ out.push('', 'Presets: logs (defaults + phone numbers), llm (all personal data, names and', 'addresses in prose), gdpr (llm + network and device IDs), strict (everything).', '', 'Check the project now: npx flare-redact --scan .', 'Check every commit: npx flare-redact init --hook', 'Scan every pull request: npx flare-redact init --ci', '');
96
123
  return out.join('\n');
97
124
  }
98
125
  /** A GitHub workflow that fails a pull request when a secret is committed. */
@@ -120,27 +147,104 @@ jobs:
120
147
  `;
121
148
  }
122
149
  export const WORKFLOW_PATH = join('.github', 'workflows', 'flare-redact.yml');
150
+ /** The line to add to a pre-commit hook that another tool manages. */
151
+ export const HOOK_COMMAND = 'npx flare-redact --scan --staged';
152
+ /**
153
+ * The git pre-commit hook `--hook` writes. It prefers the project's own copy
154
+ * and falls back to the pinned release, so it works before `npm install` too.
155
+ */
156
+ export function preCommitHook(version) {
157
+ return `#!/bin/sh
158
+ # Added by 'flare-redact init --hook': stop commits that add secrets or
159
+ # personal data. Only the lines a commit adds are scanned.
160
+ # Skip the check once with: git commit --no-verify
161
+ if ! command -v node >/dev/null 2>&1 || ! command -v npx >/dev/null 2>&1; then
162
+ # A git client started without Node on its PATH: let the commit through
163
+ # and say so, rather than block every commit from that client.
164
+ echo "flare-redact: Node not found on PATH, commit not scanned" >&2
165
+ exit 0
166
+ fi
167
+ if [ -x node_modules/.bin/flare-redact ]; then
168
+ exec node_modules/.bin/flare-redact --scan --staged
169
+ fi
170
+ exec npx --yes --package flare-redact@${version} flare-redact --scan --staged
171
+ `;
172
+ }
123
173
  export const INIT_HELP = `flare-redact init: suggest the integrations that fit this project
124
174
 
125
175
  USAGE
126
- flare-redact init [dir] [--ci] [--force]
176
+ flare-redact init [dir] [--ci] [--hook] [--force]
127
177
 
128
178
  Reads package.json in dir (default: the current directory) and prints the lines
129
- to paste for each library it recognises: openai, @anthropic-ai/sdk, pino,
130
- winston and express, with console as the fallback. It never edits source files.
179
+ to paste for each library it recognises: openai, @anthropic-ai/sdk, Sentry,
180
+ pino, winston and express, with console as the fallback. It never edits source
181
+ files.
131
182
 
132
183
  --ci also write ${WORKFLOW_PATH.split('\\').join('/')}, which runs
133
184
  'flare-redact --scan' on every pull request
134
- --force overwrite that workflow if it already exists
185
+ --hook also write a git pre-commit hook that runs
186
+ 'flare-redact --scan --staged', so a commit that adds a secret
187
+ stops before it is made (with husky, it prints the line to add)
188
+ --force overwrite that workflow or hook if it already exists
135
189
  `;
190
+ function installHook(dir, cwd, version, force) {
191
+ const git = (...args) => execFileSync('git', args, { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
192
+ let hooks;
193
+ let roots;
194
+ try {
195
+ hooks = git('rev-parse', '--git-path', 'hooks');
196
+ // resolve() also turns git's forward slashes into the platform's separator.
197
+ roots = [resolve(git('rev-parse', '--show-toplevel')), resolve(realpathSync(dir), git('rev-parse', '--git-common-dir'))]
198
+ .map((root) => (existsSync(root) ? realpathSync(root) : root));
199
+ }
200
+ catch {
201
+ process.stderr.write("--hook needs a git repository; run 'git init' first.\n");
202
+ return 2;
203
+ }
204
+ // husky owns core.hooksPath and regenerates that folder; a file written
205
+ // there would vanish, so say where the line belongs instead.
206
+ if (/(?:^|[\\/])\.husky(?:[\\/]|$)/.test(hooks)) {
207
+ process.stdout.write(`This repository runs its hooks through husky. Add this line to .husky/pre-commit:\n ${HOOK_COMMAND}\n`);
208
+ return 0;
209
+ }
210
+ // git prints real paths; resolve ours the same way (macOS /var is /private/var).
211
+ // A hooks folder that is a symlink counts as where it points.
212
+ const lexical = isAbsolute(hooks) ? resolve(hooks) : resolve(realpathSync(dir), hooks);
213
+ const hooksDir = existsSync(lexical) ? realpathSync(lexical) : lexical;
214
+ // A core.hooksPath outside the repository is shared with other projects;
215
+ // writing there would change them too.
216
+ if (!roots.some((root) => hooksDir === root || hooksDir.startsWith(root + sep))) {
217
+ process.stdout.write(`Hooks for this repository live in ${hooksDir}, outside it. Add this line to the pre-commit hook there:\n ${HOOK_COMMAND}\n`);
218
+ return 0;
219
+ }
220
+ const target = join(hooksDir, 'pre-commit');
221
+ const shown = relative(cwd, target) || target;
222
+ // lstat, not exists: a symlink counts as a hook even when it dangles, and
223
+ // is replaced by --force rather than written through.
224
+ const present = lstatSync(target, { throwIfNoEntry: false }) !== undefined;
225
+ if (present && !force) {
226
+ process.stdout.write(`${shown} already exists; left unchanged. Add this line to it, or use --force to replace it:\n ${HOOK_COMMAND}\n`);
227
+ return 0;
228
+ }
229
+ mkdirSync(hooksDir, { recursive: true });
230
+ if (present)
231
+ rmSync(target, { force: true });
232
+ writeFileSync(target, preCommitHook(version), { flag: 'wx' });
233
+ chmodSync(target, 0o755);
234
+ process.stdout.write(`Wrote ${shown}. Every commit is now scanned; skip once with git commit --no-verify.\n`);
235
+ return 0;
236
+ }
136
237
  /** Run `flare-redact init`. Returns the exit code. */
137
238
  export function runInit(argv, version, cwd = process.cwd()) {
138
239
  let dir = cwd;
139
240
  let ci = false;
241
+ let hook = false;
140
242
  let force = false;
141
243
  for (const arg of argv) {
142
244
  if (arg === '--ci')
143
245
  ci = true;
246
+ else if (arg === '--hook')
247
+ hook = true;
144
248
  else if (arg === '--force')
145
249
  force = true;
146
250
  else if (arg === '-h' || arg === '--help' || arg === 'help') {
@@ -152,7 +256,7 @@ export function runInit(argv, version, cwd = process.cwd()) {
152
256
  return 2;
153
257
  }
154
258
  else
155
- dir = join(cwd, arg);
259
+ dir = resolve(cwd, arg);
156
260
  }
157
261
  const manifest = join(dir, 'package.json');
158
262
  let pkg;
@@ -172,12 +276,13 @@ export function runInit(argv, version, cwd = process.cwd()) {
172
276
  const shown = relative(cwd, target);
173
277
  if (existsSync(target) && !force) {
174
278
  process.stdout.write(`${shown} already exists; left unchanged (use --force to overwrite).\n`);
175
- return 0;
176
279
  }
177
- mkdirSync(dirname(target), { recursive: true });
178
- writeFileSync(target, ciWorkflow(version));
179
- process.stdout.write(`Wrote ${shown}.\n`);
280
+ else {
281
+ mkdirSync(dirname(target), { recursive: true });
282
+ writeFileSync(target, ciWorkflow(version));
283
+ process.stdout.write(`Wrote ${shown}.\n`);
284
+ }
180
285
  }
181
- return 0;
286
+ return hook ? installHook(dir, cwd, version, force) : 0;
182
287
  }
183
288
  //# sourceMappingURL=init.js.map
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAuBpD,MAAM,GAAG,GAAW,KAAK,CAAC;AAC1B,MAAM,IAAI,GAAW,MAAM,CAAC;AAE5B,uEAAuE;AACvE,MAAM,OAAO,GAAgE;IAC3E;QACE,GAAG,EAAE,QAAQ;QACb,KAAK,EAAE,sEAAsE;QAC7E,IAAI,EAAE;;;qDAG2C,GAAG,OAAO;KAC5D;IACD;QACE,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,yEAAyE;QAChF,IAAI,EAAE;;;8DAGoD,GAAG,OAAO;KACrE;IACD;QACE,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,kCAAkC;QACzC,IAAI,EAAE;;;yCAG+B,IAAI,QAAQ;KAClD;IACD;QACE,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,sCAAsC;QAC7C,IAAI,EAAE;;;;2EAIiE,IAAI;;IAE3E;KACD;IACD;QACE,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,0CAA0C;QACjD,IAAI,EAAE;;kCAEwB,IAAI;wEACkC;KACrE;CACF,CAAC;AAEF,MAAM,YAAY,GAAa;IAC7B,KAAK,EAAE,mDAAmD;IAC1D,IAAI,EAAE;;yBAEiB,IAAI,OAAO;CACnC,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,GAA4B;IACnD,MAAM,IAAI,GAAG,EAAE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3
+ * application starts and every console.log, info, warn, error and debug call
4
+ * is redacted.
5
+ *
6
+ * node --import flare-redact/register app.js
7
+ * NODE_OPTIONS="--import flare-redact/register" npm start
8
+ *
9
+ * FLARE_REDACT_PRESET picks a preset (logs, llm, gdpr, strict). An unknown
10
+ * name stops the process at startup: a typo should fail the deploy, not leave
11
+ * the logs unredacted.
12
+ */
13
+ import { type RedactOptions } from './index.js';
14
+ export declare const PRESET_ENV = "FLARE_REDACT_PRESET";
15
+ /** The options the environment asks for. Throws on an unknown preset. */
16
+ export declare function registerOptions(env: Record<string, string | undefined>): RedactOptions;
17
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5E,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAEhD,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,aAAa,CAKtF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Redaction without touching the code: load this module before the
3
+ * application starts and every console.log, info, warn, error and debug call
4
+ * is redacted.
5
+ *
6
+ * node --import flare-redact/register app.js
7
+ * NODE_OPTIONS="--import flare-redact/register" npm start
8
+ *
9
+ * FLARE_REDACT_PRESET picks a preset (logs, llm, gdpr, strict). An unknown
10
+ * name stops the process at startup: a typo should fail the deploy, not leave
11
+ * the logs unredacted.
12
+ */
13
+ import { compilePolicy, wrapConsole } from './index.js';
14
+ export const PRESET_ENV = 'FLARE_REDACT_PRESET';
15
+ /** The options the environment asks for. Throws on an unknown preset. */
16
+ export function registerOptions(env) {
17
+ const preset = env[PRESET_ENV]?.trim();
18
+ const opts = preset ? { preset: preset } : {};
19
+ compilePolicy(opts);
20
+ return opts;
21
+ }
22
+ const env = typeof process === 'undefined' ? {} : process.env;
23
+ wrapConsole(registerOptions(env));
24
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAE5E,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,GAAuC;IACrE,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC;IACvC,MAAM,IAAI,GAAkB,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAiC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxF,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9D,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Sentry hooks that redact an event before it leaves the process: messages,
3
+ * exception values, stack-frame variables and source lines, request data,
4
+ * breadcrumbs, span names and Sentry Logs.
5
+ *
6
+ * Sentry.init({ dsn, ...sentryRedact({ preset: 'gdpr' }) });
7
+ *
8
+ * Sentry's own fields (event, trace, span and debug ids, release, timestamps,
9
+ * SDK metadata, the file and function of each stack frame) are put back after
10
+ * redaction, so events still group, link to their traces and resolve source
11
+ * maps even under `preset: 'strict'`. A field is put back only when both
12
+ * things hold: it sits where Sentry keeps that field (never by name alone, so
13
+ * `extra.release` is user data), and its value has the shape that field has
14
+ * (an id is hex, a release is `name@version`, a file is a path with no query
15
+ * string). A value that fails the shape stays redacted. Cookies are always
16
+ * masked whole, whatever the options say.
17
+ */
18
+ import { type RedactOptions } from './index.js';
19
+ export interface SentryRedactor {
20
+ /** Error and message events. */
21
+ beforeSend: <T>(event: T, hint?: unknown) => T;
22
+ /**
23
+ * Transactions: span descriptions (SQL, URLs) and span data. Sentry 11
24
+ * streams spans instead and ignores this hook unless `traceLifecycle` is
25
+ * `'static'`; leave it out there to avoid Sentry's notice about it.
26
+ */
27
+ beforeSendTransaction: <T>(event: T, hint?: unknown) => T;
28
+ /** Spans sent on their own: streamed spans in Sentry 11, standalone spans before. */
29
+ beforeSendSpan: <T>(span: T) => T;
30
+ /** Sentry Logs: the message and its attributes. */
31
+ beforeSendLog: <T>(log: T) => T;
32
+ /** Breadcrumbs, before they are stored on the scope. */
33
+ beforeBreadcrumb: <T>(breadcrumb: T, hint?: unknown) => T;
34
+ }
35
+ export interface SentryHookOptions {
36
+ /**
37
+ * Sentry's own `traceLifecycle`. `'stream'` (the default in Sentry 11)
38
+ * leaves out `beforeSendTransaction`, which that mode ignores and warns
39
+ * about. Leave it unset on Sentry 8 to 10, or with `'static'`.
40
+ */
41
+ traceLifecycle?: 'static' | 'stream';
42
+ }
43
+ /**
44
+ * Build the Sentry hooks once and spread them into `Sentry.init`. If you
45
+ * already have a `beforeSend`, call `hooks.beforeSend(event)` from it.
46
+ */
47
+ export declare function sentryRedact(opts: RedactOptions, sentry: {
48
+ traceLifecycle: 'stream';
49
+ }): Omit<SentryRedactor, 'beforeSendTransaction'>;
50
+ export declare function sentryRedact(opts?: RedactOptions, sentry?: SentryHookOptions): SentryRedactor;
51
+ /**
52
+ * Redact one Sentry error event or transaction. For a span, a log or a
53
+ * breadcrumb use the matching hook from `sentryRedact()`: their own fields
54
+ * sit in different places.
55
+ */
56
+ export declare function redactSentryEvent<T>(event: T, opts?: RedactOptions): T;
57
+ //# sourceMappingURL=sentry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../src/sentry.ts"],"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