diff --git a/lib/Providers/Mail/Provider.php b/lib/Providers/Mail/Provider.php index ee3f979..8650a11 100644 --- a/lib/Providers/Mail/Provider.php +++ b/lib/Providers/Mail/Provider.php @@ -175,8 +175,6 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceDiscove ?string $secret = null ): ResourceServiceLocationInterface|null { $discovery = new Discovery(); - - // TODO: Make SSL verification configurable based on tenant/user settings $verifySSL = true; return $discovery->discover($identity, $location, $secret, $verifySSL); diff --git a/lib/Providers/Mail/Service.php b/lib/Providers/Mail/Service.php index 5d5a683..fd94fa0 100644 --- a/lib/Providers/Mail/Service.php +++ b/lib/Providers/Mail/Service.php @@ -175,7 +175,7 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC ], fn($v) => $v !== null); } - public function jsonDeserialize(array|string $data): static { + public function jsonDeserialize(array|string $data, bool $delta = false): static { if (is_string($data)) { $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR); } @@ -193,13 +193,11 @@ class Service implements ServiceBaseInterface, ServiceMutableInterface, ServiceC $this->setIdentity($this->freshIdentity(null, $data[self::JSON_PROPERTY_IDENTITY])); } if (isset($data[self::JSON_PROPERTY_PRIMARY_ADDRESS]) && is_string($data[self::JSON_PROPERTY_PRIMARY_ADDRESS])) { - if (is_array($data[self::JSON_PROPERTY_PRIMARY_ADDRESS]) && isset($data[self::JSON_PROPERTY_PRIMARY_ADDRESS]['address'])) { - $this->setPrimaryAddress(new Address($data[self::JSON_PROPERTY_PRIMARY_ADDRESS])); - } + $this->setPrimaryAddress(new Address($data[self::JSON_PROPERTY_PRIMARY_ADDRESS])); } if (isset($data[self::JSON_PROPERTY_SECONDARY_ADDRESSES]) && is_array($data[self::JSON_PROPERTY_SECONDARY_ADDRESSES])) { $this->setSecondaryAddresses(array_map( - fn($addr) => new Address($addr['address']), + fn($addr) => new Address(is_array($addr) ? ($addr['address'] ?? $addr) : $addr), $data[self::JSON_PROPERTY_SECONDARY_ADDRESSES] )); } diff --git a/src/components/AccountConfigurationPanel.vue b/src/components/AccountConfigurationPanel.vue deleted file mode 100644 index 88ceb8e..0000000 --- a/src/components/AccountConfigurationPanel.vue +++ /dev/null @@ -1,506 +0,0 @@ - - - - - diff --git a/src/components/JmapAuthPanel.vue b/src/components/JmapAuthPanel.vue index 742c898..6364594 100644 --- a/src/components/JmapAuthPanel.vue +++ b/src/components/JmapAuthPanel.vue @@ -5,10 +5,9 @@ import { IdentityOAuth, IdentityToken, } from '@KTXM/MailManager/models/identity' -import type { ServiceObject } from '@KTXM/MailManager/models/service' +import { ServiceObject } from '@KTXM/MailManager/models/service' import type { ServiceIdentity } from '@KTXM/MailManager/types/service' import type { ProviderAuthPanelProps, ProviderAuthPanelEmits } from '@KTXM/MailManager/types/integration' -import { JmapServiceObject } from '@/models/JmapServiceObject' const props = defineProps() const emit = defineEmits() @@ -95,8 +94,30 @@ watch( return } - const nextService = createServiceObject(props.service) - nextService.identity = createIdentityModel(identity) + const nextService = props.service ?? new ServiceObject() + const nextIdentity = createIdentityModel(identity) + + if (nextIdentity === null) { + nextService.identity = null + emit('update:service', nextService) + return + } + + if (nextIdentity instanceof IdentityBasic && nextService.identity instanceof IdentityBasic) { + nextService.identity.identity = nextIdentity.identity + nextService.identity.secret = nextIdentity.secret + } else if (nextIdentity instanceof IdentityToken && nextService.identity instanceof IdentityToken) { + nextService.identity.token = nextIdentity.token + } else if (nextIdentity instanceof IdentityOAuth && nextService.identity instanceof IdentityOAuth) { + nextService.identity.accessToken = nextIdentity.accessToken + nextService.identity.accessScope = nextIdentity.accessScope + nextService.identity.accessExpiry = nextIdentity.accessExpiry + nextService.identity.refreshToken = nextIdentity.refreshToken + nextService.identity.refreshLocation = nextIdentity.refreshLocation + } else { + nextService.identity = nextIdentity + } + emit('update:service', nextService) }, { immediate: true, deep: true } @@ -146,16 +167,6 @@ function syncFromService(service?: ServiceObject) { } } -function createServiceObject(service?: ServiceObject): JmapServiceObject { - const nextService = new JmapServiceObject() - - if (service) { - nextService.fromJson(service.toJson()) - } - - return nextService -} - function createIdentityModel(identity: ServiceIdentity | null) { if (identity === null) { return null @@ -174,6 +185,8 @@ function createIdentityModel(identity: ServiceIdentity | null) { identity.refreshToken, identity.refreshLocation ) + default: + return null } } @@ -221,13 +234,8 @@ async function initiateOAuth() {

Authentication

Choose your authentication method and enter your credentials.

- - -
- JMAP supports multiple authentication methods. Choose the one your server uses. -
+ + JMAP supports multiple authentication methods. Choose the one your server uses. diff --git a/src/components/JmapAuxiliaryPanel.vue b/src/components/JmapAuxiliaryPanel.vue new file mode 100644 index 0000000..9f232ac --- /dev/null +++ b/src/components/JmapAuxiliaryPanel.vue @@ -0,0 +1,268 @@ + + + + + \ No newline at end of file diff --git a/src/components/JmapProtocolPanel.vue b/src/components/JmapProtocolPanel.vue index 17c9149..6d46e77 100644 --- a/src/components/JmapProtocolPanel.vue +++ b/src/components/JmapProtocolPanel.vue @@ -1,10 +1,9 @@