MCPcopy Create free account
hub / github.com/F12FLASH/CTF / validateAccessCode

Method validateAccessCode

7.GraphQL Apocalypse/server/storage.ts:41–66  ·  view source on GitHub ↗
(inputCode: string)

Source from the content-addressed store, hash-verified

39 }
40
41 async validateAccessCode(inputCode: string): Promise<boolean> {
42 try {
43 const now = Date.now();
44
45 if (now - this.lastAttemptTime > this.RATE_LIMIT_WINDOW) {
46 this.attemptCount = 0;
47 }
48
49 this.attemptCount++;
50 this.lastAttemptTime = now;
51
52 if (this.attemptCount > this.MAX_ATTEMPTS) {
53 await new Promise(resolve => setTimeout(resolve, 3000));
54 }
55
56 const isValid = await bcrypt.compare(inputCode, this.SECRET_ACCESS_CODE_HASH);
57
58 if (isValid) {
59 this.attemptCount = 0;
60 }
61
62 return isValid;
63 } catch (error) {
64 return false;
65 }
66 }
67
68 async unlockSecretData(accessCode: string): Promise<{ flag: string } | null> {
69 const isValid = await this.validateAccessCode(accessCode);

Callers 1

unlockSecretDataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected