Fixed even more ttp stuff
This commit is contained in:
parent
1dd75e9369
commit
dcd31cb0c5
2 changed files with 35 additions and 3 deletions
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit bafbf13f43a9f7092341ec102621e234438be163
|
|
||||||
|
|
@ -17,6 +17,7 @@ import Loading from "@tensamin/ui/screens/loading";
|
||||||
import ErrorScreen from "@tensamin/ui/screens/error";
|
import ErrorScreen from "@tensamin/ui/screens/error";
|
||||||
|
|
||||||
const FATAL_IDENTIFICATION_ERROR_TYPES = new Set([
|
const FATAL_IDENTIFICATION_ERROR_TYPES = new Set([
|
||||||
|
"error",
|
||||||
"error_invalid_user_id",
|
"error_invalid_user_id",
|
||||||
"error_no_user_id",
|
"error_no_user_id",
|
||||||
"error_invalid_challenge",
|
"error_invalid_challenge",
|
||||||
|
|
@ -82,7 +83,9 @@ function isFatalIdentificationError(error: unknown) {
|
||||||
if (
|
if (
|
||||||
error.message.includes("Missing or invalid user id") ||
|
error.message.includes("Missing or invalid user id") ||
|
||||||
error.message.includes("Missing private key") ||
|
error.message.includes("Missing private key") ||
|
||||||
error.message.includes("Identification challenge was rejected")
|
error.message.includes("Identification challenge was rejected") ||
|
||||||
|
error.message.includes("timed out after") ||
|
||||||
|
error.message.includes("Response validation failed")
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +93,33 @@ function isFatalIdentificationError(error: unknown) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts structured protocol error details for identification logging.
|
||||||
|
* @param error Unknown error raised during identification.
|
||||||
|
* @returns Structured protocol error details when available.
|
||||||
|
*/
|
||||||
|
function getProtocolErrorDetails(error: unknown) {
|
||||||
|
if (typeof error !== "object" || error === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!("type" in error)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const protocolError = error as {
|
||||||
|
id?: unknown;
|
||||||
|
type?: unknown;
|
||||||
|
data?: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: protocolError.id,
|
||||||
|
type: protocolError.type,
|
||||||
|
data: protocolError.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type ContextType = {
|
type ContextType = {
|
||||||
send: BoundSendFn<Schemas>;
|
send: BoundSendFn<Schemas>;
|
||||||
readyState: () => number;
|
readyState: () => number;
|
||||||
|
|
@ -415,13 +445,16 @@ export default function Provider(props: { children: React.ReactNode }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFatal = isFatalIdentificationError(identificationError);
|
const isFatal = isFatalIdentificationError(identificationError);
|
||||||
|
const protocolErrorDetails = getProtocolErrorDetails(
|
||||||
|
identificationError,
|
||||||
|
);
|
||||||
|
|
||||||
log(
|
log(
|
||||||
isFatal ? 0 : 1,
|
isFatal ? 0 : 1,
|
||||||
"Socket",
|
"Socket",
|
||||||
isFatal ? "red" : "yellow",
|
isFatal ? "red" : "yellow",
|
||||||
"Identification handshake failed",
|
"Identification handshake failed",
|
||||||
identificationError,
|
protocolErrorDetails ?? identificationError,
|
||||||
);
|
);
|
||||||
|
|
||||||
setIdentified(false);
|
setIdentified(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue