@noy-db/hub 0.1.0-pre.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.
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/aggregate/index.cjs +476 -0
- package/dist/aggregate/index.cjs.map +1 -0
- package/dist/aggregate/index.d.cts +38 -0
- package/dist/aggregate/index.d.ts +38 -0
- package/dist/aggregate/index.js +53 -0
- package/dist/aggregate/index.js.map +1 -0
- package/dist/blobs/index.cjs +1480 -0
- package/dist/blobs/index.cjs.map +1 -0
- package/dist/blobs/index.d.cts +45 -0
- package/dist/blobs/index.d.ts +45 -0
- package/dist/blobs/index.js +48 -0
- package/dist/blobs/index.js.map +1 -0
- package/dist/bundle/index.cjs +496 -0
- package/dist/bundle/index.cjs.map +1 -0
- package/dist/bundle/index.d.cts +7 -0
- package/dist/bundle/index.d.ts +7 -0
- package/dist/bundle/index.js +51 -0
- package/dist/bundle/index.js.map +1 -0
- package/dist/chunk-2QR2PQTT.js +217 -0
- package/dist/chunk-2QR2PQTT.js.map +1 -0
- package/dist/chunk-72UIIX3E.js +1109 -0
- package/dist/chunk-72UIIX3E.js.map +1 -0
- package/dist/chunk-A4NFZKRW.js +722 -0
- package/dist/chunk-A4NFZKRW.js.map +1 -0
- package/dist/chunk-AOYCZP2H.js +793 -0
- package/dist/chunk-AOYCZP2H.js.map +1 -0
- package/dist/chunk-CIMZBAZB.js +72 -0
- package/dist/chunk-CIMZBAZB.js.map +1 -0
- package/dist/chunk-E3AGCGJ4.js +160 -0
- package/dist/chunk-E3AGCGJ4.js.map +1 -0
- package/dist/chunk-EKX3YVCI.js +97 -0
- package/dist/chunk-EKX3YVCI.js.map +1 -0
- package/dist/chunk-EMIGCR7X.js +39 -0
- package/dist/chunk-EMIGCR7X.js.map +1 -0
- package/dist/chunk-EMMRIE3C.js +72 -0
- package/dist/chunk-EMMRIE3C.js.map +1 -0
- package/dist/chunk-EUNIORPU.js +680 -0
- package/dist/chunk-EUNIORPU.js.map +1 -0
- package/dist/chunk-FZU343FL.js +32 -0
- package/dist/chunk-FZU343FL.js.map +1 -0
- package/dist/chunk-GHGXG53C.js +795 -0
- package/dist/chunk-GHGXG53C.js.map +1 -0
- package/dist/chunk-GKA4BGJN.js +79 -0
- package/dist/chunk-GKA4BGJN.js.map +1 -0
- package/dist/chunk-HG2OWBLX.js +430 -0
- package/dist/chunk-HG2OWBLX.js.map +1 -0
- package/dist/chunk-IGAROPKM.js +34 -0
- package/dist/chunk-IGAROPKM.js.map +1 -0
- package/dist/chunk-J66GRPNH.js +111 -0
- package/dist/chunk-J66GRPNH.js.map +1 -0
- package/dist/chunk-LVMMDXFT.js +275 -0
- package/dist/chunk-LVMMDXFT.js.map +1 -0
- package/dist/chunk-M5INGEFC.js +84 -0
- package/dist/chunk-M5INGEFC.js.map +1 -0
- package/dist/chunk-NBYQNDXA.js +557 -0
- package/dist/chunk-NBYQNDXA.js.map +1 -0
- package/dist/chunk-NPC4LFV5.js +132 -0
- package/dist/chunk-NPC4LFV5.js.map +1 -0
- package/dist/chunk-NSWHB5VQ.js +1285 -0
- package/dist/chunk-NSWHB5VQ.js.map +1 -0
- package/dist/chunk-OLM4LA6K.js +392 -0
- package/dist/chunk-OLM4LA6K.js.map +1 -0
- package/dist/chunk-UAFBZWFB.js +155 -0
- package/dist/chunk-UAFBZWFB.js.map +1 -0
- package/dist/chunk-UF3BUNQZ.js +1 -0
- package/dist/chunk-UF3BUNQZ.js.map +1 -0
- package/dist/chunk-UMMAVAYW.js +17 -0
- package/dist/chunk-UMMAVAYW.js.map +1 -0
- package/dist/chunk-UPY7WLBH.js +381 -0
- package/dist/chunk-UPY7WLBH.js.map +1 -0
- package/dist/chunk-W63BWEJH.js +311 -0
- package/dist/chunk-W63BWEJH.js.map +1 -0
- package/dist/chunk-WIGI5OJK.js +90 -0
- package/dist/chunk-WIGI5OJK.js.map +1 -0
- package/dist/chunk-XNL2TKKR.js +490 -0
- package/dist/chunk-XNL2TKKR.js.map +1 -0
- package/dist/chunk-XWNUJPIS.js +367 -0
- package/dist/chunk-XWNUJPIS.js.map +1 -0
- package/dist/chunk-YWKJZZGV.js +715 -0
- package/dist/chunk-YWKJZZGV.js.map +1 -0
- package/dist/consent/index.cjs +204 -0
- package/dist/consent/index.cjs.map +1 -0
- package/dist/consent/index.d.cts +24 -0
- package/dist/consent/index.d.ts +24 -0
- package/dist/consent/index.js +23 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/crdt/index.cjs +152 -0
- package/dist/crdt/index.cjs.map +1 -0
- package/dist/crdt/index.d.cts +30 -0
- package/dist/crdt/index.d.ts +30 -0
- package/dist/crdt/index.js +24 -0
- package/dist/crdt/index.js.map +1 -0
- package/dist/crypto-6PNIHP7W.js +44 -0
- package/dist/crypto-6PNIHP7W.js.map +1 -0
- package/dist/delegation-WVIVMF73.js +17 -0
- package/dist/delegation-WVIVMF73.js.map +1 -0
- package/dist/dev-unlock-D4xB0_gs.d.cts +263 -0
- package/dist/dev-unlock-Dz8GEbd3.d.ts +263 -0
- package/dist/hash--EflSV65.d.cts +63 -0
- package/dist/hash-CRdXYnv3.d.ts +63 -0
- package/dist/history/index.cjs +1215 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +62 -0
- package/dist/history/index.d.ts +62 -0
- package/dist/history/index.js +79 -0
- package/dist/history/index.js.map +1 -0
- package/dist/i18n/index.cjs +840 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +38 -0
- package/dist/i18n/index.d.ts +38 -0
- package/dist/i18n/index.js +68 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-CD1VnONm.d.cts +415 -0
- package/dist/index-CLRxPs-W.d.cts +1960 -0
- package/dist/index-CUi9wfss.d.ts +415 -0
- package/dist/index-DtV93TMP.d.ts +1960 -0
- package/dist/index.cjs +17387 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +565 -0
- package/dist/index.d.ts +565 -0
- package/dist/index.js +7525 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/index.cjs +736 -0
- package/dist/indexing/index.cjs.map +1 -0
- package/dist/indexing/index.d.cts +36 -0
- package/dist/indexing/index.d.ts +36 -0
- package/dist/indexing/index.js +77 -0
- package/dist/indexing/index.js.map +1 -0
- package/dist/lazy-builder-BwEoBQZ9.d.ts +304 -0
- package/dist/lazy-builder-CZVLKh0Z.d.cts +304 -0
- package/dist/ledger-HBBH2NPZ.js +33 -0
- package/dist/ledger-HBBH2NPZ.js.map +1 -0
- package/dist/mime-magic-CBBSOkjm.d.cts +50 -0
- package/dist/mime-magic-CBBSOkjm.d.ts +50 -0
- package/dist/periods/index.cjs +1035 -0
- package/dist/periods/index.cjs.map +1 -0
- package/dist/periods/index.d.cts +21 -0
- package/dist/periods/index.d.ts +21 -0
- package/dist/periods/index.js +25 -0
- package/dist/periods/index.js.map +1 -0
- package/dist/predicate-SBHmi6D0.d.cts +161 -0
- package/dist/predicate-SBHmi6D0.d.ts +161 -0
- package/dist/public-envelope-TLQA6REO.js +31 -0
- package/dist/public-envelope-TLQA6REO.js.map +1 -0
- package/dist/query/index.cjs +1999 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/index.d.cts +3 -0
- package/dist/query/index.d.ts +3 -0
- package/dist/query/index.js +73 -0
- package/dist/query/index.js.map +1 -0
- package/dist/session/index.cjs +495 -0
- package/dist/session/index.cjs.map +1 -0
- package/dist/session/index.d.cts +45 -0
- package/dist/session/index.d.ts +45 -0
- package/dist/session/index.js +51 -0
- package/dist/session/index.js.map +1 -0
- package/dist/shadow/index.cjs +133 -0
- package/dist/shadow/index.cjs.map +1 -0
- package/dist/shadow/index.d.cts +16 -0
- package/dist/shadow/index.d.ts +16 -0
- package/dist/shadow/index.js +20 -0
- package/dist/shadow/index.js.map +1 -0
- package/dist/store/index.cjs +1083 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +491 -0
- package/dist/store/index.d.ts +491 -0
- package/dist/store/index.js +37 -0
- package/dist/store/index.js.map +1 -0
- package/dist/strategy-BSxFXGzb.d.cts +110 -0
- package/dist/strategy-BSxFXGzb.d.ts +110 -0
- package/dist/strategy-D-SrOLCl.d.cts +548 -0
- package/dist/strategy-D-SrOLCl.d.ts +548 -0
- package/dist/sync/index.cjs +1062 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +42 -0
- package/dist/sync/index.d.ts +42 -0
- package/dist/sync/index.js +28 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/team/index.cjs +2606 -0
- package/dist/team/index.cjs.map +1 -0
- package/dist/team/index.d.cts +117 -0
- package/dist/team/index.d.ts +117 -0
- package/dist/team/index.js +106 -0
- package/dist/team/index.js.map +1 -0
- package/dist/tx/index.cjs +212 -0
- package/dist/tx/index.cjs.map +1 -0
- package/dist/tx/index.d.cts +20 -0
- package/dist/tx/index.d.ts +20 -0
- package/dist/tx/index.js +20 -0
- package/dist/tx/index.js.map +1 -0
- package/dist/types-DSFLtbKg.d.ts +9702 -0
- package/dist/types-zwwMOqkg.d.cts +9702 -0
- package/dist/ulid-COREQ2RQ.js +9 -0
- package/dist/ulid-COREQ2RQ.js.map +1 -0
- package/dist/util/index.cjs +230 -0
- package/dist/util/index.cjs.map +1 -0
- package/dist/util/index.d.cts +77 -0
- package/dist/util/index.d.ts +77 -0
- package/dist/util/index.js +190 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +244 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { at as NoydbStore, aR as UserEnvelope, aS as PublicEnvelope, aT as GateName, aU as GatePolicy, aV as VaultPolicy, aW as ActiveTier, aX as FactorProof, ar as UnlockedKeyring, aY as Vault, aA as DiffEntry } from './types-zwwMOqkg.cjs';
|
|
2
|
+
export { aZ as AccessibleVault, ax as AppendInput, p as BLOB_CHUNKS_COLLECTION, q as BLOB_COLLECTION, t as BLOB_INDEX_COLLECTION, u as BLOB_SLOTS_PREFIX, w as BLOB_VERSIONS_PREFIX, a_ as BUNDLE_STORE_POLICY, A as BlobObject, C as BlobPutOptions, E as BlobResponseOptions, F as BlobSet, a$ as BuiltInGateName, b0 as BundleRecipient, _ as CONSENT_AUDIT_COLLECTION, b1 as CacheOptions, b2 as CacheStats, b3 as ChangeEvent, ay as ChangeType, a7 as ClosePeriodOptions, b4 as Collection, b5 as CollectionChangeEvent, b6 as CollectionConflictResolver, ai as CollectionFrame, az as CollectionInstant, b7 as Conflict, b8 as ConflictPolicy, b9 as ConflictStrategy, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, ba as CrossTierAccessEvent, L as DEFAULT_CHUNK_SIZE, bb as DEFAULT_PUBLIC_ENVELOPE_SCHEMA, bc as DELEGATIONS_COLLECTION, D as DICT_COLLECTION_PREFIX, bd as DeepPartial, be as DeepPartialOrNull, bf as DelegationToken, bg as DeleteManyResult, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, bh as DirtyEntry, bi as ELEVATION_AUDIT_COLLECTION, bj as ElevatedHandle, av as EncryptedEnvelope, bk as EnrollAuthenticatorOptions, bl as EnrollAuthenticatorWrappingDEKsOptions, bm as EnrollAuthenticatorWrappingKEKOptions, bn as ExportCapability, bo as ExportChunk, bp as ExportFormat, bq as ExportStreamOptions, br as FactorKind, bs as FactorProofBundle, bt as FactorRequirement, bu as GhostRecord, bv as GrantOptions, bw as HistoryConfig, bx as HistoryEntry, au as HistoryOptions, e as I18nTextDescriptor, f as I18nTextOptions, by as INDEXED_STORE_POLICY, bz as ImportCapability, bA as InferOutput, bB as IssueDelegationOptions, bC as IssueMagicLinkGrantOptions, aB as JsonPatch, aC as JsonPatchOp, bD as KeyringAuthenticator, bE as KeyringAuthenticatorWrappingDEKs, bF as KeyringAuthenticatorWrappingKEK, bG as KeyringFile, aD as LedgerEntry, aE as LedgerStore, bH as ListAccessibleVaultsOptions, bI as ListPageResult, bJ as LiveUserEnvelope, bK as LocaleReadOptions, bL as Lru, bM as LruOptions, bN as LruStats, bO as MAGIC_LINK_CONTENT_INFO_PREFIX, bP as MAGIC_LINK_GRANTS_COLLECTION, bQ as MAGIC_LINK_KEK_INFO_PREFIX, bR as MagicLinkGrantPayload, bS as MagicLinkGrantRecord, bT as NOYDB_BACKUP_VERSION, bU as NOYDB_FORMAT_VERSION, bV as NOYDB_KEYRING_VERSION, bW as NOYDB_SYNC_VERSION, bX as Noydb, bY as NoydbBundleStore, bZ as NoydbEventMap, b_ as NoydbOptions, a8 as OpenPeriodOptions, a9 as PERIODS_COLLECTION, b$ as PUBLIC_ENVELOPE_FIELDS, c0 as PaperRecoveryDoc, c1 as PaperRecoveryEntry, c2 as PassphrasePolicy, c3 as PassphraseValidationResult, aa as PeriodRecord, c4 as Permission, c5 as Permissions, c6 as PlaintextTranslatorContext, c7 as PlaintextTranslatorFn, P as PolicyEnforcer, c8 as PresenceHandle, c9 as PresencePeer, aw as PruneOptions, ca as PublicEnvelopeField, cb as PublicEnvelopeSchema, cc as PublicEnvelopeText, cd as PullMode, ce as PullOptions, cf as PullPolicy, cg as PullResult, ch as PushMode, ci as PushOptions, cj as PushPolicy, ck as PushResult, cl as PutManyItemOptions, cm as PutManyOptions, cn as PutManyResult, co as QueryAcrossOptions, cp as QueryAcrossResult, cq as QuickUnlockState, cr as QuickUnlockStore, cs as ReAuthOperation, ct as RecoverPassphraseInput, cu as RecoverPassphraseResult, cv as RecoverUserOptions, cw as RecoveryProof, cx as ResolvedPublicEnvelopeSchema, cy as RevokeOptions, aq as Role, cz as RotatePassphraseInput, cA as SessionPolicy, cB as SetPublicEnvelopeInput, U as SlotInfo, V as SlotRecord, cC as SlotRewrapCeremony, cD as SlotRewrapContext, cE as StandardSchemaV1, cF as StandardSchemaV1Issue, cG as StandardSchemaV1SyncResult, cH as StoreAuth, cI as StoreAuthKind, cJ as StoreCapabilities, cK as SyncEngine, cL as SyncMetadata, cM as SyncPolicy, cN as SyncScheduler, cO as SyncSchedulerStatus, cP as SyncStatus, cQ as SyncTarget, cR as SyncTargetRole, cS as SyncTransaction, cT as SyncTransactionResult, cU as TierMode, cV as TranslatorAuditEntry, al as TxCollection, am as TxContext, cW as TxOp, an as TxVault, cX as USER_ENVELOPE_COLLECTION, cY as USER_ENVELOPE_MAX_BYTES, cZ as Unsubscribe, c_ as UpdateAuthenticatorOptions, c$ as UpdateUserOptions, d0 as UserApi, d1 as UserEnvelopeCheckGate, d2 as UserEnvelopeOversizedError, d3 as UserEnvelopePresented, d4 as UserInfo, d5 as VaultBackup, aF as VaultEngine, aj as VaultFrame, aG as VaultInstant, d6 as VaultPolicyOnDisk, d7 as VaultSnapshot, aH as VerifyResult, W as VersionRecord, d8 as WarningRules, d9 as WeakPassphraseError, da as WeakPassphraseReason, db as WrappedDeksBlob, g as applyI18nLocale, aI as applyPatch, dc as assertStrongPassphrase, dd as buildRecipientKeyringFile, de as burnPaperRecoveryEntry, aJ as canonicalJson, aK as computePatch, n as createEnforcer, df as createNoydb, dg as createStore, dh as deriveMagicLinkContentKey, h as dictCollectionName, i as dictKey, aL as diff, di as enrollAuthenticator, dj as estimateEntropy, dk as evaluateExportCapability, dl as evaluateImportCapability, dm as findAuthenticator, aM as formatDiff, dn as hasExportCapability, dp as hasImportCapability, dq as hasRecoveryEnrolled, aN as hashEntry, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, dr as isMagicLinkGrantExpired, ds as isPublicEnvelope, dt as issueDelegation, du as keyringRecoverPassphrase, dv as keyringRotatePassphrase, dw as listMagicLinkGrants, dx as listUsers, dy as listUsersWithEnvelopes, dz as loadActiveDelegations, dA as loadPaperRecoveryEntries, dB as magicLinkGrantRecordId, dC as mintPaperRecoveryEntry, dD as mintWrappedDeksBlob, aO as paddedIndex, aP as parseIndex, dE as readMagicLinkGrantRecord, dF as recoverUser, dG as removeAuthenticator, r as resolveI18nText, dH as resolvePublicEnvelopeSchema, dI as revokeDelegation, dJ as revokeMagicLinkGrant, ao as runTransaction, dK as savePaperRecoveryEntries, aQ as sha256Hex, dL as unwrapDeksFromBlob, dM as unwrapDeksFromPaperEntry, dN as unwrapMagicLinkGrant, v as validateI18nTextValue, dO as validatePassphrase, dP as validatePublicEnvelopeInput, dQ as validateSchemaInput, dR as validateSchemaOutput, o as validateSessionPolicy, dS as writeMagicLinkGrant } from './types-zwwMOqkg.cjs';
|
|
3
|
+
export { d as detectMagic, a as detectMimeType, i as isPreCompressed } from './mime-magic-CBBSOkjm.cjs';
|
|
4
|
+
export { AgeRoute, BlobLifecyclePolicy, BlobStoreRoute, CircuitBreakerOptions, HealthCheckOptions, LogLevel, LoggingOptions, MetricsOptions, OverrideOptions, OverrideTarget, RetryOptions, RouteStatus, RouteStoreOptions, RoutedNoydbStore, StoreCacheOptions, StoreMiddleware, StoreOperation, SuspendOptions, WrapBundleStoreOptions, WrappedBundleNoydbStore, createBundleStore, routeStore, withCache, withCircuitBreaker, withHealthCheck, withLogging, withMetrics, withRetry, wrapBundleStore, wrapStore } from './store/index.cjs';
|
|
5
|
+
import { N as NoydbError } from './index-CLRxPs-W.cjs';
|
|
6
|
+
export { A as AlreadyElevatedError, B as BackupCorruptedError, d as BackupLedgerError, e as BundleIntegrityError, f as BundleVersionConflictError, C as ConflictError, g as DEFAULT_JOIN_MAX_ROWS, h as DanglingReferenceError, i as DecryptionError, j as DelegationTargetMissingError, D as DictKeyInUseError, a as DictKeyMissingError, E as ElevationExpiredError, k as ExportCapabilityError, F as FilenameSanitizationError, G as GroupCardinalityError, I as ImportCapabilityError, l as IndexRequiredError, m as IndexWriteFailureError, n as InvalidKeyError, J as JoinContext, o as JoinLeg, p as JoinStrategy, q as JoinTooLargeError, r as JoinableSource, K as KeyringCorruptError, s as KeyringExpiredError, t as LedgerContentionError, u as LiveQuery, v as LiveUpstream, L as LocaleNotSpecifiedError, M as MissingTranslationError, w as NetworkError, x as NoAccessError, y as NotFoundError, O as OrderBy, P as PathEscapeError, z as PeriodClosedError, H as PermissionDeniedError, Q as PrivilegeEscalationError, U as Query, V as QueryPlan, W as QuerySource, X as ReadOnlyAtInstantError, Y as ReadOnlyError, Z as ReadOnlyFrameError, _ as RefDescriptor, $ as RefIntegrityError, a0 as RefMode, a1 as RefRegistry, a2 as RefScopeError, a3 as RefViolation, R as ReservedCollectionNameError, a4 as ScanBuilder, a5 as ScanPageProvider, a6 as SchemaValidationError, S as SessionExpiredError, b as SessionNotFoundError, c as SessionPolicyError, a7 as StoreCapabilityError, a8 as TamperedError, a9 as TierDemoteDeniedError, aa as TierNotGrantedError, T as TranslatorNotConfiguredError, ab as ValidationError, ac as applyJoins, ad as buildLiveQuery, ae as executePlan, af as ref, ag as resetJoinWarnings } from './index-CLRxPs-W.cjs';
|
|
7
|
+
export { C as CompressionAlgo, N as NOYDB_BUNDLE_FORMAT_VERSION, a as NOYDB_BUNDLE_MAGIC, b as NOYDB_BUNDLE_PREFIX_BYTES, c as NoydbBundleHeader, d as NoydbBundleReadResult, W as WriteNoydbBundleOptions, g as generateULID, h as hasNoydbBundleMagic, i as isULID, r as readNoydbBundle, e as readNoydbBundleHeader, f as readNoydbBundlePublicEnvelope, j as resetBrotliSupportCache, w as writeNoydbBundle } from './index-CD1VnONm.cjs';
|
|
8
|
+
export { a as CrdtMode, b as CrdtState, L as LwwMapState, R as RgaState, Y as YjsState, m as mergeCrdtStates, r as resolveCrdtSnapshot } from './strategy-BSxFXGzb.cjs';
|
|
9
|
+
export { SYNC_CREDENTIALS_COLLECTION, SyncCredential, credentialStatus, deleteCredential, getCredential, listCredentials, putCredential } from './team/index.cjs';
|
|
10
|
+
export { C as CreateSessionOptions, a as CreateSessionResult, D as DevUnlockOptions, S as SessionToken, b as activeSessionCount, c as clearDevUnlock, d as createSession, e as enableDevUnlock, i as isDevUnlockActive, f as isSessionAlive, l as loadDevUnlock, r as resolveSession, g as revokeAllSessions, h as revokeSession } from './dev-unlock-D4xB0_gs.cjs';
|
|
11
|
+
export { a as Clause, C as CollectionIndexes, F as FieldClause, b as FilterClause, G as GroupClause, H as HashIndex, I as IndexDef, O as Operator, e as evaluateClause, c as evaluateFieldClause, r as readPath } from './predicate-SBHmi6D0.cjs';
|
|
12
|
+
export { a as AggregateResult, b as AggregateSpec, c as Aggregation, d as AggregationUpstream, G as GROUPBY_MAX_CARDINALITY, e as GROUPBY_WARN_CARDINALITY, f as GroupedAggregation, g as GroupedQuery, h as GroupedRow, L as LiveAggregation, R as Reducer, i as ReducerOptions, j as avg, l as count, m as groupAndReduce, n as max, o as min, r as reduceRecords, s as sum } from './strategy-D-SrOLCl.cjs';
|
|
13
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from './hash--EflSV65.cjs';
|
|
14
|
+
import './lazy-builder-CZVLKh0Z.cjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Persistence helpers for per-principal user envelopes stored at
|
|
18
|
+
* `_users/<keyringId>` (logically: `_meta/user/<keyringId>`).
|
|
19
|
+
*
|
|
20
|
+
* Unlike `_meta/policy` and `_meta/handle` which are plaintext, user
|
|
21
|
+
* envelopes carry user data and are encrypted with a dedicated
|
|
22
|
+
* {@link USER_ENVELOPE_COLLECTION} DEK (provisioned at vault open and
|
|
23
|
+
* propagated to every keyring via the system-collection DEK path in
|
|
24
|
+
* `team/keyring.ts`).
|
|
25
|
+
*
|
|
26
|
+
* This module is the **storage primitive** layer. The public API
|
|
27
|
+
* (`vault.user.*`) sits on top of this; permission gates, own-only
|
|
28
|
+
* write enforcement, and presence-channel propagation live there.
|
|
29
|
+
*
|
|
30
|
+
* @see docs/superpowers/specs/2026-05-05-user-envelope-design.md
|
|
31
|
+
*
|
|
32
|
+
* @module
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Read and decrypt the user envelope for `keyringId`. Returns `null`
|
|
37
|
+
* when no envelope has been persisted (either the principal has never
|
|
38
|
+
* called `updateMe`, or the keyring predates this feature).
|
|
39
|
+
*
|
|
40
|
+
* Decryption errors propagate — a tampered or wrong-keyed envelope
|
|
41
|
+
* surfaces as the underlying crypto error rather than masquerading as
|
|
42
|
+
* "not found".
|
|
43
|
+
*/
|
|
44
|
+
declare function loadUserEnvelope<T = unknown>(store: NoydbStore, vault: string, keyringId: string, dek: CryptoKey): Promise<UserEnvelope<T> | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Encrypt and persist the user envelope for `keyringId`. The new
|
|
47
|
+
* version is `(prior._v ?? 0) + 1`. Pass `expectedVersion` to enable
|
|
48
|
+
* optimistic-concurrency checks: a mismatch with the stored version
|
|
49
|
+
* throws {@link ConflictError} with the actual stored version.
|
|
50
|
+
*
|
|
51
|
+
* `expectedVersion: 0` means "expect no prior envelope"; the write
|
|
52
|
+
* succeeds only if no envelope exists yet.
|
|
53
|
+
*
|
|
54
|
+
* Soft-caps the JSON-serialized payload at {@link USER_ENVELOPE_MAX_BYTES};
|
|
55
|
+
* larger payloads throw {@link UserEnvelopeOversizedError}.
|
|
56
|
+
*/
|
|
57
|
+
declare function saveUserEnvelope<T>(store: NoydbStore, vault: string, keyringId: string, payload: T, dek: CryptoKey, expectedVersion?: number): Promise<UserEnvelope<T>>;
|
|
58
|
+
/**
|
|
59
|
+
* Delete the user envelope for `keyringId`. Idempotent — no error if
|
|
60
|
+
* the envelope is already absent. Called from the keyring revoke path
|
|
61
|
+
* (cascade-delete) and is a no-op for keyrings that never wrote.
|
|
62
|
+
*/
|
|
63
|
+
declare function deleteUserEnvelope(store: NoydbStore, vault: string, keyringId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* List the keyring ids that have a user envelope persisted in `vault`.
|
|
66
|
+
* Order is store-defined — callers that need a stable order should sort.
|
|
67
|
+
*/
|
|
68
|
+
declare function listUserEnvelopeIds(store: NoydbStore, vault: string): Promise<string[]>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cache policy helpers — parse human-friendly byte budgets into raw numbers.
|
|
72
|
+
*
|
|
73
|
+
* Accepted shapes (case-insensitive on suffix):
|
|
74
|
+
* number — interpreted as raw bytes
|
|
75
|
+
* '1024' — string of digits, raw bytes
|
|
76
|
+
* '50KB' — kilobytes (×1024)
|
|
77
|
+
* '50MB' — megabytes (×1024²)
|
|
78
|
+
* '1GB' — gigabytes (×1024³)
|
|
79
|
+
*
|
|
80
|
+
* Decimals are accepted (`'1.5GB'` → 1610612736 bytes).
|
|
81
|
+
*
|
|
82
|
+
* Anything else throws — better to fail loud at construction time than
|
|
83
|
+
* to silently treat a typo as 0 bytes (which would evict everything).
|
|
84
|
+
*/
|
|
85
|
+
/** Parse a byte budget into a positive integer number of bytes. */
|
|
86
|
+
declare function parseBytes(input: number | string): number;
|
|
87
|
+
/**
|
|
88
|
+
* Estimate the in-memory byte size of a decrypted record.
|
|
89
|
+
*
|
|
90
|
+
* Uses `JSON.stringify().length` as a stand-in for actual heap usage.
|
|
91
|
+
* It's a deliberate approximation: real V8 heap size includes pointer
|
|
92
|
+
* overhead, hidden classes, and string interning that we can't measure
|
|
93
|
+
* from JavaScript. The JSON length is a stable, monotonic proxy that
|
|
94
|
+
* costs O(record size) per insert — fine when records are typically
|
|
95
|
+
* < 1 KB and the cache eviction is the slow path anyway.
|
|
96
|
+
*
|
|
97
|
+
* Returns `0` (and the caller must treat it as 1 for accounting) if
|
|
98
|
+
* stringification throws on circular references; this is documented
|
|
99
|
+
* but in practice records always come from JSON-decoded envelopes.
|
|
100
|
+
*/
|
|
101
|
+
declare function estimateRecordBytes(record: unknown): number;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Persistence helpers for `_meta/public-envelope`. Mirrors the
|
|
105
|
+
* bypass-AES pattern used by `_meta/handle` and `_meta/policy` —
|
|
106
|
+
* the document is plaintext JSON, the envelope's `_iv` field is
|
|
107
|
+
* left empty.
|
|
108
|
+
*
|
|
109
|
+
* @module
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/** Reserved id for the vault-level public envelope record. */
|
|
113
|
+
declare const PUBLIC_ENVELOPE_RECORD_ID = "public-envelope";
|
|
114
|
+
/**
|
|
115
|
+
* Read the public envelope from `_meta/public-envelope`. Returns
|
|
116
|
+
* `undefined` when no envelope has been persisted (fresh vault, or
|
|
117
|
+
* a vault written before the feature was enabled). Tolerates
|
|
118
|
+
* corrupted documents — a JSON parse failure surfaces as `undefined`,
|
|
119
|
+
* not a thrown error, mirroring `_meta/handle`'s contract.
|
|
120
|
+
*/
|
|
121
|
+
declare function loadPublicEnvelope(store: NoydbStore, vault: string): Promise<PublicEnvelope | undefined>;
|
|
122
|
+
/** Persist the public envelope. Idempotent — overwrites any prior write. */
|
|
123
|
+
declare function savePublicEnvelope(store: NoydbStore, vault: string, envelope: PublicEnvelope): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Public, no-key reader. Plain function, not a method on `Noydb` —
|
|
126
|
+
* the whole point is it works without an authenticated session, so
|
|
127
|
+
* a UI can show "Acme 2026 Tax Records" before unlocking.
|
|
128
|
+
*
|
|
129
|
+
* Resolves any `name` / `description` locale map through the supplied
|
|
130
|
+
* `locale` (when provided). Omitting `locale` returns the raw
|
|
131
|
+
* envelope, which a multilingual picker can render as it pleases.
|
|
132
|
+
*/
|
|
133
|
+
declare function readPublicEnvelope(store: NoydbStore, vault: string, opts?: {
|
|
134
|
+
readonly locale?: string;
|
|
135
|
+
}): Promise<PublicEnvelope | undefined>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Why a gate denied a request. Stable across hub versions so consumers
|
|
139
|
+
* can switch on the value in error UIs.
|
|
140
|
+
*/
|
|
141
|
+
type PolicyDenyReason = 'insufficient-tier' | 'missing-factor' | 'stale-proof' | 'disabled' | 'shared-device-blocked';
|
|
142
|
+
/**
|
|
143
|
+
* Thrown by {@link checkGate} when the active session does not meet
|
|
144
|
+
* the gate's requirements. Carries the gate name, the reason, and the
|
|
145
|
+
* full required {@link GatePolicy} so error UIs can prompt the user
|
|
146
|
+
* for the missing factor without re-reading the policy document.
|
|
147
|
+
*/
|
|
148
|
+
declare class PolicyDeniedError extends NoydbError {
|
|
149
|
+
readonly gate: GateName;
|
|
150
|
+
readonly reason: PolicyDenyReason;
|
|
151
|
+
readonly required: GatePolicy;
|
|
152
|
+
constructor(gate: GateName, reason: PolicyDenyReason, required: GatePolicy, message?: string);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Raised by `createNoydb({ ... })` when the developer omits a recovery
|
|
156
|
+
* profile and `recover-passphrase` is not explicitly disabled. Vaults
|
|
157
|
+
* MUST have at least one recovery path enrolled before being
|
|
158
|
+
* production-ready (paper, shamir, multi-channel, or admin-mediated).
|
|
159
|
+
*
|
|
160
|
+
* The error references issue #10 in its message so a developer hitting
|
|
161
|
+
* it gets a one-line pointer to the design.
|
|
162
|
+
*/
|
|
163
|
+
declare class RecoveryNotEnrolledError extends NoydbError {
|
|
164
|
+
constructor(message?: string);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Raised by `db.recoverPassphrase` when the developer requests a
|
|
168
|
+
* recovery profile other than `'paper'` in v0.1.0-pre.5. The other
|
|
169
|
+
* three profiles (Shamir, multi-channel, admin-mediated) ship the API
|
|
170
|
+
* shape now; their per-profile dispatch lands in follow-up issues.
|
|
171
|
+
*
|
|
172
|
+
* The carried `profile` and `tracking` fields let consumers steer the
|
|
173
|
+
* UI ("Shamir recovery is not yet wired up — open issue #N to follow").
|
|
174
|
+
*/
|
|
175
|
+
declare class RecoveryProfileNotImplementedError extends NoydbError {
|
|
176
|
+
readonly profile: string;
|
|
177
|
+
readonly tracking: string;
|
|
178
|
+
constructor(profile: string, tracking: string);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Default policy for personal vaults and SMB deployments — the gates
|
|
183
|
+
* that need an off-device factor get one (TOTP / email-OTP / paper
|
|
184
|
+
* recovery), the rest take a tier-1 unlock alone. Tier-3 (PIN) is the
|
|
185
|
+
* floor only for `rotate-unlock` because that's the
|
|
186
|
+
* "change my PIN" flow.
|
|
187
|
+
*
|
|
188
|
+
* The unspecified gates (e.g. `view-user-auth`) inherit the engine
|
|
189
|
+
* default of `{ enabled: false, minTier: 1 }` — they fail closed.
|
|
190
|
+
*
|
|
191
|
+
* @see docs/subsystems/session-tiers.md → Built-in gates
|
|
192
|
+
*/
|
|
193
|
+
declare const PERSONAL_POLICY: VaultPolicy;
|
|
194
|
+
/**
|
|
195
|
+
* Strict policy for regulated deployments and shared workstations —
|
|
196
|
+
* raises the phrase floor to 8 words, demands two distinct factors for
|
|
197
|
+
* exports, and blocks export-on-shared-device. Use as a base for
|
|
198
|
+
* `policy: { ...STRICT_POLICY, gates: { ...STRICT_POLICY.gates, ... } }`
|
|
199
|
+
* tweaks.
|
|
200
|
+
*/
|
|
201
|
+
declare const STRICT_POLICY: VaultPolicy;
|
|
202
|
+
/**
|
|
203
|
+
* Merge a developer override onto a preset. Unspecified gates inherit;
|
|
204
|
+
* specified gates fully replace the preset's entry for that gate.
|
|
205
|
+
*
|
|
206
|
+
* Example:
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* mergePolicy(PERSONAL_POLICY, {
|
|
210
|
+
* gates: {
|
|
211
|
+
* 'app:approve-large-payment': { minTier: 2, factors: [{ anyOf: ['totp'] }] },
|
|
212
|
+
* },
|
|
213
|
+
* })
|
|
214
|
+
* // → PERSONAL_POLICY plus the new app gate; existing gates intact.
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare function mergePolicy(base: VaultPolicy, override?: Partial<VaultPolicy>): VaultPolicy;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Policy gate engine — the {@link checkGate} entry point.
|
|
221
|
+
*
|
|
222
|
+
* Given a configured {@link VaultPolicy}, an active session tier, and
|
|
223
|
+
* the factor proofs an actor is presenting, decide whether the gate
|
|
224
|
+
* permits the action. On denial, throws {@link PolicyDeniedError} with
|
|
225
|
+
* a stable {@link PolicyDenyReason} so consumers can branch in error
|
|
226
|
+
* UIs.
|
|
227
|
+
*
|
|
228
|
+
* @see docs/subsystems/session-tiers.md → checkGate() API
|
|
229
|
+
*
|
|
230
|
+
* @module
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
/** Default freshness window — 5 minutes. */
|
|
234
|
+
declare const DEFAULT_FRESHNESS_MS: number;
|
|
235
|
+
/** Caller-supplied context for one `checkGate` invocation. */
|
|
236
|
+
interface CheckGateContext {
|
|
237
|
+
/** Tier the active session currently holds. */
|
|
238
|
+
readonly activeTier: ActiveTier;
|
|
239
|
+
/** Proofs the actor is presenting for this gate. */
|
|
240
|
+
readonly factors?: ReadonlyArray<FactorProof>;
|
|
241
|
+
/**
|
|
242
|
+
* If the host knows the actor is on a shared device, set this to
|
|
243
|
+
* `true` so the engine can apply `warn.sharedDevice` rules. Defaults
|
|
244
|
+
* to `false`.
|
|
245
|
+
*/
|
|
246
|
+
readonly sharedDevice?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Override `now()` for tests. Defaults to `Date.now()`.
|
|
249
|
+
* @internal
|
|
250
|
+
*/
|
|
251
|
+
readonly now?: number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Decide whether `gate` permits the action under `context`. Throws
|
|
255
|
+
* {@link PolicyDeniedError} on denial; resolves with `void` on success.
|
|
256
|
+
*
|
|
257
|
+
* Lookup rules:
|
|
258
|
+
* - **Built-in gates** without a configured policy fail closed
|
|
259
|
+
* (`enabled: false`).
|
|
260
|
+
* - **App-defined gates** (`app:*`) without a configured policy are
|
|
261
|
+
* treated as no-op (allow). The developer registered the policy if
|
|
262
|
+
* they wanted enforcement; absence means the gate is informational.
|
|
263
|
+
*/
|
|
264
|
+
declare function checkGate(policy: VaultPolicy, gate: GateName, context: CheckGateContext): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Same as {@link checkGate} but returns a structured verdict instead
|
|
267
|
+
* of throwing. Useful when an error UI wants to show the user
|
|
268
|
+
* "you'll need TOTP plus a recovery code to do that" without first
|
|
269
|
+
* triggering the action.
|
|
270
|
+
*/
|
|
271
|
+
declare function describeGate(policy: VaultPolicy, gate: GateName, context: CheckGateContext): Promise<{
|
|
272
|
+
ok: true;
|
|
273
|
+
} | {
|
|
274
|
+
ok: false;
|
|
275
|
+
reason: PolicyDenyReason;
|
|
276
|
+
required: GatePolicy;
|
|
277
|
+
}>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Persistence helpers for the vault-level policy document
|
|
281
|
+
* (`_meta/policy`). Mirrors the bypass-AES pattern used by
|
|
282
|
+
* `_meta/handle` — the policy document is plain JSON, the envelope's
|
|
283
|
+
* `_iv` field is left empty.
|
|
284
|
+
*
|
|
285
|
+
* @see docs/subsystems/session-tiers.md → Storage location
|
|
286
|
+
*
|
|
287
|
+
* @module
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
/** Reserved collection name for vault-level metadata documents. */
|
|
291
|
+
declare const META_COLLECTION = "_meta";
|
|
292
|
+
/** Reserved id for the vault-level policy document. */
|
|
293
|
+
declare const POLICY_RECORD_ID = "policy";
|
|
294
|
+
/**
|
|
295
|
+
* Read the vault-level policy from `_meta/policy`. Returns `undefined`
|
|
296
|
+
* when no policy has been persisted (fresh vault, or a vault written
|
|
297
|
+
* before the policy module landed). The caller falls back to the
|
|
298
|
+
* default preset.
|
|
299
|
+
*
|
|
300
|
+
* Tolerates corrupted documents the same way `_meta/handle` does: a
|
|
301
|
+
* JSON parse failure surfaces as `undefined`, not a thrown error, so
|
|
302
|
+
* a bad write never permanently locks a vault.
|
|
303
|
+
*/
|
|
304
|
+
declare function loadVaultPolicy(store: NoydbStore, vault: string): Promise<VaultPolicy | undefined>;
|
|
305
|
+
/**
|
|
306
|
+
* Persist the vault-level policy at `_meta/policy`. Idempotent — call
|
|
307
|
+
* once at vault creation and again on `db.updatePolicy()` invocations.
|
|
308
|
+
*/
|
|
309
|
+
declare function saveVaultPolicy(store: NoydbStore, vault: string, policy: VaultPolicy): Promise<void>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Authentication introspection — issue #13.
|
|
313
|
+
*
|
|
314
|
+
* Three surfaces over the configured tier model and the actual
|
|
315
|
+
* per-user enrollment state:
|
|
316
|
+
*
|
|
317
|
+
* 1. **Vault-wide English summary** — {@link describeAuthConfig}.
|
|
318
|
+
* 2. **Vault-wide Mermaid diagram** — {@link diagramAuthConfig}.
|
|
319
|
+
* 3. **Per-user introspection** — {@link describeUserAuth}, gated by
|
|
320
|
+
* the `view-user-auth` policy gate (off by default).
|
|
321
|
+
*
|
|
322
|
+
* The per-user surface is held to a strict allowlist — fields not on
|
|
323
|
+
* the allowlist are dropped, never rendered. The negative test in
|
|
324
|
+
* `auth-introspection.test.ts` exercises the allowlist by feeding a
|
|
325
|
+
* contrived keyring with fake "secret" fields and asserting that none
|
|
326
|
+
* of them appear in the output.
|
|
327
|
+
*
|
|
328
|
+
* @module
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
/** Vault-wide English summary of the configured authentication graph. */
|
|
332
|
+
declare function describeAuthConfig(store: NoydbStore, vault: string): Promise<string>;
|
|
333
|
+
/**
|
|
334
|
+
* Render the vault's auth graph as Mermaid `flowchart TB` source. The
|
|
335
|
+
* caller pipes this through Mermaid (CLI or browser) to get an SVG.
|
|
336
|
+
*/
|
|
337
|
+
declare function diagramAuthConfig(store: NoydbStore, vault: string): Promise<string>;
|
|
338
|
+
/**
|
|
339
|
+
* Render the per-user enrollment summary. Returns an empty
|
|
340
|
+
* (non-throwing) string when the user has no keyring file — never
|
|
341
|
+
* confirms or denies the existence of the user from the document
|
|
342
|
+
* alone.
|
|
343
|
+
*
|
|
344
|
+
* Sanitization is strict: only the slot list, enrollment dates, and
|
|
345
|
+
* recovery-profile counts are rendered. WebAuthn cred ids, OIDC
|
|
346
|
+
* subject ids, password hashes, recovery codes, TOTP secrets — all
|
|
347
|
+
* dropped at the allowlist boundary, not redacted.
|
|
348
|
+
*/
|
|
349
|
+
declare function describeUserAuth(store: NoydbStore, vault: string, userId: string): Promise<string>;
|
|
350
|
+
/** Bulk variant for owner dashboards. */
|
|
351
|
+
declare function describeAllUsersAuth(store: NoydbStore, vault: string): Promise<Array<{
|
|
352
|
+
userId: string;
|
|
353
|
+
description: string;
|
|
354
|
+
}>>;
|
|
355
|
+
|
|
356
|
+
interface EncryptResult {
|
|
357
|
+
iv: string;
|
|
358
|
+
data: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Encrypt raw bytes with AES-256-GCM using a fresh random IV.
|
|
362
|
+
* Used by the attachment store so binary blobs avoid double base64 encoding
|
|
363
|
+
* (the existing `encrypt()` function calls `TextEncoder` on a string — here
|
|
364
|
+
* we pass the `Uint8Array` directly to `subtle.encrypt`).
|
|
365
|
+
*/
|
|
366
|
+
declare function encryptBytes(data: Uint8Array, dek: CryptoKey): Promise<EncryptResult>;
|
|
367
|
+
/**
|
|
368
|
+
* Decrypt AES-256-GCM ciphertext back to raw bytes.
|
|
369
|
+
* Counterpart to `encryptBytes`. Throws `TamperedError` on auth-tag failure.
|
|
370
|
+
*/
|
|
371
|
+
declare function decryptBytes(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<Uint8Array>;
|
|
372
|
+
/**
|
|
373
|
+
* Derive an AES-256-GCM presence key from a collection DEK using HKDF-SHA256.
|
|
374
|
+
*
|
|
375
|
+
* The presence key is domain-separated from the data DEK by the fixed salt
|
|
376
|
+
* `'noydb-presence'` and the `info` = collection name. This means:
|
|
377
|
+
* - The adapter never sees the presence key.
|
|
378
|
+
* - Presence payloads rotate automatically when the collection DEK is rotated.
|
|
379
|
+
* - Revoked users cannot derive the new presence key after a DEK rotation.
|
|
380
|
+
*
|
|
381
|
+
* @param dek The collection's AES-256-GCM DEK (extractable).
|
|
382
|
+
* @param collectionName Used as the HKDF `info` parameter for domain separation.
|
|
383
|
+
* @returns A non-extractable AES-256-GCM key suitable for presence payload encryption.
|
|
384
|
+
*/
|
|
385
|
+
declare function derivePresenceKey(dek: CryptoKey, collectionName: string): Promise<CryptoKey>;
|
|
386
|
+
/**
|
|
387
|
+
* Encrypt a plaintext string with AES-256-GCM and a deterministic,
|
|
388
|
+
* HKDF-derived IV.
|
|
389
|
+
*
|
|
390
|
+
* The same `{ dek, context, plaintext }` triple always produces the
|
|
391
|
+
* same `{ iv, data }` — call this twice and you can string-compare the
|
|
392
|
+
* ciphertexts to check equality of the inputs without decrypting them.
|
|
393
|
+
*
|
|
394
|
+
* @param context Domain-separation string — by convention
|
|
395
|
+
* `'<collection>/<field>'`. Different contexts encrypt
|
|
396
|
+
* the same plaintext to different ciphertexts, so
|
|
397
|
+
* `email` in collection `users` does not collide with
|
|
398
|
+
* `email` in collection `customers`.
|
|
399
|
+
*/
|
|
400
|
+
declare function encryptDeterministic(plaintext: string, dek: CryptoKey, context: string): Promise<EncryptResult>;
|
|
401
|
+
/**
|
|
402
|
+
* Counterpart to {@link encryptDeterministic}. The IV is stored
|
|
403
|
+
* alongside the ciphertext (exactly like the randomized path), so
|
|
404
|
+
* decrypt uses the stored IV and verifies the GCM auth tag — a tampered
|
|
405
|
+
* ciphertext throws `TamperedError` just like randomized AES-GCM.
|
|
406
|
+
*/
|
|
407
|
+
declare function decryptDeterministic(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<string>;
|
|
408
|
+
declare function bufferToBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
409
|
+
declare function base64ToBuffer(base64: string): Uint8Array<ArrayBuffer>;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Hierarchical access — tier-aware keyring helpers.
|
|
413
|
+
*
|
|
414
|
+
* The keyring's existing `deks: Map<string, CryptoKey>` is keyed by
|
|
415
|
+
* collection name. extends the key space:
|
|
416
|
+
*
|
|
417
|
+
* `'invoices'` — tier-0 DEK (unchanged from v0.x)
|
|
418
|
+
* `'invoices#1'` — tier-1 DEK
|
|
419
|
+
* `'invoices#2'` — tier-2 DEK
|
|
420
|
+
*
|
|
421
|
+
* Tier 0 keeps the bare collection name so any keyring written
|
|
422
|
+
* before tiers existed loads without migration. Tiers ≥ 1 use `#N`
|
|
423
|
+
* suffixes that
|
|
424
|
+
* would be invalid as user-supplied collection names (see
|
|
425
|
+
* `ReservedCollectionNameError` — `#` is reserved).
|
|
426
|
+
*
|
|
427
|
+
* @module
|
|
428
|
+
*/
|
|
429
|
+
|
|
430
|
+
/** Canonical DEK key for a given collection + tier. Tier 0 → bare name. */
|
|
431
|
+
declare function dekKey(collection: string, tier: number): string;
|
|
432
|
+
/**
|
|
433
|
+
* Returns the user's effective clearance for a given collection: the
|
|
434
|
+
* maximum tier for which their keyring holds a DEK. Falls back to 0
|
|
435
|
+
* when the user has only the tier-0 DEK (or none — the getDEK caller
|
|
436
|
+
* will raise separately).
|
|
437
|
+
*/
|
|
438
|
+
declare function effectiveClearance(keyring: UnlockedKeyring, collection: string): number;
|
|
439
|
+
/**
|
|
440
|
+
* Assert the caller is cleared for the requested tier. Owners and
|
|
441
|
+
* admins always pass (they can mint any new tier DEK on demand);
|
|
442
|
+
* other roles must already hold the tier DEK — via a prior grant or
|
|
443
|
+
* an active delegation — otherwise this throws `TierNotGrantedError`.
|
|
444
|
+
*
|
|
445
|
+
* This gate runs BEFORE `getDEK()` on the mutation path so a
|
|
446
|
+
* non-cleared operator never has the opportunity to silently
|
|
447
|
+
* auto-create a tier DEK they shouldn't have.
|
|
448
|
+
*/
|
|
449
|
+
declare function assertTierAccess(keyring: UnlockedKeyring, collection: string, tier: number): void;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Vault-level diff orchestrator.
|
|
453
|
+
*
|
|
454
|
+
* Compares a live `Vault`'s plaintext state against a candidate state
|
|
455
|
+
* (another vault, a plain `{ collection: records[] }` map, or a vault
|
|
456
|
+
* dump JSON) and returns a structured `VaultDiff` plan listing the
|
|
457
|
+
* records that would be added, modified, or deleted to bring the live
|
|
458
|
+
* vault into the candidate's shape.
|
|
459
|
+
*
|
|
460
|
+
* Builds on two existing record-level helpers:
|
|
461
|
+
*
|
|
462
|
+
* 1. `diff(a, b)` from `./history/diff.ts` — emits dot-pathed
|
|
463
|
+
* `DiffEntry[]` with `type: 'added' | 'removed' | 'changed'` for
|
|
464
|
+
* each changed field of two records. Used here for the
|
|
465
|
+
* `fieldDiffs` of every `modified` entry, and (with empty result)
|
|
466
|
+
* as the default deep-equal check.
|
|
467
|
+
*
|
|
468
|
+
* 2. `Vault.exportStream()` from `./vault.ts` — the canonical
|
|
469
|
+
* decrypt-and-stream-records iterator. Used to walk both sides
|
|
470
|
+
* when the candidate is itself a `Vault`. ACL-scoped: collections
|
|
471
|
+
* the caller can't read silently drop out, the same way every
|
|
472
|
+
* other plaintext-emitting export pipeline filters them.
|
|
473
|
+
*
|
|
474
|
+
* The new orchestration is the **vault-level** enumeration: bucket
|
|
475
|
+
* each record id into added (only in candidate), deleted (only in
|
|
476
|
+
* vault), or modified (in both with field changes); leave the
|
|
477
|
+
* field-level granularity to the existing `diff()`.
|
|
478
|
+
*
|
|
479
|
+
* Use cases:
|
|
480
|
+
*
|
|
481
|
+
* - Import preview (`@noy-db/as-*` `fromString` returns a plan
|
|
482
|
+
* whose body is a `VaultDiff`).
|
|
483
|
+
* - Backup verification ("does this `.noydb` bundle from yesterday
|
|
484
|
+
* match the current vault?").
|
|
485
|
+
* - Two-vault reconciliation ("what's different between Office A
|
|
486
|
+
* and Office B before we sync?").
|
|
487
|
+
* - Test assertions (golden-file testing with one-liner
|
|
488
|
+
* `expect(plan.summary).toEqual(...)`).
|
|
489
|
+
*
|
|
490
|
+
* @module
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
/** Per-record entry shape — added and deleted records carry only the record value. */
|
|
494
|
+
interface VaultDiffEntry<T = unknown> {
|
|
495
|
+
readonly collection: string;
|
|
496
|
+
readonly id: string;
|
|
497
|
+
readonly record: T;
|
|
498
|
+
}
|
|
499
|
+
/** Modified records carry both halves of the diff plus the field-level breakdown. */
|
|
500
|
+
interface VaultDiffModifiedEntry<T = unknown> extends VaultDiffEntry<T> {
|
|
501
|
+
/** The record as it stands in the live vault. */
|
|
502
|
+
readonly before: T;
|
|
503
|
+
/** Top-level keys whose values differ between `before` and `record`. */
|
|
504
|
+
readonly fieldsChanged: readonly string[];
|
|
505
|
+
/**
|
|
506
|
+
* Field-level diff entries from `diff(before, record)`. Reuses the
|
|
507
|
+
* existing per-record diff helper so consumers can render git-style
|
|
508
|
+
* `path: from → to` rows without re-walking the records.
|
|
509
|
+
*/
|
|
510
|
+
readonly fieldDiffs: readonly DiffEntry[];
|
|
511
|
+
}
|
|
512
|
+
interface VaultDiff<T = unknown> {
|
|
513
|
+
readonly added: readonly VaultDiffEntry<T>[];
|
|
514
|
+
readonly modified: readonly VaultDiffModifiedEntry<T>[];
|
|
515
|
+
readonly deleted: readonly VaultDiffEntry<T>[];
|
|
516
|
+
/** Only populated when `options.includeUnchanged: true`. */
|
|
517
|
+
readonly unchanged: readonly VaultDiffEntry<T>[] | undefined;
|
|
518
|
+
readonly summary: {
|
|
519
|
+
readonly add: number;
|
|
520
|
+
readonly modify: number;
|
|
521
|
+
readonly delete: number;
|
|
522
|
+
readonly total: number;
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Format the diff as a human-readable string.
|
|
526
|
+
*
|
|
527
|
+
* - `'count'` — one line, just the numbers (`12 added · 3 modified · 0 deleted`)
|
|
528
|
+
* - `'one-line'` — count plus a single overview line
|
|
529
|
+
* - `'full'` — count + one row per added/modified/deleted record (default)
|
|
530
|
+
*/
|
|
531
|
+
format(opts?: {
|
|
532
|
+
detail?: 'count' | 'one-line' | 'full';
|
|
533
|
+
}): string;
|
|
534
|
+
}
|
|
535
|
+
interface DiffOptions {
|
|
536
|
+
/** Restrict the diff to a subset of collections. */
|
|
537
|
+
readonly collections?: readonly string[];
|
|
538
|
+
/** Field on each record that carries its id. Defaults to `'id'`. */
|
|
539
|
+
readonly idKey?: string;
|
|
540
|
+
/** Override the default deep-equal check for "modified vs unchanged". */
|
|
541
|
+
readonly compareFn?: (a: unknown, b: unknown) => boolean;
|
|
542
|
+
/** If true, include unchanged records in the diff (off by default to save memory). */
|
|
543
|
+
readonly includeUnchanged?: boolean;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Candidate state to diff the vault against:
|
|
547
|
+
*
|
|
548
|
+
* - A `Vault` instance — both sides are walked via `exportStream()`.
|
|
549
|
+
* - A `Record<collection, records[]>` map — same shape `as-json.toObject()`
|
|
550
|
+
* produces. Useful for diffing parsed file content against the live vault.
|
|
551
|
+
* - A `VaultDump` (output of `vault.dump()`) — a JSON string carrying the
|
|
552
|
+
* full vault state. Parsed and reduced to the map shape above.
|
|
553
|
+
*/
|
|
554
|
+
type DiffCandidate<T = unknown> = Vault | Record<string, readonly T[]> | string;
|
|
555
|
+
/**
|
|
556
|
+
* Compute the diff between a live vault and a candidate state.
|
|
557
|
+
*
|
|
558
|
+
* Returns a fully buffered `VaultDiff` — no streaming. Memory cost is
|
|
559
|
+
* O(n + m) in the row count of vault + candidate. For documented
|
|
560
|
+
* 1K-50K-record vaults this is fine; a streaming variant lands as a
|
|
561
|
+
* follow-up if a > 100K-record consumer arrives.
|
|
562
|
+
*/
|
|
563
|
+
declare function diffVault<T = unknown>(vault: Vault, candidate: DiffCandidate<T>, options?: DiffOptions): Promise<VaultDiff<T>>;
|
|
564
|
+
|
|
565
|
+
export { ActiveTier, type CheckGateContext, DEFAULT_FRESHNESS_MS, type DiffCandidate, DiffEntry, type DiffOptions, FactorProof, GateName, GatePolicy, META_COLLECTION, NoydbError, NoydbStore, PERSONAL_POLICY, POLICY_RECORD_ID, PUBLIC_ENVELOPE_RECORD_ID, PolicyDeniedError, type PolicyDenyReason, PublicEnvelope, RecoveryNotEnrolledError, RecoveryProfileNotImplementedError, STRICT_POLICY, UnlockedKeyring, UserEnvelope, Vault, type VaultDiff, type VaultDiffEntry, type VaultDiffModifiedEntry, VaultPolicy, assertTierAccess, base64ToBuffer, bufferToBase64, checkGate, decryptBytes, decryptDeterministic, dekKey, deleteUserEnvelope, derivePresenceKey, describeAllUsersAuth, describeAuthConfig, describeGate, describeUserAuth, diagramAuthConfig, diffVault, effectiveClearance, encryptBytes, encryptDeterministic, estimateRecordBytes, listUserEnvelopeIds, loadPublicEnvelope, loadUserEnvelope, loadVaultPolicy, mergePolicy, parseBytes, readPublicEnvelope, savePublicEnvelope, saveUserEnvelope, saveVaultPolicy };
|