@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.mjs
CHANGED
|
@@ -802,15 +802,6 @@ import {
|
|
|
802
802
|
} from "aws-cdk-lib/aws-cognito";
|
|
803
803
|
import { Key as Key2 } from "aws-cdk-lib/aws-kms";
|
|
804
804
|
var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
805
|
-
constructor(ohEnv, props = {}) {
|
|
806
|
-
super(ohEnv, _OpenHiAuthService.SERVICE_TYPE, props);
|
|
807
|
-
this.props = props;
|
|
808
|
-
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
809
|
-
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
810
|
-
this.userPool = this.createUserPool();
|
|
811
|
-
this.userPoolClient = this.createUserPoolClient();
|
|
812
|
-
this.userPoolDomain = this.createUserPoolDomain();
|
|
813
|
-
}
|
|
814
805
|
/**
|
|
815
806
|
* Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
|
|
816
807
|
*/
|
|
@@ -861,6 +852,15 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
861
852
|
get serviceType() {
|
|
862
853
|
return _OpenHiAuthService.SERVICE_TYPE;
|
|
863
854
|
}
|
|
855
|
+
constructor(ohEnv, props = {}) {
|
|
856
|
+
super(ohEnv, _OpenHiAuthService.SERVICE_TYPE, props);
|
|
857
|
+
this.props = props;
|
|
858
|
+
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
859
|
+
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
860
|
+
this.userPool = this.createUserPool();
|
|
861
|
+
this.userPoolClient = this.createUserPoolClient();
|
|
862
|
+
this.userPoolDomain = this.createUserPoolDomain();
|
|
863
|
+
}
|
|
864
864
|
/**
|
|
865
865
|
* Creates the KMS key for the Cognito User Pool and exports its ARN to SSM.
|
|
866
866
|
* Look up via {@link OpenHiAuthService.userPoolKmsKeyFromConstruct}.
|
|
@@ -992,6 +992,7 @@ var _OpenHiGlobalService = class _OpenHiGlobalService extends OpenHiService {
|
|
|
992
992
|
}
|
|
993
993
|
constructor(ohEnv, props = {}) {
|
|
994
994
|
super(ohEnv, _OpenHiGlobalService.SERVICE_TYPE, props);
|
|
995
|
+
this.props = props;
|
|
995
996
|
this.validateConfig(props);
|
|
996
997
|
this.rootHostedZone = this.createRootHostedZone();
|
|
997
998
|
this.childHostedZone = this.createChildHostedZone();
|
|
@@ -1052,9 +1053,11 @@ var OpenHiGlobalService = _OpenHiGlobalService;
|
|
|
1052
1053
|
|
|
1053
1054
|
// src/services/open-hi-rest-api-service.ts
|
|
1054
1055
|
import {
|
|
1056
|
+
CorsHttpMethod,
|
|
1055
1057
|
DomainName,
|
|
1056
1058
|
HttpApi as HttpApi2,
|
|
1057
1059
|
HttpMethod,
|
|
1060
|
+
HttpNoneAuthorizer,
|
|
1058
1061
|
HttpRoute,
|
|
1059
1062
|
HttpRouteKey
|
|
1060
1063
|
} from "aws-cdk-lib/aws-apigatewayv2";
|
|
@@ -1067,6 +1070,7 @@ import {
|
|
|
1067
1070
|
RecordTarget
|
|
1068
1071
|
} from "aws-cdk-lib/aws-route53";
|
|
1069
1072
|
import { ApiGatewayv2DomainProperties } from "aws-cdk-lib/aws-route53-targets";
|
|
1073
|
+
import { Duration as Duration2 } from "aws-cdk-lib/core";
|
|
1070
1074
|
|
|
1071
1075
|
// src/services/open-hi-data-service.ts
|
|
1072
1076
|
import { Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
|
|
@@ -1103,6 +1107,7 @@ var _OpenHiDataService = class _OpenHiDataService extends OpenHiService {
|
|
|
1103
1107
|
}
|
|
1104
1108
|
constructor(ohEnv, props = {}) {
|
|
1105
1109
|
super(ohEnv, _OpenHiDataService.SERVICE_TYPE, props);
|
|
1110
|
+
this.props = props;
|
|
1106
1111
|
this.dataEventBus = this.createDataEventBus();
|
|
1107
1112
|
this.opsEventBus = this.createOpsEventBus();
|
|
1108
1113
|
this.dataStore = this.createDataStore();
|
|
@@ -1180,6 +1185,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1180
1185
|
}
|
|
1181
1186
|
constructor(ohEnv, props = {}) {
|
|
1182
1187
|
super(ohEnv, _OpenHiRestApiService.SERVICE_TYPE, props);
|
|
1188
|
+
this.props = props;
|
|
1183
1189
|
this.validateConfig(props);
|
|
1184
1190
|
const hostedZone = this.createHostedZone();
|
|
1185
1191
|
const certificate = this.createCertificate();
|
|
@@ -1296,6 +1302,19 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1296
1302
|
})
|
|
1297
1303
|
);
|
|
1298
1304
|
const integration = new HttpLambdaIntegration("lambda-integration", lambda);
|
|
1305
|
+
const noAuth = new HttpNoneAuthorizer();
|
|
1306
|
+
new HttpRoute(this, "options-route-root", {
|
|
1307
|
+
httpApi: this.rootHttpApi,
|
|
1308
|
+
routeKey: HttpRouteKey.with("/", HttpMethod.OPTIONS),
|
|
1309
|
+
integration,
|
|
1310
|
+
authorizer: noAuth
|
|
1311
|
+
});
|
|
1312
|
+
new HttpRoute(this, "options-route-proxy", {
|
|
1313
|
+
httpApi: this.rootHttpApi,
|
|
1314
|
+
routeKey: HttpRouteKey.with("/{proxy+}", HttpMethod.OPTIONS),
|
|
1315
|
+
integration,
|
|
1316
|
+
authorizer: noAuth
|
|
1317
|
+
});
|
|
1299
1318
|
new HttpRoute(this, "proxy-route-root", {
|
|
1300
1319
|
httpApi: this.rootHttpApi,
|
|
1301
1320
|
routeKey: HttpRouteKey.with("/", HttpMethod.ANY),
|
|
@@ -1331,12 +1350,32 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1331
1350
|
userPool,
|
|
1332
1351
|
{ userPoolClients: [userPoolClient] }
|
|
1333
1352
|
);
|
|
1353
|
+
const cors = this.props.cors;
|
|
1354
|
+
const corsPreflight = cors && cors.allowOrigins.length > 0 ? {
|
|
1355
|
+
allowOrigins: cors.allowOrigins,
|
|
1356
|
+
allowMethods: cors.allowMethods ?? [
|
|
1357
|
+
CorsHttpMethod.GET,
|
|
1358
|
+
CorsHttpMethod.HEAD,
|
|
1359
|
+
CorsHttpMethod.POST,
|
|
1360
|
+
CorsHttpMethod.PUT,
|
|
1361
|
+
CorsHttpMethod.PATCH,
|
|
1362
|
+
CorsHttpMethod.DELETE,
|
|
1363
|
+
CorsHttpMethod.OPTIONS
|
|
1364
|
+
],
|
|
1365
|
+
allowHeaders: cors.allowHeaders ?? [
|
|
1366
|
+
"Content-Type",
|
|
1367
|
+
"Authorization"
|
|
1368
|
+
],
|
|
1369
|
+
allowCredentials: cors.allowCredentials ?? true,
|
|
1370
|
+
maxAge: cors.maxAge ?? Duration2.days(1)
|
|
1371
|
+
} : void 0;
|
|
1334
1372
|
const rootHttpApi = new RootHttpApi(this, {
|
|
1335
1373
|
defaultDomainMapping: {
|
|
1336
1374
|
domainName,
|
|
1337
1375
|
mappingKey: void 0
|
|
1338
1376
|
},
|
|
1339
|
-
defaultAuthorizer: cognitoAuthorizer
|
|
1377
|
+
defaultAuthorizer: cognitoAuthorizer,
|
|
1378
|
+
...corsPreflight && { corsPreflight }
|
|
1340
1379
|
});
|
|
1341
1380
|
new DiscoverableStringParameter(this, "http-api-url-param", {
|
|
1342
1381
|
ssmParamName: RootHttpApi.SSM_PARAM_NAME,
|