-
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core,schemas): add auditLogs to experience API (#6361)
* refactor(core): refactor backup code generate flow refactor backup code generate flow * fix(core): fix api payload fix api payload * fix(core): fix rebase issue fix rebase issue * feat(core,schemas): add auditLogs to experience API add auditLogs to experience API
- Loading branch information
Showing
16 changed files
with
341 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/core/src/routes/experience/middleware/koa-experience-verifications-audit-log.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { type VerificationType } from '@logto/schemas'; | ||
import { type Action } from '@logto/schemas/lib/types/log/interaction.js'; | ||
import { type MiddlewareType } from 'koa'; | ||
import { type IRouterParamContext } from 'koa-router'; | ||
|
||
import { type LogContext, type LogEntry } from '#src/middleware/koa-audit-log.js'; | ||
|
||
import { type WithExperienceInteractionContext } from './koa-experience-interaction.js'; | ||
|
||
type WithExperienceVerificationAuditLogContext<ContextT extends IRouterParamContext> = ContextT & { | ||
verificationAuditLog: LogEntry; | ||
}; | ||
|
||
export default function koaExperienceVerificationsAuditLog< | ||
StateT, | ||
ContextT extends WithExperienceInteractionContext & LogContext, | ||
ResponseT, | ||
>({ | ||
type, | ||
action, | ||
}: { | ||
type: VerificationType; | ||
action: Action; | ||
}): MiddlewareType<StateT, WithExperienceVerificationAuditLogContext<ContextT>, ResponseT> { | ||
return async (ctx, next) => { | ||
const { experienceInteraction, createLog } = ctx; | ||
|
||
const log = createLog( | ||
`Interaction.${experienceInteraction.interactionEvent}.Verification.${type}.${action}` | ||
); | ||
|
||
ctx.verificationAuditLog = log; | ||
|
||
return next(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.