Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/fnd-server/src/router.ts
Copy link
Member

@matthiasgeihs matthiasgeihs Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that is to be addressed here is unfortunately not clearly specified in the PR description.

From chat context, I assume that this is to resolve an issue where clients were sending invalid (keytype, sigtype) pairs. The change here will not help with this. The fix must be done in the client.

One thing we could change here is to improve the error messaging:
Currently we only print Invalid key type for ${sigType}, which doesn't print the keyType.
We could change the error message to include Invalid key type ${keyType} for sig type ${sigType}. (

if (sigType === SIG_TYPE.ECDSA_SECP256K1) {
if (keyType !== KEY_TYPE.SECP256K1) {
throw new Error("Invalid key type for ecdsa-secp256k1");
}
return dklsPath;
} else if (sigType === SIG_TYPE.ED25519) {
if (keyType !== KEY_TYPE.ED25519) {
throw new Error("Invalid key type for ed25519");
}
return frostPath;
} else if (sigType === SIG_TYPE.BIP340) {
if (keyType !== KEY_TYPE.SECP256K1) {
throw new Error("Invalid key type for bip340");
}
)

Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,21 @@ router.get(
),
async (req: Request, res: Response) => {
try {
const { network, keyType = KEY_TYPE.SECP256K1, sigType = SIG_TYPE.ECDSA_SECP256K1 } = req.query as Record<string, string>;
const { network, keyType, sigType } = req.query as Record<string, string>;
if ((keyType && !sigType) || (!keyType && sigType)) {
res.status(400).json({
success: false,
message: "keyType and sigType must be provided together",
});
return;
}
const finalNetwork = network.toLowerCase();
// use static details for sapphire mainnet and testnet
const nodeDetails = fetchLocalConfig(finalNetwork as TORUS_NETWORK_TYPE, keyType as WEB3AUTH_KEY_TYPE, sigType as WEB3AUTH_SIG_TYPE);
const nodeDetails = fetchLocalConfig(
finalNetwork as TORUS_NETWORK_TYPE,
(keyType ?? KEY_TYPE.SECP256K1) as WEB3AUTH_KEY_TYPE,
(sigType ?? SIG_TYPE.ECDSA_SECP256K1) as WEB3AUTH_SIG_TYPE
);

res.status(200).json({
nodeDetails,
Expand Down