/** * Workbook protection — lock structure and/or windows so the workbook layout cannot be changed freely. * * This is Excel’s “Protect Workbook” (structure and windows), **not** file encryption. * Call {@link Workbook.protect} with optional password and {@link WorkbookProtectionOptions}. * Unlike sheet protection, options use **lock** polarity (`true` means that feature is locked). * * Citations: * - ECMA-376-1 §18.2.29 (`workbookProtection`) * - transitional sml.xsd `CT_WorkbookProtection` (~L4371–4387) * - `CT_Workbook` sequence: after `workbookPr`, before `bookViews` (rank 40) * - MS-OE376 iterative password hash (same as sheet: SHA-512, salt prepended) * - docs/specs/workbook-protection.md; docs/ooxml-mapping/workbook-protection.md */ /** Default spin count for modern workbook password hash (same as sheet). */ export declare const WORKBOOK_PROTECTION_DEFAULT_SPIN_COUNT = 100000; /** Algorithm name authored on new protect. */ export declare const WORKBOOK_PROTECTION_ALGORITHM = "SHA-512"; /** * Options for {@link Workbook.protect}. * * Each flag is **lock** polarity: `true` means that capability is locked for the user. */ export interface WorkbookProtectionOptions { /** * Prevent adding, deleting, renaming, or reordering sheets. * Default `true` when you call protect. */ lockStructure?: boolean; /** * Prevent resizing or moving workbook windows. * Default `false`. */ lockWindows?: boolean; /** * Lock shared-workbook revision tracking. Mostly preserved when opening existing files; * default `false` on new protect. */ lockRevision?: boolean; } /** * Read-only view of the workbook’s current protection settings. * * Returned by {@link Workbook.workbookProtection} when protection is on; * otherwise that property is `undefined`. */ export interface WorkbookProtectionInfo { readonly isProtected: true; /** `true` when unprotecting requires a password. */ readonly hasPassword: boolean; /** Effective lock flags after defaults are applied. */ readonly options: Readonly>; /** * Modern OOXML `workbookAlgorithmName` when present (e.g. `SHA-512`). * Undefined for password-less protection or legacy-only password. */ readonly algorithmName: string | undefined; /** * Modern OOXML `workbookHashValue` (base64) when present. * Read-only snapshot of wire material; not a cleartext password. */ readonly hashValue: string | undefined; /** * Modern OOXML `workbookSaltValue` (base64) when present. */ readonly saltValue: string | undefined; /** * Modern OOXML `workbookSpinCount` when present. */ readonly spinCount: number | undefined; } /** * Wire model for `workbookProtection` (empty element, attributes only). * @private */ export interface WorkbookProtectionModel { /** Whether a `workbookProtection` element is present / authored. */ readonly present: boolean; /** Public lock flags (direct wire polarity). */ readonly options: Required; /** Modern `workbookAlgorithmName` when present. */ readonly algorithmName: string | undefined; /** Modern `workbookHashValue` (base64) when present. */ readonly hashValue: string | undefined; /** Modern `workbookSaltValue` (base64) when present. */ readonly saltValue: string | undefined; /** Modern `workbookSpinCount` when present. */ readonly spinCount: number | undefined; /** * Legacy `workbookPassword` ST_UnsignedShortHex when present (preserve-only; * never authored by `protect()`). */ readonly legacyPassword: string | undefined; /** Legacy `workbookPasswordCharacterSet` when present. */ readonly legacyPasswordCharacterSet: string | undefined; /** Preserved `revisionsPassword`. */ readonly revisionsPassword: string | undefined; /** Preserved `revisionsPasswordCharacterSet`. */ readonly revisionsPasswordCharacterSet: string | undefined; /** Preserved revisions modern hash material. */ readonly revisionsAlgorithmName: string | undefined; readonly revisionsHashValue: string | undefined; readonly revisionsSaltValue: string | undefined; readonly revisionsSpinCount: number | undefined; /** Unknown attributes preserved as XML fragment. */ readonly extraAttrsXml: string; } /** * Host notifications for protection mutations. * @private */ export interface WorkbookProtectionHost { markDirty(): void; } /** * Defaults when calling `protect()` without options (XlsIO structure protect). * @private */ export declare const DEFAULT_WORKBOOK_PROTECT_OPTIONS: Readonly>; /** * Mutable workbook-protection store bound to a workbook. * @private */ export declare class WorkbookProtectionImpl { private model; private host; constructor(initial?: WorkbookProtectionModel); /** @private */ bindHost(host: WorkbookProtectionHost): void; /** @private */ replaceFromParse(model: WorkbookProtectionModel): void; /** @private */ toModel(): WorkbookProtectionModel; /** * True when protection is active: element present and at least one lock or * password material exists. */ readonly isProtected: boolean; /** * Snapshot when protected; `undefined` when not. */ readonly workbookProtection: WorkbookProtectionInfo | undefined; /** * Enable or replace workbook structure/windows protection. * * @param password Optional password; non-empty authors modern SHA-512 hash. * @param options Lock flags merged over defaults (`lockStructure: true`). */ protect(password?: string, options?: WorkbookProtectionOptions): void; /** * Remove workbook protection. * * @param password Required when the workbook has a password (modern or legacy). * @throws InvalidProtectionError when password is required/wrong/unsupported. */ unprotect(password?: string): void; } /** * Parse a `workbookProtection` element into a model. * @private */ export declare function parseWorkbookProtectionXml(xml: string): WorkbookProtectionModel; /** * Serialize model to a `workbookProtection` element, or `undefined` when absent. * Omits lock attributes that equal XSD defaults (false). * @private */ export declare function serializeWorkbookProtectionXml(model: WorkbookProtectionModel | undefined): string | undefined;