@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.js CHANGED
@@ -997,16 +997,6 @@ var normalizeSessionStorage = (value) => {
997
997
  return acc;
998
998
  }, {});
999
999
  };
1000
- var normalizeAuth = (value) => {
1001
- const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1002
- return Object.entries(source).reduce((acc, [key, item]) => {
1003
- const safeKey = String(key || "").trim();
1004
- const safeValue = String(item ?? "").trim();
1005
- if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
1006
- acc[safeKey] = safeValue;
1007
- return acc;
1008
- }, {});
1009
- };
1010
1000
  var normalizeCookieSameSite = (value) => {
1011
1001
  const raw = String(value || "").trim().toLowerCase();
1012
1002
  if (!raw) return "";
@@ -1139,8 +1129,7 @@ var normalizeRawSnapshot = (value = {}) => {
1139
1129
  cookies: Array.isArray(source.cookies) ? deepClone(source.cookies) : [],
1140
1130
  local_storage: normalizeLocalStorage(source.local_storage ?? source.localStorage),
1141
1131
  session_storage: normalizeSessionStorage(source.session_storage ?? source.sessionStorage),
1142
- browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource),
1143
- auth: normalizeAuth(source.auth)
1132
+ browser_profile_observed: normalizeObservedBrowserProfile(browserProfileObservedSource)
1144
1133
  };
1145
1134
  };
1146
1135
  var collectCookieUrlsFromSnapshot = (snapshot = {}) => {
@@ -1164,7 +1153,6 @@ var buildEnvPayloadFromSnapshot = (snapshot = {}, options = {}) => {
1164
1153
  const cookies = filterCookiesBySnapshot(snapshot?.cookies || normalized.cookies, normalized);
1165
1154
  const localStorage = normalized.local_storage;
1166
1155
  const sessionStorage = normalized.session_storage;
1167
- const auth = normalizeAuth(options.auth ?? normalized.auth);
1168
1156
  const browserProfileCore = normalizeBrowserProfileCore(
1169
1157
  options.browserProfileCore ?? snapshot?.browser_profile?.core ?? snapshot?.browserProfile?.core
1170
1158
  );
@@ -1173,7 +1161,6 @@ var buildEnvPayloadFromSnapshot = (snapshot = {}, options = {}) => {
1173
1161
  ...cookies.length > 0 ? { cookies } : {},
1174
1162
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
1175
1163
  ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
1176
- ...Object.keys(auth).length > 0 ? { auth } : {},
1177
1164
  ...Object.keys(browserProfile).length > 0 ? { browser_profile: browserProfile } : {}
1178
1165
  };
1179
1166
  return Object.keys(payload).length > 0 ? payload : null;
@@ -1437,7 +1424,6 @@ var RuntimeEnv = {
1437
1424
  normalizeCookies,
1438
1425
  normalizeLocalStorage,
1439
1426
  normalizeSessionStorage,
1440
- normalizeAuth,
1441
1427
  normalizeBrowserProfileCore,
1442
1428
  normalizeObservedBrowserProfile,
1443
1429
  normalizeSnapshot(snapshot = {}) {
@@ -1465,15 +1451,12 @@ var RuntimeEnv = {
1465
1451
  const cookieMap = buildCookieMap(cookies);
1466
1452
  const localStorage = normalizeLocalStorage(runtime2?.local_storage);
1467
1453
  const sessionStorage = normalizeSessionStorage(runtime2?.session_storage);
1468
- const auth = normalizeAuth(runtime2?.auth);
1469
1454
  const browserProfile = normalizeBrowserProfile(runtime2?.browser_profile);
1470
1455
  const envId = String(input?.env_id || "").trim();
1471
1456
  const normalizedRuntime = {
1472
- ...runtime2,
1473
1457
  ...cookies.length > 0 ? { cookies } : {},
1474
1458
  ...Object.keys(localStorage).length > 0 ? { local_storage: localStorage } : {},
1475
- ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {},
1476
- ...Object.keys(auth).length > 0 ? { auth } : {}
1459
+ ...Object.keys(sessionStorage).length > 0 ? { session_storage: sessionStorage } : {}
1477
1460
  };
1478
1461
  if (Object.keys(browserProfile.payload).length > 0) {
1479
1462
  normalizedRuntime.browser_profile = browserProfile.payload;
@@ -1485,7 +1468,6 @@ var RuntimeEnv = {
1485
1468
  runtime: normalizedRuntime,
1486
1469
  envId,
1487
1470
  query,
1488
- auth,
1489
1471
  cookies,
1490
1472
  cookieMap,
1491
1473
  localStorage,
@@ -1502,7 +1484,6 @@ var RuntimeEnv = {
1502
1484
  const state = normalizeRuntimeState(source, actor);
1503
1485
  const browserProfile = buildBrowserProfilePayload(state.browserProfileCore, state.browserProfileObserved);
1504
1486
  const envPatch = {
1505
- ...Object.keys(state.auth || {}).length > 0 ? { auth: state.auth } : {},
1506
1487
  ...Array.isArray(state.cookies) && state.cookies.length > 0 ? { cookies: state.cookies } : {},
1507
1488
  ...Object.keys(state.localStorage || {}).length > 0 ? { local_storage: state.localStorage } : {},
1508
1489
  ...Object.keys(state.sessionStorage || {}).length > 0 ? { session_storage: state.sessionStorage } : {},
@@ -1510,16 +1491,10 @@ var RuntimeEnv = {
1510
1491
  };
1511
1492
  return Object.keys(envPatch).length > 0 ? envPatch : null;
1512
1493
  },
1513
- // hasLoginState 用来区分“必须鉴权的平台”和“可匿名运行的平台”。
1494
+ // hasLoginState 只判断 runtime 是否存在有效载荷,不再区分具体字段来源。
1514
1495
  hasLoginState(source = {}, actor = "") {
1515
1496
  const state = normalizeRuntimeState(source, actor);
1516
- 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;
1517
- },
1518
- getAuthValue(source = {}, key = "", actor = "") {
1519
- const state = normalizeRuntimeState(source, actor);
1520
- const safeKey = String(key || "").trim();
1521
- if (!safeKey) return "";
1522
- return String(state.auth?.[safeKey] ?? "").trim();
1497
+ return isPlainObject(state.runtime) && Object.keys(state.runtime || {}).length > 0;
1523
1498
  },
1524
1499
  rememberState(source = {}) {
1525
1500
  const state = normalizeRuntimeState(source);
@@ -1618,7 +1593,6 @@ var RuntimeEnv = {
1618
1593
  cookies
1619
1594
  },
1620
1595
  {
1621
- auth: state.auth,
1622
1596
  browserProfileCore: state.browserProfileCore
1623
1597
  }
1624
1598
  );