@objectstack/core 15.0.0 → 15.1.0

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.
package/dist/index.d.cts CHANGED
@@ -1924,6 +1924,40 @@ declare function isAuthGateAllowlisted(rawPath: string | undefined | null): bool
1924
1924
  */
1925
1925
  declare function evaluateAuthGate(sessionUser: any, path: string): AuthGate | null;
1926
1926
 
1927
+ /** HTTP status every seam returns for an anonymous-denied request. */
1928
+ declare const ANONYMOUS_DENY_STATUS: 401;
1929
+ /** Stable machine code (mirrors the REST `enforceAuth` seam). */
1930
+ declare const ANONYMOUS_DENY_CODE: "unauthenticated";
1931
+ /** Human-facing message. */
1932
+ declare const ANONYMOUS_DENY_MESSAGE = "Authentication is required to access this endpoint.";
1933
+ /** The single 401 body shape every seam returns: `{ error, message }`. */
1934
+ declare const ANONYMOUS_DENY_BODY: {
1935
+ readonly error: "unauthenticated";
1936
+ readonly message: "Authentication is required to access this endpoint.";
1937
+ };
1938
+ interface AnonymousDenyInput {
1939
+ /** The `requireAuth` posture. Falsy ⇒ no-op (demo / single-tenant). */
1940
+ requireAuth: boolean | undefined;
1941
+ /** Resolved caller id, if any. */
1942
+ userId?: string | null;
1943
+ /** Internal system context (never set on inbound HTTP; cannot be forged). */
1944
+ isSystem?: boolean;
1945
+ /** HTTP method — `OPTIONS` (CORS preflight) always passes. */
1946
+ method?: string | null;
1947
+ /**
1948
+ * OPTIONAL request path. When a NON-EMPTY string, a control-plane path
1949
+ * (auth / health / ready / discovery — see {@link isAuthGateAllowlisted}) is
1950
+ * exempt. Body-routed seams (GraphQL) have no meaningful path and pass
1951
+ * `undefined`; see the guard below for why that is load-bearing.
1952
+ */
1953
+ path?: string | null;
1954
+ }
1955
+ /**
1956
+ * True when the request MUST be rejected with 401. The one decision every HTTP
1957
+ * seam shares.
1958
+ */
1959
+ declare function shouldDenyAnonymous(input: AnonymousDenyInput): boolean;
1960
+
1927
1961
  /** The validity-window shape shared by both user-grant tables (ADR-0091 D1). */
1928
1962
  interface GrantValidityWindow {
1929
1963
  valid_from?: unknown;
@@ -2510,4 +2544,4 @@ declare class NamespaceResolver {
2510
2544
  private suggestAlternative;
2511
2545
  }
2512
2546
 
2513
- export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, type AuthGate, type BulkWriteOptions, type BulkWriteRowResult, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, type GrantValidityWindow, HotReloadManager, type KernelState, type KeyInput, type LadderPrincipal, type LadderRow, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, POSTURE_INJECTION_RULE, POSTURE_LADDER, POSTURE_RANK, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PostureEvidence, type PublisherVerifyResult, index as QA, type ResolveAuthzInput, type ResolveLocalizationInput, type ResolvedAuthzContext, type ResourceUsage, type RetryOptions, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, bulkWrite, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, deepMerge, defaultIsTransientError, derivePosture, evaluateAuthGate, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isAuthGateAllowlisted, isExpired, isGrantActive, isGrantExpired, isNode, parseScopes, parseSignature, postureVisibleRows, readAuthoredTranslationLayer, resolveApiKeyPrincipal, resolveAuthzContext, resolveLocale, resolveLocalizationContext, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature, wireAuthoredTranslationSync, withTransientRetry };
2547
+ export { ANONYMOUS_DENY_BODY, ANONYMOUS_DENY_CODE, ANONYMOUS_DENY_MESSAGE, ANONYMOUS_DENY_STATUS, API_KEY_PREFIX, type AnonymousDenyInput, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, type AuthGate, type BulkWriteOptions, type BulkWriteRowResult, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, type GrantValidityWindow, HotReloadManager, type KernelState, type KeyInput, type LadderPrincipal, type LadderRow, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, POSTURE_INJECTION_RULE, POSTURE_LADDER, POSTURE_RANK, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PostureEvidence, type PublisherVerifyResult, index as QA, type ResolveAuthzInput, type ResolveLocalizationInput, type ResolvedAuthzContext, type ResourceUsage, type RetryOptions, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, bulkWrite, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, deepMerge, defaultIsTransientError, derivePosture, evaluateAuthGate, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isAuthGateAllowlisted, isExpired, isGrantActive, isGrantExpired, isNode, parseScopes, parseSignature, postureVisibleRows, readAuthoredTranslationLayer, resolveApiKeyPrincipal, resolveAuthzContext, resolveLocale, resolveLocalizationContext, safeExit, shouldDenyAnonymous, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature, wireAuthoredTranslationSync, withTransientRetry };
package/dist/index.d.ts CHANGED
@@ -1924,6 +1924,40 @@ declare function isAuthGateAllowlisted(rawPath: string | undefined | null): bool
1924
1924
  */
