@openhi/constructs 0.0.6 → 0.0.7
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 +17 -1
- package/lib/index.d.ts +17 -1
- package/lib/index.js +50 -11
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +49 -11
- package/lib/index.mjs.map +1 -1
- package/lib/pre-token-generation.handler.d.mts +9 -0
- package/lib/pre-token-generation.handler.d.ts +9 -0
- package/lib/pre-token-generation.handler.js +34 -0
- package/lib/pre-token-generation.handler.js.map +1 -0
- package/lib/pre-token-generation.handler.mjs +11 -0
- package/lib/pre-token-generation.handler.mjs.map +1 -0
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -6,10 +6,12 @@ import { HttpApi, HttpApiProps, IHttpApi, DomainName } from 'aws-cdk-lib/aws-api
|
|
|
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';
|
|
9
|
+
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
9
10
|
import { Table, TableProps, ITable } from 'aws-cdk-lib/aws-dynamodb';
|
|
10
11
|
import { EventBus, EventBusProps, IEventBus } from 'aws-cdk-lib/aws-events';
|
|
11
12
|
import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
|
|
12
13
|
import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
|
|
14
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Properties for creating an OpenHiStage instance.
|
|
@@ -395,6 +397,14 @@ declare class CognitoUserPoolKmsKey extends Key {
|
|
|
395
397
|
constructor(scope: Construct, props?: KeyProps);
|
|
396
398
|
}
|
|
397
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Lambda used as Cognito Pre Token Generation trigger.
|
|
402
|
+
*/
|
|
403
|
+
declare class PreTokenGenerationLambda extends Construct {
|
|
404
|
+
readonly lambda: NodejsFunction;
|
|
405
|
+
constructor(scope: Construct);
|
|
406
|
+
}
|
|
407
|
+
|
|
398
408
|
/**
|
|
399
409
|
* DynamoDB table name for the data store. Used for cross-stack reference and
|
|
400
410
|
* deterministic naming per branch. The table backs multiple use cases (e.g.
|
|
@@ -578,6 +588,7 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
578
588
|
static userPoolKmsKeyFromConstruct(scope: Construct): IKey;
|
|
579
589
|
get serviceType(): string;
|
|
580
590
|
readonly userPoolKmsKey: IKey;
|
|
591
|
+
readonly preTokenGenerationLambda: IFunction;
|
|
581
592
|
readonly userPool: IUserPool;
|
|
582
593
|
readonly userPoolClient: IUserPoolClient;
|
|
583
594
|
readonly userPoolDomain: IUserPoolDomain;
|
|
@@ -588,6 +599,11 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
588
599
|
* Override to customize.
|
|
589
600
|
*/
|
|
590
601
|
protected createUserPoolKmsKey(): IKey;
|
|
602
|
+
/**
|
|
603
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). Phase 2 will add
|
|
604
|
+
* openhi_* claims to the access token only; trigger version V2_0 may be required.
|
|
605
|
+
*/
|
|
606
|
+
protected createPreTokenGenerationLambda(): IFunction;
|
|
591
607
|
/**
|
|
592
608
|
* Creates the Cognito User Pool and exports its ID to SSM.
|
|
593
609
|
* Look up via {@link OpenHiAuthService.userPoolFromConstruct}.
|
|
@@ -785,4 +801,4 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
785
801
|
protected createDataStore(): ITable;
|
|
786
802
|
}
|
|
787
803
|
|
|
788
|
-
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, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
|
|
804
|
+
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 };
|
package/lib/index.d.ts
CHANGED
|
@@ -5,10 +5,12 @@ import { IHttpApi, HttpApi, HttpApiProps, DomainName } from 'aws-cdk-lib/aws-api
|
|
|
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';
|
|
8
|
+
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
8
9
|
import { Table, TableProps, ITable } from 'aws-cdk-lib/aws-dynamodb';
|
|
9
10
|
import { EventBus, EventBusProps, IEventBus } from 'aws-cdk-lib/aws-events';
|
|
10
11
|
import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
|
|
11
12
|
import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
|
|
13
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
12
14
|
|
|
13
15
|
/*******************************************************************************
|
|
14
16
|
*
|
|
@@ -475,6 +477,14 @@ declare class CognitoUserPoolKmsKey extends Key {
|
|
|
475
477
|
constructor(scope: Construct, props?: KeyProps);
|
|
476
478
|
}
|
|
477
479
|
|
|
480
|
+
/**
|
|
481
|
+
* Lambda used as Cognito Pre Token Generation trigger.
|
|
482
|
+
*/
|
|
483
|
+
declare class PreTokenGenerationLambda extends Construct {
|
|
484
|
+
readonly lambda: NodejsFunction;
|
|
485
|
+
constructor(scope: Construct);
|
|
486
|
+
}
|
|
487
|
+
|
|
478
488
|
/**
|
|
479
489
|
* DynamoDB table name for the data store. Used for cross-stack reference and
|
|
480
490
|
* deterministic naming per branch. The table backs multiple use cases (e.g.
|
|
@@ -658,6 +668,7 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
658
668
|
static userPoolKmsKeyFromConstruct(scope: Construct): IKey;
|
|
659
669
|
get serviceType(): string;
|
|
660
670
|
readonly userPoolKmsKey: IKey;
|
|
671
|
+
readonly preTokenGenerationLambda: IFunction;
|
|
661
672
|
readonly userPool: IUserPool;
|
|
662
673
|
readonly userPoolClient: IUserPoolClient;
|
|
663
674
|
readonly userPoolDomain: IUserPoolDomain;
|
|
@@ -668,6 +679,11 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
668
679
|
* Override to customize.
|
|
669
680
|
*/
|
|
670
681
|
protected createUserPoolKmsKey(): IKey;
|
|
682
|
+
/**
|
|
683
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). Phase 2 will add
|
|
684
|
+
* openhi_* claims to the access token only; trigger version V2_0 may be required.
|
|
685
|
+
*/
|
|
686
|
+
protected createPreTokenGenerationLambda(): IFunction;
|
|
671
687
|
/**
|
|
672
688
|
* Creates the Cognito User Pool and exports its ID to SSM.
|
|
673
689
|
* Look up via {@link OpenHiAuthService.userPoolFromConstruct}.
|
|
@@ -865,5 +881,5 @@ declare class OpenHiDataService extends OpenHiService {
|
|
|
865
881
|
protected createDataStore(): ITable;
|
|
866
882
|
}
|
|
867
883
|
|
|
868
|
-
export { ChildHostedZone, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, DynamoDbDataStore, OpenHiApp, OpenHiAuthService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiRestApiService, OpenHiService, OpenHiStage, OpsEventBus, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
|
|
884
|
+
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 };
|
|
869
885
|
export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RootGraphqlApiProps };
|
package/lib/index.js
CHANGED
|
@@ -110,6 +110,7 @@ __export(src_exports, {
|
|
|
110
110
|
OpenHiService: () => OpenHiService,
|
|
111
111
|
OpenHiStage: () => OpenHiStage,
|
|
112
112
|
OpsEventBus: () => OpsEventBus,
|
|
113
|
+
PreTokenGenerationLambda: () => PreTokenGenerationLambda,
|
|
113
114
|
REST_API_BASE_URL_SSM_NAME: () => REST_API_BASE_URL_SSM_NAME,
|
|
114
115
|
RootGraphqlApi: () => RootGraphqlApi,
|
|
115
116
|
RootHostedZone: () => RootHostedZone,
|
|
@@ -656,6 +657,31 @@ var CognitoUserPoolKmsKey = class extends import_aws_kms.Key {
|
|
|
656
657
|
*/
|
|
657
658
|
CognitoUserPoolKmsKey.SSM_PARAM_NAME = "COGNITO_USER_POOL_KMS_KEY";
|
|
658
659
|
|
|
660
|
+
// src/components/cognito/pre-token-generation-lambda.ts
|
|
661
|
+
var import_fs = __toESM(require("fs"));
|
|
662
|
+
var import_path = __toESM(require("path"));
|
|
663
|
+
var import_aws_lambda = require("aws-cdk-lib/aws-lambda");
|
|
664
|
+
var import_aws_lambda_nodejs = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
665
|
+
var import_constructs = require("constructs");
|
|
666
|
+
var HANDLER_NAME = "pre-token-generation.handler.js";
|
|
667
|
+
function resolveHandlerEntry(dirname) {
|
|
668
|
+
const sameDir = import_path.default.join(dirname, HANDLER_NAME);
|
|
669
|
+
if (import_fs.default.existsSync(sameDir)) {
|
|
670
|
+
return sameDir;
|
|
671
|
+
}
|
|
672
|
+
const fromLib = import_path.default.join(dirname, "..", "..", "..", "lib", HANDLER_NAME);
|
|
673
|
+
return fromLib;
|
|
674
|
+
}
|
|
675
|
+
var PreTokenGenerationLambda = class extends import_constructs.Construct {
|
|
676
|
+
constructor(scope) {
|
|
677
|
+
super(scope, "pre-token-generation-lambda");
|
|
678
|
+
this.lambda = new import_aws_lambda_nodejs.NodejsFunction(this, "handler", {
|
|
679
|
+
entry: resolveHandlerEntry(__dirname),
|
|
680
|
+
runtime: import_aws_lambda.Runtime.NODEJS_LATEST
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
|
|
659
685
|
// src/components/dynamodb/dynamo-db-data-store.ts
|
|
660
686
|
var import_aws_dynamodb = require("aws-cdk-lib/aws-dynamodb");
|
|
661
687
|
function getDynamoDbDataStoreTableName(scope) {
|
|
@@ -797,8 +823,8 @@ var ChildHostedZone = class extends import_aws_route53.HostedZone {
|
|
|
797
823
|
ChildHostedZone.SSM_PARAM_NAME = "CHILDHOSTEDZONE";
|
|
798
824
|
|
|
799
825
|
// src/components/route-53/root-hosted-zone.ts
|
|
800
|
-
var
|
|
801
|
-
var RootHostedZone = class extends
|
|
826
|
+
var import_constructs2 = require("constructs");
|
|
827
|
+
var RootHostedZone = class extends import_constructs2.Construct {
|
|
802
828
|
};
|
|
803
829
|
|
|
804
830
|
// src/services/open-hi-auth-service.ts
|
|
@@ -809,6 +835,7 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
809
835
|
super(ohEnv, _OpenHiAuthService.SERVICE_TYPE, props);
|
|
810
836
|
this.props = props;
|
|
811
837
|
this.userPoolKmsKey = this.createUserPoolKmsKey();
|
|
838
|
+
this.preTokenGenerationLambda = this.createPreTokenGenerationLambda();
|
|
812
839
|
this.userPool = this.createUserPool();
|
|
813
840
|
this.userPoolClient = this.createUserPoolClient();
|
|
814
841
|
this.userPoolDomain = this.createUserPoolDomain();
|
|
@@ -877,6 +904,14 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
877
904
|
});
|
|
878
905
|
return key;
|
|
879
906
|
}
|
|
907
|
+
/**
|
|
908
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). Phase 2 will add
|
|
909
|
+
* openhi_* claims to the access token only; trigger version V2_0 may be required.
|
|
910
|
+
*/
|
|
911
|
+
createPreTokenGenerationLambda() {
|
|
912
|
+
const construct = new PreTokenGenerationLambda(this);
|
|
913
|
+
return construct.lambda;
|
|
914
|
+
}
|
|
880
915
|
/**
|
|
881
916
|
* Creates the Cognito User Pool and exports its ID to SSM.
|
|
882
917
|
* Look up via {@link OpenHiAuthService.userPoolFromConstruct}.
|
|
@@ -885,7 +920,10 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
885
920
|
createUserPool() {
|
|
886
921
|
const userPool = new CognitoUserPool(this, {
|
|
887
922
|
...this.props.userPoolProps,
|
|
888
|
-
customSenderKmsKey: this.userPoolKmsKey
|
|
923
|
+
customSenderKmsKey: this.userPoolKmsKey,
|
|
924
|
+
lambdaTriggers: {
|
|
925
|
+
preTokenGeneration: this.preTokenGenerationLambda
|
|
926
|
+
}
|
|
889
927
|
});
|
|
890
928
|
new DiscoverableStringParameter(this, "user-pool-param", {
|
|
891
929
|
ssmParamName: CognitoUserPool.SSM_PARAM_NAME,
|
|
@@ -1106,16 +1144,16 @@ _OpenHiDataService.SERVICE_TYPE = "data";
|
|
|
1106
1144
|
var OpenHiDataService = _OpenHiDataService;
|
|
1107
1145
|
|
|
1108
1146
|
// src/data/lambda/rest-api-lambda.ts
|
|
1109
|
-
var
|
|
1110
|
-
var
|
|
1111
|
-
var
|
|
1112
|
-
var
|
|
1113
|
-
var RestApiLambda = class extends
|
|
1147
|
+
var import_path2 = __toESM(require("path"));
|
|
1148
|
+
var import_aws_lambda2 = require("aws-cdk-lib/aws-lambda");
|
|
1149
|
+
var import_aws_lambda_nodejs2 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
1150
|
+
var import_constructs3 = require("constructs");
|
|
1151
|
+
var RestApiLambda = class extends import_constructs3.Construct {
|
|
1114
1152
|
constructor(scope, props) {
|
|
1115
1153
|
super(scope, "rest-api-lambda");
|
|
1116
|
-
this.lambda = new
|
|
1117
|
-
entry:
|
|
1118
|
-
runtime:
|
|
1154
|
+
this.lambda = new import_aws_lambda_nodejs2.NodejsFunction(this, "handler", {
|
|
1155
|
+
entry: import_path2.default.join(__dirname, "rest-api-lambda.handler.js"),
|
|
1156
|
+
runtime: import_aws_lambda2.Runtime.NODEJS_LATEST,
|
|
1119
1157
|
environment: {
|
|
1120
1158
|
DYNAMO_TABLE_NAME: props.dynamoTableName,
|
|
1121
1159
|
BRANCH_TAG_VALUE: props.branchTagValue,
|
|
@@ -1332,6 +1370,7 @@ var OpenHiRestApiService = _OpenHiRestApiService;
|
|
|
1332
1370
|
OpenHiService,
|
|
1333
1371
|
OpenHiStage,
|
|
1334
1372
|
OpsEventBus,
|
|
1373
|
+
PreTokenGenerationLambda,
|
|
1335
1374
|
REST_API_BASE_URL_SSM_NAME,
|
|
1336
1375
|
RootGraphqlApi,
|
|
1337
1376
|
RootHostedZone,
|