feat: implement TASK-WP1-01 registration transaction

This commit is contained in:
suyx
2026-07-28 15:54:28 +08:00
parent 1bf7e42294
commit f467e7c09f
15 changed files with 2191 additions and 4 deletions
+25
View File
@@ -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;
}
}