@openhi/constructs 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.mts +33 -3
- package/lib/index.d.ts +33 -3
- package/lib/index.js +47 -10
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +49 -10
- package/lib/index.mjs.map +1 -1
- package/lib/pre-token-generation.handler.d.mts +1 -1
- package/lib/pre-token-generation.handler.d.ts +1 -1
- package/lib/pre-token-generation.handler.js +5 -1
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +5 -1
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { OPEN_HI_STAGE, OPEN_HI_DEPLOYMENT_TARGET_ROLE, OpenHiEnvironmentConfig,
|
|
|
2
2
|
import { Stage, StageProps, App, AppProps, Stack, StackProps, RemovalPolicy } from 'aws-cdk-lib';
|
|
3
3
|
import { IConstruct, Construct } from 'constructs';
|
|
4
4
|
import { Certificate, CertificateProps, ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
|
|
5
|
-
import { HttpApi, HttpApiProps, IHttpApi, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
5
|
+
import { HttpApi, HttpApiProps, IHttpApi, CorsHttpMethod, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
6
6
|
import { GraphqlApi, IGraphqlApi, GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
|
|
7
7
|
import { UserPool, UserPoolProps, UserPoolClient, UserPoolClientProps, UserPoolDomain, UserPoolDomainProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
|
|
8
8
|
import { Key, KeyProps, IKey } from 'aws-cdk-lib/aws-kms';
|
|
@@ -12,6 +12,7 @@ import { EventBus, EventBusProps, IEventBus } from 'aws-cdk-lib/aws-events';
|
|
|
12
12
|
import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
|
|
13
13
|
import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
|
|
14
14
|
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
15
|
+
import { Duration } from 'aws-cdk-lib/core';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Properties for creating an OpenHiStage instance.
|
|
@@ -613,7 +614,6 @@ interface OpenHiAuthServiceProps extends OpenHiServiceProps {
|
|
|
613
614
|
* @public
|
|
614
615
|
*/
|
|
615
616
|
declare class OpenHiAuthService extends OpenHiService {
|
|
616
|
-
props: OpenHiAuthServiceProps;
|
|
617
617
|
static readonly SERVICE_TYPE = "auth";
|
|
618
618
|
/**
|
|
619
619
|
* Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
|
|
@@ -632,6 +632,8 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
632
632
|
*/
|
|
633
633
|
static userPoolKmsKeyFromConstruct(scope: Construct): IKey;
|
|
634
634
|
get serviceType(): string;
|
|
635
|
+
/** Override so this.props is typed with this service's options (e.g. userPoolProps). */
|
|
636
|
+
props: OpenHiAuthServiceProps;
|
|
635
637
|
readonly userPoolKmsKey: IKey;
|
|
636
638
|
readonly preTokenGenerationLambda: IFunction;
|
|
637
639
|
readonly userPool: IUserPool;
|
|
@@ -697,6 +699,8 @@ declare class OpenHiGlobalService extends OpenHiService {
|
|
|
697
699
|
serviceType?: OpenHiServiceType;
|
|
698
700
|
}): IHostedZone;
|
|
699
701
|
get serviceType(): string;
|
|
702
|
+
/** Override so this.props is typed with this service's options. */
|
|
703
|
+
props: OpenHiGlobalServiceProps;
|
|
700
704
|
readonly rootHostedZone: IHostedZone;
|
|
701
705
|
readonly childHostedZone?: IHostedZone;
|
|
702
706
|
readonly rootWildcardCertificate: ICertificate;
|
|
@@ -728,7 +732,29 @@ declare class OpenHiGlobalService extends OpenHiService {
|
|
|
728
732
|
/**
|
|
729
733
|
* @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-rest-api-service.md
|
|
730
734
|
*/
|
|
735
|
+
/**
|
|
736
|
+
* CORS configuration for the REST API HTTP API (API Gateway v2).
|
|
737
|
+
* When origins are set, API Gateway sends CORS headers; backend CORS headers are ignored for browser requests.
|
|
738
|
+
*/
|
|
739
|
+
interface RestApiCorsOptions {
|
|
740
|
+
/** Allowed origins (e.g. https://app.example.com, http://localhost:3000). Required when enabling CORS. */
|
|
741
|
+
readonly allowOrigins: string[];
|
|
742
|
+
/** Allowed HTTP methods. Defaults to GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
743
|
+
readonly allowMethods?: CorsHttpMethod[];
|
|
744
|
+
/** Allowed request headers. Defaults to Content-Type, Authorization. */
|
|
745
|
+
readonly allowHeaders?: string[];
|
|
746
|
+
/** Whether to allow credentials (cookies, auth headers). Default true. */
|
|
747
|
+
readonly allowCredentials?: boolean;
|
|
748
|
+
/** How long preflight results can be cached. Default 1 day. */
|
|
749
|
+
readonly maxAge?: Duration;
|
|
750
|
+
}
|
|
731
751
|
interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
|
|
752
|
+
/**
|
|
753
|
+
* Optional CORS configuration for the root HTTP API.
|
|
754
|
+
* When set, API Gateway will send CORS headers for the given origins.
|
|
755
|
+
* When omitted, no CORS is configured at the gateway (Express CORS in the Lambda still applies for direct or non-browser use).
|
|
756
|
+
*/
|
|
757
|
+
readonly cors?: RestApiCorsOptions;
|
|
732
758
|
}
|
|
733
759
|
/**
|
|
734
760
|
* SSM parameter name suffix for the REST API base URL.
|
|
@@ -751,6 +777,8 @@ declare class OpenHiRestApiService extends OpenHiService {
|
|
|
751
777
|
*/
|
|
752
778
|
static restApiBaseUrlFromConstruct(scope: Construct): string;
|
|
753
779
|
get serviceType(): string;
|
|
780
|
+
/** Override so this.props is typed with this service's options (e.g. cors). */
|
|
781
|
+
props: OpenHiRestApiServiceProps;
|
|
754
782
|
readonly rootHttpApi: RootHttpApi;
|
|
755
783
|
constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
|
|
756
784
|
/**
|
|
@@ -822,6 +850,8 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
822
850
|
*/
|
|
823
851
|
static dynamoDbDataStoreFromConstruct(scope: Construct, id?: string): ITable;
|
|
824
852
|
get serviceType(): string;
|
|
853
|
+
/** Override so this.props is typed with this service's options. */
|
|
854
|
+
props: OpenHiDataServiceProps;
|
|
825
855
|
/**
|
|
826
856
|
* Event bus for data-related events (ingestion, transformation, storage).
|
|
827
857
|
* Other stacks obtain it via {@link OpenHiDataService.dataEventBusFromConstruct}.
|
|
@@ -855,4 +885,4 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
855
885
|
protected createDataStore(): ITable;
|
|
856
886
|
}
|
|
857
887
|
|
|
858
|
-
export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, OpenHiApp, type OpenHiAppProps, OpenHiAuthService, type OpenHiAuthServiceProps, OpenHiDataService, type OpenHiDataServiceProps, OpenHiEnvironment, type OpenHiEnvironmentProps, OpenHiGlobalService, type OpenHiGlobalServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
|
|
888
|
+
export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, OpenHiApp, type OpenHiAppProps, OpenHiAuthService, type OpenHiAuthServiceProps, OpenHiDataService, type OpenHiDataServiceProps, OpenHiEnvironment, type OpenHiEnvironmentProps, OpenHiGlobalService, type OpenHiGlobalServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, type RestApiCorsOptions, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RemovalPolicy, App, AppProps, Stage, StageProps, Stack, StackProps } from 'aws-cdk-lib';
|
|
2
2
|
import { Construct, IConstruct } from 'constructs';
|
|
3
3
|
import { ICertificate, Certificate, CertificateProps } from 'aws-cdk-lib/aws-certificatemanager';
|
|
4
|
-
import { IHttpApi, HttpApi, HttpApiProps, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
4
|
+
import { IHttpApi, CorsHttpMethod, HttpApi, HttpApiProps, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
5
5
|
import { GraphqlApi, IGraphqlApi, GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
|
|
6
6
|
import { UserPool, UserPoolProps, UserPoolClient, UserPoolClientProps, UserPoolDomain, UserPoolDomainProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
|
|
7
7
|
import { Key, KeyProps, IKey } from 'aws-cdk-lib/aws-kms';
|
|
@@ -11,6 +11,7 @@ import { EventBus, EventBusProps, IEventBus } from 'aws-cdk-lib/aws-events';
|
|
|
11
11
|
import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
|
|
12
12
|
import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
|
|
13
13
|
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
14
|
+
import { Duration } from 'aws-cdk-lib/core';
|
|
14
15
|
|
|
15
16
|
/*******************************************************************************
|
|
16
17
|
*
|
|
@@ -693,7 +694,6 @@ interface OpenHiAuthServiceProps extends OpenHiServiceProps {
|
|
|
693
694
|
* @public
|
|
694
695
|
*/
|
|
695
696
|
declare class OpenHiAuthService extends OpenHiService {
|
|
696
|
-
props: OpenHiAuthServiceProps;
|
|
697
697
|
static readonly SERVICE_TYPE = "auth";
|
|
698
698
|
/**
|
|
699
699
|
* Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
|
|
@@ -712,6 +712,8 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
712
712
|
*/
|
|
713
713
|
static userPoolKmsKeyFromConstruct(scope: Construct): IKey;
|
|
714
714
|
get serviceType(): string;
|
|
715
|
+
/** Override so this.props is typed with this service's options (e.g. userPoolProps). */
|
|
716
|
+
props: OpenHiAuthServiceProps;
|
|
715
717
|
readonly userPoolKmsKey: IKey;
|
|
716
718
|
readonly preTokenGenerationLambda: IFunction;
|
|
717
719
|
readonly userPool: IUserPool;
|
|
@@ -777,6 +779,8 @@ declare class OpenHiGlobalService extends OpenHiService {
|
|
|
777
779
|
serviceType?: OpenHiServiceType;
|
|
778
780
|
}): IHostedZone;
|
|
779
781
|
get serviceType(): string;
|
|
782
|
+
/** Override so this.props is typed with this service's options. */
|
|
783
|
+
props: OpenHiGlobalServiceProps;
|
|
780
784
|
readonly rootHostedZone: IHostedZone;
|
|
781
785
|
readonly childHostedZone?: IHostedZone;
|
|
782
786
|
readonly rootWildcardCertificate: ICertificate;
|
|
@@ -808,7 +812,29 @@ declare class OpenHiGlobalService extends OpenHiService {
|
|
|
808
812
|
/**
|
|
809
813
|
* @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-rest-api-service.md
|
|
810
814
|
*/
|
|
815
|
+
/**
|
|
816
|
+
* CORS configuration for the REST API HTTP API (API Gateway v2).
|
|
817
|
+
* When origins are set, API Gateway sends CORS headers; backend CORS headers are ignored for browser requests.
|
|
818
|
+
*/
|
|
819
|
+
interface RestApiCorsOptions {
|
|
820
|
+
/** Allowed origins (e.g. https://app.example.com, http://localhost:3000). Required when enabling CORS. */
|
|
821
|
+
readonly allowOrigins: string[];
|
|
822
|
+
/** Allowed HTTP methods. Defaults to GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
823
|
+
readonly allowMethods?: CorsHttpMethod[];
|
|
824
|
+
/** Allowed request headers. Defaults to Content-Type, Authorization. */
|
|
825
|
+
readonly allowHeaders?: string[];
|
|
826
|
+
/** Whether to allow credentials (cookies, auth headers). Default true. */
|
|
827
|
+
readonly allowCredentials?: boolean;
|
|
828
|
+
/** How long preflight results can be cached. Default 1 day. */
|
|
829
|
+
readonly maxAge?: Duration;
|
|
830
|
+
}
|
|
811
831
|
interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
|
|
832
|
+
/**
|
|
833
|
+
* Optional CORS configuration for the root HTTP API.
|
|
834
|
+
* When set, API Gateway will send CORS headers for the given origins.
|
|
835
|
+
* When omitted, no CORS is configured at the gateway (Express CORS in the Lambda still applies for direct or non-browser use).
|
|
836
|
+
*/
|
|
837
|
+
readonly cors?: RestApiCorsOptions;
|
|
812
838
|
}
|
|
813
839
|
/**
|
|
814
840
|
* SSM parameter name suffix for the REST API base URL.
|
|
@@ -831,6 +857,8 @@ declare class OpenHiRestApiService extends OpenHiService {
|
|
|
831
857
|
*/
|
|
832
858
|
static restApiBaseUrlFromConstruct(scope: Construct): string;
|
|
833
859
|
get serviceType(): string;
|
|
860
|
+
/** Override so this.props is typed with this service's options (e.g. cors). */
|
|
861
|
+
props: OpenHiRestApiServiceProps;
|
|
834
862
|
readonly rootHttpApi: RootHttpApi;
|
|
835
863
|
constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
|
|
836
864
|
/**
|
|
@@ -902,6 +930,8 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
902
930
|
*/
|
|
903
931
|
static dynamoDbDataStoreFromConstruct(scope: Construct, id?: string): ITable;
|
|
904
932
|
get serviceType(): string;
|
|
933
|
+
/** Override so this.props is typed with this service's options. */
|
|
934
|
+
props: OpenHiDataServiceProps;
|
|
905
935
|
/**
|
|
906
936
|
* Event bus for data-related events (ingestion, transformation, storage).
|
|
907
937
|
* Other stacks obtain it via {@link OpenHiDataService.dataEventBusFromConstruct}.
|
|
@@ -936,4 +966,4 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
936
966
|
}
|
|
937
967
|
|
|
938
968
|
export { ChildHostedZone, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, DynamoDbDataStore, OpenHiApp, OpenHiAuthService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiRestApiService, OpenHiService, OpenHiStage, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
|
|
939
|
-
export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RootGraphqlApiProps };
|
|
969
|
+
export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RestApiCorsOptions, RootGraphqlApiProps };
|
package/lib/index.js
CHANGED
|
@@ -831,15 +831,6 @@ var RootHostedZone = class extends import_constructs2.Construct {
|
|
|
831
831
|
var import_aws_cognito4 = require("aws-cdk-lib/aws-cognito");
|
|
832
832
|
var import_aws_kms2 = require("aws-cdk-lib/aws-kms");
|
|
833
833
|
var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
834
|
-
constructor(ohEnv, props = {}) {
|
|
835
|
-
super(ohEnv, _OpenHiAuthService.SERVICE_TYPE, props);
|
|
836
|
-
this.props = props;
|
|
837
|
-
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
838
|
-
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
839
|
-
this.userPool = this.createUserPool();
|
|
840
|
-
this.userPoolClient = this.createUserPoolClient();
|
|
841
|
-
this.userPoolDomain = this.createUserPoolDomain();
|
|
842
|
-
}
|
|
843
834
|
/**
|
|
844
835
|
* Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
|
|
845
836
|
*/
|
|
@@ -890,6 +881,15 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
890
881
|
get serviceType() {
|
|
891
882
|
return _OpenHiAuthService.SERVICE_TYPE;
|
|
892
883
|
}
|
|
884
|
+
constructor(ohEnv, props = {}) {
|
|
885
|
+
super(ohEnv, _OpenHiAuthService.SERVICE_TYPE, props);
|
|
886
|
+
this.props = props;
|
|
887
|
+
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
888
|
+
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
889
|
+
this.userPool = this.createUserPool();
|
|
890
|
+
this.userPoolClient = this.createUserPoolClient();
|
|
891
|
+
this.userPoolDomain = this.createUserPoolDomain();
|
|
892
|
+
}
|
|
893
893
|
/**
|
|
894
894
|
* Creates the KMS key for the Cognito User Pool and exports its ARN to SSM.
|
|
895
895
|
* Look up via {@link OpenHiAuthService.userPoolKmsKeyFromConstruct}.
|
|
@@ -1016,6 +1016,7 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
constructor(ohEnv, props = {}) {
|
|
1018
1018
|
super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
|
|
1019
|
+
this.props = props;
|
|
1019
1020
|
this.validateConfig(props);
|
|
1020
1021
|
this.rootHostedZone = this.createRootHostedZone();
|
|
1021
1022
|
this.childHostedZone = this.createChildHostedZone();
|
|
@@ -1081,6 +1082,7 @@ var import_aws_apigatewayv2_integrations = require("aws-cdk-lib/aws-apigatewayv2
|
|
|
1081
1082
|
var import_aws_iam = require("aws-cdk-lib/aws-iam");
|
|
1082
1083
|
var import_aws_route533 = require("aws-cdk-lib/aws-route53");
|
|
1083
1084
|
var import_aws_route53_targets = require("aws-cdk-lib/aws-route53-targets");
|
|
1085
|
+
var import_core = require("aws-cdk-lib/core");
|
|
1084
1086
|
|
|
1085
1087
|
// src/services/open-hi-data-service.ts
|
|
1086
1088
|
var import_aws_dynamodb2 = require("aws-cdk-lib/aws-dynamodb");
|
|
@@ -1117,6 +1119,7 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1117
1119
|
}
|
|
1118
1120
|
constructor(ohEnv, props = {}) {
|
|
1119
1121
|
super(ohEnv, _OpenHiDataService.SERVICE_TYPE, props);
|
|
1122
|
+
this.props = props;
|
|
1120
1123
|
this.dataEventBus = this.createDataEventBus();
|
|
1121
1124
|
this.opsEventBus = this.createOpsEventBus();
|
|
1122
1125
|
this.dataStore = this.createDataStore();
|
|
@@ -1194,6 +1197,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1194
1197
|
}
|
|
1195
1198
|
constructor(ohEnv, props = {}) {
|
|
1196
1199
|
super(ohEnv, _OpenHiRestApiService.SERVICE_TYPE, props);
|
|
1200
|
+
this.props = props;
|
|
1197
1201
|
this.validateConfig(props);
|
|
1198
1202
|
const hostedZone = this.createHostedZone();
|
|
1199
1203
|
const certificate = this.createCertificate();
|
|
@@ -1310,6 +1314,19 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1310
1314
|
})
|
|
1311
1315
|
);
|
|
1312
1316
|
const integration = new import_aws_apigatewayv2_integrations.HttpLambdaIntegration("lambda-integration", lambda);
|
|
1317
|
+
const noAuth = new import_aws_apigatewayv22.HttpNoneAuthorizer();
|
|
1318
|
+
new import_aws_apigatewayv22.HttpRoute(this, "options-route-root", {
|
|
1319
|
+
httpApi: this.rootHttpApi,
|
|
1320
|
+
routeKey: import_aws_apigatewayv22.HttpRouteKey.with("/", import_aws_apigatewayv22.HttpMethod.OPTIONS),
|
|
1321
|
+
integration,
|
|
1322
|
+
authorizer: noAuth
|
|
1323
|
+
});
|
|
1324
|
+
new import_aws_apigatewayv22.HttpRoute(this, "options-route-proxy", {
|
|
1325
|
+
httpApi: this.rootHttpApi,
|
|
1326
|
+
routeKey: import_aws_apigatewayv22.HttpRouteKey.with("/{proxy+}", import_aws_apigatewayv22.HttpMethod.OPTIONS),
|
|
1327
|
+
integration,
|
|
1328
|
+
authorizer: noAuth
|
|
1329
|
+
});
|
|
1313
1330
|
new import_aws_apigatewayv22.HttpRoute(this, "proxy-route-root", {
|
|
1314
1331
|
httpApi: this.rootHttpApi,
|
|
1315
1332
|
routeKey: import_aws_apigatewayv22.HttpRouteKey.with("/", import_aws_apigatewayv22.HttpMethod.ANY),
|
|
@@ -1345,12 +1362,32 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1345
1362
|
userPool,
|
|
1346
1363
|
{ userPoolClients: [userPoolClient] }
|
|
1347
1364
|
);
|
|
1365
|
+
const cors = this.props.cors;
|
|
1366
|
+
const corsPreflight = cors && cors.allowOrigins.length > 0 ? {
|
|
1367
|
+
allowOrigins: cors.allowOrigins,
|
|
1368
|
+
allowMethods: cors.allowMethods ?? [
|
|
1369
|
+
import_aws_apigatewayv22.CorsHttpMethod.GET,
|
|
1370
|
+
import_aws_apigatewayv22.CorsHttpMethod.HEAD,
|
|
1371
|
+
import_aws_apigatewayv22.CorsHttpMethod.POST,
|
|
1372
|
+
import_aws_apigatewayv22.CorsHttpMethod.PUT,
|
|
1373
|
+
import_aws_apigatewayv22.CorsHttpMethod.PATCH,
|
|
1374
|
+
import_aws_apigatewayv22.CorsHttpMethod.DELETE,
|
|
1375
|
+
import_aws_apigatewayv22.CorsHttpMethod.OPTIONS
|
|
1376
|
+
],
|
|
1377
|
+
allowHeaders: cors.allowHeaders ?? [
|
|
1378
|
+
"Content-Type",
|
|
1379
|
+
"Authorization"
|
|
1380
|
+
],
|
|
1381
|
+
allowCredentials: cors.allowCredentials ?? true,
|
|
1382
|
+
maxAge: cors.maxAge ?? import_core.Duration.days(1)
|
|
1383
|
+
} : void 0;
|
|
1348
1384
|
const rootHttpApi = new RootHttpApi(this, {
|
|
1349
1385
|
defaultDomainMapping: {
|
|
1350
1386
|
domainName,
|
|
1351
1387
|
mappingKey: void 0
|
|
1352
1388
|
},
|
|
1353
|
-
defaultAuthorizer: cognitoAuthorizer
|
|
1389
|
+
defaultAuthorizer: cognitoAuthorizer,
|
|
1390
|
+
...corsPreflight && { corsPreflight }
|
|
1354
1391
|
});
|
|
1355
1392
|
new DiscoverableStringParameter(this, "http-api-url-param", {
|
|
1356
1393
|
ssmParamName: RootHttpApi.SSM_PARAM_NAME,
|