@getalby/mcp
Version:
MCP server for controlling a Lightning wallet using Nostr Wallet Connect
21 lines (20 loc) • 764 B
JavaScript
function getConnectionSecretFromBearerAuth(authorizationHeader) {
const authParts = authorizationHeader?.split(" ");
if (authParts?.length !== 2 ||
authParts[0] !== "Bearer" ||
!authParts[1].startsWith("nostr+walletconnect://")) {
return undefined;
}
return authParts[1];
}
function getConnectionSecretFromQueryParam(nwcParam) {
if (!nwcParam || !nwcParam.startsWith("nostr+walletconnect://")) {
return undefined;
}
return nwcParam;
}
export function getConnectionSecret(authorizationHeader, nwcQueryParam) {
// Try query parameter first, then fall back to bearer auth
return (getConnectionSecretFromQueryParam(nwcQueryParam) ||
getConnectionSecretFromBearerAuth(authorizationHeader));
}