init
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2025-09-02 14:49:16 +08:00
commit 38ba663466
2885 changed files with 391107 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
/**
* The type of (redux) action to add known domains to the list of domains known
* to the feature base/known-domains.
*
* {
* type: ADD_KNOWN_DOMAINS,
* knownDomains: Array<string>
* }
*/
export const ADD_KNOWN_DOMAINS = 'ADD_KNOWN_DOMAINS';

View File

@@ -0,0 +1,20 @@
import { ADD_KNOWN_DOMAINS } from './actionTypes';
/**
* Creates a (redux) action to add known domains to the list of domains known to
* the feature base/known-domains.
*
* @param {string | Array<string>} knownDomains - The known domain(s) to add to
* the list of domains known to the feature base/known-domains.
* @returns {{
* type: ADD_KNOWN_DOMAINS,
* knownDomains: Array<string>
* }}
*/
export function addKnownDomains(knownDomains: string | Array<string>) {
return {
type: ADD_KNOWN_DOMAINS,
knownDomains:
typeof knownDomains === 'string' ? [ knownDomains ] : knownDomains
};
}

View File

@@ -0,0 +1,55 @@
import { getDefaultURL } from '../../app/functions';
import { IStore } from '../../app/types';
import { APP_WILL_MOUNT } from '../app/actionTypes';
import { SET_ROOM } from '../conference/actionTypes';
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import { parseURIString } from '../util/uri';
import { addKnownDomains } from './actions';
MiddlewareRegistry.register(store => next => action => {
const result = next(action);
switch (action.type) {
case APP_WILL_MOUNT:
_appWillMount(store);
break;
case SET_ROOM:
_setRoom(store);
break;
}
return result;
});
/**
* Adds the domain of the app's {@code defaultURL} to the list of domains known
* to the feature base/known-domains.
*
* @param {Object} store - The redux store.
* @private
* @returns {Promise}
*/
function _appWillMount({ dispatch, getState }: IStore) {
const defaultURL = parseURIString(getDefaultURL(getState));
dispatch(addKnownDomains(defaultURL?.host));
}
/**
* Adds the domain of {@code locationURL} to the list of domains known to the
* feature base/known-domains.
*
* @param {Object} store - The redux store.
* @private
* @returns {Promise}
*/
function _setRoom({ dispatch, getState }: IStore) {
const { locationURL } = getState()['features/base/connection'];
let host;
locationURL
&& (host = locationURL.host)
&& dispatch(addKnownDomains(host));
}

View File

@@ -0,0 +1,61 @@
import PersistenceRegistry from '../redux/PersistenceRegistry';
import ReducerRegistry from '../redux/ReducerRegistry';
import { ADD_KNOWN_DOMAINS } from './actionTypes';
/**
* The default list of domains known to the feature base/known-domains.
* Generally, it should be in sync with the domains associated with the app
* through its manifest (in other words, Universal Links, deep linking). Anyway,
* we need a hardcoded list because it has proven impossible to programmatically
* read the information out of the app's manifests: App Store strips the
* associated domains manifest out of the app so it's never downloaded on the
* client and we did not spend a lot of effort to read the associated domains
* out of the Android manifest.
*/
export const DEFAULT_STATE = [
'alpha.jitsi.net',
'beta.meet.jit.si',
'meet.jit.si',
'8x8.vc'
];
const STORE_NAME = 'features/base/known-domains';
PersistenceRegistry.register(STORE_NAME);
export type IKnownDomainsState = Array<string>;
ReducerRegistry.register<IKnownDomainsState>(STORE_NAME, (state = DEFAULT_STATE, action): IKnownDomainsState => {
switch (action.type) {
case ADD_KNOWN_DOMAINS:
return _addKnownDomains(state, action.knownDomains);
default:
return state;
}
});
/**
* Adds an array of known domains to the list of domains known to the feature
* base/known-domains.
*
* @param {Object} state - The redux state.
* @param {Array<string>} knownDomains - The array of known domains to add to
* the list of domains known to the feature base/known-domains.
* @private
* @returns {Object} The next redux state.
*/
function _addKnownDomains(state: IKnownDomainsState, knownDomains: Array<string>) {
// In case persistence has deserialized a weird redux state:
let nextState = Array.isArray(state) ? state : [];
if (Array.isArray(knownDomains)) {
nextState = Array.from(state);
for (let knownDomain of knownDomains) {
knownDomain = knownDomain.toLowerCase();
!nextState.includes(knownDomain) && nextState.push(knownDomain);
}
}
return nextState;
}