Workspace Config
Reading and writing workspace-wide settings with getConfig() and setBusinessTimezone(), including the WorkspaceConfig shape and IANA timezone validation.
Every workspace carries a small bag of business-wide settings, persisted as its own record. You read and write it through methods on the workspace itself — there is no need to reach for the underlying provider.
import { Workspace } from "wative-core";
const ws = await Workspace.open({ path: "./my-wallet", password: "wsp-pwd" });
await ws.setBusinessTimezone("America/New_York");
await ws.getConfig(); // { businessTimezone: "America/New_York" }All three members below require a live session. Calling them on a locked workspace throws WORKSPACE_LOCKED; on a closed one, UNSUPPORTED_OP.
getConfig() and the config snapshot
There are two ways to read the config, differing only in sync-vs-async and mutability.
| Member | Signature | Returns |
|---|---|---|
getConfig() | getConfig(): Promise<WorkspaceConfig> | A fresh plain copy of the current config. |
config | get config(): WorkspaceConfig | A frozen shallow copy, read synchronously. |
Both hand back a copy, never the live internal object, so mutating the result never changes stored state. The config getter goes further and freezes what it returns — assigning to a field on it is a silent no-op:
const snapshot = ws.config;
Object.isFrozen(snapshot); // true
snapshot.settlementWindow = "ny-close";
snapshot.settlementWindow; // undefined — the write did nothingTo change a setting, go through a writer method such as setBusinessTimezone(), which persists and then updates the in-memory copy.
setBusinessTimezone()
setBusinessTimezone(timezone: string): Promise<void>Sets the workspace's business timezone. The value is validated as an IANA timezone, written to the config record, and only then committed in memory. Valid IANA identifiers include region names and the Etc/ and UTC forms:
await ws.setBusinessTimezone("UTC");
await ws.getConfig(); // { businessTimezone: "UTC" }
await ws.setBusinessTimezone("Etc/UTC");
await ws.getConfig(); // { businessTimezone: "Etc/UTC" }The setting round-trips a lock/reopen cycle like every other persisted record.
WorkspaceConfig
The config is an open-ended object with one known field:
interface WorkspaceConfig {
businessTimezone?: string;
readonly [key: string]: unknown;
}The index signature means additional keys may appear over time; businessTimezone is the one the current API reads and writes.
IANA timezone validation
An invalid timezone is rejected before anything is written. setBusinessTimezone() validates the argument by constructing an Intl.DateTimeFormat with it; a non-string, an empty/whitespace string, or an unrecognized identifier all fail the same way — a WativeError with:
code === "PARAMETER_ERROR", and- a message containing the token
INVALID_BUSINESS_TIMEZONE.
The error message deliberately does not echo the rejected input back — it names the constraint (INVALID_BUSINESS_TIMEZONE: businessTimezone must be a valid IANA timezone.), not the value you passed.
try {
await ws.setBusinessTimezone("Not/AZone");
} catch (err) {
err.code; // "PARAMETER_ERROR"
/INVALID_BUSINESS_TIMEZONE/.test(err.message); // true
}