{"version":3,"file":"hasActiveUserSession.mjs","sources":["../../../../src/auth/utils/hasActiveUserSession.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getCurrentUser } from 'aws-amplify/auth/server';\nexport const hasActiveUserSessionWithAppRouter = async ({ request, runWithAmplifyServerContext, }) => {\n    const dummyResponse = new Response();\n    try {\n        await runWithAmplifyServerContext({\n            nextServerContext: { request, response: dummyResponse },\n            operation(contextSpec) {\n                return getCurrentUser(contextSpec);\n            },\n        });\n        return true;\n    }\n    catch (_) {\n        // `getCurrentUser()` throws if there is no valid token\n        return false;\n    }\n};\nexport const hasActiveUserSessionWithPagesRouter = async ({ request, response, runWithAmplifyServerContext, }) => {\n    try {\n        await runWithAmplifyServerContext({\n            nextServerContext: { request, response },\n            operation(contextSpec) {\n                return getCurrentUser(contextSpec);\n            },\n        });\n        return true;\n    }\n    catch (_) {\n        // `getCurrentUser()` throws if there is no valid token\n        return false;\n    }\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,iCAAiC,GAAG,OAAO,EAAE,OAAO,EAAE,2BAA2B,GAAG,KAAK;AACtG,IAAI,MAAM,aAAa,GAAG,IAAI,QAAQ,EAAE;AACxC,IAAI,IAAI;AACR,QAAQ,MAAM,2BAA2B,CAAC;AAC1C,YAAY,iBAAiB,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE;AACnE,YAAY,SAAS,CAAC,WAAW,EAAE;AACnC,gBAAgB,OAAO,cAAc,CAAC,WAAW,CAAC;AAClD,YAAY,CAAC;AACb,SAAS,CAAC;AACV,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,OAAO,CAAC,EAAE;AACd;AACA,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ;AACY,MAAC,mCAAmC,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,2BAA2B,GAAG,KAAK;AAClH,IAAI,IAAI;AACR,QAAQ,MAAM,2BAA2B,CAAC;AAC1C,YAAY,iBAAiB,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;AACpD,YAAY,SAAS,CAAC,WAAW,EAAE;AACnC,gBAAgB,OAAO,cAAc,CAAC,WAAW,CAAC;AAClD,YAAY,CAAC;AACb,SAAS,CAAC;AACV,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,OAAO,CAAC,EAAE;AACd;AACA,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ;;;;"}