Integrate address sources with credential envelopes

This commit is contained in:
2026-07-28 19:33:08 +02:00
parent 93dddbb8c5
commit eab24750f9
6 changed files with 362 additions and 20 deletions

View File

@@ -216,6 +216,22 @@ export type AddressCardDavAddressBook = {
sync_token?: string | null;
};
export type AddressCredentialEnvelope = {
id: string;
scope_type: string;
scope_id?: string | null;
name: string;
description?: string | null;
credential_kind: string;
public_data: Record<string, unknown>;
secret_keys: string[];
secret_configured: boolean;
allowed_modules: string[];
inherit_to_lower_scopes: boolean;
is_active: boolean;
revision: string;
};
export type AddressSyncPlanStats = {
created: number;
updated: number;
@@ -305,6 +321,10 @@ type AddressCardDavDiscoveryResponse = {
address_books: AddressCardDavAddressBook[];
};
type AddressCredentialEnvelopeListResponse = {
credentials: AddressCredentialEnvelope[];
};
type AddressSyncDiagnosticListResponse = {
diagnostics: AddressSyncDiagnostic[];
};
@@ -450,7 +470,14 @@ export async function listAddressSyncSources(
export function discoverCardDavAddressBooks(
settings: ApiSettings,
payload: { url: string; auth_type: "none" | "basic" | "bearer"; username?: string | null; password?: string | null; bearer_token?: string | null }
payload: {
url: string;
auth_type: "none" | "basic" | "bearer";
username?: string | null;
password?: string | null;
bearer_token?: string | null;
credential_ref?: string | null;
}
): Promise<AddressCardDavAddressBook[]> {
return apiFetch<AddressCardDavDiscoveryResponse>(settings, "/api/v1/addresses/carddav/discover", {
method: "POST",
@@ -468,6 +495,7 @@ export function createCardDavSyncSource(
username?: string | null;
password?: string | null;
bearer_token?: string | null;
credential_ref?: string | null;
sync_direction: "read_only" | "import" | "export" | "two_way";
read_only?: boolean | null;
sync_token?: string | null;
@@ -481,6 +509,17 @@ export function createCardDavSyncSource(
});
}
export async function listAddressCredentials(
settings: ApiSettings,
sourceId?: string | null
): Promise<AddressCredentialEnvelope[]> {
const response = await apiFetch<AddressCredentialEnvelopeListResponse>(
settings,
`/api/v1/addresses/credentials${queryString({ source_id: sourceId })}`
);
return response.credentials;
}
export function updateAddressSyncSource(
settings: ApiSettings,
syncSourceId: string,