feat(api): show a user pool's Lambda triggers
This commit is contained in:
@@ -460,10 +460,43 @@ function toResource(pool: UserPoolType, clients: UserPoolClientDescription[], us
|
||||
mfaConfiguration: pool.MfaConfiguration ?? null,
|
||||
deletionProtection: pool.DeletionProtection ?? null,
|
||||
appClients: clients.map((client) => ({clientId: client.ClientId ?? '', clientName: client.ClientName ?? ''})),
|
||||
lambdaTriggers: lambdaTriggersOf(pool.LambdaConfig),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Labels as the AWS console names them, in the order a sign-up and sign-in reach them.
|
||||
const LAMBDA_TRIGGERS = [
|
||||
['PreSignUp', 'Pre sign-up'],
|
||||
['UserMigration', 'User migration'],
|
||||
['CustomMessage', 'Custom message'],
|
||||
['PostConfirmation', 'Post confirmation'],
|
||||
['PreAuthentication', 'Pre authentication'],
|
||||
['DefineAuthChallenge', 'Define auth challenge'],
|
||||
['CreateAuthChallenge', 'Create auth challenge'],
|
||||
['VerifyAuthChallengeResponse', 'Verify auth challenge response'],
|
||||
['PostAuthentication', 'Post authentication'],
|
||||
['PreTokenGeneration', 'Pre token generation'],
|
||||
['CustomEmailSender', 'Custom email sender'],
|
||||
['CustomSMSSender', 'Custom SMS sender'],
|
||||
] as const
|
||||
|
||||
type LambdaTrigger = {trigger: string; label: string; functionArn: string; functionName: string; version: string | null}
|
||||
|
||||
function lambdaTriggersOf(config: UserPoolType['LambdaConfig']): LambdaTrigger[] {
|
||||
if (!config) return []
|
||||
return LAMBDA_TRIGGERS.flatMap(([trigger, label]) => {
|
||||
// PreTokenGenerationConfig carries the trigger version and supersedes the older PreTokenGeneration field.
|
||||
const versioned = trigger === 'PreTokenGeneration' ? config.PreTokenGenerationConfig
|
||||
: trigger === 'CustomEmailSender' ? config.CustomEmailSender
|
||||
: trigger === 'CustomSMSSender' ? config.CustomSMSSender
|
||||
: undefined
|
||||
const functionArn = versioned?.LambdaArn ?? config[trigger]
|
||||
if (typeof functionArn !== 'string' || !functionArn) return []
|
||||
return [{trigger, label, functionArn, functionName: functionArn.split(':')[6] ?? functionArn, version: versioned?.LambdaVersion ?? null}]
|
||||
})
|
||||
}
|
||||
|
||||
function toUserItem(
|
||||
username: string | undefined,
|
||||
attributes: AttributeType[] | undefined,
|
||||
|
||||
Reference in New Issue
Block a user