# Live Trunk Session Security

# Live Trunk Session Security

Why an already-open trunk closes when access becomes invalid.

**Applies to:** `Nord Inventory v2.0.0`
# Vehicle Trunk Access & Live Session Guard

Nord Inventory validates trunk access both before opening and while the inventory remains open.

## Locked vehicles

A locked vehicle cannot open its trunk inventory. The client checks both the normal GTA lock status and per-player door locks. The server revalidates the lock state whenever the artifact exposes the native, and also receives the normal-client preflight status for compatibility.

## Live trunk session

Once a trunk is open, Nord continuously validates the same live vehicle context. The inventory closes automatically when:

- the vehicle becomes locked;
- the vehicle moves away from its opening position;
- the vehicle starts moving above the configured threshold;
- the player is no longer close enough to the physical trunk/frunk interaction point;
- the vehicle despawns;
- the network id is recycled to another entity;
- the plate no longer matches the opened vehicle.

This is especially important for ambient/NPC vehicles: an NPC cannot drive away while the player keeps the old trunk inventory open.

## Configuration

```lua
Config.VehicleInteraction.Trunk.SessionGuard = {
    Enabled = true,
    ClientCheckInterval = 150,
    ServerCheckInterval = 750,
    DistanceTolerance = 1.60,
    VehicleMoveDistance = 1.00,
    VehicleMoveSpeed = 0.65,
    CloseWhenLocked = true,
    CloseWhenVehicleMoves = true,
}
```

The client guard is for immediate UX. The server guard protects the inventory session and rejects further inventory actions once the vehicle context becomes invalid.


## Player-owned vehicles and vehicle-key resources

Player-owned/personal vehicles must obey the same trunk lock rule as every other vehicle.

Nord Inventory now has a dedicated open lock bridge:

```text
client/bridge/vehiclelocks.lua
server/bridge/vehiclelocks.lua
```

With the default configuration:

```lua
LockIntegration = {
    Provider = 'auto'
}
```

`auto` detects `nord_vehiclekeys`.

When `nord_vehiclekeys` is running, Nord Inventory reads its synchronized:

```text
nordkeys:locked
```

state on the client and validates the server state through:

```lua
exports.nord_vehiclekeys:GetLockState(netId)
```

A `locked = true` result always blocks the trunk, even if GTA's native
`GetVehicleDoorLockStatus` is briefly stale/unlocked for the owner.

The provider and native checks are intentionally combined: if either reliable
source says the vehicle is locked, trunk access is denied.

### Other vehicle-key resources

Use:

```lua
LockIntegration = {
    Provider = 'custom'
}
```

and implement the resolver in the open bridge files, or set the provider to a
resource exposing an `IsVehicleLocked` export.
