@empiricalrun/playwright-utils 0.67.0 → 0.67.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.67.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 735e68a: chore: getProxyConfig uses per-project authentication credentials; no change required for callers
8
+ - @empiricalrun/cua@0.6.0
9
+ - @empiricalrun/reporter@0.30.3
10
+
3
11
  ## 0.67.0
4
12
 
5
13
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/config/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,KAAK,WAAW,GAAG,WAAW,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/D,KAAK,WAAW,GAAG,YAAY,CAAC;AAOhC,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAM/D"}
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/config/proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,KAAK,WAAW,GAAG,WAAW,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/D,KAAK,WAAW,GAAG,YAAY,CAAC;AAiDhC,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAM/D"}
@@ -1,13 +1,53 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getProxyConfig = getProxyConfig;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
4
8
  const proxyEndpoints = {
5
9
  "ap-south-1": "http://prod-proxy-nlb-6b53da958ae0b30e.elb.ap-south-1.amazonaws.com:8080",
6
10
  };
11
+ const DEFAULT_TOKEN_FILE = "/tmp/static-ip-proxy-token";
12
+ function tokenExpiry(token) {
13
+ const [payloadB64] = token.split(".");
14
+ if (!payloadB64) {
15
+ return undefined;
16
+ }
17
+ try {
18
+ const payload = JSON.parse(Buffer.from(payloadB64, "base64").toString("utf8"));
19
+ const exp = payload?.exp;
20
+ return typeof exp === "number" ? exp : undefined;
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ function isUnexpiredToken(token) {
27
+ if (!token) {
28
+ return false;
29
+ }
30
+ const exp = tokenExpiry(token);
31
+ return exp !== undefined && exp * 1000 > Date.now();
32
+ }
33
+ function readTokenFile() {
34
+ const path = process.env.EMPIRICAL_STATIC_IP_PROXY_TOKEN_FILE ?? DEFAULT_TOKEN_FILE;
35
+ try {
36
+ return node_fs_1.default.readFileSync(path, "utf8").trim();
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ function staticIpProxyToken() {
43
+ return [readTokenFile(), process.env.EMPIRICAL_STATIC_IP_PROXY_TOKEN?.trim()]
44
+ .filter(isUnexpiredToken)
45
+ .at(0);
46
+ }
7
47
  function getProxyConfig(region) {
8
48
  return {
9
49
  server: proxyEndpoints[region],
10
50
  username: "proxyuser",
11
- password: process.env.EMPIRICAL_PROXY_PASSWORD,
51
+ password: staticIpProxyToken() ?? process.env.EMPIRICAL_PROXY_PASSWORD,
12
52
  };
13
53
  }
@@ -22699,7 +22699,7 @@ export interface operations {
22699
22699
  pw_test_id: string;
22700
22700
  /** @description Dry-run this matcher source instead of the groups' matchers: `async ({ testRun, testCase, traceUtils }) => boolean`. */
22701
22701
  source?: string;
22702
- /** @description Only run these groups' matchers. Default: every open group with a matcher. */
22702
+ /** @description Only run these groups' matchers, by label or ID. Default: every open group with a matcher. */
22703
22703
  group_ids?: string[];
22704
22704
  };
22705
22705
  };