feat: implement TASK-WP1-01 registration transaction
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
export interface RegistrationCodeMessage {
|
||||
challengeId: string;
|
||||
code: string;
|
||||
email: string;
|
||||
purpose: "register";
|
||||
}
|
||||
|
||||
export interface ResendAdapter {
|
||||
sendRegistrationCode(message: RegistrationCodeMessage): Promise<void>;
|
||||
}
|
||||
|
||||
export class MockResendAdapter implements ResendAdapter {
|
||||
readonly calls: RegistrationCodeMessage[] = [];
|
||||
|
||||
async sendRegistrationCode(message: RegistrationCodeMessage) {
|
||||
this.calls.push({ ...message });
|
||||
}
|
||||
|
||||
readLatestCode(email: string) {
|
||||
const normalizedEmail = email.trim().toLowerCase();
|
||||
const call = this.calls.findLast((candidate) => candidate.email === normalizedEmail);
|
||||
if (!call) throw new Error("No mock registration message exists for that email.");
|
||||
return call.code;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user