Skip to content

Commit

Permalink
fix(response): add access denied catch and prevent throwing on `_Sign…
Browse files Browse the repository at this point in the history
…ature_` check because of `in` (#60)
  • Loading branch information
Vexcited committed Sep 8, 2024
1 parent 297af6a commit c58b193
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/response-function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageUnavailableError, RateLimitedError, ServerSideError, SessionExpiredError, SuspendedIPError, type SessionHandle } from "~/models";
import { AccessDeniedError, PageUnavailableError, RateLimitedError, ServerSideError, SessionExpiredError, SuspendedIPError, type SessionHandle } from "~/models";
import forge from "node-forge";
import { AES } from "../api/private/aes";
import pako from "pako";
Expand Down Expand Up @@ -27,7 +27,7 @@ export class ResponseFN {
this.data = JSON.parse(this.data);
}

if ("_Signature_" in this.data && this.data._Signature_.Erreur) {
if (typeof this.data?._Signature_?.Erreur !== "undefined") {
throw new ServerSideError(this.data._Signature_.MessageErreur);
}
}
Expand All @@ -48,6 +48,11 @@ export class ResponseFN {
throw new RateLimitedError();
}

// "Accès refusé", we just trying to prevent using accents.
else if (content.includes("s refus")) {
throw new AccessDeniedError();
}

throw error;
}
}
Expand Down

0 comments on commit c58b193

Please sign in to comment.