38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { defineCodes } from "@suaveplan/error";
|
|
|
|
/**
|
|
* Stable error code registry for `@suaveplan/vault`.
|
|
*
|
|
* Every code is namespaced under `VAULT.<MODULE>.<REASON>`. The full set is
|
|
* frozen at module-load time and may never be removed without a major version
|
|
* bump — consumer code MAY assert on these literal strings to drive recovery
|
|
* logic (e.g. prompting the user to re-enter their password on
|
|
* `VAULT.INVALID_CREDENTIALS`).
|
|
*/
|
|
export const VAULT_CODES = defineCodes("VAULT", [
|
|
"LOCKED",
|
|
"INVALID_CREDENTIALS",
|
|
"ALREADY_OPEN",
|
|
"NOT_INITIALIZED",
|
|
"MANIFEST_INVALID",
|
|
"MANIFEST_VERSION_UNSUPPORTED",
|
|
"DECRYPT_FAILED",
|
|
"ITEM.NOT_FOUND",
|
|
"ITEM.VALIDATION_FAILED",
|
|
"ITEM.VERSION_CONFLICT",
|
|
"ATTACHMENT.NOT_FOUND",
|
|
"ATTACHMENT.TOO_LARGE",
|
|
"SHARE.NOT_FOUND",
|
|
"SHARE.REVOKED",
|
|
"SYNC.FAILED",
|
|
"OPAQUE_HANDLE_INVALID",
|
|
"DRIVE.FAILURE",
|
|
] as const);
|
|
|
|
/**
|
|
* Union of every fully-qualified error code emitted by `vault`. Use as the
|
|
* type parameter of {@link import("./vault-error.js").VaultError} for
|
|
* narrowed `code` checks.
|
|
*/
|
|
export type VaultErrorCode = (typeof VAULT_CODES)[keyof typeof VAULT_CODES];
|