{"version":3,"file":"getCookieValuesFromRequest.mjs","sources":["../../../../src/auth/utils/getCookieValuesFromRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ensureEncodedForJSCookie } from '../../utils/cookie/ensureEncodedForJSCookie';\nexport const getCookieValuesFromRequest = (request, cookieNames) => {\n    const cookieHeader = request.headers.get('Cookie');\n    if (!cookieHeader) {\n        return {};\n    }\n    const cookieValues = cookieHeader\n        .split(';')\n        .map(cookie => cookie.trim().split('='))\n        .reduce((result, [key, value]) => {\n        result[key] = value;\n        return result;\n    }, {});\n    // Cookie names are written via `ensureEncodedForJSCookie`, so they appear\n    // percent-encoded on the wire when they contain unsafe characters (e.g. `@`\n    // in email-based Cognito usernames). Match the lookup keys using the same\n    // encoding so reads align with writes.\n    const result = {};\n    for (const cookieName of cookieNames) {\n        result[cookieName] = cookieValues[ensureEncodedForJSCookie(cookieName)];\n    }\n    return result;\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,0BAA0B,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK;AACpE,IAAI,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACtD,IAAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,OAAO,EAAE;AACjB,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG;AACzB,SAAS,KAAK,CAAC,GAAG;AAClB,SAAS,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;AAC/C,SAAS,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC1C,QAAQ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AAC3B,QAAQ,OAAO,MAAM;AACrB,IAAI,CAAC,EAAE,EAAE,CAAC;AACV;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,EAAE;AACrB,IAAI,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;AAC1C,QAAQ,MAAM,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;AAC/E,IAAI;AACJ,IAAI,OAAO,MAAM;AACjB;;;;"}