type PairingCommandAuthParams = {
channel: string;
gatewayClientScopes?: readonly string[] | null ;
};
export type PairingCommandAuthState = {
isInternalGatewayCaller: boolean ;
isMissingInternalPairingPrivilege: boolean ;
approvalCallerScopes?: readonly string[];
};
function isInternalGatewayPairingCaller(params: PairingCommandAuthParams): boolean {
return params.channel === "webchat" || Array.isArray(params.gatewayClientScopes);
}
export function resolvePairingCommandAuthState(
params: PairingCommandAuthParams,
): PairingCommandAuthState {
const isInternalGatewayCaller = isInternalGatewayPairingCaller(params);
if (!isInternalGatewayCaller) {
return {
isInternalGatewayCaller,
isMissingInternalPairingPrivilege: false ,
approvalCallerScopes: undefined,
};
}
const approvalCallerScopes = Array.isArray(params.gatewayClientScopes)
? params.gatewayClientScopes
: [];
const isMissingInternalPairingPrivilege =
!approvalCallerScopes.includes("operator.pairing" ) &&
!approvalCallerScopes.includes("operator.admin" );
return {
isInternalGatewayCaller,
isMissingInternalPairingPrivilege,
approvalCallerScopes,
};
}
export function buildMissingPairingScopeReply(): { text: string } {
return {
text: "⚠️ This command requires operator.pairing for internal gateway callers." ,
};
}
Messung V0.5 in Prozent C=92 H=98 G=94
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland