-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Require mfa code to disable mfa
Continuation of #10341 Also enables rate limiting for the `/mfa/disable` endpoint. For the FE: - adds a typed event emitter - a mechanism to use Modal event emitter to provide data back from the modal
- Loading branch information
Showing
19 changed files
with
260 additions
and
87 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
7 changes: 7 additions & 0 deletions
7
packages/cli/src/errors/response-errors/invalid-mfa-code.error.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,7 @@ | ||
import { ForbiddenError } from './forbidden.error'; | ||
|
||
export class InvalidMfaCodeError extends ForbiddenError { | ||
constructor(hint?: string) { | ||
super('Invalid two-factor code.', hint); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { UnregisterFn } from './event-bus'; | ||
import { createEventBus as createUntypedEventBus } from './event-bus'; | ||
|
||
export type Listener<Payload> = (payload: Payload) => void; | ||
|
||
export type Payloads<ListenerMap> = { | ||
[E in keyof ListenerMap]: unknown; | ||
}; | ||
|
||
export interface TypedEventBus<ListenerMap extends Payloads<ListenerMap>> { | ||
on: <EventName extends keyof ListenerMap & string>( | ||
eventName: EventName, | ||
fn: Listener<ListenerMap[EventName]>, | ||
) => UnregisterFn; | ||
|
||
once: <EventName extends keyof ListenerMap & string>( | ||
eventName: EventName, | ||
fn: Listener<ListenerMap[EventName]>, | ||
) => UnregisterFn; | ||
|
||
off: <EventName extends keyof ListenerMap & string>( | ||
eventName: EventName, | ||
fn: Listener<ListenerMap[EventName]>, | ||
) => void; | ||
|
||
emit: <EventName extends keyof ListenerMap & string>( | ||
eventName: EventName, | ||
event?: ListenerMap[EventName], | ||
) => void; | ||
} | ||
|
||
export function createTypedEventBus< | ||
ListenerMap extends Payloads<ListenerMap>, | ||
>(): TypedEventBus<ListenerMap> { | ||
return createUntypedEventBus() as TypedEventBus<ListenerMap>; | ||
} |
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
Oops, something went wrong.