@noy-db/hub 0.1.0-pre.4 → 0.1.0-pre.7
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/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +3 -3
- package/dist/blobs/index.d.ts +3 -3
- package/dist/blobs/index.js +2 -2
- package/dist/bundle/index.cjs +26 -3
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +3 -3
- package/dist/bundle/index.d.ts +3 -3
- package/dist/bundle/index.js +3 -1
- package/dist/{chunk-LSZHBNDG.js → chunk-3WCRU7TI.js} +2 -2
- package/dist/{chunk-PSHTHSIX.js → chunk-6IJQ27XN.js} +213 -10
- package/dist/chunk-6IJQ27XN.js.map +1 -0
- package/dist/{chunk-O5GK62FJ.js → chunk-B6HF6NTZ.js} +1 -1
- package/dist/chunk-B6HF6NTZ.js.map +1 -0
- package/dist/{chunk-AVWFLPNR.js → chunk-CL37QSND.js} +2 -2
- package/dist/chunk-EMIGCR7X.js +39 -0
- package/dist/chunk-EMIGCR7X.js.map +1 -0
- package/dist/{chunk-GJILMRPO.js → chunk-FAAWLVTF.js} +42 -4
- package/dist/chunk-FAAWLVTF.js.map +1 -0
- package/dist/chunk-GILMPJXB.js +155 -0
- package/dist/chunk-GILMPJXB.js.map +1 -0
- package/dist/{chunk-L77MEFCH.js → chunk-INSJBB5W.js} +3 -3
- package/dist/{chunk-QZIACZZU.js → chunk-KPF2HHPI.js} +2 -2
- package/dist/{chunk-NK2NSXXK.js → chunk-N2LMZKLR.js} +2 -2
- package/dist/{chunk-EARQCIL7.js → chunk-NZ4XCIKS.js} +3 -3
- package/dist/{chunk-E445ICYI.js → chunk-UFL4DUEV.js} +5 -3
- package/dist/chunk-UFL4DUEV.js.map +1 -0
- package/dist/consent/index.d.cts +3 -3
- package/dist/consent/index.d.ts +3 -3
- package/dist/{dev-unlock-XOUecfQ9.d.ts → dev-unlock-CcJ1qIi7.d.ts} +1 -1
- package/dist/{dev-unlock-5SmCVGyx.d.cts → dev-unlock-Dk14V6lX.d.cts} +1 -1
- package/dist/{hash-Bxud16vM.d.ts → hash-1Xsqx1jl.d.ts} +1 -1
- package/dist/{hash-CvuKN2gH.d.cts → hash-h_2U3TFb.d.cts} +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +4 -4
- package/dist/history/index.d.ts +4 -4
- package/dist/history/index.js +2 -2
- package/dist/i18n/index.cjs +3 -1
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.js +3 -3
- package/dist/{index-DN-J-5wT.d.cts → index-6xNpPsxR.d.cts} +1 -1
- package/dist/{index-Cy-MKrdK.d.ts → index-Cvb0efA_.d.cts} +39 -5
- package/dist/{index-BRHBCmLt.d.ts → index-DJTf9yxn.d.ts} +1 -1
- package/dist/{index-BvUiM47h.d.cts → index-DZn6Yick.d.ts} +39 -5
- package/dist/index.cjs +2001 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +315 -19
- package/dist/index.d.ts +315 -19
- package/dist/index.js +1503 -41
- package/dist/index.js.map +1 -1
- package/dist/{ledger-HWXYGUIQ.js → ledger-5V67MAIL.js} +3 -3
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +3 -3
- package/dist/periods/index.d.ts +3 -3
- package/dist/periods/index.js +3 -3
- package/dist/public-envelope-DFJZHXVH.js +31 -0
- package/dist/public-envelope-DFJZHXVH.js.map +1 -0
- package/dist/query/index.d.cts +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/session/index.cjs +4 -2
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +4 -4
- package/dist/session/index.d.ts +4 -4
- package/dist/session/index.js +1 -1
- package/dist/shadow/index.d.cts +3 -3
- package/dist/shadow/index.d.ts +3 -3
- package/dist/store/index.d.cts +3 -3
- package/dist/store/index.d.ts +3 -3
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +2 -2
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.js +2 -2
- package/dist/team/index.cjs +3 -1
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +3 -3
- package/dist/team/index.d.ts +3 -3
- package/dist/team/index.js +4 -4
- package/dist/tx/index.d.cts +3 -3
- package/dist/tx/index.d.ts +3 -3
- package/dist/{types-Dmi7nrC9.d.ts → types-D-6bmD2c.d.ts} +1271 -3
- package/dist/{types-BVSfkYg6.d.cts → types-D3QLmhlk.d.cts} +1271 -3
- package/package.json +1 -1
- package/dist/chunk-E445ICYI.js.map +0 -1
- package/dist/chunk-GJILMRPO.js.map +0 -1
- package/dist/chunk-O5GK62FJ.js.map +0 -1
- package/dist/chunk-PSHTHSIX.js.map +0 -1
- /package/dist/{chunk-LSZHBNDG.js.map → chunk-3WCRU7TI.js.map} +0 -0
- /package/dist/{chunk-AVWFLPNR.js.map → chunk-CL37QSND.js.map} +0 -0
- /package/dist/{chunk-L77MEFCH.js.map → chunk-INSJBB5W.js.map} +0 -0
- /package/dist/{chunk-QZIACZZU.js.map → chunk-KPF2HHPI.js.map} +0 -0
- /package/dist/{chunk-NK2NSXXK.js.map → chunk-N2LMZKLR.js.map} +0 -0
- /package/dist/{chunk-EARQCIL7.js.map → chunk-NZ4XCIKS.js.map} +0 -0
- /package/dist/{ledger-HWXYGUIQ.js.map → ledger-5V67MAIL.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,72 @@
|
|
|
1
|
-
import { ar as UnlockedKeyring,
|
|
2
|
-
export {
|
|
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-D-6bmD2c.js';
|
|
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 DelegationToken, bf as DeleteManyResult, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, bg as DirtyEntry, bh as ELEVATION_AUDIT_COLLECTION, bi as ElevatedHandle, av as EncryptedEnvelope, bj as EnrollAuthenticatorOptions, bk as ExportCapability, bl as ExportChunk, bm as ExportFormat, bn as ExportStreamOptions, bo as FactorKind, bp as FactorRequirement, bq as GhostRecord, br as GrantOptions, bs as HistoryConfig, bt as HistoryEntry, au as HistoryOptions, e as I18nTextDescriptor, f as I18nTextOptions, bu as INDEXED_STORE_POLICY, bv as ImportCapability, bw as InferOutput, bx as IssueDelegationOptions, by as IssueMagicLinkGrantOptions, aB as JsonPatch, aC as JsonPatchOp, bz as KeyringAuthenticator, bA as KeyringFile, aD as LedgerEntry, aE as LedgerStore, bB as ListAccessibleVaultsOptions, bC as ListPageResult, bD as LiveUserEnvelope, bE as LocaleReadOptions, bF as Lru, bG as LruOptions, bH as LruStats, bI as MAGIC_LINK_CONTENT_INFO_PREFIX, bJ as MAGIC_LINK_GRANTS_COLLECTION, bK as MAGIC_LINK_KEK_INFO_PREFIX, bL as MagicLinkGrantPayload, bM as MagicLinkGrantRecord, bN as NOYDB_BACKUP_VERSION, bO as NOYDB_FORMAT_VERSION, bP as NOYDB_KEYRING_VERSION, bQ as NOYDB_SYNC_VERSION, bR as Noydb, bS as NoydbBundleStore, bT as NoydbEventMap, bU as NoydbOptions, a8 as OpenPeriodOptions, a9 as PERIODS_COLLECTION, bV as PUBLIC_ENVELOPE_FIELDS, bW as PaperRecoveryDoc, bX as PaperRecoveryEntry, bY as PassphrasePolicy, bZ as PassphraseValidationResult, aa as PeriodRecord, b_ as Permission, b$ as Permissions, c0 as PlaintextTranslatorContext, c1 as PlaintextTranslatorFn, P as PolicyEnforcer, c2 as PresenceHandle, c3 as PresencePeer, aw as PruneOptions, c4 as PublicEnvelopeField, c5 as PublicEnvelopeSchema, c6 as PublicEnvelopeText, c7 as PullMode, c8 as PullOptions, c9 as PullPolicy, ca as PullResult, cb as PushMode, cc as PushOptions, cd as PushPolicy, ce as PushResult, cf as PutManyItemOptions, cg as PutManyOptions, ch as PutManyResult, ci as QueryAcrossOptions, cj as QueryAcrossResult, ck as QuickUnlockState, cl as QuickUnlockStore, cm as ReAuthOperation, cn as RecoverPassphraseInput, co as RecoveryProof, cp as ResolvedPublicEnvelopeSchema, cq as RevokeOptions, aq as Role, cr as RotatePassphraseInput, cs as SessionPolicy, ct as SetPublicEnvelopeInput, U as SlotInfo, V as SlotRecord, cu as StandardSchemaV1, cv as StandardSchemaV1Issue, cw as StandardSchemaV1SyncResult, cx as StoreAuth, cy as StoreAuthKind, cz as StoreCapabilities, cA as SyncEngine, cB as SyncMetadata, cC as SyncPolicy, cD as SyncScheduler, cE as SyncSchedulerStatus, cF as SyncStatus, cG as SyncTarget, cH as SyncTargetRole, cI as SyncTransaction, cJ as SyncTransactionResult, cK as TierMode, cL as TranslatorAuditEntry, al as TxCollection, am as TxContext, cM as TxOp, an as TxVault, cN as USER_ENVELOPE_COLLECTION, cO as USER_ENVELOPE_MAX_BYTES, cP as Unsubscribe, cQ as UserApi, cR as UserEnvelopeCheckGate, cS as UserEnvelopeOversizedError, cT as UserEnvelopePresented, cU as UserInfo, cV as VaultBackup, aF as VaultEngine, aj as VaultFrame, aG as VaultInstant, cW as VaultPolicyOnDisk, cX as VaultSnapshot, aH as VerifyResult, W as VersionRecord, cY as WarningRules, cZ as WeakPassphraseError, c_ as WeakPassphraseReason, g as applyI18nLocale, aI as applyPatch, c$ as assertStrongPassphrase, d0 as buildRecipientKeyringFile, d1 as burnPaperRecoveryEntry, aJ as canonicalJson, aK as computePatch, n as createEnforcer, d2 as createNoydb, d3 as createStore, d4 as deriveMagicLinkContentKey, h as dictCollectionName, i as dictKey, aL as diff, d5 as enrollAuthenticator, d6 as estimateEntropy, d7 as evaluateExportCapability, d8 as evaluateImportCapability, d9 as findAuthenticator, aM as formatDiff, da as hasExportCapability, db as hasImportCapability, dc as hasRecoveryEnrolled, aN as hashEntry, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, dd as isMagicLinkGrantExpired, de as isPublicEnvelope, df as issueDelegation, dg as keyringRecoverPassphrase, dh as keyringRotatePassphrase, di as listMagicLinkGrants, dj as listUsers, dk as listUsersWithEnvelopes, dl as loadActiveDelegations, dm as loadPaperRecoveryEntries, dn as magicLinkGrantRecordId, aO as paddedIndex, aP as parseIndex, dp as readMagicLinkGrantRecord, dq as removeAuthenticator, r as resolveI18nText, dr as resolvePublicEnvelopeSchema, ds as revokeDelegation, dt as revokeMagicLinkGrant, ao as runTransaction, du as savePaperRecoveryEntries, aQ as sha256Hex, dv as unwrapMagicLinkGrant, v as validateI18nTextValue, dw as validatePassphrase, dx as validatePublicEnvelopeInput, dy as validateSchemaInput, dz as validateSchemaOutput, o as validateSessionPolicy, dA as writeMagicLinkGrant } from './types-D-6bmD2c.js';
|
|
3
3
|
export { d as detectMagic, a as detectMimeType, i as isPreCompressed } from './mime-magic-CBBSOkjm.js';
|
|
4
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.js';
|
|
5
|
-
|
|
6
|
-
export {
|
|
5
|
+
import { N as NoydbError } from './index-DJTf9yxn.js';
|
|
6
|
+
export { A as AlreadyElevatedError, B as BackupCorruptedError, a as BackupLedgerError, b as BundleIntegrityError, c as BundleVersionConflictError, C as ConflictError, D as DEFAULT_JOIN_MAX_ROWS, d as DanglingReferenceError, e as DecryptionError, f as DelegationTargetMissingError, g as DictKeyInUseError, h as DictKeyMissingError, E as ElevationExpiredError, i as ExportCapabilityError, F as FilenameSanitizationError, G as GroupCardinalityError, I as ImportCapabilityError, j as IndexRequiredError, k as IndexWriteFailureError, l as InvalidKeyError, J as JoinContext, m as JoinLeg, n as JoinStrategy, o as JoinTooLargeError, p as JoinableSource, K as KeyringExpiredError, L as LedgerContentionError, q as LiveQuery, r as LiveUpstream, s as LocaleNotSpecifiedError, M as MissingTranslationError, t as NetworkError, u as NoAccessError, v as NotFoundError, O as OrderBy, P as PathEscapeError, w as PeriodClosedError, x as PermissionDeniedError, y as PrivilegeEscalationError, Q as Query, z as QueryPlan, H as QuerySource, R as ReadOnlyAtInstantError, S as ReadOnlyError, T as ReadOnlyFrameError, U as RefDescriptor, V as RefIntegrityError, W as RefMode, X as RefRegistry, Y as RefScopeError, Z as RefViolation, _ as ReservedCollectionNameError, $ as ScanBuilder, a0 as ScanPageProvider, a1 as SchemaValidationError, a2 as SessionExpiredError, a3 as SessionNotFoundError, a4 as SessionPolicyError, a5 as StoreCapabilityError, a6 as TamperedError, a7 as TierDemoteDeniedError, a8 as TierNotGrantedError, a9 as TranslatorNotConfiguredError, aa as ValidationError, ab as applyJoins, ac as buildLiveQuery, ad as executePlan, ae as ref, af as resetJoinWarnings } from './index-DJTf9yxn.js';
|
|
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-DZn6Yick.js';
|
|
7
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.js';
|
|
8
9
|
export { SYNC_CREDENTIALS_COLLECTION, SyncCredential, credentialStatus, deleteCredential, getCredential, listCredentials, putCredential } from './team/index.js';
|
|
9
|
-
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-
|
|
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-CcJ1qIi7.js';
|
|
10
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.js';
|
|
11
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.js';
|
|
12
|
-
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from './hash-
|
|
13
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from './hash-1Xsqx1jl.js';
|
|
13
14
|
import './lazy-builder-BwEoBQZ9.js';
|
|
14
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
|
+
|
|
15
70
|
/**
|
|
16
71
|
* Cache policy helpers — parse human-friendly byte budgets into raw numbers.
|
|
17
72
|
*
|
|
@@ -45,6 +100,259 @@ declare function parseBytes(input: number | string): number;
|
|
|
45
100
|
*/
|
|
46
101
|
declare function estimateRecordBytes(record: unknown): number;
|
|
47
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
|
+
|
|
48
356
|
interface EncryptResult {
|
|
49
357
|
iv: string;
|
|
50
358
|
data: string;
|
|
@@ -254,16 +562,4 @@ type DiffCandidate<T = unknown> = Vault | Record<string, readonly T[]> | string;
|
|
|
254
562
|
*/
|
|
255
563
|
declare function diffVault<T = unknown>(vault: Vault, candidate: DiffCandidate<T>, options?: DiffOptions): Promise<VaultDiff<T>>;
|
|
256
564
|
|
|
257
|
-
|
|
258
|
-
* Validate passphrase strength.
|
|
259
|
-
* Checks length and basic entropy heuristics.
|
|
260
|
-
* Throws ValidationError if too weak.
|
|
261
|
-
*/
|
|
262
|
-
declare function validatePassphrase(passphrase: string): void;
|
|
263
|
-
/**
|
|
264
|
-
* Estimate passphrase entropy in bits.
|
|
265
|
-
* Uses character class analysis (not dictionary-based).
|
|
266
|
-
*/
|
|
267
|
-
declare function estimateEntropy(passphrase: string): number;
|
|
268
|
-
|
|
269
|
-
export { type DiffCandidate, DiffEntry, type DiffOptions, UnlockedKeyring, Vault, type VaultDiff, type VaultDiffEntry, type VaultDiffModifiedEntry, assertTierAccess, base64ToBuffer, bufferToBase64, decryptBytes, decryptDeterministic, dekKey, derivePresenceKey, diffVault, effectiveClearance, encryptBytes, encryptDeterministic, estimateEntropy, estimateRecordBytes, parseBytes, validatePassphrase };
|
|
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 };
|