@microsoft/agents-telemetry 1.10.0-beta.8.g158a2c07ad → 1.10.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.
@@ -1,121 +1,614 @@
1
+ /*! @noble/hashes
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the “Software”), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ */
1
24
  "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.redactString = redactString;
8
- exports.redactUrl = redactUrl;
9
- exports.redactScopes = redactScopes;
10
- exports.pseudonymizeConversationId = pseudonymizeConversationId;
11
- exports.redactDiagnosticObject = redactDiagnosticObject;
12
- const hmac_1 = require("@noble/hashes/hmac");
13
- const sha2_1 = require("@noble/hashes/sha2");
14
- const utils_1 = require("@noble/hashes/utils");
15
- const REDACTED_VALUE = '<redacted>';
16
- const REDACTION_PEEK_LENGTH = 2;
17
- let processLocalKey;
18
- /**
19
- * Redacts a string value, optionally allowing a peek at the beginning of the string for context.
20
- * @param value The string value to redact.
21
- * @param peek Whether to allow a peek at the beginning of the string (default: false). If true and the string is long enough, the first few characters of the string will be included in the redacted output for context before `'<redacted>'`.
22
- * @returns The redacted string, or undefined if the input value was undefined.
23
- */
24
- function redactString(value, peek = false) {
25
- if (value === undefined) {
26
- return undefined;
25
+ var __defProp = Object.defineProperty;
26
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
27
+ var __getOwnPropNames = Object.getOwnPropertyNames;
28
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
29
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, { get: all[name], enumerable: true });
33
+ };
34
+ var __copyProps = (to, from, except, desc) => {
35
+ if (from && typeof from === "object" || typeof from === "function") {
36
+ for (let key of __getOwnPropNames(from))
37
+ if (!__hasOwnProp.call(to, key) && key !== except)
38
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
39
+ }
40
+ return to;
41
+ };
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
44
+
45
+ // src/utils/redact.ts
46
+ var redact_exports = {};
47
+ __export(redact_exports, {
48
+ pseudonymizeConversationId: () => pseudonymizeConversationId,
49
+ redactDiagnosticObject: () => redactDiagnosticObject,
50
+ redactScopes: () => redactScopes,
51
+ redactString: () => redactString,
52
+ redactUrl: () => redactUrl
53
+ });
54
+ module.exports = __toCommonJS(redact_exports);
55
+
56
+ // ../../node_modules/@noble/hashes/utils.js
57
+ function isBytes(a) {
58
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
59
+ }
60
+ var atitle = (title) => title ? `"${title}" ` : "";
61
+ function anumber(n, title = "") {
62
+ if (typeof n !== "number")
63
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
64
+ if (!Number.isSafeInteger(n) || n < 0)
65
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
66
+ return n;
67
+ }
68
+ function abytes(value, length, title = "") {
69
+ if (isBytes(value) && (length === void 0 || value.length === length))
70
+ return value;
71
+ if (length !== void 0)
72
+ anumber(length, "length");
73
+ const bytes = isBytes(value);
74
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
75
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
76
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
77
+ if (!bytes)
78
+ throw new TypeError(message);
79
+ throw new RangeError(message);
80
+ }
81
+ function ahash(h) {
82
+ if (typeof h !== "function" || typeof h.create !== "function")
83
+ throw new TypeError("expected hash wrapped by utils.createHasher");
84
+ anumber(h.outputLen);
85
+ anumber(h.blockLen);
86
+ if (h.outputLen < 1 || h.blockLen < 1)
87
+ throw new Error("hash blockLen / outputLen must be >= 1");
88
+ }
89
+ var aobject = (value, label) => {
90
+ if (value === null || typeof value !== "object" || Array.isArray(value))
91
+ throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
92
+ };
93
+ var aopts = (value, label) => {
94
+ aobject(value, label);
95
+ const proto = Object.getPrototypeOf(value);
96
+ if (proto !== Object.prototype && proto !== null)
97
+ throw new TypeError(`"${label}" expected plain object`);
98
+ if (Object.hasOwn(value, "__proto__"))
99
+ throw new TypeError(`"${label}.__proto__" is not allowed`);
100
+ };
101
+ function aexists(instance, checkFinished = true) {
102
+ if (instance.destroyed)
103
+ throw new Error("hash was destroyed");
104
+ if (checkFinished && instance.finished)
105
+ throw new Error("digest() was already called");
106
+ }
107
+ function aoutput(out, instance) {
108
+ abytes(out, void 0, "output");
109
+ const min = instance.outputLen;
110
+ if (!(out.length >= min)) {
111
+ throw new RangeError('"output" expected length >= ' + min);
112
+ }
113
+ }
114
+ function clean(...arrays) {
115
+ for (let i = 0; i < arrays.length; i++) {
116
+ arrays[i].fill(0);
117
+ }
118
+ }
119
+ function createView(arr) {
120
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
121
+ }
122
+ function rotr(word, shift) {
123
+ return word << 32 - shift | word >>> shift;
124
+ }
125
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
126
+ // @ts-ignore
127
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
128
+ ))();
129
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
130
+ function bytesToHex(bytes) {
131
+ abytes(bytes);
132
+ if (hasHexBuiltin)
133
+ return bytes.toHex();
134
+ let hex = "";
135
+ for (let i = 0; i < bytes.length; i++) {
136
+ hex += hexes[bytes[i]];
137
+ }
138
+ return hex;
139
+ }
140
+ function utf8ToBytes(str) {
141
+ if (typeof str !== "string")
142
+ throw new TypeError("string expected");
143
+ const encoded = new TextEncoder().encode(str);
144
+ try {
145
+ return new Uint8Array(encoded);
146
+ } finally {
147
+ clean(encoded);
148
+ }
149
+ }
150
+ function checkOpts(defaults, opts, title = "opts") {
151
+ aopts(defaults, "defaults");
152
+ if (opts !== void 0)
153
+ aopts(opts, title);
154
+ const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
155
+ return merged;
156
+ }
157
+ function createHasher(hashCons, info = {}) {
158
+ if (typeof hashCons !== "function")
159
+ throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
160
+ info = checkOpts({}, info, "info");
161
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
162
+ const tmp = hashCons(void 0);
163
+ hashC.outputLen = tmp.outputLen;
164
+ hashC.blockLen = tmp.blockLen;
165
+ hashC.canXOF = tmp.canXOF;
166
+ hashC.create = (opts) => hashCons(opts);
167
+ Object.assign(hashC, info);
168
+ return Object.freeze(hashC);
169
+ }
170
+ var oidNist = (suffix) => ({
171
+ // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
172
+ // Larger suffix values would need base-128 OID encoding and a different length byte.
173
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
174
+ });
175
+
176
+ // ../../node_modules/@noble/hashes/hmac.js
177
+ var _HMAC = class {
178
+ constructor(hash, key) {
179
+ __publicField(this, "oHash");
180
+ __publicField(this, "iHash");
181
+ __publicField(this, "blockLen");
182
+ __publicField(this, "outputLen");
183
+ __publicField(this, "canXOF", false);
184
+ __publicField(this, "finished", false);
185
+ __publicField(this, "destroyed", false);
186
+ ahash(hash);
187
+ abytes(key, void 0, "key");
188
+ this.iHash = hash.create();
189
+ if (typeof this.iHash.update !== "function")
190
+ throw new Error("expected Hash instance");
191
+ this.blockLen = this.iHash.blockLen;
192
+ this.outputLen = this.iHash.outputLen;
193
+ const blockLen = this.blockLen;
194
+ const pad = new Uint8Array(blockLen);
195
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
196
+ for (let i = 0; i < pad.length; i++)
197
+ pad[i] ^= 54;
198
+ this.iHash.update(pad);
199
+ this.oHash = hash.create();
200
+ for (let i = 0; i < pad.length; i++)
201
+ pad[i] ^= 54 ^ 92;
202
+ this.oHash.update(pad);
203
+ clean(pad);
204
+ }
205
+ update(buf) {
206
+ aexists(this);
207
+ this.iHash.update(buf);
208
+ return this;
209
+ }
210
+ digestInto(out) {
211
+ aexists(this);
212
+ aoutput(out, this);
213
+ this.finished = true;
214
+ const buf = out.subarray(0, this.outputLen);
215
+ this.iHash.digestInto(buf);
216
+ this.oHash.update(buf);
217
+ this.oHash.digestInto(buf);
218
+ this.destroy();
219
+ }
220
+ digest() {
221
+ const out = new Uint8Array(this.oHash.outputLen);
222
+ this.digestInto(out);
223
+ return out;
224
+ }
225
+ _cloneInto(to) {
226
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
227
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen, canXOF } = this;
228
+ to = to;
229
+ to.finished = finished;
230
+ to.destroyed = destroyed;
231
+ to.blockLen = blockLen;
232
+ to.outputLen = outputLen;
233
+ to.canXOF = canXOF;
234
+ to.oHash = oHash._cloneInto(to.oHash);
235
+ to.iHash = iHash._cloneInto(to.iHash);
236
+ return to;
237
+ }
238
+ clone() {
239
+ return this._cloneInto();
240
+ }
241
+ destroy() {
242
+ this.destroyed = true;
243
+ this.oHash.destroy();
244
+ this.iHash.destroy();
245
+ }
246
+ };
247
+ var hmac = /* @__PURE__ */ (() => {
248
+ const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
249
+ hmac_.create = (hash, key) => new _HMAC(hash, key);
250
+ return hmac_;
251
+ })();
252
+
253
+ // ../../node_modules/@noble/hashes/_u64.js
254
+ var fromNumH = (n) => n / 2 ** 32 | 0;
255
+ var fromNumL = (n) => n >>> 0;
256
+ function setU64FromNum(view, byteOffset, n, isLE) {
257
+ const h = fromNumH(n);
258
+ const l = fromNumL(n);
259
+ view.setUint32(byteOffset, isLE ? l : h, isLE);
260
+ view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
261
+ }
262
+
263
+ // ../../node_modules/@noble/hashes/_md.js
264
+ function Chi(a, b, c) {
265
+ return a & b ^ ~a & c;
266
+ }
267
+ function Maj(a, b, c) {
268
+ return a & b ^ a & c ^ b & c;
269
+ }
270
+ var HashMD = class {
271
+ constructor(blockLen, outputLen, padOffset, isLE) {
272
+ __publicField(this, "blockLen");
273
+ __publicField(this, "outputLen");
274
+ __publicField(this, "canXOF", false);
275
+ __publicField(this, "padOffset");
276
+ __publicField(this, "isLE");
277
+ // For partial updates less than block size
278
+ __publicField(this, "buffer");
279
+ __publicField(this, "view");
280
+ __publicField(this, "finished", false);
281
+ __publicField(this, "length", 0);
282
+ __publicField(this, "pos", 0);
283
+ __publicField(this, "destroyed", false);
284
+ this.blockLen = blockLen;
285
+ this.outputLen = outputLen;
286
+ this.padOffset = padOffset;
287
+ this.isLE = isLE;
288
+ this.buffer = new Uint8Array(blockLen);
289
+ this.view = createView(this.buffer);
290
+ }
291
+ update(data) {
292
+ aexists(this);
293
+ abytes(data);
294
+ const { view, buffer, blockLen } = this;
295
+ const len = data.length;
296
+ let processed = false;
297
+ for (let pos = 0; pos < len; ) {
298
+ const take = Math.min(blockLen - this.pos, len - pos);
299
+ if (take === blockLen) {
300
+ const dataView = createView(data);
301
+ for (; blockLen <= len - pos; pos += blockLen)
302
+ this.process(dataView, pos);
303
+ processed = true;
304
+ continue;
305
+ }
306
+ buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
307
+ this.pos += take;
308
+ pos += take;
309
+ if (this.pos === blockLen) {
310
+ this.process(view, 0);
311
+ this.pos = 0;
312
+ processed = true;
313
+ }
27
314
  }
28
- return peek && value.length > REDACTION_PEEK_LENGTH + 6
29
- ? `${value.slice(0, REDACTION_PEEK_LENGTH)}${REDACTED_VALUE}`
30
- : REDACTED_VALUE;
31
- }
32
- /**
33
- * Redacts sensitive information from a URL by removing path segments and query parameters.
34
- * @param value The URL string to redact.
35
- * @returns The redacted URL string, which includes only the origin and an indication of how many path segments were redacted, or just the origin if there are no path segments. Query parameters are not included in the output to avoid exposing sensitive information. If the input value is not a valid URL, the function returns a fully redacted placeholder.
36
- */
37
- function redactUrl(value) {
38
- if (!(value === null || value === void 0 ? void 0 : value.trim())) {
39
- return undefined;
315
+ this.length += data.length;
316
+ if (processed)
317
+ this.roundClean();
318
+ return this;
319
+ }
320
+ digestInto(out) {
321
+ aexists(this);
322
+ aoutput(out, this);
323
+ this.finished = true;
324
+ const { buffer, view, blockLen, isLE } = this;
325
+ let { pos } = this;
326
+ buffer[pos++] = 128;
327
+ buffer.fill(0, pos);
328
+ if (this.padOffset > blockLen - pos) {
329
+ this.process(view, 0);
330
+ buffer.fill(0);
40
331
  }
41
- try {
42
- const url = new URL(value);
43
- const pathSegments = url.pathname.split('/').filter(Boolean);
44
- if (pathSegments.length === 0) {
45
- return url.origin;
46
- }
47
- return `${url.origin}/${REDACTED_VALUE} (${pathSegments.length} segments)`;
332
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
333
+ this.process(view, 0);
334
+ this.roundClean();
335
+ const oview = out === buffer ? view : createView(out);
336
+ const len = this.outputLen;
337
+ const outLen = len / 4;
338
+ const state = this.get();
339
+ if (len % 4 || outLen > state.length)
340
+ throw new Error("invalid outputLen");
341
+ for (let i = 0; i < outLen; i++)
342
+ oview.setUint32(4 * i, state[i], isLE);
343
+ }
344
+ digest() {
345
+ const { buffer, outputLen } = this;
346
+ this.digestInto(buffer);
347
+ const res = buffer.slice(0, outputLen);
348
+ this.destroy();
349
+ return res;
350
+ }
351
+ _cloneIntoMeta(to) {
352
+ const { buffer, length, finished, destroyed, pos } = this;
353
+ to.destroyed = destroyed;
354
+ to.finished = finished;
355
+ to.length = length;
356
+ to.pos = pos;
357
+ if (pos)
358
+ to.buffer.set(buffer);
359
+ return to;
360
+ }
361
+ clone() {
362
+ return this._cloneInto();
363
+ }
364
+ };
365
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
366
+ 1779033703,
367
+ 3144134277,
368
+ 1013904242,
369
+ 2773480762,
370
+ 1359893119,
371
+ 2600822924,
372
+ 528734635,
373
+ 1541459225
374
+ ]);
375
+
376
+ // ../../node_modules/@noble/hashes/sha2.js
377
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
378
+ 1116352408,
379
+ 1899447441,
380
+ 3049323471,
381
+ 3921009573,
382
+ 961987163,
383
+ 1508970993,
384
+ 2453635748,
385
+ 2870763221,
386
+ 3624381080,
387
+ 310598401,
388
+ 607225278,
389
+ 1426881987,
390
+ 1925078388,
391
+ 2162078206,
392
+ 2614888103,
393
+ 3248222580,
394
+ 3835390401,
395
+ 4022224774,
396
+ 264347078,
397
+ 604807628,
398
+ 770255983,
399
+ 1249150122,
400
+ 1555081692,
401
+ 1996064986,
402
+ 2554220882,
403
+ 2821834349,
404
+ 2952996808,
405
+ 3210313671,
406
+ 3336571891,
407
+ 3584528711,
408
+ 113926993,
409
+ 338241895,
410
+ 666307205,
411
+ 773529912,
412
+ 1294757372,
413
+ 1396182291,
414
+ 1695183700,
415
+ 1986661051,
416
+ 2177026350,
417
+ 2456956037,
418
+ 2730485921,
419
+ 2820302411,
420
+ 3259730800,
421
+ 3345764771,
422
+ 3516065817,
423
+ 3600352804,
424
+ 4094571909,
425
+ 275423344,
426
+ 430227734,
427
+ 506948616,
428
+ 659060556,
429
+ 883997877,
430
+ 958139571,
431
+ 1322822218,
432
+ 1537002063,
433
+ 1747873779,
434
+ 1955562222,
435
+ 2024104815,
436
+ 2227730452,
437
+ 2361852424,
438
+ 2428436474,
439
+ 2756734187,
440
+ 3204031479,
441
+ 3329325298
442
+ ]);
443
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
444
+ var SHA2_32B = class extends HashMD {
445
+ constructor(outputLen, IV) {
446
+ super(64, outputLen, 8, false);
447
+ // We cannot use array here since array allows indexing by variable
448
+ // which means optimizer/compiler cannot use registers.
449
+ // Numeric initializers matter: starting the fields as `undefined` changes
450
+ // V8's field representation and makes sha256 3x slower (measured).
451
+ __publicField(this, "A", 0);
452
+ __publicField(this, "B", 0);
453
+ __publicField(this, "C", 0);
454
+ __publicField(this, "D", 0);
455
+ __publicField(this, "E", 0);
456
+ __publicField(this, "F", 0);
457
+ __publicField(this, "G", 0);
458
+ __publicField(this, "H", 0);
459
+ this.A = IV[0] | 0;
460
+ this.B = IV[1] | 0;
461
+ this.C = IV[2] | 0;
462
+ this.D = IV[3] | 0;
463
+ this.E = IV[4] | 0;
464
+ this.F = IV[5] | 0;
465
+ this.G = IV[6] | 0;
466
+ this.H = IV[7] | 0;
467
+ }
468
+ get() {
469
+ const { A, B, C, D, E, F, G, H } = this;
470
+ return [A, B, C, D, E, F, G, H];
471
+ }
472
+ // prettier-ignore
473
+ set(A, B, C, D, E, F, G, H) {
474
+ this.A = A | 0;
475
+ this.B = B | 0;
476
+ this.C = C | 0;
477
+ this.D = D | 0;
478
+ this.E = E | 0;
479
+ this.F = F | 0;
480
+ this.G = G | 0;
481
+ this.H = H | 0;
482
+ }
483
+ _cloneInto(to) {
484
+ (to || (to = new this.constructor())).set(...this.get());
485
+ return this._cloneIntoMeta(to);
486
+ }
487
+ process(view, offset) {
488
+ for (let i = 0; i < 16; i++, offset += 4)
489
+ SHA256_W[i] = view.getUint32(offset, false);
490
+ for (let i = 16; i < 64; i++) {
491
+ const W15 = SHA256_W[i - 15];
492
+ const W2 = SHA256_W[i - 2];
493
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
494
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
495
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
48
496
  }
49
- catch {
50
- return REDACTED_VALUE;
497
+ let { A, B, C, D, E, F, G, H } = this;
498
+ for (let i = 0; i < 64; i++) {
499
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
500
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
501
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
502
+ const T2 = sigma0 + Maj(A, B, C) | 0;
503
+ H = G;
504
+ G = F;
505
+ F = E;
506
+ E = D + T1 | 0;
507
+ D = C;
508
+ C = B;
509
+ B = A;
510
+ A = T1 + T2 | 0;
51
511
  }
512
+ A = A + this.A | 0;
513
+ B = B + this.B | 0;
514
+ C = C + this.C | 0;
515
+ D = D + this.D | 0;
516
+ E = E + this.E | 0;
517
+ F = F + this.F | 0;
518
+ G = G + this.G | 0;
519
+ H = H + this.H | 0;
520
+ this.set(A, B, C, D, E, F, G, H);
521
+ }
522
+ roundClean() {
523
+ clean(SHA256_W);
524
+ }
525
+ destroy() {
526
+ this.destroyed = true;
527
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
528
+ clean(this.buffer);
529
+ }
530
+ };
531
+ var _SHA256 = class extends SHA2_32B {
532
+ constructor() {
533
+ super(32, SHA256_IV);
534
+ }
535
+ };
536
+ var sha256 = /* @__PURE__ */ createHasher(
537
+ () => new _SHA256(),
538
+ /* @__PURE__ */ oidNist(1)
539
+ );
540
+
541
+ // src/utils/redact.ts
542
+ var REDACTED_VALUE = "<redacted>";
543
+ var REDACTION_PEEK_LENGTH = 2;
544
+ var processLocalKey;
545
+ function redactString(value, peek = false) {
546
+ if (value === void 0) {
547
+ return void 0;
548
+ }
549
+ return peek && value.length > REDACTION_PEEK_LENGTH + 6 ? `${value.slice(0, REDACTION_PEEK_LENGTH)}${REDACTED_VALUE}` : REDACTED_VALUE;
52
550
  }
53
- /**
54
- * Redacts sensitive information from an array of scopes.
55
- * @param scopes The array of scopes to redact.
56
- * @returns The redacted scopes string, which includes an indication of how many scopes were redacted. If the input value is undefined, it will be returned as undefined.
57
- */
58
- function redactScopes(scopes) {
59
- if (scopes === undefined) {
60
- return undefined;
551
+ function redactUrl(value) {
552
+ if (!(value == null ? void 0 : value.trim())) {
553
+ return void 0;
554
+ }
555
+ try {
556
+ const url = new URL(value);
557
+ const pathSegments = url.pathname.split("/").filter(Boolean);
558
+ if (pathSegments.length === 0) {
559
+ return url.origin;
61
560
  }
62
- const count = scopes.length;
63
- return `${REDACTED_VALUE} (${count} ${count === 1 ? 'scope' : 'scopes'})`;
64
- }
65
- /**
66
- * Returns a stable, non-reversible identifier for diagnostic correlation.
67
- * @param conversationId The conversation ID to pseudonymize.
68
- * @param key Optional secret used to keep pseudonyms stable across restarts.
69
- * @returns A pseudonymized conversation ID, or undefined when no ID is supplied.
70
- */
561
+ return `${url.origin}/${REDACTED_VALUE} (${pathSegments.length} segments)`;
562
+ } catch {
563
+ return REDACTED_VALUE;
564
+ }
565
+ }
566
+ function redactScopes(scopes) {
567
+ if (scopes === void 0) {
568
+ return void 0;
569
+ }
570
+ const count = scopes.length;
571
+ return `${REDACTED_VALUE} (${count} ${count === 1 ? "scope" : "scopes"})`;
572
+ }
71
573
  function pseudonymizeConversationId(conversationId, key) {
72
- if (!(conversationId === null || conversationId === void 0 ? void 0 : conversationId.trim())) {
73
- return undefined;
74
- }
75
- const trimmedKey = key === null || key === void 0 ? void 0 : key.trim();
76
- const hmacKey = trimmedKey
77
- ? (0, utils_1.utf8ToBytes)(trimmedKey)
78
- : (processLocalKey !== null && processLocalKey !== void 0 ? processLocalKey : (processLocalKey = createProcessLocalKey()));
79
- const digest = (0, hmac_1.hmac)(sha2_1.sha256, hmacKey, (0, utils_1.utf8ToBytes)(conversationId));
80
- return `cid_${(0, utils_1.bytesToHex)(digest).slice(0, 32)}`;
574
+ if (!(conversationId == null ? void 0 : conversationId.trim())) {
575
+ return void 0;
576
+ }
577
+ const trimmedKey = key == null ? void 0 : key.trim();
578
+ const hmacKey = trimmedKey ? utf8ToBytes(trimmedKey) : processLocalKey != null ? processLocalKey : processLocalKey = createProcessLocalKey();
579
+ const digest = hmac(sha256, hmacKey, utf8ToBytes(conversationId));
580
+ return `cid_${bytesToHex(digest).slice(0, 32)}`;
81
581
  }
82
582
  function createProcessLocalKey() {
83
- const key = new Uint8Array(32);
84
- globalThis.crypto.getRandomValues(key);
85
- return key;
86
- }
87
- /**
88
- * Creates a redacted copy of an object for diagnostic logging.
89
- * Conversation IDs, activity text, and URL-valued properties are redacted while all other values are preserved.
90
- * @param value The value to sanitize for diagnostics.
91
- * @param diagnosticsPseudonymKey Optional secret used to keep conversation pseudonyms stable across restarts.
92
- * @returns A non-mutating, redacted copy of the value.
93
- */
583
+ const key = new Uint8Array(32);
584
+ globalThis.crypto.getRandomValues(key);
585
+ return key;
586
+ }
94
587
  function redactDiagnosticObject(value, diagnosticsPseudonymKey) {
95
- return redactValue(value, [], diagnosticsPseudonymKey);
588
+ return redactValue(value, [], diagnosticsPseudonymKey);
96
589
  }
97
590
  function redactValue(value, path, diagnosticsPseudonymKey) {
98
- var _a, _b;
99
- if (typeof value === 'string') {
100
- const propertyName = (_a = path.at(-1)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
101
- const parentPropertyName = (_b = path.at(-2)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
102
- if (propertyName === 'conversationid' || (propertyName === 'id' && parentPropertyName === 'conversation')) {
103
- return pseudonymizeConversationId(value, diagnosticsPseudonymKey);
104
- }
105
- if (propertyName === 'text' || propertyName === 'activitytext') {
106
- return redactString(value, true);
107
- }
108
- if ((propertyName === null || propertyName === void 0 ? void 0 : propertyName.includes('url')) || propertyName === 'uri' || propertyName === 'href') {
109
- return redactUrl(value);
110
- }
111
- return value;
591
+ var _a, _b;
592
+ if (typeof value === "string") {
593
+ const propertyName = (_a = path.at(-1)) == null ? void 0 : _a.toLowerCase();
594
+ const parentPropertyName = (_b = path.at(-2)) == null ? void 0 : _b.toLowerCase();
595
+ if (propertyName === "conversationid" || propertyName === "id" && parentPropertyName === "conversation") {
596
+ return pseudonymizeConversationId(value, diagnosticsPseudonymKey);
112
597
  }
113
- if (Array.isArray(value)) {
114
- return value.map(item => redactValue(item, path, diagnosticsPseudonymKey));
598
+ if (propertyName === "text" || propertyName === "activitytext") {
599
+ return redactString(value, true);
115
600
  }
116
- if (value && typeof value === 'object') {
117
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item, [...path, key], diagnosticsPseudonymKey)]));
601
+ if ((propertyName == null ? void 0 : propertyName.includes("url")) || propertyName === "uri" || propertyName === "href") {
602
+ return redactUrl(value);
118
603
  }
119
604
  return value;
605
+ }
606
+ if (Array.isArray(value)) {
607
+ return value.map((item) => redactValue(item, path, diagnosticsPseudonymKey));
608
+ }
609
+ if (value && typeof value === "object") {
610
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item, [...path, key], diagnosticsPseudonymKey)]));
611
+ }
612
+ return value;
120
613
  }
121
- //# sourceMappingURL=redact.js.map
614
+ //# sourceMappingURL=redact.js.map