diff --git a/frontend/sync-client/src/services/sync-service.ts b/frontend/sync-client/src/services/sync-service.ts index 741aa012..bbb559ff 100644 --- a/frontend/sync-client/src/services/sync-service.ts +++ b/frontend/sync-client/src/services/sync-service.ts @@ -1,6 +1,6 @@ import type { Client } from "openapi-fetch"; import createClient from "openapi-fetch"; -import type { components, paths } from "./types"; // generated by openapi-typescript +import type { components, paths } from "./types/http-api"; // generated by openapi-typescript import type { DocumentId, RelativePath, @@ -44,19 +44,6 @@ export class SyncService { }); } - private get deviceIdHeader(): string { - // @ts-expect-error, injected by webpack - const packageVersion = __CURRENT_VERSION__; // eslint-disable-line - - const platform = - typeof navigator !== "undefined" - ? navigator.platform // eslint-disable-line @typescript-eslint/no-deprecated - : typeof process !== "undefined" - ? process.platform - : "unknown"; - return `vault-link/${packageVersion} (${this.deviceId}; ${platform})`; - } - private static formatError( error: components["schemas"]["SerializedError"] ): string { @@ -86,7 +73,6 @@ export class SyncService { formData.append("document_id", documentId); } formData.append("relative_path", relativePath); - formData.append("device_id", this.deviceId); formData.append("content", new Blob([contentBytes])); const response = await this.client.POST( @@ -97,7 +83,7 @@ export class SyncService { vault_id: vaultName }, header: { - "device-id": this.deviceIdHeader + "device-id": this.deviceId } }, // eslint-disable-next-line @@ -141,7 +127,6 @@ export class SyncService { const formData = new FormData(); formData.append("parent_version_id", parentVersionId.toString()); formData.append("relative_path", relativePath); - formData.append("device_id", this.deviceId); formData.append("content", new Blob([contentBytes])); const response = await this.client.PUT( @@ -153,7 +138,7 @@ export class SyncService { document_id: documentId }, header: { - "device-id": this.deviceIdHeader + "device-id": this.deviceId } }, // eslint-disable-next-line @@ -196,13 +181,12 @@ export class SyncService { document_id: documentId }, header: { - "device-id": this.deviceIdHeader + "device-id": this.deviceId } }, body: { - relativePath, - deviceId: this.deviceId + relativePath } } ); diff --git a/frontend/sync-client/src/utils/create-client-id.ts b/frontend/sync-client/src/utils/create-client-id.ts new file mode 100644 index 00000000..60143b75 --- /dev/null +++ b/frontend/sync-client/src/utils/create-client-id.ts @@ -0,0 +1,15 @@ +import { v4 as uuidv4 } from "uuid"; + +export function createClientId(): string { + // @ts-expect-error, injected by webpack + const packageVersion = __CURRENT_VERSION__; // eslint-disable-line + + const platform = + typeof navigator !== "undefined" + ? navigator.platform // eslint-disable-line @typescript-eslint/no-deprecated + : typeof process !== "undefined" + ? process.platform + : "unknown"; + + return `vault-link/${packageVersion} (${uuidv4()}; ${platform})`; +}