您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.any.ts 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 {URL} locationURL - The location URL.
  15. * @param {Object} options: - Config options {
  16. * audioMuted: boolean | undefined
  17. * audioOnlyEnabled: boolean | undefined,
  18. * skipPrejoin: boolean | undefined,
  19. * videoMuted: boolean | undefined
  20. * }.
  21. * @param {string?} roomName - The room name.
  22. * @param {string?} tenant - The tenant name if any.
  23. *
  24. * @returns {Object} The state object.
  25. */
  26. export const _getTokenAuthState = (
  27. locationURL: URL,
  28. options: {
  29. audioMuted: boolean | undefined;
  30. audioOnlyEnabled: boolean | undefined;
  31. skipPrejoin: boolean | undefined;
  32. videoMuted: boolean | undefined;
  33. },
  34. roomName: string | undefined,
  35. tenant: string | undefined): object => {
  36. const state = {
  37. room: roomName,
  38. roomSafe: getBackendSafeRoomName(roomName),
  39. tenant
  40. };
  41. const {
  42. audioMuted = false,
  43. audioOnlyEnabled = false,
  44. skipPrejoin = false,
  45. videoMuted = false
  46. } = options;
  47. if (audioMuted) {
  48. // @ts-ignore
  49. state['config.startWithAudioMuted'] = true;
  50. }
  51. if (audioOnlyEnabled) {
  52. // @ts-ignore
  53. state['config.startAudioOnly'] = true;
  54. }
  55. if (skipPrejoin) {
  56. // We have already shown the prejoin screen, no need to show it again after obtaining the token.
  57. // @ts-ignore
  58. state['config.prejoinConfig.enabled'] = false;
  59. }
  60. if (videoMuted) {
  61. // @ts-ignore
  62. state['config.startWithVideoMuted'] = true;
  63. }
  64. const params = new URLSearchParams(locationURL.hash);
  65. for (const [ key, value ] of params) {
  66. // we allow only config and interfaceConfig overrides in the state
  67. if (key.startsWith('config.') || key.startsWith('interfaceConfig.')) {
  68. // @ts-ignore
  69. state[key] = value;
  70. }
  71. }
  72. return state;
  73. };