Skip to content

Commit 9b3d6e3

Browse files
authored
Merge branch 'master' into issue-5955-compatibility-uses-iso-expiration-date-format
2 parents f6354ed + 4c07c91 commit 9b3d6e3

File tree

23 files changed

+619
-401
lines changed

23 files changed

+619
-401
lines changed

extension/chrome/elements/shared/create_key.template.htm

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@
4444
</label>
4545
</div>
4646
<div class="line left display_none remove_if_pubkey_submitting_not_user_configurable also_submit_alias_key_view">
47-
<label>
48-
<input type="checkbox" class="input_submit_all" disabled="disabled" />
49-
<span>
50-
Also submit the same pubkey for:
51-
<br /><span class="addresses"></span>
52-
</span>
53-
</label>
47+
Also submit the same pubkey for:
48+
<div class="submit_pubkey_addresses"></div>
5449
</div>
5550

5651
<div class="line left">

extension/chrome/settings/modules/add_key.htm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ <h1>Add Private Key <span id="spinner_container"></span></h1>
4141
</li>
4242
</ul>
4343
</div>
44+
<div class="display_none generate_alias_key_view">
45+
Also generate private key for:
46+
<br />
47+
<div class="generate_private_key_addresses"></div>
48+
</div>
4449
<div class="source_generate_container display_none">
4550
<div id="generate-key-container"></div>
4651
<div id="backup-template-container"></div>
@@ -69,7 +74,7 @@ <h1>Add Private Key <span id="spinner_container"></span></h1>
6974
</div>
7075
<div class="line">
7176
<br />
72-
<button class="button long green action_add_private_key">Add Private Key</button>
77+
<button class="button long green action_add_private_key" data-test="action-add-private-key-btn">Add Private Key</button>
7378
</div>
7479
</div>
7580
</div>

