@openhi/constructs 0.0.92 → 0.0.93
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 +28 -5
- package/lib/index.d.ts +28 -5
- package/lib/index.js +34 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +34 -5
- package/lib/index.mjs.map +1 -1
- package/lib/pre-token-generation.handler.d.mts +0 -7
- package/lib/pre-token-generation.handler.d.ts +0 -7
- package/lib/pre-token-generation.handler.js +885 -11
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +87 -11
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/package.json +3 -3
package/lib/index.d.mts
CHANGED
|
@@ -500,12 +500,23 @@ declare class PostConfirmationLambda extends Construct {
|
|
|
500
500
|
constructor(scope: Construct, props: PostConfirmationLambdaProps);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
+
interface PreTokenGenerationLambdaProps {
|
|
504
|
+
/**
|
|
505
|
+
* DynamoDB data store table name. Passed to the Lambda as DYNAMO_TABLE_NAME
|
|
506
|
+
* so the control-plane ElectroDB service reads the User by Cognito `sub`
|
|
507
|
+
* (GSI2) and the user's first active Membership (fallback path).
|
|
508
|
+
*/
|
|
509
|
+
readonly dynamoTableName: string;
|
|
510
|
+
}
|
|
503
511
|
/**
|
|
504
|
-
* Lambda used as Cognito Pre Token Generation trigger.
|
|
512
|
+
* Lambda used as Cognito Pre Token Generation trigger. Resolves the OpenHI
|
|
513
|
+
* User from the request's Cognito `sub` and injects `ohi_tid`, `ohi_wid`,
|
|
514
|
+
* `ohi_uid`, `ohi_uname` into both the ID token and the access token
|
|
515
|
+
* (ADR 2026-03-17-01).
|
|
505
516
|
*/
|
|
506
517
|
declare class PreTokenGenerationLambda extends Construct {
|
|
507
518
|
readonly lambda: NodejsFunction;
|
|
508
|
-
constructor(scope: Construct);
|
|
519
|
+
constructor(scope: Construct, props: PreTokenGenerationLambdaProps);
|
|
509
520
|
}
|
|
510
521
|
|
|
511
522
|
/**
|
|
@@ -983,8 +994,10 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
983
994
|
*/
|
|
984
995
|
protected createUserPoolKmsKey(): IKey;
|
|
985
996
|
/**
|
|
986
|
-
* Creates the Pre Token Generation Lambda (Cognito trigger).
|
|
987
|
-
*
|
|
997
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). On every
|
|
998
|
+
* sign-in and token refresh the Lambda resolves the User by Cognito `sub`
|
|
999
|
+
* (GSI2) and injects `ohi_tid`, `ohi_wid`, `ohi_uid`, `ohi_uname` into
|
|
1000
|
+
* both the ID token and the access token (ADR 2026-03-17-01).
|
|
988
1001
|
*/
|
|
989
1002
|
protected createPreTokenGenerationLambda(): IFunction;
|
|
990
1003
|
/**
|
|
@@ -1008,6 +1021,16 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
1008
1021
|
* Override to customize.
|
|
1009
1022
|
*/
|
|
1010
1023
|
protected createUserPool(): IUserPool;
|
|
1024
|
+
/**
|
|
1025
|
+
* Grants the Pre Token Generation Lambda read-only access on the data
|
|
1026
|
+
* store table and its GSIs. The Lambda only needs:
|
|
1027
|
+
* - `Query` on GSI2 to resolve a User by Cognito `sub`
|
|
1028
|
+
* - `GetItem` on the base table for direct User reads
|
|
1029
|
+
*
|
|
1030
|
+
* No write or scan access: a User missing `currentTenant`/`currentWorkspace`
|
|
1031
|
+
* falls into the absent-claims path; repair belongs in a separate backfill.
|
|
1032
|
+
*/
|
|
1033
|
+
protected grantPreTokenGenerationPermissions(): void;
|
|
1011
1034
|
/**
|
|
1012
1035
|
* Grants the Post Authentication Lambda permission to call
|
|
1013
1036
|
* `cognito-idp:AdminUserGlobalSignOut`.
|
|
@@ -1289,4 +1312,4 @@ declare class OpenHiGraphqlService extends OpenHiService {
|
|
|
1289
1312
|
protected createRootGraphqlApi(): RootGraphqlApi;
|
|
1290
1313
|
}
|
|
1291
1314
|
|
|
1292
|
-
export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoFixtureSeederClient, type CognitoFixtureSeederClientProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES, DATA_STORE_CHANGE_DETAIL_TYPE, DATA_STORE_CHANGE_EVENT_SOURCE, DataEventBus, DataStoreHistoricalArchive, type DataStoreHistoricalArchiveProps, DataStorePostgresReplica, type DataStorePostgresReplicaProps, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, type FhirCurrentResourceChangeDetail, OpenHiApp, type OpenHiAppProps, OpenHiAuthService, type OpenHiAuthServiceProps, OpenHiDataService, type OpenHiDataServiceProps, OpenHiEnvironment, type OpenHiEnvironmentProps, OpenHiGlobalService, type OpenHiGlobalServiceProps, OpenHiGraphqlService, type OpenHiGraphqlServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME, POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME, POSTGRES_REPLICA_SECRET_ARN_SSM_NAME, PostAuthenticationLambda, PostConfirmationLambda, type PostConfirmationLambdaProps, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, type RootHttpApiProps, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, type StaticHostingProps, buildFhirCurrentResourceChangeDetail, getDynamoDbDataStoreTableName, getPostgresReplicaSchemaName };
|
|
1315
|
+
export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoFixtureSeederClient, type CognitoFixtureSeederClientProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES, DATA_STORE_CHANGE_DETAIL_TYPE, DATA_STORE_CHANGE_EVENT_SOURCE, DataEventBus, DataStoreHistoricalArchive, type DataStoreHistoricalArchiveProps, DataStorePostgresReplica, type DataStorePostgresReplicaProps, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, type FhirCurrentResourceChangeDetail, OpenHiApp, type OpenHiAppProps, OpenHiAuthService, type OpenHiAuthServiceProps, OpenHiDataService, type OpenHiDataServiceProps, OpenHiEnvironment, type OpenHiEnvironmentProps, OpenHiGlobalService, type OpenHiGlobalServiceProps, OpenHiGraphqlService, type OpenHiGraphqlServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME, POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME, POSTGRES_REPLICA_SECRET_ARN_SSM_NAME, PostAuthenticationLambda, PostConfirmationLambda, type PostConfirmationLambdaProps, PreTokenGenerationLambda, type PreTokenGenerationLambdaProps, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, type RootHttpApiProps, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, type StaticHostingProps, buildFhirCurrentResourceChangeDetail, getDynamoDbDataStoreTableName, getPostgresReplicaSchemaName };
|
package/lib/index.d.ts
CHANGED
|
@@ -595,12 +595,23 @@ declare class PostConfirmationLambda extends Construct {
|
|
|
595
595
|
constructor(scope: Construct, props: PostConfirmationLambdaProps);
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
+
interface PreTokenGenerationLambdaProps {
|
|
599
|
+
/**
|
|
600
|
+
* DynamoDB data store table name. Passed to the Lambda as DYNAMO_TABLE_NAME
|
|
601
|
+
* so the control-plane ElectroDB service reads the User by Cognito `sub`
|
|
602
|
+
* (GSI2) and the user's first active Membership (fallback path).
|
|
603
|
+
*/
|
|
604
|
+
readonly dynamoTableName: string;
|
|
605
|
+
}
|
|
598
606
|
/**
|
|
599
|
-
* Lambda used as Cognito Pre Token Generation trigger.
|
|
607
|
+
* Lambda used as Cognito Pre Token Generation trigger. Resolves the OpenHI
|
|
608
|
+
* User from the request's Cognito `sub` and injects `ohi_tid`, `ohi_wid`,
|
|
609
|
+
* `ohi_uid`, `ohi_uname` into both the ID token and the access token
|
|
610
|
+
* (ADR 2026-03-17-01).
|
|
600
611
|
*/
|
|
601
612
|
declare class PreTokenGenerationLambda extends Construct {
|
|
602
613
|
readonly lambda: NodejsFunction;
|
|
603
|
-
constructor(scope: Construct);
|
|
614
|
+
constructor(scope: Construct, props: PreTokenGenerationLambdaProps);
|
|
604
615
|
}
|
|
605
616
|
|
|
606
617
|
/**
|
|
@@ -1078,8 +1089,10 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
1078
1089
|
*/
|
|
1079
1090
|
protected createUserPoolKmsKey(): IKey;
|
|
1080
1091
|
/**
|
|
1081
|
-
* Creates the Pre Token Generation Lambda (Cognito trigger).
|
|
1082
|
-
*
|
|
1092
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). On every
|
|
1093
|
+
* sign-in and token refresh the Lambda resolves the User by Cognito `sub`
|
|
1094
|
+
* (GSI2) and injects `ohi_tid`, `ohi_wid`, `ohi_uid`, `ohi_uname` into
|
|
1095
|
+
* both the ID token and the access token (ADR 2026-03-17-01).
|
|
1083
1096
|
*/
|
|
1084
1097
|
protected createPreTokenGenerationLambda(): IFunction;
|
|
1085
1098
|
/**
|
|
@@ -1103,6 +1116,16 @@ declare class OpenHiAuthService extends OpenHiService {
|
|
|
1103
1116
|
* Override to customize.
|
|
1104
1117
|
*/
|
|
1105
1118
|
protected createUserPool(): IUserPool;
|
|
1119
|
+
/**
|
|
1120
|
+
* Grants the Pre Token Generation Lambda read-only access on the data
|
|
1121
|
+
* store table and its GSIs. The Lambda only needs:
|
|
1122
|
+
* - `Query` on GSI2 to resolve a User by Cognito `sub`
|
|
1123
|
+
* - `GetItem` on the base table for direct User reads
|
|
1124
|
+
*
|
|
1125
|
+
* No write or scan access: a User missing `currentTenant`/`currentWorkspace`
|
|
1126
|
+
* falls into the absent-claims path; repair belongs in a separate backfill.
|
|
1127
|
+
*/
|
|
1128
|
+
protected grantPreTokenGenerationPermissions(): void;
|
|
1106
1129
|
/**
|
|
1107
1130
|
* Grants the Post Authentication Lambda permission to call
|
|
1108
1131
|
* `cognito-idp:AdminUserGlobalSignOut`.
|
|
@@ -1385,4 +1408,4 @@ declare class OpenHiGraphqlService extends OpenHiService {
|
|
|
1385
1408
|
}
|
|
1386
1409
|
|
|
1387
1410
|
export { ChildHostedZone, CognitoFixtureSeederClient, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES, DATA_STORE_CHANGE_DETAIL_TYPE, DATA_STORE_CHANGE_EVENT_SOURCE, DataEventBus, DataStoreHistoricalArchive, DataStorePostgresReplica, DiscoverableStringParameter, DynamoDbDataStore, OpenHiApp, OpenHiAuthService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiGraphqlService, OpenHiRestApiService, OpenHiService, OpenHiStage, OpsEventBus, POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME, POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME, POSTGRES_REPLICA_SECRET_ARN_SSM_NAME, PostAuthenticationLambda, PostConfirmationLambda, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, RootHostedZone, RootHttpApi, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, buildFhirCurrentResourceChangeDetail, getDynamoDbDataStoreTableName, getPostgresReplicaSchemaName };
|
|
1388
|
-
export type { BuildParameterNameProps, ChildHostedZoneProps, CognitoFixtureSeederClientProps, DataStoreHistoricalArchiveProps, DataStorePostgresReplicaProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, FhirCurrentResourceChangeDetail, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiGraphqlServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, PostConfirmationLambdaProps, RootGraphqlApiProps, RootHttpApiProps, StaticHostingProps };
|
|
1411
|
+
export type { BuildParameterNameProps, ChildHostedZoneProps, CognitoFixtureSeederClientProps, DataStoreHistoricalArchiveProps, DataStorePostgresReplicaProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, FhirCurrentResourceChangeDetail, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiGraphqlServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, PostConfirmationLambdaProps, PreTokenGenerationLambdaProps, RootGraphqlApiProps, RootHttpApiProps, StaticHostingProps };
|
package/lib/index.js
CHANGED
|
@@ -795,12 +795,15 @@ function resolveHandlerEntry3(dirname) {
|
|
|
795
795
|
return fromLib;
|
|
796
796
|
}
|
|
797
797
|
var PreTokenGenerationLambda = class extends import_constructs3.Construct {
|
|
798
|
-
constructor(scope) {
|
|
798
|
+
constructor(scope, props) {
|
|
799
799
|
super(scope, "pre-token-generation-lambda");
|
|
800
800
|
this.lambda = new import_aws_lambda_nodejs3.NodejsFunction(this, "handler", {
|
|
801
801
|
entry: resolveHandlerEntry3(__dirname),
|
|
802
802
|
runtime: import_aws_lambda3.Runtime.NODEJS_LATEST,
|
|
803
|
-
memorySize: 1024
|
|
803
|
+
memorySize: 1024,
|
|
804
|
+
environment: {
|
|
805
|
+
DYNAMO_TABLE_NAME: props.dynamoTableName
|
|
806
|
+
}
|
|
804
807
|
});
|
|
805
808
|
}
|
|
806
809
|
};
|
|
@@ -1513,6 +1516,7 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1513
1516
|
this.postAuthenticationLambda = this.createPostAuthenticationLambda();
|
|
1514
1517
|
this.postConfirmationLambda = this.createPostConfirmationLambda();
|
|
1515
1518
|
this.userPool = this.createUserPool();
|
|
1519
|
+
this.grantPreTokenGenerationPermissions();
|
|
1516
1520
|
this.grantPostAuthenticationPermissions();
|
|
1517
1521
|
this.grantPostConfirmationPermissions();
|
|
1518
1522
|
this.userPoolClient = this.createUserPoolClient();
|
|
@@ -1605,11 +1609,15 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1605
1609
|
return key;
|
|
1606
1610
|
}
|
|
1607
1611
|
/**
|
|
1608
|
-
* Creates the Pre Token Generation Lambda (Cognito trigger).
|
|
1609
|
-
*
|
|
1612
|
+
* Creates the Pre Token Generation Lambda (Cognito trigger). On every
|
|
1613
|
+
* sign-in and token refresh the Lambda resolves the User by Cognito `sub`
|
|
1614
|
+
* (GSI2) and injects `ohi_tid`, `ohi_wid`, `ohi_uid`, `ohi_uname` into
|
|
1615
|
+
* both the ID token and the access token (ADR 2026-03-17-01).
|
|
1610
1616
|
*/
|
|
1611
1617
|
createPreTokenGenerationLambda() {
|
|
1612
|
-
const construct = new PreTokenGenerationLambda(this
|
|
1618
|
+
const construct = new PreTokenGenerationLambda(this, {
|
|
1619
|
+
dynamoTableName: this.dataStoreTable().tableName
|
|
1620
|
+
});
|
|
1613
1621
|
return construct.lambda;
|
|
1614
1622
|
}
|
|
1615
1623
|
/**
|
|
@@ -1670,6 +1678,27 @@ var _OpenHiAuthService = class _OpenHiAuthService extends OpenHiService {
|
|
|
1670
1678
|
});
|
|
1671
1679
|
return userPool;
|
|
1672
1680
|
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Grants the Pre Token Generation Lambda read-only access on the data
|
|
1683
|
+
* store table and its GSIs. The Lambda only needs:
|
|
1684
|
+
* - `Query` on GSI2 to resolve a User by Cognito `sub`
|
|
1685
|
+
* - `GetItem` on the base table for direct User reads
|
|
1686
|
+
*
|
|
1687
|
+
* No write or scan access: a User missing `currentTenant`/`currentWorkspace`
|
|
1688
|
+
* falls into the absent-claims path; repair belongs in a separate backfill.
|
|
1689
|
+
*/
|
|
1690
|
+
grantPreTokenGenerationPermissions() {
|
|
1691
|
+
const dataStoreTable = this.dataStoreTable();
|
|
1692
|
+
const dynamoActions = ["dynamodb:GetItem", "dynamodb:Query"];
|
|
1693
|
+
dataStoreTable.grant(this.preTokenGenerationLambda, ...dynamoActions);
|
|
1694
|
+
this.preTokenGenerationLambda.addToRolePolicy(
|
|
1695
|
+
new import_aws_iam.PolicyStatement({
|
|
1696
|
+
effect: import_aws_iam.Effect.ALLOW,
|
|
1697
|
+
actions: [...dynamoActions],
|
|
1698
|
+
resources: [`${dataStoreTable.tableArn}/index/*`]
|
|
1699
|
+
})
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1673
1702
|
/**
|
|
1674
1703
|
* Grants the Post Authentication Lambda permission to call
|
|
1675
1704
|
* `cognito-idp:AdminUserGlobalSignOut`.
|