UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.33 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpUserPoolAuthorizer=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var aws_apigatewayv2_1=()=>{var tmp=require("../../../aws-apigatewayv2");return aws_apigatewayv2_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../../core/lib/errors");return errors_1=()=>tmp,tmp};class HttpUserPoolAuthorizer{constructor(id,pool,props={}){this.id=id,this.pool=pool,this.props=props,this.authorizationType="JWT";try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cognito_IUserPool(pool),jsiiDeprecationWarnings().aws_cdk_lib_aws_apigatewayv2_authorizers_HttpUserPoolAuthorizerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HttpUserPoolAuthorizer),error}}get authorizerId(){if(!this.authorizer)throw new(errors_1()).UnscopedValidationError("Cannot access authorizerId until authorizer is attached to a HttpRoute");return this.authorizer.authorizerId}bind(options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigatewayv2_HttpRouteAuthorizerBindOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(!this.authorizer){const region=this.props.userPoolRegion??core_1().Stack.of(options.scope).region,clients=this.props.userPoolClients??[this.pool.addClient("UserPoolAuthorizerClient")];this.authorizer=new(aws_apigatewayv2_1()).HttpAuthorizer(options.scope,this.id,{httpApi:options.route.httpApi,identitySource:this.props.identitySource??["$request.header.Authorization"],type:aws_apigatewayv2_1().HttpAuthorizerType.JWT,authorizerName:this.props.authorizerName??this.id,jwtAudience:clients.map(c=>c.userPoolClientId),jwtIssuer:`https://cognito-idp.${region}.amazonaws.com/${this.pool.userPoolId}`})}return{authorizerId:this.authorizer.authorizerId,authorizationType:this.authorizationType}}}exports.HttpUserPoolAuthorizer=HttpUserPoolAuthorizer,_a=JSII_RTTI_SYMBOL_1,HttpUserPoolAuthorizer[_a]={fqn:"aws-cdk-lib.aws_apigatewayv2_authorizers.HttpUserPoolAuthorizer",version:"2.185.0"};