extension/chrome/settings/modules/add_key.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,31 @@ export class AddKeyView extends View {
5656
<br><br>
5757
`
5858
);
59-
} else {
60-
$('#content').show();
61-
if (!this.clientConfiguration.forbidStoringPassPhrase()) {
62-
$('.import_input_passphrase_save').prop('checked', true).prop('disabled', false);
63-
}
64-
await initPassphraseToggle(['input_passphrase']);
65-
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId);
66-
Xss.sanitizeRender('#spinner_container', Ui.spinner('green') + ' loading..');
67-
await this.loadAndRenderKeyBackupsOrRenderError();
68-
$('.source_selector').css('display', 'block');
69-
$('#spinner_container').text('');
59+
return;
60+
}
61+
$('#content').show();
62+
if (!this.clientConfiguration.forbidStoringPassPhrase()) {
63+
$('.import_input_passphrase_save').prop('checked', true).prop('disabled', false);
64+
}
65+
if (this.clientConfiguration.mustSubmitToAttester() || !this.clientConfiguration.canSubmitPubToAttester()) {
66+
$('.remove_if_pubkey_submitting_not_user_configurable').remove();
7067
}
68+
await initPassphraseToggle(['input_passphrase']);
69+
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId);
70+
Xss.sanitizeRender('#spinner_container', Ui.spinner('green') + ' loading..');
71+
await this.loadAndRenderKeyBackupsOrRenderError();
72+
$('.source_selector').css('display', 'block');
73+
$('#spinner_container').text('');
74+
await this.keyImportUi.renderEmailAliasView(this.acctEmail);
7175
};
7276

7377
public setHandlers = () => {
7478
$('.action_add_private_key').on('click', this.setHandlerPrevent('double', this.addPrivateKeyHandler));
7579
$('#input_passphrase').on('keydown', this.setEnterHandlerThatClicks('.action_add_private_key'));
80+
$('.input_submit_key').on(
81+
'click',
82+
this.setHandler(el => this.keyImportUi.actionSubmitPublicKeyToggleHandler(el))
83+
);
7684
this.addKeyGenerateModule.setHandlers();
7785
};
7886

extension/chrome/settings/modules/add_key_generate_module.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ export class AddKeyGenerateModule extends ViewModule<AddKeyView> {
5151
$('#step_2a_manual_create.input_password2').on('keydown', this.view.setEnterHandlerThatClicks('#step_2a_manual_create .action_proceed_private'));
5252
};
5353

54-
public createSaveKeyPair = async (options: SetupOptions, keyAlgo: KeyAlgo): Promise<KeyIdentity> => {
54+
public createSaveKeyPair = async (options: SetupOptions, keyAlgo: KeyAlgo, aliasList: { name: string; email: string }[] = []): Promise<KeyIdentity> => {
5555
// eslint-disable-next-line @typescript-eslint/naming-convention
5656
const { full_name } = await AcctStore.get(this.view.acctEmail, ['full_name']);
57-
const pgpUids = [{ name: full_name || '', email: this.view.acctEmail }]; // todo - add all addresses?
57+
const fullName = full_name ?? '';
58+
const pgpUids = [{ name: fullName, email: this.view.acctEmail }];
59+
for (const alias of aliasList) {
60+
pgpUids.push({ name: alias.name ?? fullName, email: alias.email });
61+
}
5862
const expireMonths = this.view.clientConfiguration.getEnforcedKeygenExpirationMonths();
5963
const key = await OpenPGPKey.create(pgpUids, keyAlgo, options.passphrase, expireMonths);
6064
const prv = await KeyUtil.parse(key.private);
@@ -72,12 +76,11 @@ export class AddKeyGenerateModule extends ViewModule<AddKeyView> {
7276
passphrase_save: Boolean($('#step_2a_manual_create .input_passphrase_save').prop('checked')),
7377
passphrase_ensure_single_copy: false, // there can't be any saved passphrases for the new key
7478
submit_main: this.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2a_manual_create .input_submit_key'),
75-
submit_all: this.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2a_manual_create .input_submit_all'),
7679
recovered: false,
7780
};
7881
/* eslint-enable @typescript-eslint/naming-convention */
7982
const keyAlgo = this.view.clientConfiguration.getEnforcedKeygenAlgo() || ($('#step_2a_manual_create .key_type').val() as KeyAlgo);
80-
const keyIdentity = await this.createSaveKeyPair(opts, keyAlgo);
83+
const keyIdentity = await this.createSaveKeyPair(opts, keyAlgo, this.keyImportUi.getSelectedEmailAliases('generate_private_key'));
8184
if (this.view.clientConfiguration.getPublicKeyForPrivateKeyBackupToDesignatedMailbox()) {
8285
const adminPubkey = this.view.clientConfiguration.getPublicKeyForPrivateKeyBackupToDesignatedMailbox();
8386
if (adminPubkey) {
@@ -141,18 +144,17 @@ export class AddKeyGenerateModule extends ViewModule<AddKeyView> {
141144
};
142145

143146
/* eslint-disable @typescript-eslint/naming-convention */
144-
private submitPublicKeys = async ({ submit_main, submit_all }: { submit_main: boolean; submit_all: boolean }): Promise<void> => {
147+
private submitPublicKeys = async ({ submit_main }: { submit_main: boolean }): Promise<void> => {
145148
const mostUsefulPrv = KeyStoreUtil.chooseMostUseful(await KeyStoreUtil.parse(await KeyStore.getRequired(this.view.acctEmail)), 'ONLY-FULLY-USABLE');
146149
try {
147150
await submitPublicKeyIfNeeded(this.view.clientConfiguration, this.view.acctEmail, [], this.pubLookup.attester, mostUsefulPrv?.keyInfo.public, {
148151
submit_main,
149-
submit_all,
150152
});
151153
} catch (e) {
152154
return await Settings.promptToRetry(
153155
e,
154156
e instanceof CompanyLdapKeyMismatchError ? Lang.setup.failedToImportUnknownKey : Lang.setup.failedToSubmitToAttester,
155-
() => this.submitPublicKeys({ submit_main, submit_all }),
157+
() => this.submitPublicKeys({ submit_main }),
156158
Lang.general.contactIfNeedAssistance(Boolean(this.view.fesUrl))
157159
);
158160
}

extension/chrome/settings/setup.htm

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,8 @@ <h1>Set Up FlowCrypt</h1>
181181
data-test="container-for-import-key-email-alias"
182182
style="display: none"
183183
>
184-
<label>
185-
<input type="checkbox" class="input_submit_all" disabled="disabled" />
186-
<span>
187-
Also submit the same pubkey for:
188-
<br /><span class="addresses"></span>
189-
</span>
190-
</label>
184+
Also submit the same pubkey for:
185+
<div class="submit_pubkey_addresses"></div>
191186
</div>
192187

193188
<div class="wide line">

extension/chrome/settings/setup.ts

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export interface PassphraseOptions {
4242

4343
export interface SetupOptions extends PassphraseOptions {
4444
submit_main: boolean;
45-
submit_all: boolean;
4645
recovered?: boolean;
4746
}
4847
/* eslint-enable @typescript-eslint/naming-convention */
@@ -72,7 +71,6 @@ export class SetupView extends View {
7271
public fetchedKeyBackupsUniqueLongids: string[] = [];
7372
public importedKeysUniqueLongids: string[] = [];
7473
public mathingPassphrases: string[] = [];
75-
public submitKeyForAddrs: string[];
7674

7775
public constructor() {
7876
super();
@@ -89,8 +87,7 @@ export class SetupView extends View {
8987
} else {
9088
window.location.href = 'index.htm';
9189
}
92-
this.submitKeyForAddrs = [];
93-
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId, this.submitKeyForAddrs); // for step_2b_manual_enter, if user chooses so
90+
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId); // for step_2b_manual_enter, if user chooses so
9491
this.keyImportUi.onBadPassphrase = () => $('#step_2b_manual_enter .input_passphrase').val('').trigger('focus');
9592
this.keyImportUi.renderPassPhraseStrengthValidationInput(
9693
$('#step_2_ekm_choose_pass_phrase .input_password'),
@@ -155,6 +152,8 @@ export class SetupView extends View {
155152
$('.remove_if_backup_not_allowed').remove();
156153
}
157154
await this.setupRender.renderInitial();
155+
156+
await this.keyImportUi.renderEmailAliasView(this.acctEmail);
158157
};
159158

160159
public setHandlers = () => {
@@ -203,7 +202,7 @@ export class SetupView extends View {
203202
);
204203
$('.input_submit_key').on(
205204
'click',
206-
this.setHandler(el => this.actionSubmitPublicKeyToggleHandler(el))
205+
this.setHandler(el => this.keyImportUi.actionSubmitPublicKeyToggleHandler(el))
207206
);
208207
$('#step_0_backup_to_designated_mailbox .action_manual_create_key, #step_1_easy_or_manual .action_manual_create_key').on(
209208
'click',
@@ -285,19 +284,6 @@ export class SetupView extends View {
285284
);
286285
};
287286

288-
public actionSubmitPublicKeyToggleHandler = (target: HTMLElement) => {
289-
// will be hidden / ignored / forced true when rules.mustSubmitToAttester() === true (for certain orgs)
290-
const inputSubmitAll = $(target).closest('.manual').find('.input_submit_all').first();
291-
if ($(target).prop('checked')) {
292-
if (inputSubmitAll.closest('div.line').css('visibility') === 'visible') {
293-
$('.input_email_alias').prop({ disabled: false });
294-
}
295-
} else {
296-
$('.input_email_alias').prop({ checked: false });
297-
$('.input_email_alias').prop({ disabled: true });
298-
}
299-
};
300-
301287
public actionCloseHandler = () => {
302288
if (this.parentTabId) {
303289
BrowserMsg.send.redirect(this.parentTabId, {
@@ -309,18 +295,24 @@ export class SetupView extends View {
309295
};
310296

311297
/* eslint-disable @typescript-eslint/naming-convention */
312-
public submitPublicKeys = async ({ submit_main, submit_all }: { submit_main: boolean; submit_all: boolean }): Promise<void> => {
298+
public submitPublicKeys = async ({ submit_main }: { submit_main: boolean }): Promise<void> => {
313299
const mostUsefulPrv = KeyStoreUtil.chooseMostUseful(await KeyStoreUtil.parse(await KeyStore.getRequired(this.acctEmail)), 'ONLY-FULLY-USABLE');
314300
try {
315-
await submitPublicKeyIfNeeded(this.clientConfiguration, this.acctEmail, this.submitKeyForAddrs, this.pubLookup.attester, mostUsefulPrv?.keyInfo.public, {
316-
submit_main,
317-
submit_all,
318-
});
301+
await submitPublicKeyIfNeeded(
302+
this.clientConfiguration,
303+
this.acctEmail,
304+
this.keyImportUi.getSelectedEmailAliases('submit_pubkey').map(alias => alias.email),
305+
this.pubLookup.attester,
306+
mostUsefulPrv?.keyInfo.public,
307+
{
308+
submit_main,
309+
}
310+
);
319311
} catch (e) {
320312
return await Settings.promptToRetry(
321313
e,
322314
e instanceof CompanyLdapKeyMismatchError ? Lang.setup.failedToImportUnknownKey : Lang.setup.failedToSubmitToAttester,
323-
() => this.submitPublicKeys({ submit_main, submit_all }),
315+
() => this.submitPublicKeys({ submit_main }),
324316
Lang.general.contactIfNeedAssistance(this.isCustomerUrlFesUsed())
325317
);
326318
}

extension/chrome/settings/setup/setup-create-key.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export class SetupCreateKeyModule {
3434
passphrase_save: Boolean($('#step_2a_manual_create .input_passphrase_save').prop('checked')),
3535
passphrase_ensure_single_copy: false, // there can't be any saved passphrases for the new key
3636
submit_main: this.view.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2a_manual_create .input_submit_key'),
37-
submit_all: this.view.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2a_manual_create .input_submit_all'),
3837
recovered: false,
3938
};
4039
/* eslint-enable @typescript-eslint/naming-convention */
@@ -131,7 +130,12 @@ export class SetupCreateKeyModule {
131130
const expireMonths = this.view.clientConfiguration.getEnforcedKeygenExpirationMonths();
132131
const key = await OpenPGPKey.create(pgpUids, keyAlgo, options.passphrase, expireMonths);
133132
const prv = await KeyUtil.parse(key.private);
134-
await saveKeysAndPassPhrase(this.view.acctEmail, [prv], options, this.view.submitKeyForAddrs);
133+
await saveKeysAndPassPhrase(
134+
this.view.acctEmail,
135+
[prv],
136+
options,
137+
this.view.keyImportUi.getSelectedEmailAliases('submit_pubkey').map(alias => alias.email)
138+
);
135139
return { id: prv.id, family: prv.family };
136140
};
137141
}

extension/chrome/settings/setup/setup-import-key.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export class SetupImportKeyModule {
2323
const options: SetupOptions = {
2424
passphrase: String($('#step_2b_manual_enter .input_passphrase').val()),
2525
submit_main: this.view.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2b_manual_enter .input_submit_key'),
26-
submit_all: this.view.keyImportUi.shouldSubmitPubkey(this.view.clientConfiguration, '#step_2b_manual_enter .input_submit_all'),
2726
passphrase_save: Boolean($('#step_2b_manual_enter .input_passphrase_save').prop('checked')),
2827
passphrase_ensure_single_copy: true,
2928
recovered: false,
@@ -47,7 +46,12 @@ export class SetupImportKeyModule {
4746
}
4847
}
4948
Xss.sanitizeRender('#step_2b_manual_enter .action_add_private_key', Ui.spinner('white'));
50-
await saveKeysAndPassPhrase(this.view.acctEmail, [checked.encrypted], options, this.view.submitKeyForAddrs);
49+
await saveKeysAndPassPhrase(
50+
this.view.acctEmail,
51+
[checked.encrypted],
52+
options,
53+
this.view.keyImportUi.getSelectedEmailAliases('submit_pubkey').map(alias => alias.email)
54+
);
5155
await this.view.submitPublicKeys(options);
5256
await this.view.finalizeSetup();
5357
await this.view.setupRender.renderSetupDone();

extension/chrome/settings/setup/setup-key-manager-autogen.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class SetupWithEmailKeyManagerModule {
5050
this.view.clientConfiguration.mustAutogenPassPhraseQuietly() || Boolean($('#step_2_ekm_choose_pass_phrase .input_passphrase_save').prop('checked')),
5151
passphrase_ensure_single_copy: false, // there can't be any saved passphrases for the new key
5252
submit_main: this.view.clientConfiguration.canSubmitPubToAttester(),
53-
submit_all: false,
5453
passphrase,
5554
};
5655
/* eslint-enable @typescript-eslint/naming-convention */

extension/chrome/settings/setup/setup-recover-key.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export class SetupRecoverKeyModule {
6060
/* eslint-disable @typescript-eslint/naming-convention */
6161
const options: SetupOptions = {
6262
submit_main: false, // todo - reevaluate submitting when recovering
63-
submit_all: false,
6463
passphrase,
6564
passphrase_save: true, // todo - reevaluate saving passphrase when recovering
6665
passphrase_ensure_single_copy: true,

0 commit comments

Comments
 (0)