Vaultrice SDK - v0.9.18
    Preparing search index...

    Interface OfflineSyncOptions

    Options for creating an offline sync object.

    Use this interface to configure offline-first behavior, including storage backend and conflict resolution.

    const offlineSync = await createOfflineSyncObject(credentials, {
    id: 'my-id',
    storage: new LocalStorageAdapter({ projectId, className, id }),
    resolveConflict: (local, remote) => {
    // Custom merge logic
    return local.updatedAt > remote.updatedAt ? local : remote
    }
    })
    interface OfflineSyncOptions {
        id?: string;
        class?: string;
        ttl?: number;
        passphrase?: string;
        keyDerivationOptions?: KeyDerivationOptions;
        getEncryptionHandler?: (
            encryptionSettings: EncryptionSettings,
        ) => Promise<EncryptionHandler>;
        autoUpdateOldEncryptedValues?: boolean;
        idSignature?: string;
        idSignatureKeyVersion?: number;
        logLevel?: LogLevel;
        connectionSettings?: {
            autoReconnect?: boolean;
            reconnectBaseDelay?: number;
            reconnectMaxDelay?: number;
            pingInterval?: number;
            pongTimeout?: number;
        };
        throttling?: ThrottleConfig;
        storage?: | (
            new (
                options: {
                    projectId: string;
                    class?: string;
                    id?: string;
                    ttl?: number;
                },
            ) => StorageAdapter
        )
        | (
            (
                options: {
                    projectId: string;
                    class?: string;
                    id?: string;
                    ttl?: number;
                },
            ) => StorageAdapter
        );
        resolveConflict?: (local: ItemType, remote: ItemType) => ItemType;
        expirationSweepInterval?: number;
    }

    Hierarchy (View Summary)

    Index

    Properties

    id?: string
    class?: string

    Storage class.

    '_undefined_'
    
    ttl?: number

    Time-to-live in milliseconds for this item.

    3600000 (1 hour)
    
    passphrase?: string

    Passphrase used for e2e encryption

    keyDerivationOptions?: KeyDerivationOptions

    Key derivation options.

    getEncryptionHandler?: (
        encryptionSettings: EncryptionSettings,
    ) => Promise<EncryptionHandler>

    Custom encryption handler.

    autoUpdateOldEncryptedValues?: boolean

    Auto-update old encrypted values.

    true
    
    idSignature?: string

    Signature (generated in your backend) of the id.

    idSignatureKeyVersion?: number

    Key version for the signature (generated in your backend) of the id.

    logLevel?: LogLevel

    Log level.

    'warn'
    
    connectionSettings?: {
        autoReconnect?: boolean;
        reconnectBaseDelay?: number;
        reconnectMaxDelay?: number;
        pingInterval?: number;
        pongTimeout?: number;
    }

    Connection settings (mainly for WebSocket connection).

    Type Declaration

    • OptionalautoReconnect?: boolean

      If true, automatically reconnect on unexpected disconnects.

      true
      
    • OptionalreconnectBaseDelay?: number

      Base delay in milliseconds for exponential backoff between reconnect attempts.

      1000
      
    • OptionalreconnectMaxDelay?: number

      Maximum delay in milliseconds for exponential backoff between reconnect attempts.

      60000
      
    • OptionalpingInterval?: number

      Interval in milliseconds between WebSocket ping messages to keep the connection alive.

      20000
      

      The client will send a ping message at this interval. If a pong response is not received within the pongTimeout, the connection will be closed and a reconnect will be attempted if autoReconnect is enabled.

    • OptionalpongTimeout?: number

      Timeout in milliseconds to wait for a pong response after sending a ping.

      10000
      

      If a pong response is not received within this timeout after a ping, the connection will be considered lost and closed.

    true
    
    1000
    
    60000
    
    throttling?: ThrottleConfig

    Throttling configuration

    storage?:
        | (
            new (
                options: {
                    projectId: string;
                    class?: string;
                    id?: string;
                    ttl?: number;
                },
            ) => StorageAdapter
        )
        | (
            (
                options: {
                    projectId: string;
                    class?: string;
                    id?: string;
                    ttl?: number;
                },
            ) => StorageAdapter
        )

    The storage adapter to use for local persistence.

    resolveConflict?: (local: ItemType, remote: ItemType) => ItemType

    Optional function to resolve conflicts between local and remote items.

    expirationSweepInterval?: number

    Interval in milliseconds for periodic expiration sweep. Expired items will be removed from local storage at this interval. Defaults to 15 minutes (900000 ms).

    900000
    
    expirationSweepInterval: 60000 // Sweep every minute