{"record":{"id":"ca646497e7353f4e","repo":"jackwener/OpenCLI","slug":"coupang-com-ca6464","errorCode":null,"errorMessage":"coupang.com","messagePattern":"coupang\\.com","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/coupang/auth.js","lineNumber":11,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { registerSiteAuthCommands } from '../_shared/site-auth.js';\n\nasync function hasCoupangSessionCookie(page) {\n  const cookies = await page.getCookies({ url: 'https://www.coupang.com' });\n  return cookies.some(c => /^(AID|MEMBER_ID|LMSESSIONID)$/.test(c.name) && c.value);\n}\n\nasync function verifyCoupangIdentity(page) {\n  if (!await hasCoupangSessionCookie(page)) {\n    throw new AuthRequiredError('coupang.com', 'Coupang session cookies (AID/MEMBER_ID/LMSESSIONID) missing');\n  }\n  await page.goto('https://www.coupang.com/np/mypage');\n  await page.wait(3);\n  const probe = await page.evaluate(`\n    (() => {\n      if (/login\\\\.coupang\\\\.com\\\\/login/.test(location.href)) {\n        return { kind: 'auth', detail: 'Coupang mypage redirected to login — anonymous' };\n      }\n      if (/Access Denied/i.test(document.title)) {\n        return { kind: 'auth', detail: 'Coupang Access Denied — anti-bot or non-KR IP' };\n      }\n      const el = document.querySelector('.my-nickname, .member-name, .mp-user-info-name, [class*=memberName]');\n      const name = (el?.textContent || '').trim();\n      if (!name) {\n        return { kind: 'auth', detail: 'Coupang mypage 200 but no member-name surface' };\n      }\n      return { ok: true, name };\n    })()","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/auth.js#L1-L29","documentation":"AuthRequiredError('coupang.com') thrown by verifyCoupangIdentity when the attached Chrome page has none of the required Coupang session cookies (AID, MEMBER_ID, LMSESSIONID with non-empty values) for https://www.coupang.com. Identity verification cannot proceed without a logged-in session.","triggerScenarios":"Running coupang auth verify (or any flow calling verify) before logging in; the page.getCookies call returns no matching session cookies because the profile was never logged in or the session expired.","commonSituations":"Freshly launched Chrome profile with empty cookies; Coupang invalidated sessions server-side (forced logout, password change); cookies cleared by browser cleanup tooling; checking the wrong profile/user-data-dir.","solutions":["Run coupang auth login coupang and complete login at https://login.coupang.com/login/login.pang in the controlled Chrome","Confirm the Chrome profile/user-data-dir passed to the CLI is the one containing your Coupang session","Check cookies for https://www.coupang.com manually (DevTools → Application → Cookies) for AID/MEMBER_ID/LMSESSIONID","If the session was invalidated server-side, log in again — no client fix exists"],"exampleFix":"// before\n coupang auth verify coupang  # AuthRequiredError: session cookies missing\n// after\n coupang auth login coupang\n coupang auth verify coupang","handlingStrategy":"try-catch","validationCode":"const cookies = await page.getCookies({ url: 'https://www.coupang.com' });\nconst hasSession = cookies.some(c => /^(AID|MEMBER_ID|LMSESSIONID)$/.test(c.name) && c.value);\nif (!hasSession) {\n  throw new Error('Coupang session missing — run coupang auth login coupang first');\n}","typeGuard":"function hasCoupangSession(cookies) {\n  return Array.isArray(cookies) && cookies.some(\n    c => c && /^(AID|MEMBER_ID|LMSESSIONID)$/.test(c.name) && typeof c.value === 'string' && c.value.length > 0\n  );\n}","tryCatchPattern":"try {\n  const identity = await coupangVerify(page);\n} catch (err) {\n  if (err instanceof AuthRequiredError) {\n    await coupangLogin(page);   // interactive login flow\n    return coupangVerify(page);\n  }\n  throw err;\n}","preventionTips":["Run auth login before any session-dependent command","Pin the correct Chrome user-data-dir so cookies persist between runs","Re-login after Coupang forces logout (password change, server-side session invalidation)"],"tags":["authentication","cookies","coupang"],"backgroundTag":"site-auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}