@happyvertical/smrt-secrets 0.60.9 → 0.60.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,366 +0,0 @@
1
- import { ObjectRegistry, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
2
- //#region src/__smrt-register__.ts
3
- ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-secrets\",\"packageVersion\":\"0.60.9\",\"objects\":{\"@happyvertical/smrt-secrets:SecretAuditLogCollection\":{\"name\":\"secretauditlogcollection\",\"className\":\"SecretAuditLogCollection\",\"qualifiedName\":\"@happyvertical/smrt-secrets:SecretAuditLogCollection\",\"collection\":\"secretauditlogs\",\"description\":\"Collection for managing SecretAuditLog objects\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/collections/SecretAuditLogCollection.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{},\"methods\":{\"listLogs\":{\"name\":\"listLogs\",\"async\":true,\"parameters\":[{\"name\":\"options\",\"type\":\"ListAuditLogsOptions\",\"optional\":true}],\"returnType\":\"Promise<SecretAuditLog[]>\",\"isStatic\":false,\"isPublic\":true},\"getSecretHistory\":{\"name\":\"getSecretHistory\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"secretName\",\"type\":\"string\",\"optional\":false},{\"name\":\"limit\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<SecretAuditLog[]>\",\"isStatic\":false,\"isPublic\":true},\"getUserActivity\":{\"name\":\"getUserActivity\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"userId\",\"type\":\"string\",\"optional\":false},{\"name\":\"limit\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<SecretAuditLog[]>\",\"isStatic\":false,\"isPublic\":true},\"getRecentFailures\":{\"name\":\"getRecentFailures\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"limit\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<SecretAuditLog[]>\",\"isStatic\":false,\"isPublic\":true},\"getRecentDenials\":{\"name\":\"getRecentDenials\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"limit\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<SecretAuditLog[]>\",\"isStatic\":false,\"isPublic\":true},\"countByAction\":{\"name\":\"countByAction\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"since\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<Record<SecretAuditAction, number>>\",\"isStatic\":false,\"isPublic\":true},\"countByResult\":{\"name\":\"countByResult\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string | null\",\"optional\":false,\"unionBranches\":[{\"type\":\"string\"},{\"type\":\"null\"}]},{\"name\":\"since\",\"type\":\"Date\",\"optional\":true}],\"returnType\":\"Promise<Record<SecretAuditResult, number>>\",\"isStatic\":false,\"isPublic\":true},\"cleanup\":{\"name\":\"cleanup\",\"async\":true,\"parameters\":[{\"name\":\"olderThanDays\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\"],\"skipApiCheck\":true}},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"SecretAuditLog\",\"exportName\":\"SecretAuditLogCollection\",\"collectionExportName\":\"SecretAuditLogCollectionCollection\",\"collectionOf\":\"@happyvertical/smrt-secrets:SecretAuditLog\",\"inheritedExposure\":[\"api\",\"mcp\",\"cli\"],\"schema\":{\"tableName\":\"secret_audit_logs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"secret_audit_logs\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"secret_id\\\" UUID,\\n \\\"secret_name\\\" TEXT DEFAULT '',\\n \\\"user_id\\\" UUID,\\n \\\"action\\\" TEXT DEFAULT 'read',\\n \\\"result\\\" TEXT DEFAULT 'success',\\n \\\"ip_address\\\" TEXT DEFAULT '',\\n \\\"user_agent\\\" TEXT DEFAULT '',\\n \\\"details\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"secret_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"secret_name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"action\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"read\"},\"result\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"success\"},\"ip_address\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"user_agent\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"details\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"secret_audit_logs_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"secret_audit_logs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"secret_audit_logs_secret_id_idx\",\"columns\":[\"secret_id\"]},{\"name\":\"secret_audit_logs_user_id_idx\",\"columns\":[\"user_id\"]}],\"version\":\"af0d679d\"},\"importPath\":\"@happyvertical/smrt-secrets\"},\"@happyvertical/smrt-secrets:SecretCollection\":{\"name\":\"secretcollection\",\"className\":\"SecretCollection\",\"qualifiedName\":\"@happyvertical/smrt-secrets:SecretCollection\",\"collection\":\"secrets\",\"description\":\"Collection for managing Secret objects\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/collections/SecretCollection.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{},\"methods\":{\"findByName\":{\"name\":\"findByName\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"name\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Secret | null>\",\"isStatic\":false,\"isPublic\":true},\"listSecrets\":{\"name\":\"listSecrets\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"options\",\"type\":\"ListSecretsOptions\",\"optional\":true}],\"returnType\":\"Promise<Secret[]>\",\"isStatic\":false,\"isPublic\":true},\"listActive\":{\"name\":\"listActive\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Secret[]>\",\"isStatic\":false,\"isPublic\":true},\"listByCategory\":{\"name\":\"listByCategory\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"category\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Secret[]>\",\"isStatic\":false,\"isPublic\":true},\"listExpiring\":{\"name\":\"listExpiring\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"daysAhead\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<Secret[]>\",\"isStatic\":false,\"isPublic\":true},\"getCategories\":{\"name\":\"getCategories\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<string[]>\",\"isStatic\":false,\"isPublic\":true},\"countByStatus\":{\"name\":\"countByStatus\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<Record<SecretStatus, number>>\",\"isStatic\":false,\"isPublic\":true},\"deleteByName\":{\"name\":\"deleteByName\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"name\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\"],\"skipApiCheck\":true}},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"Secret\",\"exportName\":\"SecretCollection\",\"collectionExportName\":\"SecretCollectionCollection\",\"collectionOf\":\"@happyvertical/smrt-secrets:Secret\",\"inheritedExposure\":[\"api\",\"mcp\",\"cli\"],\"schema\":{\"tableName\":\"secrets\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"secrets\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"description\\\" TEXT DEFAULT '',\\n \\\"category\\\" TEXT DEFAULT '',\\n \\\"encrypted_value\\\" TEXT DEFAULT '',\\n \\\"key_version\\\" INTEGER DEFAULT 1,\\n \\\"status\\\" TEXT DEFAULT 'active',\\n \\\"expires_at\\\" TIMESTAMP,\\n \\\"last_accessed_at\\\" TIMESTAMP,\\n \\\"access_count\\\" INTEGER DEFAULT 0,\\n \\\"metadata\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"category\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"encrypted_value\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"key_version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":1},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"active\"},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_accessed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"access_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"secrets_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"secrets_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"6298a980\"},\"importPath\":\"@happyvertical/smrt-secrets\"},\"@happyvertical/smrt-secrets:TenantKeyCollection\":{\"name\":\"tenantkeycollection\",\"className\":\"TenantKeyCollection\",\"qualifiedName\":\"@happyvertical/smrt-secrets:TenantKeyCollection\",\"collection\":\"tenantkeys\",\"description\":\"Collection for managing TenantKey objects\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/collections/TenantKeyCollection.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{},\"methods\":{\"getActiveKey\":{\"name\":\"getActiveKey\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantKey | null>\",\"isStatic\":false,\"isPublic\":true},\"listKeyVersions\":{\"name\":\"listKeyVersions\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<TenantKey[]>\",\"isStatic\":false,\"isPublic\":true},\"getKeyVersion\":{\"name\":\"getKeyVersion\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"version\",\"type\":\"number\",\"optional\":false}],\"returnType\":\"Promise<TenantKey | null>\",\"isStatic\":false,\"isPublic\":true},\"findKeysNeedingRotation\":{\"name\":\"findKeysNeedingRotation\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<TenantKey[]>\",\"isStatic\":false,\"isPublic\":true},\"listAllActiveKeys\":{\"name\":\"listAllActiveKeys\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<TenantKey[]>\",\"isStatic\":false,\"isPublic\":true},\"countByStatus\":{\"name\":\"countByStatus\",\"async\":true,\"parameters\":[],\"returnType\":\"Promise<Record<TenantKeyStatus, number>>\",\"isStatic\":false,\"isPublic\":true},\"markCompromised\":{\"name\":\"markCompromised\",\"async\":true,\"parameters\":[{\"name\":\"tenantId\",\"type\":\"string\",\"optional\":false},{\"name\":\"keyId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<boolean>\",\"isStatic\":false,\"isPublic\":true},\"cleanupRetiredKeys\":{\"name\":\"cleanupRetiredKeys\",\"async\":true,\"parameters\":[{\"name\":\"olderThanDays\",\"type\":\"number\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\",\"get\"],\"skipApiCheck\":true}},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"TenantKey\",\"exportName\":\"TenantKeyCollection\",\"collectionExportName\":\"TenantKeyCollectionCollection\",\"collectionOf\":\"@happyvertical/smrt-secrets:TenantKey\",\"inheritedExposure\":[\"api\",\"mcp\",\"cli\"],\"schema\":{\"tableName\":\"tenant_keys\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_keys\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"wrapped_key\\\" TEXT DEFAULT '',\\n \\\"amk_key_id\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT DEFAULT 'active',\\n \\\"version\\\" INTEGER DEFAULT 1,\\n \\\"rotate_after\\\" TIMESTAMP,\\n \\\"retired_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"notNull\":false,\"unique\":false},\"wrapped_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"amk_key_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"active\"},\"version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":1},\"rotate_after\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"retired_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"tenant_keys_tenant_id_slug_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_keys_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"abc3474a\"},\"importPath\":\"@happyvertical/smrt-secrets\"},\"@happyvertical/smrt-secrets:Secret\":{\"name\":\"secret\",\"className\":\"Secret\",\"qualifiedName\":\"@happyvertical/smrt-secrets:Secret\",\"collection\":\"secrets\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/models/Secret.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"default\":\"\",\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"mode\":\"required\",\"field\":\"tenantId\",\"autoFilter\":true,\"autoPopulate\":true,\"allowSuperAdminBypass\":false}}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"category\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"encryptedValue\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"keyVersion\":{\"type\":\"integer\",\"required\":false,\"default\":1},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"active\",\"enum\":[\"active\",\"disabled\",\"expired\"]},\"expiresAt\":{\"type\":\"datetime\",\"required\":false},\"lastAccessedAt\":{\"type\":\"datetime\",\"required\":false},\"accessCount\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"metadata\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isExpired\":{\"name\":\"isExpired\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isUsable\":{\"name\":\"isUsable\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"recordAccess\":{\"name\":\"recordAccess\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"disable\":{\"name\":\"disable\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"enable\":{\"name\":\"enable\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"sensitive\":true,\"tenantScoped\":true,\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\"],\"skipApiCheck\":true},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"Secret\",\"collectionExportName\":\"SecretCollection\",\"displayLabelField\":\"name\",\"schema\":{\"tableName\":\"secrets\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"secrets\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"description\\\" TEXT DEFAULT '',\\n \\\"category\\\" TEXT DEFAULT '',\\n \\\"encrypted_value\\\" TEXT DEFAULT '',\\n \\\"key_version\\\" INTEGER DEFAULT 1,\\n \\\"status\\\" TEXT DEFAULT 'active',\\n \\\"expires_at\\\" TIMESTAMP,\\n \\\"last_accessed_at\\\" TIMESTAMP,\\n \\\"access_count\\\" INTEGER DEFAULT 0,\\n \\\"metadata\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"description\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"category\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"encrypted_value\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"key_version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":1},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"active\"},\"expires_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"last_accessed_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"access_count\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":0},\"metadata\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"secrets_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"secrets_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"6298a980\"},\"importPath\":\"@happyvertical/smrt-secrets/models\"},\"@happyvertical/smrt-secrets:SecretAuditLog\":{\"name\":\"secretauditlog\",\"className\":\"SecretAuditLog\",\"qualifiedName\":\"@happyvertical/smrt-secrets:SecretAuditLog\",\"collection\":\"secretauditlogs\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/models/SecretAuditLog.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"__tenancy\":{\"isTenantIdField\":true,\"mode\":\"required\",\"field\":\"tenantId\",\"autoFilter\":true,\"autoPopulate\":true,\"allowSuperAdminBypass\":false}}},\"secretId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"Secret\",\"_meta\":{\"constraint\":false}},\"secretName\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"userId\":{\"type\":\"crossPackageRef\",\"required\":false,\"related\":\"@happyvertical/smrt-users:User\"},\"action\":{\"type\":\"text\",\"required\":false,\"default\":\"read\",\"enum\":[\"create\",\"read\",\"update\",\"delete\",\"rotate_key\",\"disable\",\"enable\",\"expire\"]},\"result\":{\"type\":\"text\",\"required\":false,\"default\":\"success\",\"enum\":[\"success\",\"failure\",\"denied\"]},\"ipAddress\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"userAgent\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"details\":{\"type\":\"json\",\"required\":false,\"default\":{}}},\"methods\":{\"isSuccess\":{\"name\":\"isSuccess\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isFailure\":{\"name\":\"isFailure\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isDenied\":{\"name\":\"isDenied\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isReadAction\":{\"name\":\"isReadAction\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isWriteAction\":{\"name\":\"isWriteAction\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isKeyOperation\":{\"name\":\"isKeyOperation\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tenantScoped\":true,\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\"],\"skipApiCheck\":true},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"SecretAuditLog\",\"collectionExportName\":\"SecretAuditLogCollection\",\"schema\":{\"tableName\":\"secret_audit_logs\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"secret_audit_logs\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"secret_id\\\" UUID,\\n \\\"secret_name\\\" TEXT DEFAULT '',\\n \\\"user_id\\\" UUID,\\n \\\"action\\\" TEXT DEFAULT 'read',\\n \\\"result\\\" TEXT DEFAULT 'success',\\n \\\"ip_address\\\" TEXT DEFAULT '',\\n \\\"user_agent\\\" TEXT DEFAULT '',\\n \\\"details\\\" JSON DEFAULT '{}'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"secret_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"notNull\":false,\"unique\":false},\"secret_name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"user_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":false,\"unique\":false},\"action\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"read\"},\"result\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"success\"},\"ip_address\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"user_agent\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"details\":{\"type\":\"JSON\",\"notNull\":false,\"unique\":false,\"default\":{}}},\"indexes\":[{\"name\":\"secret_audit_logs_slug_context_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"secret_audit_logs_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]},{\"name\":\"secret_audit_logs_secret_id_idx\",\"columns\":[\"secret_id\"]},{\"name\":\"secret_audit_logs_user_id_idx\",\"columns\":[\"user_id\"]}],\"version\":\"af0d679d\"},\"importPath\":\"@happyvertical/smrt-secrets/models\"},\"@happyvertical/smrt-secrets:TenantKey\":{\"name\":\"tenantkey\",\"className\":\"TenantKey\",\"qualifiedName\":\"@happyvertical/smrt-secrets:TenantKey\",\"collection\":\"tenantkeys\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/secrets/src/models/TenantKey.ts\",\"packageName\":\"@happyvertical/smrt-secrets\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"default\":\"\",\"_meta\":{\"sqlType\":\"UUID\"}},\"wrappedKey\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"amkKeyId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"active\",\"enum\":[\"active\",\"rotating\",\"retired\",\"compromised\"]},\"version\":{\"type\":\"integer\",\"required\":false,\"default\":1},\"rotateAfter\":{\"type\":\"datetime\",\"required\":false},\"retiredAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"isActive\":{\"name\":\"isActive\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"needsRotation\":{\"name\":\"needsRotation\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isRetired\":{\"name\":\"isRetired\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"isCompromised\":{\"name\":\"isCompromised\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"canDecrypt\":{\"name\":\"canDecrypt\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"canEncrypt\":{\"name\":\"canEncrypt\",\"async\":false,\"parameters\":[],\"returnType\":\"boolean\",\"isStatic\":false,\"isPublic\":true},\"retire\":{\"name\":\"retire\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true},\"markCompromised\":{\"name\":\"markCompromised\",\"async\":false,\"parameters\":[],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"sensitive\":true,\"api\":{\"include\":[]},\"mcp\":{\"include\":[]},\"cli\":{\"include\":[\"list\",\"get\"],\"skipApiCheck\":true},\"conflictColumns\":[\"tenant_id\",\"slug\",\"context\"]},\"extends\":\"SmrtObject\",\"exportName\":\"TenantKey\",\"collectionExportName\":\"TenantKeyCollection\",\"schema\":{\"tableName\":\"tenant_keys\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"tenant_keys\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"wrapped_key\\\" TEXT DEFAULT '',\\n \\\"amk_key_id\\\" TEXT DEFAULT '',\\n \\\"status\\\" TEXT DEFAULT 'active',\\n \\\"version\\\" INTEGER DEFAULT 1,\\n \\\"rotate_after\\\" TIMESTAMP,\\n \\\"retired_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"notNull\":false,\"unique\":false},\"wrapped_key\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"amk_key_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"status\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"active\"},\"version\":{\"type\":\"INTEGER\",\"notNull\":false,\"unique\":false,\"default\":1},\"rotate_after\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false},\"retired_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"tenant_keys_tenant_id_slug_idx\",\"columns\":[\"tenant_id\",\"slug\",\"context\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"tenant_keys_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"abc3474a\"},\"importPath\":\"@happyvertical/smrt-secrets/models\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"],\"browser\":{\"status\":\"server-only\",\"issues\":[\"#3624\",\"#3627\"],\"reason\":\"@happyvertical/secrets (node:child_process, node:crypto) and sql\",\"via\":[\"@happyvertical/smrt-tenancy\"]},\"stampsConstructors\":true}"));
4
- //#endregion
5
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/decorate.js
6
- function __decorate(decorators, target, key, desc) {
7
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
- return c > 3 && r && Object.defineProperty(target, key, r), r;
11
- }
12
- //#endregion
13
- //#region src/models/SecretAuditLog.ts
14
- var SecretAuditLog = class SecretAuditLog extends SmrtObject {
15
- static __smrtPackage__ = "@happyvertical/smrt-secrets";
16
- /**
17
- * Tenant associated with the audited secret operation.
18
- */
19
- tenantId = null;
20
- /**
21
- * ID of the secret (may identify a secret that has since been deleted).
22
- *
23
- * Compliance audit rows intentionally outlive their source secret, so this
24
- * remains an app-side relationship without a physical database constraint.
25
- */
26
- secretId = null;
27
- /**
28
- * Name of the secret at the time of the operation
29
- */
30
- secretName = "";
31
- /**
32
- * ID of the user who performed the action, or `null` for system-initiated
33
- * operations with no authenticated user. Stored as a native `uuid` column on
34
- * Postgres, so a non-UUID actor sentinel must never reach it —
35
- * {@link createAuditEntry} normalizes the `'system'` sentinel to null (#1444).
36
- */
37
- userId = null;
38
- /**
39
- * The action that was performed
40
- */
41
- action = "read";
42
- /**
43
- * Result of the operation
44
- */
45
- result = "success";
46
- /**
47
- * IP address of the client (if available)
48
- */
49
- ipAddress = "";
50
- /**
51
- * User agent string (if available)
52
- */
53
- userAgent = "";
54
- /**
55
- * Additional context about the operation
56
- */
57
- details = {};
58
- constructor(options = {}) {
59
- super(options);
60
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
61
- if (options.secretId !== void 0) this.secretId = options.secretId;
62
- if (options.secretName !== void 0) this.secretName = options.secretName;
63
- if (options.userId !== void 0) this.userId = options.userId;
64
- if (options.action !== void 0) this.action = options.action;
65
- if (options.result !== void 0) this.result = options.result;
66
- if (options.ipAddress !== void 0) this.ipAddress = options.ipAddress;
67
- if (options.userAgent !== void 0) this.userAgent = options.userAgent;
68
- if (options.details !== void 0) this.details = options.details;
69
- }
70
- /**
71
- * Check if this was a successful operation
72
- */
73
- isSuccess() {
74
- return this.result === "success";
75
- }
76
- /**
77
- * Check if this was a failed operation
78
- */
79
- isFailure() {
80
- return this.result === "failure";
81
- }
82
- /**
83
- * Check if this was a denied operation (permission denied)
84
- */
85
- isDenied() {
86
- return this.result === "denied";
87
- }
88
- /**
89
- * Check if this is a read operation
90
- */
91
- isReadAction() {
92
- return this.action === "read";
93
- }
94
- /**
95
- * Check if this is a write operation (create, update, delete)
96
- */
97
- isWriteAction() {
98
- return [
99
- "create",
100
- "update",
101
- "delete"
102
- ].includes(this.action);
103
- }
104
- /**
105
- * Check if this is a key operation
106
- */
107
- isKeyOperation() {
108
- return this.action === "rotate_key";
109
- }
110
- };
111
- __decorate([foreignKey("Secret", { constraint: false })], SecretAuditLog.prototype, "secretId", void 0);
112
- __decorate([crossPackageRef("@happyvertical/smrt-users:User")], SecretAuditLog.prototype, "userId", void 0);
113
- SecretAuditLog = __decorate([smrt({
114
- tenantScoped: true,
115
- api: { include: [] },
116
- mcp: { include: [] },
117
- cli: {
118
- include: ["list"],
119
- skipApiCheck: true
120
- }
121
- })], SecretAuditLog);
122
- var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
123
- /**
124
- * Create an audit log entry for a secret operation
125
- */
126
- function createAuditEntry(params) {
127
- const tenantId = params.tenantId === void 0 || params.tenantId === "system" ? null : params.tenantId;
128
- const rawUserId = params.userId == null || params.userId === "system" || params.userId === "" ? null : params.userId;
129
- const userId = rawUserId !== null && UUID_PATTERN.test(rawUserId) ? rawUserId : null;
130
- const details = rawUserId !== null && userId === null ? {
131
- ...params.details ?? {},
132
- actorId: rawUserId
133
- } : params.details ?? {};
134
- return {
135
- secretId: params.secretId ?? null,
136
- secretName: params.secretName,
137
- userId,
138
- action: params.action,
139
- result: params.result,
140
- ipAddress: params.ipAddress ?? "",
141
- userAgent: params.userAgent ?? "",
142
- details,
143
- tenantId
144
- };
145
- }
146
- //#endregion
147
- //#region src/models/Secret.ts
148
- var Secret = class Secret extends SmrtObject {
149
- static __smrtPackage__ = "@happyvertical/smrt-secrets";
150
- /**
151
- * Tenant that owns this secret. Also stored in context for per-tenant name uniqueness.
152
- */
153
- tenantId = "";
154
- /**
155
- * Unique name for the secret within the tenant
156
- */
157
- name = "";
158
- /**
159
- * Human-readable description
160
- */
161
- description = "";
162
- /**
163
- * Category for organization (e.g., 'database', 'api-key', 'oauth')
164
- */
165
- category = "";
166
- /**
167
- * JSON-encoded EncryptedEnvelope from @happyvertical/secrets
168
- */
169
- encryptedValue = "";
170
- /**
171
- * Version of the tenant key used to encrypt this secret
172
- */
173
- keyVersion = 1;
174
- /**
175
- * Current status of the secret
176
- */
177
- status = "active";
178
- /**
179
- * Optional expiration date
180
- */
181
- expiresAt = null;
182
- /**
183
- * Last time this secret was accessed (decrypted)
184
- */
185
- lastAccessedAt = null;
186
- /**
187
- * Number of times this secret has been accessed
188
- */
189
- accessCount = 0;
190
- /**
191
- * Additional metadata stored with the secret
192
- */
193
- metadata = {};
194
- constructor(options = {}) {
195
- super(options);
196
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
197
- if (options.name !== void 0) this.name = options.name;
198
- if (options.description !== void 0) this.description = options.description;
199
- if (options.category !== void 0) this.category = options.category;
200
- if (options.encryptedValue !== void 0) this.encryptedValue = options.encryptedValue;
201
- if (options.keyVersion !== void 0) this.keyVersion = options.keyVersion;
202
- if (options.status !== void 0) this.status = options.status;
203
- if (options.expiresAt !== void 0) this.expiresAt = options.expiresAt instanceof Date ? options.expiresAt : options.expiresAt ? new Date(options.expiresAt) : null;
204
- if (options.lastAccessedAt !== void 0) this.lastAccessedAt = options.lastAccessedAt instanceof Date ? options.lastAccessedAt : options.lastAccessedAt ? new Date(options.lastAccessedAt) : null;
205
- if (options.accessCount !== void 0) this.accessCount = options.accessCount;
206
- if (options.metadata !== void 0) this.metadata = options.metadata;
207
- }
208
- /**
209
- * Check if the secret is currently active
210
- */
211
- isActive() {
212
- return this.status === "active";
213
- }
214
- /**
215
- * Check if the secret has expired
216
- */
217
- isExpired() {
218
- if (!this.expiresAt) return false;
219
- return /* @__PURE__ */ new Date() >= this.expiresAt;
220
- }
221
- /**
222
- * Check if the secret can be used (active and not expired)
223
- */
224
- isUsable() {
225
- return this.isActive() && !this.isExpired();
226
- }
227
- /**
228
- * Record an access to this secret
229
- */
230
- recordAccess() {
231
- this.lastAccessedAt = /* @__PURE__ */ new Date();
232
- this.accessCount += 1;
233
- }
234
- /**
235
- * Disable the secret
236
- */
237
- disable() {
238
- this.status = "disabled";
239
- }
240
- /**
241
- * Enable the secret
242
- */
243
- enable() {
244
- this.status = "active";
245
- }
246
- };
247
- Secret = __decorate([smrt({
248
- sensitive: true,
249
- tenantScoped: true,
250
- api: { include: [] },
251
- mcp: { include: [] },
252
- cli: {
253
- include: ["list"],
254
- skipApiCheck: true
255
- }
256
- })], Secret);
257
- //#endregion
258
- //#region src/models/TenantKey.ts
259
- var TenantKey = class TenantKey extends SmrtObject {
260
- static __smrtPackage__ = "@happyvertical/smrt-secrets";
261
- /**
262
- * Tenant ID this key belongs to. Not tenant-scoped (see above), but the value
263
- * is a tenant id: uuid on Postgres, like every other tenant_id column.
264
- */
265
- tenantId = "";
266
- /**
267
- * Wrapped key data (format: wrappedKey:iv:authTag)
268
- */
269
- wrappedKey = "";
270
- /**
271
- * ID of the AMK used to wrap this key
272
- */
273
- amkKeyId = "";
274
- /**
275
- * Current status of the key
276
- */
277
- status = "active";
278
- /**
279
- * Version number (increments on rotation)
280
- */
281
- version = 1;
282
- /**
283
- * Recommended rotation date
284
- */
285
- rotateAfter = null;
286
- /**
287
- * When the key was retired (if applicable)
288
- */
289
- retiredAt = null;
290
- constructor(options = {}) {
291
- super(options);
292
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
293
- if (options.wrappedKey !== void 0) this.wrappedKey = options.wrappedKey;
294
- if (options.amkKeyId !== void 0) this.amkKeyId = options.amkKeyId;
295
- if (options.status !== void 0) this.status = options.status;
296
- if (options.version !== void 0) this.version = options.version;
297
- if (options.rotateAfter !== void 0) this.rotateAfter = options.rotateAfter instanceof Date ? options.rotateAfter : options.rotateAfter ? new Date(options.rotateAfter) : null;
298
- if (options.retiredAt !== void 0) this.retiredAt = options.retiredAt instanceof Date ? options.retiredAt : options.retiredAt ? new Date(options.retiredAt) : null;
299
- }
300
- /**
301
- * Check if this key is currently active
302
- */
303
- isActive() {
304
- return this.status === "active";
305
- }
306
- /**
307
- * Check if this key needs rotation
308
- */
309
- needsRotation() {
310
- if (!this.rotateAfter) return false;
311
- return /* @__PURE__ */ new Date() >= this.rotateAfter;
312
- }
313
- /**
314
- * Check if this key is retired
315
- */
316
- isRetired() {
317
- return this.status === "retired";
318
- }
319
- /**
320
- * Check if this key is compromised
321
- */
322
- isCompromised() {
323
- return this.status === "compromised";
324
- }
325
- /**
326
- * Check if this key can be used for decryption
327
- * (active or retired keys can decrypt)
328
- */
329
- canDecrypt() {
330
- return this.status === "active" || this.status === "retired";
331
- }
332
- /**
333
- * Check if this key can be used for encryption
334
- * (only active keys should encrypt)
335
- */
336
- canEncrypt() {
337
- return this.status === "active";
338
- }
339
- /**
340
- * Mark this key as retired
341
- */
342
- retire() {
343
- this.status = "retired";
344
- this.retiredAt = /* @__PURE__ */ new Date();
345
- }
346
- /**
347
- * Mark this key as compromised
348
- */
349
- markCompromised() {
350
- this.status = "compromised";
351
- }
352
- };
353
- __decorate([field({ sqlType: "UUID" })], TenantKey.prototype, "tenantId", void 0);
354
- TenantKey = __decorate([smrt({
355
- sensitive: true,
356
- api: { include: [] },
357
- mcp: { include: [] },
358
- cli: {
359
- include: ["list", "get"],
360
- skipApiCheck: true
361
- }
362
- })], TenantKey);
363
- //#endregion
364
- export { createAuditEntry as i, Secret as n, SecretAuditLog as r, TenantKey as t };
365
-
366
- //# sourceMappingURL=TenantKey-SHnwEIV8.js.map