review valere (more readable force new endpoint logic)
This commit is contained in:
@@ -118,15 +118,14 @@ export async function getSFUConfigWithOpenID(
|
|||||||
|
|
||||||
let sfuConfig: { url: string; jwt: string } | undefined;
|
let sfuConfig: { url: string; jwt: string } | undefined;
|
||||||
|
|
||||||
// If forceOldJwtEndpoint is set we indicate that we do not want to try the new endpoint,
|
const tryBothJwtEndpoints = opts?.forceJwtEndpoint === undefined; // This is for SFUs where we do not publish.
|
||||||
// since we are not sending the new matrix2.0 sticky events (no hashed identity in the event)
|
|
||||||
if (
|
const forceMatrix2Jwt =
|
||||||
// we do not force anything. Try with new first (remote connections)
|
opts?.forceJwtEndpoint === JwtEndpointVersion.Matrix_2_0;
|
||||||
!opts?.forceJwtEndpoint ||
|
|
||||||
// we do force the matrix2.0 endpoint
|
// We want to start using the new endpoint (with optional delay delegation)
|
||||||
(opts?.forceJwtEndpoint &&
|
// if we can use both or if we are forced to use the new one.
|
||||||
opts?.forceJwtEndpoint === JwtEndpointVersion.Matrix_2_0)
|
if (tryBothJwtEndpoints || forceMatrix2Jwt) {
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
sfuConfig = await getLiveKitJWTWithDelayDelegation(
|
sfuConfig = await getLiveKitJWTWithDelayDelegation(
|
||||||
membership,
|
membership,
|
||||||
@@ -151,15 +150,16 @@ export async function getSFUConfigWithOpenID(
|
|||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
// Make this throw a hard error in case we force the matrix2.0 endpoint.
|
// Make this throw a hard error in case we force the matrix2.0 endpoint.
|
||||||
if (opts?.forceJwtEndpoint === JwtEndpointVersion.Matrix_2_0)
|
if (forceMatrix2Jwt)
|
||||||
throw new NoMatrix2AuthorizationService(e as Error);
|
throw new NoMatrix2AuthorizationService(e as Error);
|
||||||
|
// NEVER get bejond this point if we forceMatrix2 and it failed!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
// here we either have a sfuConfig or we alredy exited becuause of `if (opts?.forceEndpoint === MatrixRTCMode.Matrix_2_0) throw e;`
|
// here we either have a sfuConfig or we alredy exited because of `if (forceMatrix2) throw ...`
|
||||||
// The only case we can get into this if is, if `opts?.forceEndpoint !== MatrixRTCMode.Matrix_2_0`
|
// The only case we can get into this condition is, if `forceMatrix2` is `false`
|
||||||
if (sfuConfig === undefined) {
|
if (sfuConfig === undefined) {
|
||||||
sfuConfig = await getLiveKitJWT(
|
sfuConfig = await getLiveKitJWT(
|
||||||
membership.deviceId,
|
membership.deviceId,
|
||||||
@@ -167,7 +167,6 @@ export async function getSFUConfigWithOpenID(
|
|||||||
roomId,
|
roomId,
|
||||||
openIdToken,
|
openIdToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
logger?.info(`Got JWT from call's active focus URL.`);
|
logger?.info(`Got JWT from call's active focus URL.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user