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

functions.any.ts 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { IConfig } from '../base/config/configType';
  2. import { parseURLParams } from '../base/util/parseURLParams';
  3. import { getBackendSafeRoomName } from '../base/util/uri';
  4. /**
  5. * Checks if the token for authentication is available.
  6. *
  7. * @param {Object} config - Configuration state object from store.
  8. * @returns {boolean}
  9. */
  10. export const isTokenAuthEnabled = (config: IConfig): boolean =>
  11. typeof config.tokenAuthUrl === 'string' && config.tokenAuthUrl.length > 0;
  12. /**
  13. * Returns the state that we can add as a parameter to the tokenAuthUrl.
  14. *
  15. * @param {URL} locationURL - The location URL.
  16. * @param {Object} options: - Config options {
  17. * audioMuted: boolean | undefined
  18. * audioOnlyEnabled: boolean | undefined,
  19. * skipPrejoin: boolean | undefined,
  20. * videoMuted: boolean | undefined
  21. * }.
  22. * @param {string?} roomName - The room name.
  23. * @param {string?} tenant - The tenant name if any.
  24. *
  25. * @returns {Object} The state object.
  26. */
  27. export const _getTokenAuthState = (
  28. locationURL: URL,
  29. options: {
  30. audioMuted: boolean | undefined;
  31. audioOnlyEnabled: boolean | undefined;
  32. skipPrejoin: boolean | undefined;
  33. videoMuted: boolean | undefined;
  34. },
  35. roomName: string | undefined,
  36. tenant: string | undefined): object => {
  37. const state = {
  38. room: roomName,
  39. roomSafe: getBackendSafeRoomName(roomName),
  40. tenant
  41. };
  42. const {
  43. audioMuted = false,
  44. audioOnlyEnabled = false,
  45. skipPrejoin = false,
  46. videoMuted = false
  47. } = options;
  48. if (audioMuted) {
  49. // @ts-ignore
  50. state['config.startWithAudioMuted'] = true;
  51. }
  52. if (audioOnlyEnabled) {
  53. // @ts-ignore
  54. state['config.startAudioOnly'] = true;
  55. }
  56. if (skipPrejoin) {
  57. // We have already shown the prejoin screen, no need to show it again after obtaining the token.
  58. // @ts-ignore
  59. state['config.prejoinConfig.enabled'] = false;
  60. }
  61. if (videoMuted) {
  62. // @ts-ignore
  63. state['config.startWithVideoMuted'] = true;
  64. }
  65. const params = parseURLParams(locationURL);
  66. for (const key of Object.keys(params)) {
  67. // we allow only config and interfaceConfig overrides in the state
  68. if (key.startsWith('config.') || key.startsWith('interfaceConfig.') || key.startsWith('iceServers.')) {
  69. // @ts-ignore
  70. state[key] = params[key];
  71. }
  72. }
  73. return state;
  74. };