@skrillex1224/playwright-toolkit 2.1.214 → 2.1.216

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/index.cjs CHANGED
@@ -1025,16 +1025,6 @@ var normalizeSessionStorage = (value) => {
1025
1025
  return acc;
1026
1026
  }, {});
1027
1027
  };
1028
- var normalizeAuth = (value) => {
1029
- const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1030
- return Object.entries(source).reduce((acc, [key, item]) => {
1031
- const safeKey = String(key || "").trim();
1032
- const safeValue = String(item ?? "").trim();
1033
- if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
1034
- acc[safeKey] = safeValue;
1035
- return acc;
1036
- }, {});
1037
- };
1038
1028
  var normalizeCookieSameSite = (value) => {
1039
1029
  const raw = String(value || "").trim().toLowerCase();
1040
1030
  if (!raw) return "";
@@ -1167,8 +1157,7 @@ var normalizeRawSnapshot = (value = {}) => {
1167
1157
  cookies: Array.isArray(source.cookies) ? deepClone(source.cookies) : [],
1168
1158
  local_storage: normalizeLocalStorage(source.local_storage ?? source.localStorage),
1169
1159
  session_storage: normalizeSessionStorage(source.session_storage ?? source.sessionStorage),
1170
- browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource),
1171
- auth: normalizeAuth(source.auth)
1160
+ browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource)
1172
1161
  };
1173
1162
  };
1174
1163
  var collectCookieUrlsFromSnapshot = (snapshot = {}) => {
@@ -1192,7 +1181,6 @@ var buildEnvPayloadFromSnapshot = (snapshot = {}, options = {}) => {
1192
1181
  const cookies = filterCookiesBySnapshot(snapshot?.cookies || normalized.cookies, normalized);
1193
1182
  const localStorage = normalized.local_storage;
1194
1183
  const sessionStorage = normalized.session_storage;
1195
- const auth = normalizeAuth(options.auth ?? normalized.auth);
1196
1184
  const browserProfileCore = normalizeBrowserProfileCore(
1197
1185
  options.browserProfileCore ?? snapshot?.browser_profile?.core ?? snapshot?.browserProfile?.core
1198
1186
  );
@@ -1201,7 +1189,6 @@ var buildEnvPayloadFromSnapshot = (snapshot = {}, options = {}) => {
1201
1189
  ...cookies.length > 0 ? { cookies } : {},
1202
1190
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
1203
1191
  ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
1204
- ...Object.keys(auth).length > 0 ? { auth } : {},
1205
1192
  ...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
1206
1193
  };
1207
1194
  return Object.keys(payload).length > 0 ? payload : null;
@@ -1465,7 +1452,6 @@ var RuntimeEnv = {
1465
1452
  normalizeCookies,
1466
1453
  normalizeLocalStorage,
1467
1454
  normalizeSessionStorage,
1468
- normalizeAuth,
1469
1455
  normalizeBrowserProfileCore,
1470
1456
  normalizeObservedBrowserProfile,
1471
1457
  normalizeSnapshot(snapshot = {}) {
@@ -1493,15 +1479,12 @@ var RuntimeEnv = {
1493
1479
  const cookieMap = buildCookieMap(cookies);
1494
1480
  const localStorage = normalizeLocalStorage(runtime2?.local_storage);
1495
1481
  const sessionStorage = normalizeSessionStorage(runtime2?.session_storage);
1496
- const auth = normalizeAuth(runtime2?.auth);
1497
1482
  const browserProfile = normalizeBrowserProfile(runtime2?.browser_profile);
1498
1483
  const envId = String(input?.env_id || "").trim();
1499
1484
  const normalizedRuntime = {
1500
- ...runtime2,
1501
1485
  ...cookies.length > 0 ? { cookies } : {},
1502
1486
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
1503
- ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
1504
- ...Object.keys(auth).length > 0 ? { auth } : {}
1487
+ ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {}
1505
1488
  };
1506
1489
  if (Object.keys(browserProfile.payload).length > 0) {
1507
1490
  normalizedRuntime.browser_profile = browserProfile.payload;
@@ -1513,7 +1496,6 @@ var RuntimeEnv = {
1513
1496
  runtime: normalizedRuntime,
1514
1497
  envId,
1515
1498
  query,
1516
- auth,
1517
1499
  cookies,
1518
1500
  cookieMap,
1519
1501
  localStorage,
@@ -1530,7 +1512,6 @@ var RuntimeEnv = {
1530
1512
  const state = normalizeRuntimeState(source, actor);
1531
1513
  const browserProfile = buildBrowserProfilePayload(state.browserProfileCore, state.browserProfileObserved);
1532
1514
  const envPatch = {
1533
- ...Object.keys(state.auth || {}).length > 0 ? { auth: state.auth } : {},
1534
1515
  ...Array.isArray(state.cookies) && state.cookies.length > 0 ? { cookies: state.cookies } : {},
1535
1516
  ...Object.keys(state.localStorage || {}).length > 0 ? { local_storage: state.localStorage } : {},
1536
1517
  ...Object.keys(state.sessionStorage || {}).length > 0 ? { session_storage: state.sessionStorage } : {},
@@ -1538,16 +1519,10 @@ var RuntimeEnv = {
1538
1519
  };
1539
1520
  return Object.keys(envPatch).length > 0 ? envPatch : null;
1540
1521
  },
1541
- // hasLoginState 用来区分“必须鉴权的平台”和“可匿名运行的平台”。
1522
+ // hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
1542
1523
  hasLoginState(source = {}, actor = "") {
1543
1524
  const state = normalizeRuntimeState(source, actor);
1544
- return Array.isArray(state.cookies) && state.cookies.length > 0 || Object.keys(state.localStorage || {}).length > 0 || Object.keys(state.sessionStorage || {}).length > 0 || Object.keys(state.auth || {}).length > 0;
1545
- },
1546
- getAuthValue(source = {}, key = "", actor = "") {
1547
- const state = normalizeRuntimeState(source, actor);
1548
- const safeKey = String(key || "").trim();
1549
- if (!safeKey) return "";
1550
- return String(state.auth?.[safeKey] ?? "").trim();
1525
+ return isPlainObject(state.runtime) && Object.keys(state.runtime || {}).length > 0;
1551
1526
  },
1552
1527
  rememberState(source = {}) {
1553
1528
  const state = normalizeRuntimeState(source);
@@ -1646,7 +1621,6 @@ var RuntimeEnv = {
1646
1621
  cookies
1647
1622
  },
1648
1623
  {
1649
- auth: state.auth,
1650
1624
  browserProfileCore: state.browserProfileCore
1651
1625
  }
1652
1626
  );