Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add import models (#2413)
Leendert de Borst1586e1abf0f9
diff --git a/core/client/src/transfer/import/models/ImportException.ts b/core/client/src/transfer/import/models/ImportException.tsnew file mode 100644index 000000000..a73ed8327--- /dev/null+++ b/core/client/src/transfer/import/models/ImportException.ts@@ -0,0 +1,39 @@+/**+ * Identifies which stage of the import process produced an error.+ */+export enum ImportStage {+ /** The file could not be opened or read as an archive (corrupt zip, truncated download, etc.). */+ Archive = 'Archive',++ /** The archive could be opened but its contents could not be parsed (missing manifest, malformed JSON, unexpected schema). */+ Parse = 'Parse',++ /** The parsed credentials could not be saved into the local vault database. */+ Save = 'Save',+}++/**+ * Raised by importers when a catastrophic failure occurs. Carries the stage so the UI can present+ * an actionable, copyable error payload.+ */+export class ImportException extends Error {+ /** The pipeline stage where the failure happened. */+ public readonly stage: ImportStage;++ /** The error that triggered this failure, if any. */+ public readonly innerError: unknown;++ /**+ * Create the exception.+ * @param stage - The pipeline stage where the failure happened+ * @param message - A human-readable description of what went wrong+ * @param innerError - The error that triggered this failure+ */+ public constructor(stage: ImportStage, message: string, innerError?: unknown) {+ super(message);+ this.name = 'ImportException';+ this.stage = stage;+ this.innerError = innerError;+ Object.setPrototypeOf(this, ImportException.prototype);+ }+}diff --git a/core/client/src/transfer/import/models/ImportedAlias.ts b/core/client/src/transfer/import/models/ImportedAlias.tsnew file mode 100644index 000000000..829420a79--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedAlias.ts@@ -0,0 +1,9 @@+/**+ * An alias in the intermediary import format.+ */+export type ImportedAlias = {+ Gender?: string | null;+ FirstName?: string | null;+ LastName?: string | null;+ BirthDate?: Date | null;+};diff --git a/core/client/src/transfer/import/models/ImportedAttachment.ts b/core/client/src/transfer/import/models/ImportedAttachment.tsnew file mode 100644index 000000000..df00ef07d--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedAttachment.ts@@ -0,0 +1,7 @@+/**+ * An attachment in the intermediary import format.+ */+export type ImportedAttachment = {+ Filename: string;+ Blob: Uint8Array;+};diff --git a/core/client/src/transfer/import/models/ImportedCredential.ts b/core/client/src/transfer/import/models/ImportedCredential.tsnew file mode 100644index 000000000..295a45dff--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedCredential.ts@@ -0,0 +1,35 @@+import type { ImportedAlias } from './ImportedAlias';+import type { ImportedAttachment } from './ImportedAttachment';+import type { ImportedCreditcard } from './ImportedCreditcard';+import type { ImportedCustomField } from './ImportedCustomField';+import type { ImportedPasskey } from './ImportedPasskey';+import type { ItemType } from '@aliasvault/models/vault';++/**+ * A credential in the intermediary import format.+ */+export type ImportedCredential = {+ /** Service name (e.g. "Facebook", "Gmail"). */+ ServiceName?: string | null;+ ServiceUrls?: string[] | null;+ Username?: string | null;+ Password?: string | null;+ Email?: string | null;+ /** 2FA secret key, either bare or as an otpauth:// URI. */+ TwoFactorSecret?: string | null;+ Notes?: string | null;+ CreatedAt?: Date | null;+ UpdatedAt?: Date | null;+ /** Favicon bytes, populated from .avux imports or other sources that provide logo data. */+ FaviconBytes?: Uint8Array | null;+ Alias?: ImportedAlias | null;+ /** Folder path from the source (e.g. "Business" or "Personal/Work"). */+ FolderPath?: string | null;+ /** The item type. If null, defaults to Login or Alias (when alias data is present). */+ ItemType?: ItemType | null;+ Creditcard?: ImportedCreditcard | null;+ Passkeys?: ImportedPasskey[] | null;+ Tags?: string[] | null;+ Attachments?: ImportedAttachment[] | null;+ CustomFieldValues?: ImportedCustomField[] | null;+};diff --git a/core/client/src/transfer/import/models/ImportedCreditcard.ts b/core/client/src/transfer/import/models/ImportedCreditcard.tsnew file mode 100644index 000000000..1cde795b1--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedCreditcard.ts@@ -0,0 +1,11 @@+/**+ * Credit card information in the intermediary import format.+ */+export type ImportedCreditcard = {+ CardholderName?: string | null;+ Number?: string | null;+ ExpiryMonth?: string | null;+ ExpiryYear?: string | null;+ Cvv?: string | null;+ Pin?: string | null;+};diff --git a/core/client/src/transfer/import/models/ImportedCustomField.ts b/core/client/src/transfer/import/models/ImportedCustomField.tsnew file mode 100644index 000000000..abe9ae4dc--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedCustomField.ts@@ -0,0 +1,20 @@+import type { FieldType } from '@aliasvault/models/vault';++/**+ * A single custom (user-defined) field value with the metadata of its field definition.+ */+export type ImportedCustomField = {+ DefinitionId: string;+ Label: string;+ Value?: string | null;+ FieldType: FieldType;+ IsMultiValue: boolean;+ IsHidden: boolean;+ EnableHistory: boolean;+ /** Display order weight of the field definition (custom field ordering in the UI). */+ Weight: number;+ /** Display order weight of this individual value (ordering within a multi-value field). */+ ValueWeight: number;+ /** The applicable item types as a JSON array (e.g. '["Login","Identity"]'); null means all types. */+ ApplicableToTypes?: string | null;+};diff --git a/core/client/src/transfer/import/models/ImportedPasskey.ts b/core/client/src/transfer/import/models/ImportedPasskey.tsnew file mode 100644index 000000000..1b93acb3d--- /dev/null+++ b/core/client/src/transfer/import/models/ImportedPasskey.ts@@ -0,0 +1,16 @@+/**+ * A passkey in the intermediary import format.+ */+export type ImportedPasskey = {+ /** The passkey id from the original record, preserved through import/export. */+ Id?: string | null;+ RpId: string;+ /** The user handle (user id provided by the relying party). */+ UserHandle?: Uint8Array | null;+ /** Public key (JWK format). */+ PublicKey: string;+ /** Private key (JWK format). */+ PrivateKey: string;+ PrfKey?: Uint8Array | null;+ DisplayName: string;+};