1925
1925
  declare function evaluateAuthGate(sessionUser: any, path: string): AuthGate | null;
1926
1926
 
1927
+ /** HTTP status every seam returns for an anonymous-denied request. */
1928
+ declare const ANONYMOUS_DENY_STATUS: 401;
1929
+ /** Stable machine code (mirrors the REST `enforceAuth` seam). */
1930
+ declare const ANONYMOUS_DENY_CODE: "unauthenticated";
1931
+ /** Human-facing message. */
1932
+ declare const ANONYMOUS_DENY_MESSAGE = "Authentication is required to access this endpoint.";
1933
+ /** The single 401 body shape every seam returns: `{ error, message }`. */
1934
+ declare const ANONYMOUS_DENY_BODY: {
1935
+ readonly error: "unauthenticated";
1936
+ readonly message: "Authentication is required to access this endpoint.";
1937
+ };
1938
+ interface AnonymousDenyInput {
1939
+ /** The `requireAuth` posture. Falsy ⇒ no-op (demo / single-tenant). */
1940
+ requireAuth: boolean | undefined;
1941
+ /** Resolved caller id, if any. */
1942
+ userId?: string | null;
1943
+ /** Internal system context (never set on inbound HTTP; cannot be forged). */
1944
+ isSystem?: boolean;
1945
+ /** HTTP method — `OPTIONS` (CORS preflight) always passes. */
1946
+ method?: string | null;
1947
+ /**
1948
+ * OPTIONAL request path. When a NON-EMPTY string, a control-plane path
1949
+ * (auth / health / ready / discovery — see {@link isAuthGateAllowlisted}) is
1950
+ * exempt. Body-routed seams (GraphQL) have no meaningful path and pass
1951
+ * `undefined`; see the guard below for why that is load-bearing.
1952
+ */
1953
+ path?: string | null;
1954
+ }
1955
+ /**
1956
+ * True when the request MUST be rejected with 401. The one decision every HTTP
1957
+ * seam shares.
1958
+ */
1959
+ declare function shouldDenyAnonymous(input: AnonymousDenyInput): boolean;
1960
+
1927
1961
  /** The validity-window shape shared by both user-grant tables (ADR-0091 D1). */
