You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.ts 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { IConfig } from '../base/config/configType';
  2. /**
  3. * Checks if the token for authentication is available.
  4. *
  5. * @param {Object} config - Configuration state object from store.
  6. * @returns {boolean}
  7. */
  8. export const isTokenAuthEnabled = (config: IConfig) =>
  9. typeof config.tokenAuthUrl === 'string'
  10. && config.tokenAuthUrl.length;
  11. /**
  12. * Creates the URL pointing to JWT token authentication service. It is
  13. * formatted from the 'urlPattern' argument which can contain the following
  14. * constants:
  15. * '{room}' - name of the conference room passed as <tt>roomName</tt>
  16. * argument to this method.
  17. * '{roleUpgrade}' - will contain 'true' if the URL will be used for
  18. * the role upgrade scenario, where user connects from anonymous domain and
  19. * then gets upgraded to the moderator by logging-in from the popup window.
  20. *
  21. * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
  22. * @param {string} roomName - The name of the conference room for which the user will be authenticated.
  23. *
  24. * @returns {string|undefined} - The URL pointing to JWT login service or
  25. * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
  26. * constructed.
  27. */
  28. export const getTokenAuthUrl = (config: IConfig, roomName: string) => {
  29. const url = config.tokenAuthUrl;
  30. if (typeof url !== 'string' || !roomName) {
  31. return undefined;
  32. }
  33. return url.replace('{room}', roomName);
  34. };