Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions.any.ts 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { IConfig } from '../base/config/configType';
  2. import { getBackendSafeRoomName } from '../base/util/uri';
  3. /**
  4. * Checks if the token for authentication is available.
  5. *
  6. * @param {Object} config - Configuration state object from store.
  7. * @returns {boolean}
  8. */
  9. export const isTokenAuthEnabled = (config: IConfig): boolean =>
  10. typeof config.tokenAuthUrl === 'string' && config.tokenAuthUrl.length > 0;
  11. /**
  12. * Returns the state that we can add as a parameter to the tokenAuthUrl.
  13. *
  14. * @param {string?} roomName - The room name.
  15. * @param {string?} tenant - The tenant name if any.
  16. * @param {boolean} skipPrejoin - Whether to skip pre-join page.
  17. * @param {URL} locationURL - The location URL.
  18. * @returns {Object} The state object.
  19. */
  20. export const _getTokenAuthState = (
  21. roomName: string | undefined,
  22. tenant: string | undefined,
  23. skipPrejoin: boolean | undefined = false,
  24. locationURL: URL): object => {
  25. const state = {
  26. room: roomName,
  27. roomSafe: getBackendSafeRoomName(roomName),
  28. tenant
  29. };
  30. if (skipPrejoin) {
  31. // We have already shown the prejoin screen, no need to show it again after obtaining the token.
  32. // @ts-ignore
  33. state['config.prejoinConfig.enabled'] = false;
  34. }
  35. const params = new URLSearchParams(locationURL.hash);
  36. for (const [ key, value ] of params) {
  37. // we allow only config and interfaceConfig overrides in the state
  38. if (key.startsWith('config.') || key.startsWith('interfaceConfig.')) {
  39. // @ts-ignore
  40. state[key] = value;
  41. }
  42. }
  43. return state;
  44. };