Implemented desktop OAuth2 account setup for Google and Microsoft. The flow uses the system browser and PKCE; access and refresh tokens stay in the main process and encrypted account store. OAuth connections use fixed provider endpoints, and existing password-based accounts remain supported. Android remains password-based in this phase.

This commit is contained in:
2026-10-17 00:51:23 +03:00
parent 1ef934045f
commit ea825adcc1
29 changed files with 943 additions and 71 deletions
+11
View File
@@ -6,6 +6,7 @@ const { hasIpcSchema, validateIpcArguments } = require('../desktop/security/ipc-
test('validates supported IPC channels and their positional argument types', () => {
assert.doesNotThrow(() => validateIpcArguments('mail:connect', [{ email: 'a@example.com' }]));
assert.doesNotThrow(() => validateIpcArguments('mail:list-oauth-providers', []));
assert.doesNotThrow(() => validateIpcArguments('mail:sync-folder', ['Inbox', 0, { hasAttachments: true }]));
assert.doesNotThrow(() => validateIpcArguments('mail:disconnect', []));
assert.doesNotThrow(() => validateIpcArguments('mail:send', [{ to: 'a@example.com', attachments: [] }]));
@@ -50,6 +51,16 @@ test('validates channel-specific field shapes, limits, and enums', () => {
imapHost: 'imap.example.test', smtpHost: 'smtp.example.test',
rules: [{ senderContains: 'alerts', action: 'flag', value: '' }]
}]));
assert.doesNotThrow(() => validateIpcArguments('mail:connect', [{
email: 'user@gmail.com', authMethod: 'oauth2', oauthProvider: 'google', displayName: 'User'
}]));
assert.doesNotThrow(() => validateIpcArguments('mail:update-account', ['account-1', {
authMethod: 'oauth2', oauthProvider: 'microsoft', reauthorizeOAuth: true
}]));
assert.throws(() => validateIpcArguments('mail:connect', [{ authMethod: 'oauth2', oauthProvider: 'other' }]), /oauthProvider/);
assert.throws(() => validateIpcArguments('mail:connect', [{
email: 'user@gmail.com', authMethod: 'oauth2', oauthProvider: 'unknown'
}]), /oauthProvider/);
assert.throws(() => validateIpcArguments('mail:connect', [{ rules: Array(51).fill({ action: 'flag' }) }]), /Invalid argument 1/);
assert.throws(() => validateIpcArguments('mail:update-message', [{ uid: '4', action: 'star' }]), /uid/);
assert.throws(() => validateIpcArguments('mail:update-message', [{ uid: 4, action: 'delete-anything' }]), /action/);