Remove safetyNumberAci remote configuration

This commit is contained in:
Fedor Indutny 2023-11-01 21:35:55 +01:00 committed by GitHub
parent ab0c12847d
commit aa03ac36bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 50 additions and 171 deletions

View file

@ -724,7 +724,7 @@
},
"icu:SafetyNumberViewer__hint--normal": {
"messageformat": "To verify end-to-end encryption with {name}, compare the numbers above with their device. They can also scan your code with their device.",
"description": "Safety number viewer, text of the hint after migration period"
"description": "(Deleted 11/01/2023). Safety number viewer, text of the hint after migration period"
},
"icu:SafetyNumberOnboarding__title": {
"messageformat": "Changes to safety numbers",

View file

@ -31,8 +31,6 @@ export type ConfigKeyType =
| 'desktop.pnp'
| 'desktop.pnp.accountE164Deprecation'
| 'desktop.retryRespondMaxAge'
| 'desktop.safetyNumberAci'
| 'desktop.safetyNumberAci.beta'
| 'desktop.senderKey.retry'
| 'desktop.senderKey.send'
| 'desktop.senderKeyMaxAge'
@ -50,8 +48,7 @@ export type ConfigKeyType =
| 'global.groupsv2.groupSizeHardLimit'
| 'global.groupsv2.maxGroupSize'
| 'global.nicknames.max'
| 'global.nicknames.min'
| 'global.safetyNumberAci';
| 'global.nicknames.min';
type ConfigValueType = {
name: ConfigKeyType;

View file

@ -3,7 +3,6 @@
import React, { useState, useCallback } from 'react';
import { SafetyNumberMode } from '../types/safetyNumber';
import { isSafetyNumberNotAvailable } from '../util/isSafetyNumberNotAvailable';
import { Modal } from './Modal';
import type { PropsType as SafetyNumberViewerPropsType } from './SafetyNumberViewer';
@ -24,11 +23,10 @@ export function SafetyNumberModal({
markHasCompletedSafetyNumberOnboarding,
...safetyNumberViewerProps
}: PropsType): JSX.Element | null {
const { contact, safetyNumberMode } = safetyNumberViewerProps;
const { contact } = safetyNumberViewerProps;
const [isOnboarding, setIsOnboarding] = useState(
safetyNumberMode !== SafetyNumberMode.JustE164 &&
!hasCompletedSafetyNumberOnboarding
!hasCompletedSafetyNumberOnboarding
);
const showOnboarding = useCallback(() => {
@ -40,14 +38,10 @@ export function SafetyNumberModal({
markHasCompletedSafetyNumberOnboarding();
}, [setIsOnboarding, markHasCompletedSafetyNumberOnboarding]);
const missingRequiredE164 =
safetyNumberMode !== SafetyNumberMode.DefaultACIAndMaybeE164 &&
!contact.e164;
let title: string | undefined;
let content: JSX.Element;
let hasXButton = true;
if (missingRequiredE164 || isSafetyNumberNotAvailable(contact)) {
if (isSafetyNumberNotAvailable(contact)) {
content = (
<SafetyNumberNotReady
i18n={i18n}

View file

@ -7,10 +7,7 @@ import type { Meta } from '@storybook/react';
import type { PropsType } from './SafetyNumberViewer';
import { SafetyNumberViewer } from './SafetyNumberViewer';
import { setupI18n } from '../util/setupI18n';
import {
SafetyNumberIdentifierType,
SafetyNumberMode,
} from '../types/safetyNumber';
import { SafetyNumberIdentifierType } from '../types/safetyNumber';
import enMessages from '../../_locales/en/messages.json';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
@ -72,8 +69,6 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
contact: overrideProps.contact || contactWithAllData,
generateSafetyNumber: action('generate-safety-number'),
i18n,
safetyNumberMode:
overrideProps.safetyNumberMode ?? SafetyNumberMode.DefaultE164AndThenACI,
safetyNumbers: overrideProps.safetyNumbers ?? [
{
identifierType: SafetyNumberIdentifierType.ACIIdentifier,
@ -97,28 +92,10 @@ export function SafetyNumber(): JSX.Element {
return <SafetyNumberViewer {...createProps({})} />;
}
export function SafetyNumberBeforeE164Transition(): JSX.Element {
return (
<SafetyNumberViewer
{...createProps({
safetyNumberMode: SafetyNumberMode.JustE164,
safetyNumbers: [
{
identifierType: SafetyNumberIdentifierType.E164Identifier,
numberBlocks: generateNumberBlocks(),
qrData: generateQRData(),
},
],
})}
/>
);
}
export function SafetyNumberE164Transition(): JSX.Element {
return (
<SafetyNumberViewer
{...createProps({
safetyNumberMode: SafetyNumberMode.DefaultE164AndThenACI,
safetyNumbers: [
{
identifierType: SafetyNumberIdentifierType.E164Identifier,

View file

@ -12,10 +12,7 @@ import { Emojify } from './conversation/Emojify';
import type { LocalizerType } from '../types/Util';
import type { SafetyNumberType } from '../types/safetyNumber';
import { SAFETY_NUMBER_MIGRATION_URL } from '../types/support';
import {
SafetyNumberIdentifierType,
SafetyNumberMode,
} from '../types/safetyNumber';
import { SafetyNumberIdentifierType } from '../types/safetyNumber';
import { arrow } from '../util/keyboard';
export type PropsType = {
@ -23,7 +20,6 @@ export type PropsType = {
generateSafetyNumber: (contact: ConversationType) => void;
i18n: LocalizerType;
onClose: () => void;
safetyNumberMode: SafetyNumberMode;
safetyNumbers?: ReadonlyArray<SafetyNumberType>;
toggleVerified: (contact: ConversationType) => void;
showOnboarding?: () => void;
@ -35,7 +31,6 @@ export function SafetyNumberViewer({
generateSafetyNumber,
i18n,
onClose,
safetyNumberMode,
safetyNumbers,
toggleVerified,
showOnboarding,
@ -115,8 +110,6 @@ export function SafetyNumberViewer({
? i18n('icu:SafetyNumberViewer__clearVerification')
: i18n('icu:SafetyNumberViewer__markAsVerified');
const isMigrationVisible = safetyNumberMode !== SafetyNumberMode.JustE164;
const visibleSafetyNumber = safetyNumbers.at(selectedIndex);
if (!visibleSafetyNumber) {
return null;
@ -188,54 +181,44 @@ export function SafetyNumberViewer({
return (
<div className="module-SafetyNumberViewer">
{isMigrationVisible && (
<div className="module-SafetyNumberViewer__migration">
<div className="module-SafetyNumberViewer__migration__icon" />
<div className="module-SafetyNumberViewer__migration">
<div className="module-SafetyNumberViewer__migration__icon" />
<div className="module-SafetyNumberViewer__migration__text">
<p>
<Intl i18n={i18n} id="icu:SafetyNumberViewer__migration__text" />
</p>
<p>
<a
href={SAFETY_NUMBER_MIGRATION_URL}
rel="noreferrer"
target="_blank"
onClick={e => {
if (showOnboarding) {
e.preventDefault();
showOnboarding();
}
}}
>
<Intl
i18n={i18n}
id="icu:SafetyNumberViewer__migration__learn_more"
/>
</a>
</p>
</div>
<div className="module-SafetyNumberViewer__migration__text">
<p>
<Intl i18n={i18n} id="icu:SafetyNumberViewer__migration__text" />
</p>
<p>
<a
href={SAFETY_NUMBER_MIGRATION_URL}
rel="noreferrer"
target="_blank"
onClick={e => {
if (showOnboarding) {
e.preventDefault();
showOnboarding();
}
}}
>
<Intl
i18n={i18n}
id="icu:SafetyNumberViewer__migration__learn_more"
/>
</a>
</p>
</div>
)}
</div>
{safetyNumberCard}
{safetyNumbers.length > 1 && carousel}
<div className="module-SafetyNumberViewer__help">
{isMigrationVisible ? (
<Intl
i18n={i18n}
id="icu:SafetyNumberViewer__hint--migration"
components={{ name: boldName }}
/>
) : (
<Intl
i18n={i18n}
id="icu:SafetyNumberViewer__hint--normal"
components={{ name: boldName }}
/>
)}
<Intl
i18n={i18n}
id="icu:SafetyNumberViewer__hint--migration"
components={{ name: boldName }}
/>
<br />
<a href={SAFETY_NUMBER_MIGRATION_URL} rel="noreferrer" target="_blank">
<Intl

View file

@ -15,7 +15,6 @@ import {
import * as log from '../../logging/log';
import * as Errors from '../../types/errors';
import type { StateType as RootStateType } from '../reducer';
import { getSafetyNumberMode } from '../selectors/items';
export type SafetyNumberContactType = ReadonlyDeep<{
safetyNumbers: ReadonlyArray<SafetyNumberType>;
@ -82,12 +81,9 @@ function clearSafetyNumber(contactId: string): ClearSafetyNumberActionType {
function generate(
contact: ConversationType
): ThunkAction<void, RootStateType, unknown, GenerateFulfilledActionType> {
return async (dispatch, getState) => {
return async dispatch => {
try {
const safetyNumbers = await generateSafetyNumbers(
contact,
getSafetyNumberMode(getState(), { now: Date.now() })
);
const safetyNumbers = await generateSafetyNumbers(contact);
dispatch({
type: GENERATE_FULFILLED,
payload: {
@ -112,7 +108,7 @@ function toggleVerified(
unknown,
ToggleVerifiedPendingActionType | ToggleVerifiedFulfilledActionType
> {
return async (dispatch, getState) => {
return async dispatch => {
dispatch({
type: TOGGLE_VERIFIED_PENDING,
payload: {
@ -132,10 +128,7 @@ function toggleVerified(
} catch (err) {
if (err.name === 'OutgoingIdentityKeyError') {
await reloadProfiles(contact.id);
const safetyNumbers = await generateSafetyNumbers(
contact,
getSafetyNumberMode(getState(), { now: Date.now() })
);
const safetyNumbers = await generateSafetyNumbers(contact);
dispatch({
type: TOGGLE_VERIFIED_FULFILLED,

View file

@ -5,7 +5,6 @@ import { createSelector } from 'reselect';
import { isInteger } from 'lodash';
import { ITEM_NAME as UNIVERSAL_EXPIRE_TIMER_ITEM } from '../../util/universalExpireTimer';
import { SafetyNumberMode } from '../../types/safetyNumber';
import { innerIsBucketValueEnabled } from '../../RemoteConfig';
import type { ConfigKeyType, ConfigMapType } from '../../RemoteConfig';
import type { StateType } from '../reducer';
@ -18,7 +17,7 @@ import type { AciString } from '../../types/ServiceId';
import { DEFAULT_CONVERSATION_COLOR } from '../../types/Colors';
import { getPreferredReactionEmoji as getPreferredReactionEmojiFromStoredValue } from '../../reactions/preferredReactionEmoji';
import { isBeta } from '../../util/version';
import { DurationInSeconds, SECOND } from '../../util/durations';
import { DurationInSeconds } from '../../util/durations';
import { generateUsernameLink } from '../../util/sgnlHref';
import * as Bytes from '../../Bytes';
import { getUserNumber, getUserACI } from './user';
@ -167,40 +166,6 @@ export const getStoriesEnabled = createSelector(
}
);
export const getSafetyNumberMode = createSelector(
getRemoteConfig,
getServerTimeSkew,
(_state: StateType, { now }: { now: number }) => now,
(
remoteConfig: ConfigMapType,
serverTimeSkew: number,
now: number
): SafetyNumberMode => {
if (
!isRemoteConfigFlagEnabled(remoteConfig, 'desktop.safetyNumberAci') &&
!(
isRemoteConfigFlagEnabled(
remoteConfig,
'desktop.safetyNumberAci.beta'
) && isBeta(window.getVersion())
)
) {
return SafetyNumberMode.JustE164;
}
const timestampInSeconds = remoteConfig['global.safetyNumberAci']?.value;
if (typeof timestampInSeconds !== 'number') {
return SafetyNumberMode.DefaultE164AndThenACI;
}
// Note: serverTimeSkew is a difference between server time and local time,
// so we have to add local time to it to correct it for a skew.
return now + serverTimeSkew >= timestampInSeconds * SECOND
? SafetyNumberMode.DefaultACIAndMaybeE164
: SafetyNumberMode.DefaultE164AndThenACI;
}
);
export const getDefaultConversationColor = createSelector(
getItems,
(

View file

@ -7,10 +7,7 @@ import { SafetyNumberModal } from '../../components/SafetyNumberModal';
import type { StateType } from '../reducer';
import { getContactSafetyNumber } from '../selectors/safetyNumber';
import { getConversationSelector } from '../selectors/conversations';
import {
getSafetyNumberMode,
getHasCompletedSafetyNumberOnboarding,
} from '../selectors/items';
import { getHasCompletedSafetyNumberOnboarding } from '../selectors/items';
import { getIntl } from '../selectors/user';
export type Props = {
@ -22,7 +19,6 @@ const mapStateToProps = (state: StateType, props: Props) => {
...props,
...getContactSafetyNumber(state, props),
contact: getConversationSelector(state)(props.contactID),
safetyNumberMode: getSafetyNumberMode(state, { now: Date.now() }),
hasCompletedSafetyNumberOnboarding:
getHasCompletedSafetyNumberOnboarding(state),
i18n: getIntl(state),

View file

@ -8,7 +8,6 @@ import type { StateType } from '../reducer';
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog';
import { getContactSafetyNumber } from '../selectors/safetyNumber';
import { getConversationSelector } from '../selectors/conversations';
import { getSafetyNumberMode } from '../selectors/items';
import { getIntl } from '../selectors/user';
const mapStateToProps = (state: StateType, props: SafetyNumberProps) => {
@ -16,7 +15,6 @@ const mapStateToProps = (state: StateType, props: SafetyNumberProps) => {
...props,
...getContactSafetyNumber(state, props),
contact: getConversationSelector(state)(props.contactID),
safetyNumberMode: getSafetyNumberMode(state, { now: Date.now() }),
i18n: getIntl(state),
};
};

View file

@ -1,12 +1,6 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export enum SafetyNumberMode {
JustE164 = 'JustE164',
DefaultE164AndThenACI = 'DefaultE164AndThenACI',
DefaultACIAndMaybeE164 = 'DefaultACIAndMaybeE164',
}
export enum SafetyNumberIdentifierType {
ACIIdentifier = 'ACIIdentifier',
E164Identifier = 'E164Identifier',

View file

@ -11,10 +11,7 @@ import { uuidToBytes } from './uuidToBytes';
import * as log from '../logging/log';
import * as Bytes from '../Bytes';
import type { SafetyNumberType } from '../types/safetyNumber';
import {
SafetyNumberIdentifierType,
SafetyNumberMode,
} from '../types/safetyNumber';
import { SafetyNumberIdentifierType } from '../types/safetyNumber';
import { isAciString } from './isAciString';
const ITERATION_COUNT = 5200;
@ -25,10 +22,9 @@ const SERVICE_ID_VERSION = 2;
const BLOCK_SIZE = 5;
export async function generateSafetyNumbers(
contact: ConversationType,
mode: SafetyNumberMode
contact: ConversationType
): Promise<ReadonlyArray<SafetyNumberType>> {
const logId = `generateSafetyNumbers(${contact.id}, ${mode})`;
const logId = `generateSafetyNumbers(${contact.id})`;
log.info(`${logId}: starting`);
const { storage } = window.textsecure;
@ -57,24 +53,10 @@ export async function generateSafetyNumbers(
const ourKey = PublicKey.deserialize(Buffer.from(ourKeyBuffer));
const theirKey = PublicKey.deserialize(Buffer.from(theirKeyBuffer));
let identifierTypes: ReadonlyArray<SafetyNumberIdentifierType>;
if (mode === SafetyNumberMode.DefaultE164AndThenACI) {
// Important: order matters, legacy safety number should be displayed first.
identifierTypes = [
SafetyNumberIdentifierType.E164Identifier,
SafetyNumberIdentifierType.ACIIdentifier,
];
// Controlled by 'desktop.safetyNumberAci'
} else if (mode === SafetyNumberMode.JustE164) {
identifierTypes = [SafetyNumberIdentifierType.E164Identifier];
} else if (mode === SafetyNumberMode.DefaultACIAndMaybeE164) {
identifierTypes = [
SafetyNumberIdentifierType.ACIIdentifier,
SafetyNumberIdentifierType.E164Identifier,
];
} else {
throw missingCaseError(mode);
}
const identifierTypes = [
SafetyNumberIdentifierType.ACIIdentifier,
SafetyNumberIdentifierType.E164Identifier,
];
return identifierTypes
.map(identifierType => {