{"version":3,"file":"predicates.mjs","sources":["../../../../src/auth/utils/predicates.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n// NextRequest is the 1st parameter type for the API route handlers in the App Router\nexport function isNextRequest(request) {\n    // NextRequest extends the Web Request API with additional convenience methods.\n    // Details: https://nextjs.org/docs/app/api-reference/functions/next-request#nexturl\n    //\n    // Use duck typing instead of instanceof to handle Lambda/serverless environments\n    // where Request constructor references may differ between invocations\n    return (typeof request === 'object' &&\n        request !== null &&\n        // NextRequest-specific properties\n        'nextUrl' in request &&\n        typeof request.nextUrl === 'object' &&\n        request.nextUrl !== null &&\n        'cookies' in request &&\n        // Basic Request API properties\n        'url' in request &&\n        typeof request.url === 'string' &&\n        'headers' in request &&\n        'method' in request &&\n        typeof request.method === 'string');\n}\n// AuthRoutesHandlersContext is the 2nd parameter type for the API route handlers in the App Router\nexport function isAuthRoutesHandlersContext(context) {\n    return ('params' in context &&\n        context.params !== undefined &&\n        context.params !== null);\n}\n// NextApiRequest is the 1st parameter type for the API route handlers in the Pages Router\nexport function isNextApiRequest(request) {\n    // Can't use `IncomingMessage` to validate the request is an instance of `NextApiRequest`\n    // as `import from 'http'` breaks the Next.js build.\n    // The `query` property is a convenience method added to the underlying `IncomingMessage`.\n    return ('query' in request &&\n        Object.prototype.toString.call(request.query) === '[object Object]');\n}\n// NextApiResponse is the 2nd parameter type for the API route handlers in the Pages Router\nexport function isNextApiResponse(response) {\n    // Can't use `ServerResponse` to validate the request is an instance of `NextApiResponse`\n    // as `import from 'http'` breaks the Next.js build.\n    // The `redirect` method is a convenience method added to the underlying `ServerResponse`.\n    return 'redirect' in response && typeof response.redirect === 'function';\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,OAAO,EAAE;AACvC;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,OAAO,OAAO,KAAK,QAAQ;AACvC,QAAQ,OAAO,KAAK,IAAI;AACxB;AACA,QAAQ,SAAS,IAAI,OAAO;AAC5B,QAAQ,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;AAC3C,QAAQ,OAAO,CAAC,OAAO,KAAK,IAAI;AAChC,QAAQ,SAAS,IAAI,OAAO;AAC5B;AACA,QAAQ,KAAK,IAAI,OAAO;AACxB,QAAQ,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;AACvC,QAAQ,SAAS,IAAI,OAAO;AAC5B,QAAQ,QAAQ,IAAI,OAAO;AAC3B,QAAQ,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ;AAC1C;AACA;AACO,SAAS,2BAA2B,CAAC,OAAO,EAAE;AACrD,IAAI,QAAQ,QAAQ,IAAI,OAAO;AAC/B,QAAQ,OAAO,CAAC,MAAM,KAAK,SAAS;AACpC,QAAQ,OAAO,CAAC,MAAM,KAAK,IAAI;AAC/B;AACA;AACO,SAAS,gBAAgB,CAAC,OAAO,EAAE;AAC1C;AACA;AACA;AACA,IAAI,QAAQ,OAAO,IAAI,OAAO;AAC9B,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,iBAAiB;AAC3E;AACA;AACO,SAAS,iBAAiB,CAAC,QAAQ,EAAE;AAC5C;AACA;AACA;AACA,IAAI,OAAO,UAAU,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,UAAU;AAC5E;;;;"}