@checkly/playwright-core 1.51.17-beta.4 → 1.51.17-beta.5

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.
@@ -4,20 +4,65 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.secretsFilter = exports.addSecret = void 0;
7
+ var diagnostics_channel = _interopRequireWildcard(require("node:diagnostics_channel"));
7
8
  var _escapeRegExp = _interopRequireDefault(require("./escapeRegExp"));
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
12
  /* Copyright Checkly
10
13
  */
11
14
 
12
15
  const IdentityFunction = s => s;
13
- const dynamicallyAddedSecrets = [];
16
+ const dynamicallyAddedSecrets = new Set();
14
17
  let cachedAuthorizationHeaderSecrets = null;
18
+ const extractAuthorizationHeaderValue = authorizationHeaderValue => {
19
+ const spaceIndex = authorizationHeaderValue.indexOf(' ');
20
+ return spaceIndex === -1 ? authorizationHeaderValue : authorizationHeaderValue.split(' ')[1];
21
+ };
22
+
23
+ // For http/https
24
+ diagnostics_channel.subscribe('http.client.request.start', message => {
25
+ const {
26
+ request
27
+ } = message;
28
+ const auth = request.getHeader('authorization');
29
+ if (auth) {
30
+ dynamicallyAddedSecrets.add(extractAuthorizationHeaderValue(auth));
31
+ cachedAuthorizationHeaderSecrets = new RegExp(Array.from(dynamicallyAddedSecrets).map(_escapeRegExp.default).join('|'), 'g');
32
+ }
33
+ });
34
+
35
+ // For undici (powers global fetch in Node 18+)
36
+ diagnostics_channel.subscribe('undici:request:create', message => {
37
+ var _request$headers;
38
+ const {
39
+ request
40
+ } = message;
41
+ const auth = (_request$headers = request.headers) === null || _request$headers === void 0 ? void 0 : _request$headers.authorization;
42
+ if (auth) {
43
+ dynamicallyAddedSecrets.add(extractAuthorizationHeaderValue(auth));
44
+ cachedAuthorizationHeaderSecrets = new RegExp(Array.from(dynamicallyAddedSecrets).map(_escapeRegExp.default).join('|'), 'g');
45
+ }
46
+ });
15
47
  const addSecret = secret => {
16
- const spaceIndex = secret.indexOf(' ');
17
- const secretValue = spaceIndex === -1 ? secret : secret.split(' ')[1];
18
- dynamicallyAddedSecrets.push(secretValue);
19
- cachedAuthorizationHeaderSecrets = new RegExp(dynamicallyAddedSecrets.map(_escapeRegExp.default).join('|'), 'g');
20
- console.log(`[CHECKLY_RUNTIME_SECRET]${secretValue}[/CHECKLY_RUNTIME_SECRET]`);
48
+ try {
49
+ if (!secret || typeof secret !== 'string') return;
50
+ const secretValue = extractAuthorizationHeaderValue(secret);
51
+ if (!secretValue) return;
52
+ dynamicallyAddedSecrets.add(secretValue);
53
+ const escapedSecrets = Array.from(dynamicallyAddedSecrets).map(s => {
54
+ try {
55
+ return (0, _escapeRegExp.default)(s);
56
+ } catch {
57
+ return null;
58
+ }
59
+ }).filter(Boolean);
60
+ if (escapedSecrets.length > 0) cachedAuthorizationHeaderSecrets = new RegExp(escapedSecrets.join('|'), 'g');
61
+ console.log(`[CHECKLY_RUNTIME_SECRET]${secretValue}[/CHECKLY_RUNTIME_SECRET]`);
62
+ } catch (error) {
63
+ // Silently fail to avoid breaking the application
64
+ // Error could be from RegExp construction or console.log
65
+ }
21
66
  };
22
67
  exports.addSecret = addSecret;
23
68
  const secretsFilter = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkly/playwright-core",
3
- "version": "1.51.17-beta.4",
3
+ "version": "1.51.17-beta.5",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",