"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GatewayAuthorizer=exports.NoAuthAuthorizer=exports.IamAuthorizer=exports.CustomJwtAuthorizer=exports.GatewayAuthorizerType=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var errors_1=()=>{var tmp=require("../../../../core/lib/errors");return errors_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp},GatewayAuthorizerType;(function(GatewayAuthorizerType2){GatewayAuthorizerType2.CUSTOM_JWT="CUSTOM_JWT",GatewayAuthorizerType2.AWS_IAM="AWS_IAM",GatewayAuthorizerType2.NONE="NONE"})(GatewayAuthorizerType||(exports.GatewayAuthorizerType=GatewayAuthorizerType={}));class CustomJwtAuthorizer{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.CustomJwtAuthorizer",version:"2.256.1"};authorizerType=GatewayAuthorizerType.CUSTOM_JWT;discoveryUrl;allowedAudience;allowedClients;allowedScopes;customClaims;constructor(config){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_CustomJwtConfiguration(config)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CustomJwtAuthorizer),error}this.discoveryUrl=config.discoveryUrl,this.allowedAudience=config.allowedAudience,this.allowedClients=config.allowedClients,this.allowedScopes=config.allowedScopes,this.customClaims=config.customClaims}_render(){return{customJwtAuthorizer:{discoveryUrl:this.discoveryUrl,...this.allowedAudience&&{allowedAudience:this.allowedAudience},...this.allowedClients&&{allowedClients:this.allowedClients},...this.allowedScopes&&{allowedScopes:this.allowedScopes},...this.customClaims&&this.customClaims.length>0&&{customClaims:this.customClaims.map(claim=>claim._render())}}}}}exports.CustomJwtAuthorizer=CustomJwtAuthorizer;class IamAuthorizer{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.IamAuthorizer",version:"2.256.1"};authorizerType=GatewayAuthorizerType.AWS_IAM;_render(){}}exports.IamAuthorizer=IamAuthorizer;class NoAuthAuthorizer{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.NoAuthAuthorizer",version:"2.256.1"};authorizerType=GatewayAuthorizerType.NONE;_render(){}}exports.NoAuthAuthorizer=NoAuthAuthorizer;class GatewayAuthorizer{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.GatewayAuthorizer",version:"2.256.1"};static usingAwsIam(){return new IamAuthorizer}static usingCustomJwt(configuration){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_CustomJwtConfiguration(configuration)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.usingCustomJwt),error}if(!configuration.allowedAudience&&!configuration.allowedClients&&!configuration.allowedScopes&&!configuration.customClaims)throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`CustomJwtConfigurationRequired`,"At least one of allowedAudience, allowedClients, allowedScopes, or customClaims must be defined for CUSTOM_JWT authorizer");return new CustomJwtAuthorizer(configuration)}static usingCognito(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_CognitoAuthorizerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.usingCognito),error}const discoveryUrl=`https://cognito-idp.${props.userPool.env.region}.amazonaws.com/${props.userPool.userPoolId}/.well-known/openid-configuration`;return new CustomJwtAuthorizer({discoveryUrl,allowedClients:props.allowedClients?.flatMap(client=>client.userPoolClientId),allowedAudience:props.allowedAudiences,allowedScopes:props.allowedScopes,customClaims:props.customClaims})}static withNoAuth(){return new NoAuthAuthorizer}}exports.GatewayAuthorizer=GatewayAuthorizer;