1928
1962
  interface GrantValidityWindow {
1929
1963
  valid_from?: unknown;
@@ -2510,4 +2544,4 @@ declare class NamespaceResolver {
2510
2544
  private suggestAlternative;
2511
2545
  }
2512
2546
 
2513
- export { API_KEY_PREFIX, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, type AuthGate, type BulkWriteOptions, type BulkWriteRowResult, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, type GrantValidityWindow, HotReloadManager, type KernelState, type KeyInput, type LadderPrincipal, type LadderRow, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, POSTURE_INJECTION_RULE, POSTURE_LADDER, POSTURE_RANK, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PostureEvidence, type PublisherVerifyResult, index as QA, type ResolveAuthzInput, type ResolveLocalizationInput, type ResolvedAuthzContext, type ResourceUsage, type RetryOptions, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, bulkWrite, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, deepMerge, defaultIsTransientError, derivePosture, evaluateAuthGate, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isAuthGateAllowlisted, isExpired, isGrantActive, isGrantExpired, isNode, parseScopes, parseSignature, postureVisibleRows, readAuthoredTranslationLayer, resolveApiKeyPrincipal, resolveAuthzContext, resolveLocale, resolveLocalizationContext, safeExit, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature, wireAuthoredTranslationSync, withTransientRetry };
2547
+ export { ANONYMOUS_DENY_BODY, ANONYMOUS_DENY_CODE, ANONYMOUS_DENY_MESSAGE, ANONYMOUS_DENY_STATUS, API_KEY_PREFIX, type AnonymousDenyInput, type ApiKeyPrincipal, ApiRegistry, type ApiRegistryPluginConfig, type AuthGate, type BulkWriteOptions, type BulkWriteRowResult, CORE_FALLBACK_FACTORIES, type CalendarParts, DependencyResolver, type GeneratedApiKey, type GrantValidityWindow, HotReloadManager, type KernelState, type KeyInput, type LadderPrincipal, type LadderRow, LiteKernel, type NamespaceCheckResult, type NamespaceConflict, type NamespaceEntry, NamespaceResolver, ObjectKernel, ObjectKernelBase, type ObjectKernelConfig, ObjectLogger, POSTURE_INJECTION_RULE, POSTURE_LADDER, POSTURE_RANK, type ParsedSignature, type PermissionCheckResult$1 as PermissionCheckResult, type PermissionGrant, type Plugin, type PluginArtifactVerifyResult, PluginConfigValidator, type PluginContext, PluginHealthMonitor, type PluginHealthStatus, type PluginLoadResult, PluginLoader, type PluginMetadata, type PermissionCheckResult as PluginPermissionCheckResult, PluginPermissionEnforcer, PluginPermissionManager, type PluginPermissions, PluginSandboxRuntime, PluginSecurityScanner, type PluginSignatureConfig, PluginSignatureVerifier, type PluginStartupResult, type PostureEvidence, type PublisherVerifyResult, index as QA, type ResolveAuthzInput, type ResolveLocalizationInput, type ResolvedAuthzContext, type ResourceUsage, type RetryOptions, SIGNATURE_ALG, type SandboxContext, type ScanTarget, SecurePluginContext, type SecurityIssue, SemanticVersionManager, type ServiceFactory, ServiceLifecycle, type ServiceRegistration, type SignatureVerificationResult, type VersionCompatibility, buildPermissionsFromGrants, bulkWrite, calendarPartsInTz, calendarPartsInTzOrUtc, counterSignPayload, createApiRegistryPlugin, createMemoryCache, createMemoryI18n, createMemoryJob, createMemoryMetadata, createMemoryQueue, createPluginConfigValidator, createPluginPermissionEnforcer, deepMerge, defaultIsTransientError, derivePosture, evaluateAuthGate, extractApiKey, generateApiKey, generateEd25519KeyPair, getEnv, getMemoryUsage, hashApiKey, isAuthGateAllowlisted, isExpired, isGrantActive, isGrantExpired, isNode, parseScopes, parseSignature, postureVisibleRows, readAuthoredTranslationLayer, resolveApiKeyPrincipal, resolveAuthzContext, resolveLocale, resolveLocalizationContext, safeExit, shouldDenyAnonymous, signPayload, verifyPayload, verifyPlatformSignature, verifyPluginArtifact, verifyPublisherSignature, wireAuthoredTranslationSync, withTransientRetry };
package/dist/index.js CHANGED
@@ -1554,6 +1554,8 @@ var ObjectKernel = class {
1554
1554
  this.validateSystemRequirements();
1555
1555
  this.logger.debug("Triggering kernel:ready hook");
1556
1556
  await this.context.trigger("kernel:ready");
1557
+ this.logger.debug("Triggering kernel:bootstrapped hook");
1558
+ await this.context.trigger("kernel:bootstrapped");
1557
1559
  this.logger.debug("Triggering kernel:listening hook");
1558
1560
  await this.context.trigger("kernel:listening");
1559
1561
  this.logger.info("\u2705 Bootstrap complete");
@@ -1837,6 +1839,7 @@ var LiteKernel = class extends ObjectKernelBase {
1837
1839
  await this.runPluginStart(plugin);
1838
1840
  }
1839
1841
  await this.triggerHook("kernel:ready");
1842
+ await this.triggerHook("kernel:bootstrapped");
1840
1843
  await this.triggerHook("kernel:listening");
1841
1844
  this.logger.info("\u2705 Bootstrap complete", {
1842
1845
  pluginCount: this.plugins.size
@@ -4456,6 +4459,26 @@ function evaluateAuthGate(sessionUser, path) {
4456
4459
  };
4457
4460
  }
4458
4461
 
4462
+ // src/security/anonymous-deny.ts
4463
+ var ANONYMOUS_DENY_STATUS = 401;
4464
+ var ANONYMOUS_DENY_CODE = "unauthenticated";
4465
+ var ANONYMOUS_DENY_MESSAGE = "Authentication is required to access this endpoint.";
4466
+ var ANONYMOUS_DENY_BODY = {
4467
+ error: ANONYMOUS_DENY_CODE,
4468
+ message: ANONYMOUS_DENY_MESSAGE
4469
+ };
4470
+ function shouldDenyAnonymous(input) {
4471
+ if (!input.requireAuth) return false;
4472
+ if (typeof input.method === "string" && input.method.toUpperCase() === "OPTIONS") {
4473
+ return false;
4474
+ }
4475
+ if (input.userId || input.isSystem) return false;
4476
+ if (typeof input.path === "string" && input.path.length > 0 && isAuthGateAllowlisted(input.path)) {
4477
+ return false;
4478
+ }
4479
+ return true;
4480
+ }
4481
+
4459
4482
  // src/utils/datetime.ts
4460
4483
  function calendarPartsInTz(d, tz) {
4461
4484
  const parts = new Intl.DateTimeFormat("en-US", {
@@ -5476,6 +5499,10 @@ var NamespaceResolver = class {
5476
5499
  }
5477
5500
  };
5478
5501
  export {
5502
+ ANONYMOUS_DENY_BODY,
5503
+ ANONYMOUS_DENY_CODE,
5504
+ ANONYMOUS_DENY_MESSAGE,
5505
+ ANONYMOUS_DENY_STATUS,
5479
5506
  API_KEY_PREFIX,
5480
5507
  ApiRegistry,
5481
5508
  CORE_FALLBACK_FACTORIES,
@@ -5540,6 +5567,7 @@ export {
5540
5567
  resolveLocale,
5541
5568
  resolveLocalizationContext,
5542
5569
  safeExit,
5570
+ shouldDenyAnonymous,
5543
5571
  signPayload,
5544
5572
  verifyPayload,
5545
5573
  verifyPlatformSignature,